lookatstudy-mobile 0.41.0 → 0.42.0

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 (138) hide show
  1. package/install-termux.sh +29 -1
  2. package/package.json +1 -1
  3. package/server.cjs +1 -1
  4. package/web/assets/{CanvasStage-D4hAqHX5.js → CanvasStage-Di9Xd_SQ.js} +1 -1
  5. package/web/assets/{CommandPalette-BHpA4Ewc.js → CommandPalette-BjIg1GAx.js} +1 -1
  6. package/web/assets/{CourseSearchPanel-ErS8Zlba.js → CourseSearchPanel-CEECNtWD.js} +1 -1
  7. package/web/assets/{ExamView-CEaKtO-T.js → ExamView-Bh2gu61P.js} +1 -1
  8. package/web/assets/{MermaidArtifact-BVmEpDZk.js → MermaidArtifact-J6xyhs4Y.js} +3 -3
  9. package/web/assets/{ModelManagerModal-CSOiYXJw.js → ModelManagerModal-B7H5t5QP.js} +1 -1
  10. package/web/assets/{PersonalProfileModal-B-4B0oxN.js → PersonalProfileModal-CywAVDIt.js} +1 -1
  11. package/web/assets/{ReviewPanel-ZCLRG73N.js → ReviewPanel-BZY64BTO.js} +1 -1
  12. package/web/assets/{SettingsView-BNv73q7Y.js → SettingsView-dG7fUQi5.js} +2 -2
  13. package/web/assets/{Toggle-DB-5Fwv6.js → Toggle-D7gNZcnf.js} +1 -1
  14. package/web/assets/{VoicePanel-DvTnIP2j.js → VoicePanel-CSLmne9b.js} +1 -1
  15. package/web/assets/{abnfDiagram-VCTEODGH-BIpSmrMk.js → abnfDiagram-VCTEODGH-Db9Qqpbg.js} +1 -1
  16. package/web/assets/{abnfDiagram-VCTEODGH-ODA7YWAP-BMGC3I9X.js → abnfDiagram-VCTEODGH-ODA7YWAP-Bcs3cVam.js} +1 -1
  17. package/web/assets/{architectureDiagram-5GKGNRK7-C4PU3XN7-ftEJ8p-w.js → architectureDiagram-5GKGNRK7-C4PU3XN7-BqEgiZYk.js} +1 -1
  18. package/web/assets/{architectureDiagram-5GKGNRK7-Cp-lchuP.js → architectureDiagram-5GKGNRK7-DsG2pBPI.js} +1 -1
  19. package/web/assets/{blockDiagram-I7D4REHJ-BVRIL2oS.js → blockDiagram-I7D4REHJ-1dib56tn.js} +1 -1
  20. package/web/assets/{blockDiagram-NRAW4CY4-UMJ6PMQQ-R9rcLO5u.js → blockDiagram-NRAW4CY4-UMJ6PMQQ-DkKtDF5_.js} +1 -1
  21. package/web/assets/{c4Diagram-7LVT6UL2-DQhHNfB8.js → c4Diagram-7LVT6UL2-CP3bR28T.js} +1 -1
  22. package/web/assets/{c4Diagram-UCG6FXSJ-75X3U2P3-B6ZoaZ9Q.js → c4Diagram-UCG6FXSJ-75X3U2P3-F_lv7YS4.js} +1 -1
  23. package/web/assets/channel-CBJ6IUEy.js +1 -0
  24. package/web/assets/{chunk-2Q5K7J3B-3RN4ct7W.js → chunk-2Q5K7J3B-C1Csza_g.js} +1 -1
  25. package/web/assets/{chunk-5VM5RSS4-D8ET8xiH.js → chunk-5VM5RSS4-NvHRULY0.js} +1 -1
  26. package/web/assets/{chunk-7XDTSPCN-BwDjiyHa.js → chunk-7XDTSPCN-C15FSD-n.js} +1 -1
  27. package/web/assets/{chunk-CTNIYPP6-AUjN6ofw.js → chunk-CTNIYPP6-HNFc_v9r.js} +1 -1
  28. package/web/assets/{chunk-CXNFBKHE-BKAWhBa5.js → chunk-CXNFBKHE-CzfxiUa1.js} +1 -1
  29. package/web/assets/{chunk-F27PBJKO-o7rGI3GA.js → chunk-F27PBJKO-yvvjbLlc.js} +1 -1
  30. package/web/assets/{chunk-IMKFNOWR-BmyrdViV.js → chunk-IMKFNOWR-BxZBJbB_.js} +1 -1
  31. package/web/assets/{chunk-ISA7TJRJ-BGxmtUia.js → chunk-ISA7TJRJ-Cp29tVok.js} +1 -1
  32. package/web/assets/{chunk-JWPE2WC7-BBAMF-rY.js → chunk-JWPE2WC7-DOdLmesh.js} +1 -1
  33. package/web/assets/{chunk-LV3HUYFY-CbkVPncJ.js → chunk-LV3HUYFY-DnwrB_LN.js} +1 -1
  34. package/web/assets/{chunk-M3IUQBOH-alEwzp03.js → chunk-M3IUQBOH-vg43mE0i.js} +1 -1
  35. package/web/assets/{chunk-NDIOYS4C-CEpVqhVP.js → chunk-NDIOYS4C-DX4rKEXU.js} +1 -1
  36. package/web/assets/{chunk-POPQ4Y6H-B9gIdvW8.js → chunk-POPQ4Y6H-DWJRWJdI.js} +1 -1
  37. package/web/assets/{chunk-RE4WF27V-DD_tIbhS.js → chunk-RE4WF27V-2wd9naKA.js} +1 -1
  38. package/web/assets/{chunk-SVP7TREG-BFXLIXsV.js → chunk-SVP7TREG-z9mziOIq.js} +1 -1
  39. package/web/assets/{chunk-TICWLB2K-CYwqg8bG.js → chunk-TICWLB2K-B96jM8cY.js} +1 -1
  40. package/web/assets/{chunk-VII2H2IX-Yeuf-zra.js → chunk-VII2H2IX-DfVfZpgr.js} +1 -1
  41. package/web/assets/{chunk-X5GNSKZ3-DjYMd0KL.js → chunk-X5GNSKZ3-cWshmpBS.js} +1 -1
  42. package/web/assets/{chunk-XCWWM2C3-DDzasFeQ.js → chunk-XCWWM2C3-wrCUXj_U.js} +1 -1
  43. package/web/assets/{chunk-XXDRQBXY-DqmUP0AR.js → chunk-XXDRQBXY-CTS6-V6O.js} +1 -1
  44. package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-CtBBilFi.js +1 -0
  45. package/web/assets/classDiagram-ZZMXUADV-Dhw084dk.js +1 -0
  46. package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-CtBBilFi.js +1 -0
  47. package/web/assets/classDiagram-v2-VYDZK3BY-Dhw084dk.js +1 -0
  48. package/web/assets/{core-C69ArKBS.js → core-CwmXubmg.js} +1 -1
  49. package/web/assets/{cose-bilkent-JH36ORCC-BNPohDkx.js → cose-bilkent-JH36ORCC-CW7ysnV0.js} +1 -1
  50. package/web/assets/{cose-bilkent-JH36ORCC-OB24KH3T-BuyM1i_z.js → cose-bilkent-JH36ORCC-OB24KH3T-BbGGxxSy.js} +1 -1
  51. package/web/assets/{cynefin-OW5HDTMX-Cvx9iyxb.js → cynefin-OW5HDTMX-B7U_atXz.js} +1 -1
  52. package/web/assets/{cynefin-OW5HDTMX-GVF3BKWE-mEE7tM4X.js → cynefin-OW5HDTMX-GVF3BKWE-DshqNIFJ.js} +1 -1
  53. package/web/assets/{cynefinDiagram-5FMLGOSQ-debMk_OJ.js → cynefinDiagram-5FMLGOSQ-DwXcXUaw.js} +1 -1
  54. package/web/assets/{cynefinDiagram-5FMLGOSQ-H3WIRU3N-ChACvZZY.js → cynefinDiagram-5FMLGOSQ-H3WIRU3N-BAEMRQyz.js} +1 -1
  55. package/web/assets/{dagre-3AP2YEHR-DCERTXHT-Cn9bP5im.js → dagre-3AP2YEHR-DCERTXHT-DXiwdG63.js} +1 -1
  56. package/web/assets/{dagre-GXQ25YYZ-hc_iIUvf.js → dagre-GXQ25YYZ-H_jWhQNy.js} +1 -1
  57. package/web/assets/{diagram-S7CK7UJ4-CYWNdfdL.js → diagram-S7CK7UJ4-DUbw3oiY.js} +1 -1
  58. package/web/assets/{diagram-S7CK7UJ4-MULGZGEL-DtHJ9UM1.js → diagram-S7CK7UJ4-MULGZGEL-BUXvUaGD.js} +1 -1
  59. package/web/assets/{diagram-UQ7AKVKN-BWIFValo.js → diagram-UQ7AKVKN-CvNB1ieU.js} +1 -1
  60. package/web/assets/{diagram-UQ7AKVKN-YQBY353J-7x8PUinx.js → diagram-UQ7AKVKN-YQBY353J-CvO9OD4J.js} +1 -1
  61. package/web/assets/{diagram-VSXAHHWV-BMd4SO60.js → diagram-VSXAHHWV-CVUZjDi2.js} +1 -1
  62. package/web/assets/{diagram-VSXAHHWV-WLNH2ELY-u_Q-wAnJ.js → diagram-VSXAHHWV-WLNH2ELY-CUKSQlvH.js} +1 -1
  63. package/web/assets/{diagram-VX7I27RA-Cnmk2y9O.js → diagram-VX7I27RA-DKmT_43c.js} +1 -1
  64. package/web/assets/{diagram-VX7I27RA-XW6YQV5G-C6Yu5zru.js → diagram-VX7I27RA-XW6YQV5G-GgsE50Kt.js} +1 -1
  65. package/web/assets/{diagram-Z3DM3KII-BhEJQERC.js → diagram-Z3DM3KII-DjFWghAZ.js} +1 -1
  66. package/web/assets/{diagram-Z3DM3KII-HG7RF65D-CtCXFo6c.js → diagram-Z3DM3KII-HG7RF65D-hKWCijxp.js} +1 -1
  67. package/web/assets/{ebnfDiagram-PWID7BFC-BoWU51y-.js → ebnfDiagram-PWID7BFC-C1BSqN0b.js} +1 -1
  68. package/web/assets/{ebnfDiagram-PWID7BFC-OKY4VHYD-d9NTWmqf.js → ebnfDiagram-PWID7BFC-OKY4VHYD-CmC9C2mz.js} +1 -1
  69. package/web/assets/{erDiagram-RLTQ6QDP-DcYLYiJ2.js → erDiagram-RLTQ6QDP-CUm4v0Ut.js} +1 -1
  70. package/web/assets/{erDiagram-SSCWMZ5O-PIPKOIK7-gWRPoZKp.js → erDiagram-SSCWMZ5O-PIPKOIK7-CQXlfkga.js} +1 -1
  71. package/web/assets/{flowDiagram-A5DVABFB-2Z4AVO5R-BFIu9Cmp.js → flowDiagram-A5DVABFB-2Z4AVO5R-j9nzXPg7.js} +1 -1
  72. package/web/assets/{flowDiagram-HODETNUW-Y8qVZRXS.js → flowDiagram-HODETNUW-CR90kxGC.js} +1 -1
  73. package/web/assets/{ganttDiagram-EL5Y4UJY-JZNG7GOG-_c_SBGjz.js → ganttDiagram-EL5Y4UJY-JZNG7GOG-D2mTiEmE.js} +1 -1
  74. package/web/assets/{ganttDiagram-EL5Y4UJY-BnrqZAcN.js → ganttDiagram-EL5Y4UJY-Tbvt5ZCZ.js} +1 -1
  75. package/web/assets/{gitGraphDiagram-WWUBYQGX-DMWMLL3G-vT0wsqyN.js → gitGraphDiagram-WWUBYQGX-DMWMLL3G-NdHmJsq3.js} +1 -1
  76. package/web/assets/{gitGraphDiagram-WWUBYQGX-CpBs9G6L.js → gitGraphDiagram-WWUBYQGX-rhFOY_a8.js} +1 -1
  77. package/web/assets/{index-C1KQONPL.js → index-CXmOpaVd.js} +1 -1
  78. package/web/assets/{index-CmgjThXN.js → index-CdZ-qnc_.js} +1 -1
  79. package/web/assets/{index-QdMubkyO.js → index-DsNNOEb3.js} +1 -1
  80. package/web/assets/{infoDiagram-27XIBGKW-DUYwCRav.js → infoDiagram-27XIBGKW-DBLlRi-_.js} +1 -1
  81. package/web/assets/{infoDiagram-RXCK75RN-HANS5KVC-4h2pUakA.js → infoDiagram-RXCK75RN-HANS5KVC-8_Zmw4hy.js} +1 -1
  82. package/web/assets/{ishikawaDiagram-5VMMS53U-7GCIT7WU-DIEERW9O.js → ishikawaDiagram-5VMMS53U-7GCIT7WU-B05fvfuA.js} +1 -1
  83. package/web/assets/{ishikawaDiagram-5VMMS53U-CJ8Ok5Yd.js → ishikawaDiagram-5VMMS53U-CRKEdsn6.js} +1 -1
  84. package/web/assets/{journeyDiagram-3NMN7TZE-D-BH10qN.js → journeyDiagram-3NMN7TZE-0fJTVj4B.js} +1 -1
  85. package/web/assets/{journeyDiagram-EYS64GPL-OAPELBT7-Cz0JuM6i.js → journeyDiagram-EYS64GPL-OAPELBT7-BPh1-hQL.js} +1 -1
  86. package/web/assets/{kanban-definition-3QL26DDD-I7RKWQQY-CjGXf_Ah.js → kanban-definition-3QL26DDD-I7RKWQQY-DnKMsYGX.js} +1 -1
  87. package/web/assets/{kanban-definition-UXKFOSKX-C5lm_g35.js → kanban-definition-UXKFOSKX-CJRw_XnQ.js} +1 -1
  88. package/web/assets/{katex-N6JRN4PM-DgbHpI_q.js → katex-N6JRN4PM-CPG5jd-m.js} +1 -1
  89. package/web/assets/{layout-BFAbPuxr.js → layout-WKxF46Sb.js} +1 -1
  90. package/web/assets/{main-qytebVny.js → main-Ddv2iP4O.js} +6 -6
  91. package/web/assets/{mermaid-layout-elk.core-DoAN-knr.js → mermaid-layout-elk.core-DjqOZdkP.js} +2 -2
  92. package/web/assets/{mermaid.core-Bjzedlbp.js → mermaid.core-qEyRpACG.js} +5 -5
  93. package/web/assets/{mindmap-definition-FBJOCRG2-KIYZG64Y-D79FJYpy.js → mindmap-definition-FBJOCRG2-KIYZG64Y-B9tQ4eM_.js} +1 -1
  94. package/web/assets/{mindmap-definition-YA3MSWOX-D_oN5N5p.js → mindmap-definition-YA3MSWOX-BkIFBGfU.js} +1 -1
  95. package/web/assets/{pegDiagram-XKGWAZYB-C7553TPw.js → pegDiagram-XKGWAZYB-DcI2AwYJ.js} +1 -1
  96. package/web/assets/{pegDiagram-XKGWAZYB-OIP57N6J-CRUAtCoM.js → pegDiagram-XKGWAZYB-OIP57N6J-Bv_JAmyG.js} +1 -1
  97. package/web/assets/{pieDiagram-E7YTZNPT-2UOTW327-B2i5DNw0.js → pieDiagram-E7YTZNPT-2UOTW327-CjuzPmf9.js} +1 -1
  98. package/web/assets/{pieDiagram-E7YTZNPT-C2lEUv4i.js → pieDiagram-E7YTZNPT-BaZynqYg.js} +1 -1
  99. package/web/assets/{quadrantDiagram-AXDQQJYC-D78smixx.js → quadrantDiagram-AXDQQJYC-C3bIuJtC.js} +1 -1
  100. package/web/assets/{quadrantDiagram-AXDQQJYC-SN3ASJJK-DQUrRZpz.js → quadrantDiagram-AXDQQJYC-SN3ASJJK-cB1UOHJA.js} +1 -1
  101. package/web/assets/{railroadDiagram-O6MQD6OU-34742W6X-CWxcUIro.js → railroadDiagram-O6MQD6OU-34742W6X-BNYVgzV6.js} +1 -1
  102. package/web/assets/{railroadDiagram-O6MQD6OU-QQRI-4P0.js → railroadDiagram-O6MQD6OU-C6oRw1Qj.js} +1 -1
  103. package/web/assets/{render-O7CIS3YK-CwFn0FZx.js → render-O7CIS3YK-D4OiLjZ5.js} +7 -7
  104. package/web/assets/{requirementDiagram-BXWQKSXE-Cnm55mmz.js → requirementDiagram-BXWQKSXE-CgbKuYIE.js} +1 -1
  105. package/web/assets/{requirementDiagram-EFPCY7ZU-NGAFFSMB-CxPYnaAo.js → requirementDiagram-EFPCY7ZU-NGAFFSMB-BDh6OgjY.js} +1 -1
  106. package/web/assets/{rotate-ccw-9hLz1k1V.js → rotate-ccw-Cxqa2-CD.js} +1 -1
  107. package/web/assets/{sankeyDiagram-P5KCCOFB-3D3M4XPB-Dz4T6Foe.js → sankeyDiagram-P5KCCOFB-3D3M4XPB-DO2Kft8v.js} +1 -1
  108. package/web/assets/{sankeyDiagram-P5KCCOFB-BXIhrNnc.js → sankeyDiagram-P5KCCOFB-CMdYOS5W.js} +1 -1
  109. package/web/assets/{sequenceDiagram-WJ2MYXX4-C5e3FKxp.js → sequenceDiagram-WJ2MYXX4-DPyN_j7t.js} +1 -1
  110. package/web/assets/{sequenceDiagram-WJ2MYXX4-Q2IOPB4R-DygYLk8A.js → sequenceDiagram-WJ2MYXX4-Q2IOPB4R-BVwDL8kF.js} +1 -1
  111. package/web/assets/{sizeCapture-INFHLROL-HvYieNKx.js → sizeCapture-INFHLROL-zWj8EzZy.js} +1 -1
  112. package/web/assets/{sizeCapture-X5ZJPWSS-PSGVOMYM-DzWaejbe.js → sizeCapture-X5ZJPWSS-PSGVOMYM-qs3e-u6k.js} +1 -1
  113. package/web/assets/{stateDiagram-D77RDMKH-CjiI23PO.js → stateDiagram-D77RDMKH-BA18h9s2.js} +1 -1
  114. package/web/assets/{stateDiagram-HBIQ2CUA-4M2S6MAN-CyhhRUm4.js → stateDiagram-HBIQ2CUA-4M2S6MAN-DOMN4ozc.js} +1 -1
  115. package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-DDBNKNcm.js +1 -0
  116. package/web/assets/stateDiagram-v2-MP3YSRHH-DS7Arj1v.js +1 -0
  117. package/web/assets/{swimlanes-42K2YHIH-Bk1rsL8z.js → swimlanes-42K2YHIH-BHPuHqvO.js} +1 -1
  118. package/web/assets/{swimlanes-XN3QIQJK-N6N2CCQ6-XAGvF6Qg.js → swimlanes-XN3QIQJK-N6N2CCQ6-BPZvFYI6.js} +1 -1
  119. package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-APyN_W2X.js +8 -0
  120. package/web/assets/swimlanesDiagram-VR7AAH4N-B2STh1Mx.js +8 -0
  121. package/web/assets/{timeline-definition-24CTP7MA-KN7RSRVM-CDneAjZK.js → timeline-definition-24CTP7MA-KN7RSRVM-Dgo6jQ3j.js} +1 -1
  122. package/web/assets/{timeline-definition-24CTP7MA-BP3cWAwx.js → timeline-definition-24CTP7MA-bluUQlQ2.js} +1 -1
  123. package/web/assets/{vennDiagram-4TSXK5OY-AKJ7LXAN-CqL015x5.js → vennDiagram-4TSXK5OY-AKJ7LXAN-BFuvFG7t.js} +1 -1
  124. package/web/assets/{vennDiagram-4TSXK5OY-CsurZQQe.js → vennDiagram-4TSXK5OY-ob9VEZPh.js} +1 -1
  125. package/web/assets/{wardleyDiagram-VM6X3IG4-3B6A3BN5-B_knfNbz.js → wardleyDiagram-VM6X3IG4-3B6A3BN5-MHSGulo9.js} +1 -1
  126. package/web/assets/{wardleyDiagram-VM6X3IG4-B_cDlwRL.js → wardleyDiagram-VM6X3IG4-pp6avJm-.js} +1 -1
  127. package/web/assets/{xychartDiagram-S5SC5T6Z-CmQnGNGQ.js → xychartDiagram-S5SC5T6Z-BOI0JhSD.js} +1 -1
  128. package/web/assets/{xychartDiagram-S5SC5T6Z-OBDNV6WG-ivpXm_6P.js → xychartDiagram-S5SC5T6Z-OBDNV6WG-C7gREAp6.js} +1 -1
  129. package/web/index.html +1 -1
  130. package/web/assets/channel-CDZDGMUE.js +0 -1
  131. package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-NC7vfyEt.js +0 -1
  132. package/web/assets/classDiagram-ZZMXUADV-zF1C0Ltn.js +0 -1
  133. package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-NC7vfyEt.js +0 -1
  134. package/web/assets/classDiagram-v2-VYDZK3BY-zF1C0Ltn.js +0 -1
  135. package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-DA4uhZ0z.js +0 -1
  136. package/web/assets/stateDiagram-v2-MP3YSRHH-VgnrePoJ.js +0 -1
  137. package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-DxUeipqx.js +0 -8
  138. package/web/assets/swimlanesDiagram-VR7AAH4N-Bpr3HF_t.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CourseSearchPanel-ErS8Zlba.js","./index-B17kVlmS.js","./index-Dg36hRBF.css","./index-QdMubkyO.js","./index-C1KQONPL.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-C69ArKBS.js","./MermaidArtifact-BVmEpDZk.js","./CanvasStage-D4hAqHX5.js","./index-CmgjThXN.js","./rotate-ccw-9hLz1k1V.js","./VoicePanel-DvTnIP2j.js","./PersonalProfileModal-B-4B0oxN.js","./ModelManagerModal-CSOiYXJw.js","./Toggle-DB-5Fwv6.js","./ReviewPanel-ZCLRG73N.js","./SettingsView-BNv73q7Y.js","./ExamView-CEaKtO-T.js","./CommandPalette-BHpA4Ewc.js","./CompanionBotLab-Bp2oeINT.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CourseSearchPanel-CEECNtWD.js","./index-B17kVlmS.js","./index-Dg36hRBF.css","./index-DsNNOEb3.js","./index-CXmOpaVd.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-CwmXubmg.js","./MermaidArtifact-J6xyhs4Y.js","./CanvasStage-Di9Xd_SQ.js","./index-CdZ-qnc_.js","./rotate-ccw-Cxqa2-CD.js","./VoicePanel-CSLmne9b.js","./PersonalProfileModal-CywAVDIt.js","./ModelManagerModal-B7H5t5QP.js","./Toggle-D7gNZcnf.js","./ReviewPanel-BZY64BTO.js","./SettingsView-dG7fUQi5.js","./ExamView-Bh2gu61P.js","./CommandPalette-BjIg1GAx.js","./CompanionBotLab-Bp2oeINT.js"])))=>i.map(i=>d[i]);
2
2
  var Db=Object.defineProperty;var Ob=(e,t,n)=>t in e?Db(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var qa=(e,t,n)=>Ob(e,typeof t!="symbol"?t+"":t,n);import{r as k,q as Fb,j as p,a as Tc,g as Zl,u as Jl,t as wc,c as Ar,v as Qo,w as Zo,x as Bb,y as jb,z as Bt,A as Hb,B as Ub,D as zb,F as Sc,E as Ac,G as Vb,H as qb,I as Rr,J as mi,K as $b,L as Cc,N as Wb,O as Yb,P as Gb,s as Kb,n as ds,Q as Xb,o as Jo,M as Qb,R as Zb,S as _c,T as hs,U as Jb,W as ex,X as $a,d as Gt,Y as Nc,Z as tx,_ as Ic,$ as nx,a0 as rx,a1 as ix,a2 as sx,a3 as ax,a4 as ox,a5 as lx,a6 as Rc,a7 as Un,a8 as ux,a9 as cx,aa as dx,ab as Mc,ac as hx,ad as fx,ae as mx,af as px,ag as eu}from"./index-B17kVlmS.js";const gx="modulepreload",bx=function(e,t){return new URL(e,t).href},Pc={},_e=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let a=function(c){return Promise.all(c.map(h=>Promise.resolve(h).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};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=bx(c,r),c in Pc)return;Pc[c]=!0;const h=c.endsWith(".css"),f=h?'[rel="stylesheet"]':"";if(!!r)for(let g=o.length-1;g>=0;g--){const b=o[g];if(b.href===c&&(!h||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${f}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":gx,h||(m.as="script"),m.crossOrigin="",m.href=c,u&&m.setAttribute("nonce",u),document.head.appendChild(m),h)return new Promise((g,b)=>{m.addEventListener("load",g),m.addEventListener("error",()=>b(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
  *
@@ -505,7 +505,7 @@ Based on my performance, decide what comes next: explain why I got questions wro
505
505
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
506
506
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
507
507
  * THE SOFTWARE.
508
- */var Sy=Ps.exports,Hc;function Ay(){return Hc||(Hc=1,(function(e,t){(function(r,s){e.exports=s()})(Sy,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 h=arguments[c];if(h)for(var f in h)u&&h[f]&&h[f].constructor===Object&&(!a[f]||a[f].constructor===Object)?(a[f]=a[f]||{},s.extend(a[f],u,h[f])):a[f]=h[f]}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 h=o.split(".").slice(u,c);return s.get(a,o,0,-1)[h[h.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 h=u[a]||[];l[a]=!0;for(var f=0;f<h.length;f+=1){var d=h[f];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,h=new Array(arguments.length),f=0,d=arguments.length;f<d;f++)h[f]=arguments[f];for(f=0;f<a.length;f+=1){var m=a[f].apply(c,h);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 Tc<"u"&&(a=Tc.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 h=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=h,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=[],h=0;h<l.length;h++){var f=l[h],d={x:f.x,y:f.y,index:h,body:u,isInternal:!1};c.push(d)}return c},i.fromPath=function(l,u){var c=/L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/ig,h=[];return l.replace(c,function(f,d,m){h.push({x:parseFloat(d),y:parseFloat(m)})}),i.create(h,u)},i.centre=function(l){for(var u=i.area(l,!0),c={x:0,y:0},h,f,d,m=0;m<l.length;m++)d=(m+1)%l.length,h=a.cross(l[m],l[d]),f=a.mult(a.add(l[m],l[d]),h),c=a.add(c,f);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,h=l.length-1,f=0;f<l.length;f++)c+=(l[h].x-l[f].x)*(l[h].y+l[f].y),h=f;return u?c/2:Math.abs(c)/2},i.inertia=function(l,u){for(var c=0,h=0,f=l,d,m,g=0;g<f.length;g++)m=(g+1)%f.length,d=Math.abs(a.cross(f[m],f[g])),c+=d*(a.dot(f[m],f[m])+a.dot(f[m],f[g])+a.dot(f[g],f[g])),h+=d;return u/6*(c/h)},i.translate=function(l,u,c){c=typeof c<"u"?c:1;var h=l.length,f=u.x*c,d=u.y*c,m;for(m=0;m<h;m++)l[m].x+=f,l[m].y+=d;return l},i.rotate=function(l,u,c){if(u!==0){var h=Math.cos(u),f=Math.sin(u),d=c.x,m=c.y,g=l.length,b,y,w,E;for(E=0;E<g;E++)b=l[E],y=b.x-d,w=b.y-m,b.x=d+(y*h-w*f),b.y=m+(y*f+w*h);return l}},i.contains=function(l,u){for(var c=u.x,h=u.y,f=l.length,d=l[f-1],m,g=0;g<f;g++){if(m=l[g],(c-d.x)*(m.y-d.y)+(h-d.y)*(d.x-m.x)>0)return!1;d=m}return!0},i.scale=function(l,u,c,h){if(u===1&&c===1)return l;h=h||i.centre(l);for(var f,d,m=0;m<l.length;m++)f=l[m],d=a.sub(f,h),l[m].x=h.x+d.x*u,l[m].y=h.y+d.y*c;return l},i.chamfer=function(l,u,c,h,f){typeof u=="number"?u=[u]:u=u||[8],c=typeof c<"u"?c:-1,h=h||2,f=f||14;for(var d=[],m=0;m<l.length;m++){var g=l[m-1>=0?m-1:l.length-1],b=l[m],y=l[(m+1)%l.length],w=u[m<u.length?m:u.length-1];if(w===0){d.push(b);continue}var E=a.normalise({x:b.y-g.y,y:g.x-b.x}),S=a.normalise({x:y.y-b.y,y:b.x-y.x}),v=Math.sqrt(2*Math.pow(w,2)),T=a.mult(o.clone(E),w),_=a.normalise(a.mult(a.add(E,S),.5)),A=a.sub(b,a.mult(_,v)),N=c;c===-1&&(N=Math.pow(w,.32)*1.75),N=o.clamp(N,h,f),N%2===1&&(N+=1);for(var C=Math.acos(a.dot(E,S)),D=C/N,P=0;P<N;P++)d.push(a.add(a.rotate(T,D*P),A))}return d},i.clockwiseSort=function(l){var u=i.mean(l);return l.sort(function(c,h){return a.angle(u,c)-a.angle(u,h)}),l},i.isConvex=function(l){var u=0,c=l.length,h,f,d,m;if(c<3)return null;for(h=0;h<c;h++)if(f=(h+1)%c,d=(h+2)%c,m=(l[f].x-l[h].x)*(l[d].y-l[f].y),m-=(l[f].y-l[h].y)*(l[d].x-l[f].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=[],h,f;for(l=l.slice(0),l.sort(function(d,m){var g=d.x-m.x;return g!==0?g:d.y-m.y}),f=0;f<l.length;f+=1){for(h=l[f];c.length>=2&&a.cross3(c[c.length-2],c[c.length-1],h)<=0;)c.pop();c.push(h)}for(f=l.length-1;f>=0;f-=1){for(h=l[f];u.length>=2&&a.cross3(u[u.length-2],u[u.length-1],h)<=0;)u.pop();u.push(h)}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),h=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},g=u.extend(m,d);return f(g,d),g},i.nextGroup=function(d){return d?i._nextNonCollidingGroupId--:i._nextCollidingGroupId++},i.nextCategory=function(){return i._nextCategory=i._nextCategory<<1,i._nextCategory};var f=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),h.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 g=d.isStatic?"#14151f":u.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),b=d.isStatic?"#555":"#ccc",y=d.isStatic&&d.render.fillStyle===null?1:0;d.render.fillStyle=d.render.fillStyle||g,d.render.strokeStyle=d.render.strokeStyle||b,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,g){var b;typeof m=="string"&&(b=m,m={},m[b]=g);for(b in m)if(Object.prototype.hasOwnProperty.call(m,b))switch(g=m[b],b){case"isStatic":i.setStatic(d,g);break;case"isSleeping":l.set(d,g);break;case"mass":i.setMass(d,g);break;case"density":i.setDensity(d,g);break;case"inertia":i.setInertia(d,g);break;case"vertices":i.setVertices(d,g);break;case"position":i.setPosition(d,g);break;case"angle":i.setAngle(d,g);break;case"velocity":i.setVelocity(d,g);break;case"angularVelocity":i.setAngularVelocity(d,g);break;case"speed":i.setSpeed(d,g);break;case"angularSpeed":i.setAngularSpeed(d,g);break;case"parts":i.setParts(d,g);break;case"centre":i.setCentre(d,g);break;default:d[b]=g}},i.setStatic=function(d,m){for(var g=0;g<d.parts.length;g++){var b=d.parts[g];b.isStatic=m,m?(b._original={restitution:b.restitution,friction:b.friction,mass:b.mass,inertia:b.inertia,density:b.density,inverseMass:b.inverseMass,inverseInertia:b.inverseInertia},b.restitution=0,b.friction=1,b.mass=b.inertia=b.density=1/0,b.inverseMass=b.inverseInertia=0,b.positionPrev.x=b.position.x,b.positionPrev.y=b.position.y,b.anglePrev=b.angle,b.angularVelocity=0,b.speed=0,b.angularSpeed=0,b.motion=0):b._original&&(b.restitution=b._original.restitution,b.friction=b._original.friction,b.mass=b._original.mass,b.inertia=b._original.inertia,b.density=b._original.density,b.inverseMass=b._original.inverseMass,b.inverseInertia=b._original.inverseInertia,b._original=null)}},i.setMass=function(d,m){var g=d.inertia/(d.mass/6);d.inertia=g*(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=h.fromVertices(d.vertices),d.area=a.area(d.vertices),i.setMass(d,d.density*d.area);var g=a.centre(d.vertices);a.translate(d.vertices,g,-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,g){var b;for(m=m.slice(0),d.parts.length=0,d.parts.push(d),d.parent=d,b=0;b<m.length;b++){var y=m[b];y!==d&&(y.parent=d,d.parts.push(y))}if(d.parts.length!==1){if(g=typeof g<"u"?g:!0,g){var w=[];for(b=0;b<m.length;b++)w=w.concat(m[b].vertices);a.clockwiseSort(w);var E=a.hull(w),S=a.centre(E);i.setVertices(d,E),a.translate(d.vertices,S)}var v=i._totalProperties(d);d.area=v.area,d.parent=d,d.position.x=v.centre.x,d.position.y=v.centre.y,d.positionPrev.x=v.centre.x,d.positionPrev.y=v.centre.y,i.setMass(d,v.mass),i.setInertia(d,v.inertia),i.setPosition(d,v.centre)}},i.setCentre=function(d,m,g){g?(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,g){var b=o.sub(m,d.position);g?(d.positionPrev.x=d.position.x,d.positionPrev.y=d.position.y,d.velocity.x=b.x,d.velocity.y=b.y,d.speed=o.magnitude(b)):(d.positionPrev.x+=b.x,d.positionPrev.y+=b.y);for(var y=0;y<d.parts.length;y++){var w=d.parts[y];w.position.x+=b.x,w.position.y+=b.y,a.translate(w.vertices,b),c.update(w.bounds,w.vertices,d.velocity)}},i.setAngle=function(d,m,g){var b=m-d.angle;g?(d.anglePrev=d.angle,d.angularVelocity=b,d.angularSpeed=Math.abs(b)):d.anglePrev+=b;for(var y=0;y<d.parts.length;y++){var w=d.parts[y];w.angle+=b,a.rotate(w.vertices,b,d.position),h.rotate(w.axes,b),c.update(w.bounds,w.vertices,d.velocity),y>0&&o.rotateAbout(w.position,b,d.position,w.position)}},i.setVelocity=function(d,m){var g=d.deltaTime/i._baseDelta;d.positionPrev.x=d.position.x-m.x*g,d.positionPrev.y=d.position.y-m.y*g,d.velocity.x=(d.position.x-d.positionPrev.x)/g,d.velocity.y=(d.position.y-d.positionPrev.y)/g,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 g=d.deltaTime/i._baseDelta;d.anglePrev=d.angle-m*g,d.angularVelocity=(d.angle-d.anglePrev)/g,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,g){i.setPosition(d,o.add(d.position,m),g)},i.rotate=function(d,m,g,b){if(!g)i.setAngle(d,d.angle+m,b);else{var y=Math.cos(m),w=Math.sin(m),E=d.position.x-g.x,S=d.position.y-g.y;i.setPosition(d,{x:g.x+(E*y-S*w),y:g.y+(E*w+S*y)},b),i.setAngle(d,d.angle+m,b)}},i.scale=function(d,m,g,b){var y=0,w=0;b=b||d.position;for(var E=0;E<d.parts.length;E++){var S=d.parts[E];a.scale(S.vertices,m,g,b),S.axes=h.fromVertices(S.vertices),S.area=a.area(S.vertices),i.setMass(S,d.density*S.area),a.translate(S.vertices,{x:-S.position.x,y:-S.position.y}),i.setInertia(S,i._inertiaScale*a.inertia(S.vertices,S.mass)),a.translate(S.vertices,{x:S.position.x,y:S.position.y}),E>0&&(y+=S.area,w+=S.inertia),S.position.x=b.x+(S.position.x-b.x)*m,S.position.y=b.y+(S.position.y-b.y)*g,c.update(S.bounds,S.vertices,d.velocity)}d.parts.length>1&&(d.area=y,d.isStatic||(i.setMass(d,d.density*y),i.setInertia(d,w))),d.circleRadius&&(m===g?d.circleRadius*=m:d.circleRadius=null)},i.update=function(d,m){m=(typeof m<"u"?m:1e3/60)*d.timeScale;var g=m*m,b=i._timeCorrection?m/(d.deltaTime||m):1,y=1-d.frictionAir*(m/u._baseDelta),w=(d.position.x-d.positionPrev.x)*b,E=(d.position.y-d.positionPrev.y)*b;d.velocity.x=w*y+d.force.x/d.mass*g,d.velocity.y=E*y+d.force.y/d.mass*g,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*b+d.torque/d.inertia*g,d.anglePrev=d.angle,d.angle+=d.angularVelocity;for(var S=0;S<d.parts.length;S++){var v=d.parts[S];a.translate(v.vertices,d.velocity),S>0&&(v.position.x+=d.velocity.x,v.position.y+=d.velocity.y),d.angularVelocity!==0&&(a.rotate(v.vertices,d.angularVelocity,d.position),h.rotate(v.axes,d.angularVelocity),S>0&&o.rotateAbout(v.position,d.angularVelocity,d.position,v.position)),c.update(v.bounds,v.vertices,d.velocity)}},i.updateVelocities=function(d){var m=i._baseDelta/d.deltaTime,g=d.velocity;g.x=(d.position.x-d.positionPrev.x)*m,g.y=(d.position.y-d.positionPrev.y)*m,d.speed=Math.sqrt(g.x*g.x+g.y*g.y),d.angularVelocity=(d.angle-d.anglePrev)*m,d.angularSpeed=Math.abs(d.angularVelocity)},i.applyForce=function(d,m,g){var b={x:m.x-d.position.x,y:m.y-d.position.y};d.force.x+=g.x,d.force.y+=g.y,d.torque+=b.x*g.y-b.y*g.x},i._totalProperties=function(d){for(var m={mass:0,area:0,inertia:0,centre:{x:0,y:0}},g=d.parts.length===1?0:1;g<d.parts.length;g++){var b=d.parts[g],y=b.mass!==1/0?b.mass:1;m.mass+=y,m.area+=b.area,m.inertia+=b.inertia,m.centre=o.add(m.centre,o.mult(b.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(" "),h,f=0;f<c.length;f++)h=c[f],o.events=o.events||{},o.events[h]=o.events[h]||[],o.events[h].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(" "),h=0;h<c.length;h++){var f=o.events[c[h]],d=[];if(u&&f)for(var m=0;m<f.length;m++)f[m]!==u&&d.push(f[m]);o.events[c[h]]=d}},i.trigger=function(o,l,u){var c,h,f,d,m=o.events;if(m&&a.keys(m).length>0){u||(u={}),c=l.split(" ");for(var g=0;g<c.length;g++)if(h=c[g],f=m[h],f){d=a.clone(u,!1),d.name=h,d.source=o;for(var b=0;b<f.length;b++)f[b].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,h,f,d){if(c.isModified=h,h&&c.cache&&(c.cache.allBodies=null,c.cache.allConstraints=null,c.cache.allComposites=null),f&&c.parent&&i.setModified(c.parent,h,f,d),d)for(var m=0;m<c.composites.length;m++){var g=c.composites[m];i.setModified(g,h,f,d)}},i.add=function(c,h){var f=[].concat(h);a.trigger(c,"beforeAdd",{object:h});for(var d=0;d<f.length;d++){var m=f[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:h}),c},i.remove=function(c,h,f){var d=[].concat(h);a.trigger(c,"beforeRemove",{object:h});for(var m=0;m<d.length;m++){var g=d[m];switch(g.type){case"body":i.removeBody(c,g,f);break;case"constraint":i.removeConstraint(c,g,f);break;case"composite":i.removeComposite(c,g,f);break;case"mouseConstraint":i.removeConstraint(c,g.constraint);break}}return a.trigger(c,"afterRemove",{object:h}),c},i.addComposite=function(c,h){return c.composites.push(h),h.parent=c,i.setModified(c,!0,!0,!1),c},i.removeComposite=function(c,h,f){var d=o.indexOf(c.composites,h);if(d!==-1&&i.removeCompositeAt(c,d),f)for(var m=0;m<c.composites.length;m++)i.removeComposite(c.composites[m],h,!0);return c},i.removeCompositeAt=function(c,h){return c.composites.splice(h,1),i.setModified(c,!0,!0,!1),c},i.addBody=function(c,h){return c.bodies.push(h),i.setModified(c,!0,!0,!1),c},i.removeBody=function(c,h,f){var d=o.indexOf(c.bodies,h);if(d!==-1&&i.removeBodyAt(c,d),f)for(var m=0;m<c.composites.length;m++)i.removeBody(c.composites[m],h,!0);return c},i.removeBodyAt=function(c,h){return c.bodies.splice(h,1),i.setModified(c,!0,!0,!1),c},i.addConstraint=function(c,h){return c.constraints.push(h),i.setModified(c,!0,!0,!1),c},i.removeConstraint=function(c,h,f){var d=o.indexOf(c.constraints,h);if(d!==-1&&i.removeConstraintAt(c,d),f)for(var m=0;m<c.composites.length;m++)i.removeConstraint(c.composites[m],h,!0);return c},i.removeConstraintAt=function(c,h){return c.constraints.splice(h,1),i.setModified(c,!0,!0,!1),c},i.clear=function(c,h,f){if(f)for(var d=0;d<c.composites.length;d++)i.clear(c.composites[d],h,!0);return h?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 h=[].concat(c.bodies),f=0;f<c.composites.length;f++)h=h.concat(i.allBodies(c.composites[f]));return c.cache&&(c.cache.allBodies=h),h},i.allConstraints=function(c){if(c.cache&&c.cache.allConstraints)return c.cache.allConstraints;for(var h=[].concat(c.constraints),f=0;f<c.composites.length;f++)h=h.concat(i.allConstraints(c.composites[f]));return c.cache&&(c.cache.allConstraints=h),h},i.allComposites=function(c){if(c.cache&&c.cache.allComposites)return c.cache.allComposites;for(var h=[].concat(c.composites),f=0;f<c.composites.length;f++)h=h.concat(i.allComposites(c.composites[f]));return c.cache&&(c.cache.allComposites=h),h},i.get=function(c,h,f){var d,m;switch(f){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(g){return g.id.toString()===h.toString()}),m.length===0?null:m[0]):null},i.move=function(c,h,f){return i.remove(c,h),i.add(f,h),c},i.rebase=function(c){for(var h=i.allBodies(c).concat(i.allConstraints(c)).concat(i.allComposites(c)),f=0;f<h.length;f++)h[f].id=o.nextId();return c},i.translate=function(c,h,f){for(var d=f?i.allBodies(c):c.bodies,m=0;m<d.length;m++)u.translate(d[m],h);return c},i.rotate=function(c,h,f,d){for(var m=Math.cos(h),g=Math.sin(h),b=d?i.allBodies(c):c.bodies,y=0;y<b.length;y++){var w=b[y],E=w.position.x-f.x,S=w.position.y-f.y;u.setPosition(w,{x:f.x+(E*m-S*g),y:f.y+(E*g+S*m)}),u.rotate(w,h)}return c},i.scale=function(c,h,f,d,m){for(var g=m?i.allBodies(c):c.bodies,b=0;b<g.length;b++){var y=g[b],w=y.position.x-d.x,E=y.position.y-d.y;u.setPosition(y,{x:d.x+w*h,y:d.y+E*f}),u.scale(y,h,f)}return c},i.bounds=function(c){for(var h=i.allBodies(c),f=[],d=0;d<h.length;d+=1){var m=h[d];f.push(m.bounds.min,m.bounds.max)}return l.create(f)}})()}),(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 h=c/l._baseDelta,f=i._motionSleepThreshold,d=0;d<u.length;d++){var m=u[d],g=a.getSpeed(m),b=a.getAngularSpeed(m),y=g*g+b*b;if(m.force.x!==0||m.force.y!==0){i.set(m,!1);continue}var w=Math.min(m.motion,y),E=Math.max(m.motion,y);m.motion=i._minBias*w+(1-i._minBias)*E,m.sleepThreshold>0&&m.motion<f?(m.sleepCounter+=1,m.sleepCounter>=m.sleepThreshold/h&&i.set(m,!0)):m.sleepCounter>0&&(m.sleepCounter-=1)}},i.afterCollisions=function(u){for(var c=i._motionSleepThreshold,h=0;h<u.length;h++){var f=u[h];if(f.isActive){var d=f.collision,m=d.bodyA.parent,g=d.bodyB.parent;if(!(m.isSleeping&&g.isSleeping||m.isStatic||g.isStatic)&&(m.isSleeping||g.isSleeping)){var b=m.isSleeping&&!m.isStatic?m:g,y=b===m?g:m;!b.isStatic&&y.motion>c&&i.set(b,!1)}}}},i.set=function(u,c){var h=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,h||o.trigger(u,"sleepStart")):(u.isSleeping=!1,u.sleepCounter=0,h&&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(h,f){return{pair:null,collided:!1,bodyA:h,bodyB:f,parentA:h.parent,parentB:f.parent,depth:0,normal:{x:0,y:0},tangent:{x:0,y:0},penetration:{x:0,y:0},supports:[]}},i.collides=function(h,f,d){if(i._overlapAxes(u,h.vertices,f.vertices,h.axes),u.overlap<=0||(i._overlapAxes(c,f.vertices,h.vertices,f.axes),c.overlap<=0))return null;var m=d&&d.table[o.id(h,f)],g;m?g=m.collision:(g=i.create(h,f),g.collided=!0,g.bodyA=h.id<f.id?h:f,g.bodyB=h.id<f.id?f:h,g.parentA=g.bodyA.parent,g.parentB=g.bodyB.parent),h=g.bodyA,f=g.bodyB;var b;u.overlap<c.overlap?b=u:b=c;var y=g.normal,w=g.supports,E=b.axis,S=E.x,v=E.y;S*(f.position.x-h.position.x)+v*(f.position.y-h.position.y)<0?(y.x=S,y.y=v):(y.x=-S,y.y=-v),g.tangent.x=-y.y,g.tangent.y=y.x,g.depth=b.overlap,g.penetration.x=y.x*g.depth,g.penetration.y=y.y*g.depth;var T=i._findSupports(h,f,y,1),_=0;if(a.contains(h.vertices,T[0])&&(w[_++]=T[0]),a.contains(h.vertices,T[1])&&(w[_++]=T[1]),_<2){var A=i._findSupports(f,h,y,-1);a.contains(f.vertices,A[0])&&(w[_++]=A[0]),_<2&&a.contains(f.vertices,A[1])&&(w[_++]=A[1])}return _===0&&(w[_++]=T[0]),w.length=_,g},i._overlapAxes=function(h,f,d,m){var g=f.length,b=d.length,y=f[0].x,w=f[0].y,E=d[0].x,S=d[0].y,v=m.length,T=Number.MAX_VALUE,_=0,A,N,C,D,P,O;for(P=0;P<v;P++){var I=m[P],R=I.x,B=I.y,V=y*R+w*B,z=E*R+S*B,Y=V,L=z;for(O=1;O<g;O+=1)D=f[O].x*R+f[O].y*B,D>Y?Y=D:D<V&&(V=D);for(O=1;O<b;O+=1)D=d[O].x*R+d[O].y*B,D>L?L=D:D<z&&(z=D);if(N=Y-z,C=L-V,A=N<C?N:C,A<T&&(T=A,_=P,A<=0))break}h.axis=m[_],h.overlap=T},i._projectToAxis=function(h,f,d){for(var m=f[0].x*d.x+f[0].y*d.y,g=m,b=1;b<f.length;b+=1){var y=f[b].x*d.x+f[b].y*d.y;y>g?g=y:y<m&&(m=y)}h.min=m,h.max=g},i._findSupports=function(h,f,d,m){var g=f.vertices,b=g.length,y=h.position.x,w=h.position.y,E=d.x*m,S=d.y*m,v=Number.MAX_VALUE,T,_,A,N,C;for(C=0;C<b;C+=1)_=g[C],N=E*(y-_.x)+S*(w-_.y),N<v&&(v=N,T=_);return A=g[(b+T.index-1)%b],v=E*(y-A.x)+S*(w-A.y),_=g[(T.index+1)%b],E*(y-_.x)+S*(w-_.y)<v?(l[0]=T,l[1]=_,l):(l[0]=T,l[1]=A,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,h={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(h,o,l),h},i.update=function(o,l,u){var c=o.contacts,h=l.supports,f=o.activeContacts,d=l.parentA,m=l.parentB,g=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,f.length=0;for(var b=0;b<h.length;b++){var y=h[b],w=y.body===d?y.index:g+y.index,E=c[w];E?f.push(E):f.push(c[w]=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),h=s(0);(function(){i._warming=.4,i._torqueDampen=1,i._minLength=1e-6,i.create=function(f){var d=f;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,g=d.bodyB?o.add(d.bodyB.position,d.pointB):d.pointB,b=o.magnitude(o.sub(m,g));d.length=typeof d.length<"u"?d.length:b,d.id=d.id||h.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=h.extend(y,d.render),d},i.preSolveAll=function(f){for(var d=0;d<f.length;d+=1){var m=f[d],g=m.constraintImpulse;m.isStatic||g.x===0&&g.y===0&&g.angle===0||(m.position.x+=g.x,m.position.y+=g.y,m.angle+=g.angle)}},i.solveAll=function(f,d){for(var m=h.clamp(d/h._baseDelta,0,1),g=0;g<f.length;g+=1){var b=f[g],y=!b.bodyA||b.bodyA&&b.bodyA.isStatic,w=!b.bodyB||b.bodyB&&b.bodyB.isStatic;(y||w)&&i.solve(f[g],m)}for(g=0;g<f.length;g+=1)b=f[g],y=!b.bodyA||b.bodyA&&b.bodyA.isStatic,w=!b.bodyB||b.bodyB&&b.bodyB.isStatic,!y&&!w&&i.solve(f[g],m)},i.solve=function(f,d){var m=f.bodyA,g=f.bodyB,b=f.pointA,y=f.pointB;if(!(!m&&!g)){m&&!m.isStatic&&(o.rotate(b,m.angle-f.angleA,b),f.angleA=m.angle),g&&!g.isStatic&&(o.rotate(y,g.angle-f.angleB,y),f.angleB=g.angle);var w=b,E=y;if(m&&(w=o.add(m.position,b)),g&&(E=o.add(g.position,y)),!(!w||!E)){var S=o.sub(w,E),v=o.magnitude(S);v<i._minLength&&(v=i._minLength);var T=(v-f.length)/v,_=f.stiffness>=1||f.length===0,A=_?f.stiffness*d:f.stiffness*d*d,N=f.damping*d,C=o.mult(S,T*A),D=(m?m.inverseMass:0)+(g?g.inverseMass:0),P=(m?m.inverseInertia:0)+(g?g.inverseInertia:0),O=D+P,I,R,B,V,z;if(N>0){var Y=o.create();B=o.div(S,v),z=o.sub(g&&o.sub(g.position,g.positionPrev)||Y,m&&o.sub(m.position,m.positionPrev)||Y),V=o.dot(B,z)}m&&!m.isStatic&&(R=m.inverseMass/D,m.constraintImpulse.x-=C.x*R,m.constraintImpulse.y-=C.y*R,m.position.x-=C.x*R,m.position.y-=C.y*R,N>0&&(m.positionPrev.x-=N*B.x*V*R,m.positionPrev.y-=N*B.y*V*R),I=o.cross(b,C)/O*i._torqueDampen*m.inverseInertia*(1-f.angularStiffness),m.constraintImpulse.angle-=I,m.angle-=I),g&&!g.isStatic&&(R=g.inverseMass/D,g.constraintImpulse.x+=C.x*R,g.constraintImpulse.y+=C.y*R,g.position.x+=C.x*R,g.position.y+=C.y*R,N>0&&(g.positionPrev.x+=N*B.x*V*R,g.positionPrev.y+=N*B.y*V*R),I=o.cross(y,C)/O*i._torqueDampen*g.inverseInertia*(1-f.angularStiffness),g.constraintImpulse.angle+=I,g.angle+=I)}}},i.postSolveAll=function(f){for(var d=0;d<f.length;d++){var m=f[d],g=m.constraintImpulse;if(!(m.isStatic||g.x===0&&g.y===0&&g.angle===0)){l.set(m,!1);for(var b=0;b<m.parts.length;b++){var y=m.parts[b];a.translate(y.vertices,g),b>0&&(y.position.x+=g.x,y.position.y+=g.y),g.angle!==0&&(a.rotate(y.vertices,g.angle,m.position),c.rotate(y.axes,g.angle),b>0&&o.rotateAbout(y.position,g.angle,m.position,y.position)),u.update(y.bounds,y.vertices,m.velocity)}g.angle*=i._warming,g.x*=i._warming,g.y*=i._warming}}},i.pointAWorld=function(f){return{x:(f.bodyA?f.bodyA.position.x:0)+(f.pointA?f.pointA.x:0),y:(f.bodyA?f.bodyA.position.y:0)+(f.pointA?f.pointA.y:0)}},i.pointBWorld=function(f){return{x:(f.bodyB?f.bodyB.position.x:0)+(f.pointB?f.pointB.x:0),y:(f.bodyB?f.bodyB.position.y:0)+(f.pointB?f.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 h=(c+1)%l.length,f=a.normalise({x:l[h].y-l[c].y,y:l[c].x-l[h].x}),d=f.y===0?1/0:f.x/f.y;d=d.toFixed(3).toString(),u[d]=f}return o.values(u)},i.rotate=function(l,u){if(u!==0)for(var c=Math.cos(u),h=Math.sin(u),f=0;f<l.length;f++){var d=l[f],m;m=d.x*c-d.y*h,d.y=d.x*h+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(h,f,d,m,g){g=g||{};var b={label:"Rectangle Body",position:{x:h,y:f},vertices:a.fromPath("L 0 0 L "+d+" 0 L "+d+" "+m+" L 0 "+m)};if(g.chamfer){var y=g.chamfer;b.vertices=a.chamfer(b.vertices,y.radius,y.quality,y.qualityMin,y.qualityMax),delete g.chamfer}return l.create(o.extend({},b,g))},i.trapezoid=function(h,f,d,m,g,b){b=b||{},g*=.5;var y=(1-g*2)*d,w=d*g,E=w+y,S=E+w,v;g<.5?v="L 0 0 L "+w+" "+-m+" L "+E+" "+-m+" L "+S+" 0":v="L 0 0 L "+E+" "+-m+" L "+S+" 0";var T={label:"Trapezoid Body",position:{x:h,y:f},vertices:a.fromPath(v)};if(b.chamfer){var _=b.chamfer;T.vertices=a.chamfer(T.vertices,_.radius,_.quality,_.qualityMin,_.qualityMax),delete b.chamfer}return l.create(o.extend({},T,b))},i.circle=function(h,f,d,m,g){m=m||{};var b={label:"Circle Body",circleRadius:d};g=g||25;var y=Math.ceil(Math.max(10,Math.min(g,d)));return y%2===1&&(y+=1),i.polygon(h,f,y,d,o.extend({},b,m))},i.polygon=function(h,f,d,m,g){if(g=g||{},d<3)return i.circle(h,f,m,g);for(var b=2*Math.PI/d,y="",w=b*.5,E=0;E<d;E+=1){var S=w+E*b,v=Math.cos(S)*m,T=Math.sin(S)*m;y+="L "+v.toFixed(3)+" "+T.toFixed(3)+" "}var _={label:"Polygon Body",position:{x:h,y:f},vertices:a.fromPath(y)};if(g.chamfer){var A=g.chamfer;_.vertices=a.chamfer(_.vertices,A.radius,A.quality,A.qualityMin,A.qualityMax),delete g.chamfer}return l.create(o.extend({},_,g))},i.fromVertices=function(h,f,d,m,g,b,y,w){var E=o.getDecomp(),S,v,T,_,A,N,C,D,P,O,I;for(S=!!(E&&E.quickDecomp),m=m||{},T=[],g=typeof g<"u"?g:!1,b=typeof b<"u"?b:.01,y=typeof y<"u"?y:10,w=typeof w<"u"?w:.01,o.isArray(d[0])||(d=[d]),O=0;O<d.length;O+=1)if(N=d[O],_=a.isConvex(N),A=!_,A&&!S&&o.warnOnce("Bodies.fromVertices: Install the 'poly-decomp' library and use Common.setDecomp or provide 'decomp' as a global to decompose concave vertices."),_||!S)_?N=a.clockwiseSort(N):N=a.hull(N),T.push({position:{x:h,y:f},vertices:N});else{var R=N.map(function(ne){return[ne.x,ne.y]});E.makeCCW(R),b!==!1&&E.removeCollinearPoints(R,b),w!==!1&&E.removeDuplicatePoints&&E.removeDuplicatePoints(R,w);var B=E.quickDecomp(R);for(C=0;C<B.length;C++){var V=B[C],z=V.map(function(ne){return{x:ne[0],y:ne[1]}});y>0&&a.area(z)<y||T.push({position:a.centre(z),vertices:z})}}for(C=0;C<T.length;C++)T[C]=l.create(o.extend(T[C],m));if(g){var Y=5;for(C=0;C<T.length;C++){var L=T[C];for(D=C+1;D<T.length;D++){var q=T[D];if(u.overlaps(L.bounds,q.bounds)){var K=L.vertices,M=q.vertices;for(P=0;P<L.vertices.length;P++)for(I=0;I<q.vertices.length;I++){var G=c.magnitudeSquared(c.sub(K[(P+1)%K.length],M[I])),ae=c.magnitudeSquared(c.sub(K[P],M[(I+1)%M.length]));G<Y&&ae<Y&&(K[P].isInternal=!0,M[I].isInternal=!0)}}}}}return T.length>1?(v=l.create(o.extend({parts:T.slice(0)},m)),l.setPosition(v,{x:h,y:f}),v):T[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,h=l.bodies,f=h.length,d=i.canCollide,m=o.collides,g,b;for(h.sort(i._compareBoundsX),g=0;g<f;g++){var y=h[g],w=y.bounds,E=y.bounds.max.x,S=y.bounds.max.y,v=y.bounds.min.y,T=y.isStatic||y.isSleeping,_=y.parts.length,A=_===1;for(b=g+1;b<f;b++){var N=h[b],C=N.bounds;if(C.min.x>E)break;if(!(S<C.min.y||v>C.max.y)&&!(T&&(N.isStatic||N.isSleeping))&&d(y.collisionFilter,N.collisionFilter)){var D=N.parts.length;if(A&&D===1){var P=m(y,N,c);P&&u.push(P)}else for(var O=_>1?1:0,I=D>1?1:0,R=O;R<_;R++)for(var B=y.parts[R],w=B.bounds,V=I;V<D;V++){var z=N.parts[V],C=z.bounds;if(!(w.min.x>C.max.x||w.max.x<C.min.x||w.max.y<C.min.y||w.min.y>C.max.y)){var P=m(B,z,c);P&&u.push(P)}}}}}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),h=u.changedTouches;h&&(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),h=u.changedTouches;h?(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),h=u.changedTouches;h&&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(),h=document.documentElement||document.body.parentNode||document.body,f=window.pageXOffset!==void 0?window.pageXOffset:h.scrollLeft,d=window.pageYOffset!==void 0?window.pageYOffset:h.scrollTop,m=o.changedTouches,g,b;return m?(g=m[0].pageX-c.left-f,b=m[0].pageY-c.top-d):(g=o.pageX-c.left-f,b=o.pageY-c.top-d),{x:g/(l.clientWidth/(l.width||l.clientWidth)*u),y:b/(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),h=[],f=0;f<c.length;f+=1)if(c[f]!==o.name){var d=i.resolve(c[f]);if(!d){h.push("❌ "+c[f]);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?(h.push("🔶 "+i.toString(d)),delete d._warned):h.push("✅ "+i.toString(d)),o.used.push(d.name))}h.length>0&&a.info(h.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(f){i.isPlugin(f)&&i.register(f);var d=i.dependencyParse(f),m=i.resolve(f);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(f),"used by",i.toString(u),"could not be resolved."),o._warned=!0),d.name});for(var h=0;h<l[c].length;h+=1)i.dependencies(l[c][h],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]),h=Number(u[5]),f=Number(u[6]);return{isRange:!!(u[1]||u[2]),version:u[3],range:o,operator:u[1]||u[2]||"",major:c,minor:h,patch:f,parts:[c,h,f],prerelease:u[7],number:c*1e8+h*1e4+f}},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),h=s(6),f=s(10),d=s(0),m=s(4);(function(){i.create=function(g){g=g||{};var b={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(b,g);return y.world=g.world||h.create({label:"World"}),y.pairs=g.pairs||u.create(),y.detector=g.detector||l.create(),y.grid={buckets:[]},y.world.gravity=y.gravity,y.broadphase=y.grid,y.metrics={},y},i.update=function(g,b){var y=d.now(),w=g.world,E=g.detector,S=g.pairs,v=g.timing,T=v.timestamp,_;b=typeof b<"u"?b:d._baseDelta,b*=v.timeScale,v.timestamp+=b,v.lastDelta=b;var A={timestamp:v.timestamp,delta:b};c.trigger(g,"beforeUpdate",A);var N=h.allBodies(w),C=h.allConstraints(w);for(w.isModified&&(l.setBodies(E,N),h.setModified(w,!1,!1,!0)),g.enableSleeping&&a.update(N,b),i._bodiesApplyGravity(N,g.gravity),b>0&&i._bodiesUpdate(N,b),f.preSolveAll(N),_=0;_<g.constraintIterations;_++)f.solveAll(C,b);f.postSolveAll(N),E.pairs=g.pairs;var D=l.collisions(E);u.update(S,D,T),g.enableSleeping&&a.afterCollisions(S.list),S.collisionStart.length>0&&c.trigger(g,"collisionStart",{pairs:S.collisionStart});var P=d.clamp(20/g.positionIterations,0,1);for(o.preSolvePosition(S.list),_=0;_<g.positionIterations;_++)o.solvePosition(S.list,b,P);for(o.postSolvePosition(N),f.preSolveAll(N),_=0;_<g.constraintIterations;_++)f.solveAll(C,b);for(f.postSolveAll(N),o.preSolveVelocity(S.list),_=0;_<g.velocityIterations;_++)o.solveVelocity(S.list,b);return i._bodiesUpdateVelocities(N),S.collisionActive.length>0&&c.trigger(g,"collisionActive",{pairs:S.collisionActive}),S.collisionEnd.length>0&&c.trigger(g,"collisionEnd",{pairs:S.collisionEnd}),i._bodiesClearForces(N),c.trigger(g,"afterUpdate",A),g.timing.lastElapsed=d.now()-y,g},i.merge=function(g,b){if(d.extend(g,b),b.world){g.world=b.world,i.clear(g);for(var y=h.allBodies(g.world),w=0;w<y.length;w++){var E=y[w];a.set(E,!1),E.id=d.nextId()}}},i.clear=function(g){u.clear(g.pairs),l.clear(g.detector)},i._bodiesClearForces=function(g){for(var b=g.length,y=0;y<b;y++){var w=g[y];w.force.x=0,w.force.y=0,w.torque=0}},i._bodiesApplyGravity=function(g,b){var y=typeof b.scale<"u"?b.scale:.001,w=g.length;if(!(b.x===0&&b.y===0||y===0))for(var E=0;E<w;E++){var S=g[E];S.isStatic||S.isSleeping||(S.force.y+=S.mass*b.y*y,S.force.x+=S.mass*b.x*y)}},i._bodiesUpdate=function(g,b){for(var y=g.length,w=0;w<y;w++){var E=g[w];E.isStatic||E.isSleeping||m.update(E,b)}},i._bodiesUpdateVelocities=function(g){for(var b=g.length,y=0;y<b;y++)m.updateVelocities(g[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,h,f,d=u.length;for(c=0;c<d;c++)h=u[c],h.isActive&&(f=h.activeContacts.length,h.collision.parentA.totalContacts+=f,h.collision.parentB.totalContacts+=f)},i.solvePosition=function(u,c,h){var f,d,m,g,b,y,w,E,S=i._positionDampen*(h||1),v=o.clamp(c/o._baseDelta,0,1),T=u.length;for(f=0;f<T;f++)d=u[f],!(!d.isActive||d.isSensor)&&(m=d.collision,g=m.parentA,b=m.parentB,y=m.normal,d.separation=y.x*(b.positionImpulse.x+m.penetration.x-g.positionImpulse.x)+y.y*(b.positionImpulse.y+m.penetration.y-g.positionImpulse.y));for(f=0;f<T;f++)d=u[f],!(!d.isActive||d.isSensor)&&(m=d.collision,g=m.parentA,b=m.parentB,y=m.normal,E=d.separation-d.slop*v,(g.isStatic||b.isStatic)&&(E*=2),g.isStatic||g.isSleeping||(w=S/g.totalContacts,g.positionImpulse.x+=y.x*E*w,g.positionImpulse.y+=y.y*E*w),b.isStatic||b.isSleeping||(w=S/b.totalContacts,b.positionImpulse.x-=y.x*E*w,b.positionImpulse.y-=y.y*E*w))},i.postSolvePosition=function(u){for(var c=i._positionWarming,h=u.length,f=a.translate,d=l.update,m=0;m<h;m++){var g=u[m],b=g.positionImpulse,y=b.x,w=b.y,E=g.velocity;if(g.totalContacts=0,y!==0||w!==0){for(var S=0;S<g.parts.length;S++){var v=g.parts[S];f(v.vertices,b),d(v.bounds,v.vertices,E),v.position.x+=y,v.position.y+=w}g.positionPrev.x+=y,g.positionPrev.y+=w,y*E.x+w*E.y<0?(b.x=0,b.y=0):(b.x*=c,b.y*=c)}}},i.preSolveVelocity=function(u){var c=u.length,h,f;for(h=0;h<c;h++){var d=u[h];if(!(!d.isActive||d.isSensor)){var m=d.activeContacts,g=m.length,b=d.collision,y=b.parentA,w=b.parentB,E=b.normal,S=b.tangent;for(f=0;f<g;f++){var v=m[f],T=v.vertex,_=v.normalImpulse,A=v.tangentImpulse;if(_!==0||A!==0){var N=E.x*_+S.x*A,C=E.y*_+S.y*A;y.isStatic||y.isSleeping||(y.positionPrev.x+=N*y.inverseMass,y.positionPrev.y+=C*y.inverseMass,y.anglePrev+=y.inverseInertia*((T.x-y.position.x)*C-(T.y-y.position.y)*N)),w.isStatic||w.isSleeping||(w.positionPrev.x-=N*w.inverseMass,w.positionPrev.y-=C*w.inverseMass,w.anglePrev-=w.inverseInertia*((T.x-w.position.x)*C-(T.y-w.position.y)*N))}}}}},i.solveVelocity=function(u,c){var h=c/o._baseDelta,f=h*h,d=f*h,m=-i._restingThresh*h,g=i._restingThreshTangent,b=i._frictionNormalMultiplier*h,y=i._frictionMaxStatic,w=u.length,E,S,v,T;for(v=0;v<w;v++){var _=u[v];if(!(!_.isActive||_.isSensor)){var A=_.collision,N=A.parentA,C=A.parentB,D=N.velocity,P=C.velocity,O=A.normal.x,I=A.normal.y,R=A.tangent.x,B=A.tangent.y,V=_.activeContacts,z=V.length,Y=1/z,L=N.inverseMass+C.inverseMass,q=_.friction*_.frictionStatic*b;for(D.x=N.position.x-N.positionPrev.x,D.y=N.position.y-N.positionPrev.y,P.x=C.position.x-C.positionPrev.x,P.y=C.position.y-C.positionPrev.y,N.angularVelocity=N.angle-N.anglePrev,C.angularVelocity=C.angle-C.anglePrev,T=0;T<z;T++){var K=V[T],M=K.vertex,G=M.x-N.position.x,ae=M.y-N.position.y,ne=M.x-C.position.x,X=M.y-C.position.y,te=D.x-ae*N.angularVelocity,ue=D.y+G*N.angularVelocity,ge=P.x-X*C.angularVelocity,Z=P.y+ne*C.angularVelocity,re=te-ge,be=ue-Z,ve=O*re+I*be,Fe=R*re+B*be,je=_.separation+ve,Se=Math.min(je,1);Se=je<0?0:Se;var Oe=Se*q;Fe<-Oe||Fe>Oe?(S=Fe>0?Fe:-Fe,E=_.friction*(Fe>0?1:-1)*d,E<-S?E=-S:E>S&&(E=S)):(E=Fe,S=y);var st=G*I-ae*O,pt=ne*I-X*O,me=Y/(L+N.inverseInertia*st*st+C.inverseInertia*pt*pt),rt=(1+_.restitution)*ve*me;if(E*=me,ve<m)K.normalImpulse=0;else{var ie=K.normalImpulse;K.normalImpulse+=rt,K.normalImpulse>0&&(K.normalImpulse=0),rt=K.normalImpulse-ie}if(Fe<-g||Fe>g)K.tangentImpulse=0;else{var Ie=K.tangentImpulse;K.tangentImpulse+=E,K.tangentImpulse<-S&&(K.tangentImpulse=-S),K.tangentImpulse>S&&(K.tangentImpulse=S),E=K.tangentImpulse-Ie}var Be=O*rt+R*E,Q=I*rt+B*E;N.isStatic||N.isSleeping||(N.positionPrev.x+=Be*N.inverseMass,N.positionPrev.y+=Q*N.inverseMass,N.anglePrev+=(G*Q-ae*Be)*N.inverseInertia),C.isStatic||C.isSleeping||(C.positionPrev.x-=Be*C.inverseMass,C.positionPrev.y-=Q*C.inverseMass,C.anglePrev-=(ne*Q-X*Be)*C.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 h=l.list,f=h.length,d=l.table,m=u.length,g=l.collisionStart,b=l.collisionEnd,y=l.collisionActive,w,E,S,v;for(g.length=0,b.length=0,y.length=0,v=0;v<f;v++)h[v].confirmedActive=!1;for(v=0;v<m;v++)w=u[v],S=w.pair,S?(S.isActive?y.push(S):g.push(S),a.update(S,w,c),S.confirmedActive=!0):(S=a.create(w,c),d[S.id]=S,g.push(S),h.push(S));var T=[];for(f=h.length,v=0;v<f;v++)S=h[v],S.confirmedActive||(a.setActive(S,!1,c),b.push(S),!S.collision.bodyA.isSleeping&&!S.collision.bodyB.isSleeping&&T.push(v));for(v=0;v<T.length;v++)E=T[v]-v,S=h[E],h.splice(E,1),delete d[S.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),h=l.deprecated;(function(){i.stack=function(f,d,m,g,b,y,w){for(var E=a.create({label:"Stack"}),S=f,v=d,T,_=0,A=0;A<g;A++){for(var N=0,C=0;C<m;C++){var D=w(S,v,C,A,T,_);if(D){var P=D.bounds.max.y-D.bounds.min.y,O=D.bounds.max.x-D.bounds.min.x;P>N&&(N=P),u.translate(D,{x:O*.5,y:P*.5}),S=D.bounds.max.x+b,a.addBody(E,D),T=D,_+=1}else S+=b}v+=N+y,S=f}return E},i.chain=function(f,d,m,g,b,y){for(var w=f.bodies,E=1;E<w.length;E++){var S=w[E-1],v=w[E],T=S.bounds.max.y-S.bounds.min.y,_=S.bounds.max.x-S.bounds.min.x,A=v.bounds.max.y-v.bounds.min.y,N=v.bounds.max.x-v.bounds.min.x,C={bodyA:S,pointA:{x:_*d,y:T*m},bodyB:v,pointB:{x:N*g,y:A*b}},D=l.extend(C,y);a.addConstraint(f,o.create(D))}return f.label+=" Chain",f},i.mesh=function(f,d,m,g,b){var y=f.bodies,w,E,S,v,T;for(w=0;w<m;w++){for(E=1;E<d;E++)S=y[E-1+w*d],v=y[E+w*d],a.addConstraint(f,o.create(l.extend({bodyA:S,bodyB:v},b)));if(w>0)for(E=0;E<d;E++)S=y[E+(w-1)*d],v=y[E+w*d],a.addConstraint(f,o.create(l.extend({bodyA:S,bodyB:v},b))),g&&E>0&&(T=y[E-1+(w-1)*d],a.addConstraint(f,o.create(l.extend({bodyA:T,bodyB:v},b)))),g&&E<d-1&&(T=y[E+1+(w-1)*d],a.addConstraint(f,o.create(l.extend({bodyA:T,bodyB:v},b))))}return f.label+=" Mesh",f},i.pyramid=function(f,d,m,g,b,y,w){return i.stack(f,d,m,g,b,y,function(E,S,v,T,_,A){var N=Math.min(g,Math.ceil(m/2)),C=_?_.bounds.max.x-_.bounds.min.x:0;if(!(T>N)){T=N-T;var D=T,P=m-1-T;if(!(v<D||v>P)){A===1&&u.translate(_,{x:(v+(m%2===1?1:-1))*C,y:0});var O=_?v*C:0;return w(f+O+v*b,S,v,T,_,A)}}})},i.newtonsCradle=function(f,d,m,g,b){for(var y=a.create({label:"Newtons Cradle"}),w=0;w<m;w++){var E=1.9,S=c.circle(f+w*(g*E),d+b,g,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),v=o.create({pointA:{x:f+w*(g*E),y:d},bodyB:S});a.addBody(y,S),a.addConstraint(y,v)}return y},h(i,"newtonsCradle","Composites.newtonsCradle ➤ moved to newtonsCradle example"),i.car=function(f,d,m,g,b){var y=u.nextGroup(!0),w=20,E=-m*.5+w,S=m*.5-w,v=0,T=a.create({label:"Car"}),_=c.rectangle(f,d,m,g,{collisionFilter:{group:y},chamfer:{radius:g*.5},density:2e-4}),A=c.circle(f+E,d+v,b,{collisionFilter:{group:y},friction:.8}),N=c.circle(f+S,d+v,b,{collisionFilter:{group:y},friction:.8}),C=o.create({bodyB:_,pointB:{x:E,y:v},bodyA:A,stiffness:1,length:0}),D=o.create({bodyB:_,pointB:{x:S,y:v},bodyA:N,stiffness:1,length:0});return a.addBody(T,_),a.addBody(T,A),a.addBody(T,N),a.addConstraint(T,C),a.addConstraint(T,D),T},h(i,"car","Composites.car ➤ moved to car example"),i.softBody=function(f,d,m,g,b,y,w,E,S,v){S=l.extend({inertia:1/0},S),v=l.extend({stiffness:.2,render:{type:"line",anchors:!1}},v);var T=i.stack(f,d,m,g,b,y,function(_,A){return c.circle(_,A,E,S)});return i.mesh(T,m,g,w,v),T.label="Soft Body",T},h(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,h,f){var d,m,g,b=h.world,y=u.buckets,w,E,S=!1;for(d=0;d<c.length;d++){var v=c[d];if(!(v.isSleeping&&!f)&&!(b.bounds&&(v.bounds.max.x<b.bounds.min.x||v.bounds.min.x>b.bounds.max.x||v.bounds.max.y<b.bounds.min.y||v.bounds.min.y>b.bounds.max.y))){var T=i._getRegion(u,v);if(!v.region||T.id!==v.region.id||f){(!v.region||f)&&(v.region=T);var _=i._regionUnion(T,v.region);for(m=_.startCol;m<=_.endCol;m++)for(g=_.startRow;g<=_.endRow;g++){E=i._getBucketId(m,g),w=y[E];var A=m>=T.startCol&&m<=T.endCol&&g>=T.startRow&&g<=T.endRow,N=m>=v.region.startCol&&m<=v.region.endCol&&g>=v.region.startRow&&g<=v.region.endRow;!A&&N&&N&&w&&i._bucketRemoveBody(u,w,v),(v.region===T||A&&!N||f)&&(w||(w=i._createBucket(y,E)),i._bucketAddBody(u,w,v))}v.region=T,S=!0}}}S&&(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 h=Math.min(u.startCol,c.startCol),f=Math.max(u.endCol,c.endCol),d=Math.min(u.startRow,c.startRow),m=Math.max(u.endRow,c.endRow);return i._createRegion(h,f,d,m)},i._getRegion=function(u,c){var h=c.bounds,f=Math.floor(h.min.x/u.bucketWidth),d=Math.floor(h.max.x/u.bucketWidth),m=Math.floor(h.min.y/u.bucketHeight),g=Math.floor(h.max.y/u.bucketHeight);return i._createRegion(f,d,m,g)},i._createRegion=function(u,c,h,f){return{id:u+","+c+","+h+","+f,startCol:u,endCol:c,startRow:h,endRow:f}},i._getBucketId=function(u,c){return"C"+u+"R"+c},i._createBucket=function(u,c){var h=u[c]=[];return h},i._bucketAddBody=function(u,c,h){var f=u.pairs,d=a.id,m=c.length,g;for(g=0;g<m;g++){var b=c[g];if(!(h.id===b.id||h.isStatic&&b.isStatic)){var y=d(h,b),w=f[y];w?w[2]+=1:f[y]=[h,b,1]}}c.push(h)},i._bucketRemoveBody=function(u,c,h){var f=u.pairs,d=a.id,m;c.splice(o.indexOf(c,h),1);var g=c.length;for(m=0;m<g;m++){var b=f[d(h,c[m])];b&&(b[2]-=1)}},i._createActivePairsList=function(u){var c,h=u.pairs,f=o.keys(h),d=f.length,m=[],g;for(g=0;g<d;g++)c=h[f[g]],c[2]>0?m.push(c):delete h[f[g]];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),h=s(10),f=s(6),d=s(0),m=s(1);(function(){i.create=function(g,b){var y=(g?g.mouse:null)||(b?b.mouse:null);y||(g&&g.render&&g.render.canvas?y=l.create(g.render.canvas):b&&b.element?y=l.create(b.element):(y=l.create(),d.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var w=h.create({label:"Mouse Constraint",pointA:y.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,render:{strokeStyle:"#90EE90",lineWidth:3}}),E={type:"mouseConstraint",mouse:y,element:null,body:null,constraint:w,collisionFilter:{category:1,mask:4294967295,group:0}},S=d.extend(E,b);return u.on(g,"beforeUpdate",function(){var v=f.allBodies(g.world);i.update(S,v),i._triggerEvents(S)}),S},i.update=function(g,b){var y=g.mouse,w=g.constraint,E=g.body;if(y.button===0){if(w.bodyB)o.set(w.bodyB,!1),w.pointA=y.position;else for(var S=0;S<b.length;S++)if(E=b[S],m.contains(E.bounds,y.position)&&c.canCollide(E.collisionFilter,g.collisionFilter))for(var v=E.parts.length>1?1:0;v<E.parts.length;v++){var T=E.parts[v];if(a.contains(T.vertices,y.position)){w.pointA=y.position,w.bodyB=g.body=E,w.pointB={x:y.position.x-E.position.x,y:y.position.y-E.position.y},w.angleB=E.angle,o.set(E,!1),u.trigger(g,"startdrag",{mouse:y,body:E});break}}}else w.bodyB=g.body=null,w.pointB=null,E&&u.trigger(g,"enddrag",{mouse:y,body:E})},i._triggerEvents=function(g){var b=g.mouse,y=b.sourceEvents;y.mousemove&&u.trigger(g,"mousemove",{mouse:b}),y.mousedown&&u.trigger(g,"mousedown",{mouse:b}),y.mouseup&&u.trigger(g,"mouseup",{mouse:b}),l.clearSourceEvents(b)}})()}),(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(h,f){for(var d=[],m=f.length,g=h.bounds,b=o.collides,y=l.overlaps,w=0;w<m;w++){var E=f[w],S=E.parts.length,v=S===1?0:1;if(y(E.bounds,g))for(var T=v;T<S;T++){var _=E.parts[T];if(y(_.bounds,g)){var A=b(_,h);if(A){d.push(A);break}}}}return d},i.ray=function(h,f,d,m){m=m||1e-100;for(var g=a.angle(f,d),b=a.magnitude(a.sub(f,d)),y=(d.x+f.x)*.5,w=(d.y+f.y)*.5,E=u.rectangle(y,w,b,m,{angle:g}),S=i.collides(E,h),v=0;v<S.length;v+=1){var T=S[v];T.body=T.bodyB=T.bodyA}return S},i.region=function(h,f,d){for(var m=[],g=0;g<h.length;g++){var b=h[g],y=l.overlaps(b.bounds,f);(y&&!d||!y&&d)&&m.push(b)}return m},i.point=function(h,f){for(var d=[],m=0;m<h.length;m++){var g=h[m];if(l.contains(g.bounds,f))for(var b=g.parts.length===1?0:1;b<g.parts.length;b++){var y=g.parts[b];if(l.contains(y.bounds,f)&&c.contains(y.vertices,f)){d.push(g);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),h=s(2),f=s(14);(function(){var d,m;typeof window<"u"&&(d=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(v){window.setTimeout(function(){v(o.now())},1e3/60)},m=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),i._goodFps=30,i._goodDelta=1e3/60,i.create=function(v){var T={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:!!v.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(T,v);return _.canvas&&(_.canvas.width=_.options.width||_.canvas.width,_.canvas.height=_.options.height||_.canvas.height),_.mouse=v.mouse,_.engine=v.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(v){(function T(_){v.frameRequestId=d(T),g(v,_),i.world(v,_),(v.options.showStats||v.options.showDebug)&&i.stats(v,v.context,_),(v.options.showPerformance||v.options.showDebug)&&i.performance(v,v.context,_)})()},i.stop=function(v){m(v.frameRequestId)},i.setPixelRatio=function(v,T){var _=v.options,A=v.canvas;T==="auto"&&(T=w(A)),_.pixelRatio=T,A.setAttribute("data-pixel-ratio",T),A.width=_.width*T,A.height=_.height*T,A.style.width=_.width+"px",A.style.height=_.height+"px"},i.lookAt=function(v,T,_,A){A=typeof A<"u"?A:!0,T=o.isArray(T)?T:[T],_=_||{x:0,y:0};for(var N={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},C=0;C<T.length;C+=1){var D=T[C],P=D.bounds?D.bounds.min:D.min||D.position||D,O=D.bounds?D.bounds.max:D.max||D.position||D;P&&O&&(P.x<N.min.x&&(N.min.x=P.x),O.x>N.max.x&&(N.max.x=O.x),P.y<N.min.y&&(N.min.y=P.y),O.y>N.max.y&&(N.max.y=O.y))}var I=N.max.x-N.min.x+2*_.x,R=N.max.y-N.min.y+2*_.y,B=v.canvas.height,V=v.canvas.width,z=V/B,Y=I/R,L=1,q=1;Y>z?q=Y/z:L=z/Y,v.options.hasBounds=!0,v.bounds.min.x=N.min.x,v.bounds.max.x=N.min.x+I*L,v.bounds.min.y=N.min.y,v.bounds.max.y=N.min.y+R*q,A&&(v.bounds.min.x+=I*.5-I*L*.5,v.bounds.max.x+=I*.5-I*L*.5,v.bounds.min.y+=R*.5-R*q*.5,v.bounds.max.y+=R*.5-R*q*.5),v.bounds.min.x-=_.x,v.bounds.max.x-=_.x,v.bounds.min.y-=_.y,v.bounds.max.y-=_.y,v.mouse&&(f.setScale(v.mouse,{x:(v.bounds.max.x-v.bounds.min.x)/v.canvas.width,y:(v.bounds.max.y-v.bounds.min.y)/v.canvas.height}),f.setOffset(v.mouse,v.bounds.min))},i.startViewTransform=function(v){var T=v.bounds.max.x-v.bounds.min.x,_=v.bounds.max.y-v.bounds.min.y,A=T/v.options.width,N=_/v.options.height;v.context.setTransform(v.options.pixelRatio/A,0,0,v.options.pixelRatio/N,0,0),v.context.translate(-v.bounds.min.x,-v.bounds.min.y)},i.endViewTransform=function(v){v.context.setTransform(v.options.pixelRatio,0,0,v.options.pixelRatio,0,0)},i.world=function(v,T){var _=o.now(),A=v.engine,N=A.world,C=v.canvas,D=v.context,P=v.options,O=v.timing,I=l.allBodies(N),R=l.allConstraints(N),B=P.wireframes?P.wireframeBackground:P.background,V=[],z=[],Y,L={timestamp:A.timing.timestamp};if(c.trigger(v,"beforeRender",L),v.currentBackground!==B&&S(v,B),D.globalCompositeOperation="source-in",D.fillStyle="transparent",D.fillRect(0,0,C.width,C.height),D.globalCompositeOperation="source-over",P.hasBounds){for(Y=0;Y<I.length;Y++){var q=I[Y];u.overlaps(q.bounds,v.bounds)&&V.push(q)}for(Y=0;Y<R.length;Y++){var K=R[Y],M=K.bodyA,G=K.bodyB,ae=K.pointA,ne=K.pointB;M&&(ae=h.add(M.position,K.pointA)),G&&(ne=h.add(G.position,K.pointB)),!(!ae||!ne)&&(u.contains(v.bounds,ae)||u.contains(v.bounds,ne))&&z.push(K)}i.startViewTransform(v),v.mouse&&(f.setScale(v.mouse,{x:(v.bounds.max.x-v.bounds.min.x)/v.options.width,y:(v.bounds.max.y-v.bounds.min.y)/v.options.height}),f.setOffset(v.mouse,v.bounds.min))}else z=R,V=I,v.options.pixelRatio!==1&&v.context.setTransform(v.options.pixelRatio,0,0,v.options.pixelRatio,0,0);!P.wireframes||A.enableSleeping&&P.showSleeping?i.bodies(v,V,D):(P.showConvexHulls&&i.bodyConvexHulls(v,V,D),i.bodyWireframes(v,V,D)),P.showBounds&&i.bodyBounds(v,V,D),(P.showAxes||P.showAngleIndicator)&&i.bodyAxes(v,V,D),P.showPositions&&i.bodyPositions(v,V,D),P.showVelocity&&i.bodyVelocity(v,V,D),P.showIds&&i.bodyIds(v,V,D),P.showSeparations&&i.separations(v,A.pairs.list,D),P.showCollisions&&i.collisions(v,A.pairs.list,D),P.showVertexNumbers&&i.vertexNumbers(v,V,D),P.showMousePosition&&i.mousePosition(v,v.mouse,D),i.constraints(z,D),P.hasBounds&&i.endViewTransform(v),c.trigger(v,"afterRender",L),O.lastElapsed=o.now()-_},i.stats=function(v,T,_){for(var A=v.engine,N=A.world,C=l.allBodies(N),D=0,P=55,O=44,I=0,R=0,B=0;B<C.length;B+=1)D+=C[B].parts.length;var V={Part:D,Body:C.length,Cons:l.allConstraints(N).length,Comp:l.allComposites(N).length,Pair:A.pairs.list.length};T.fillStyle="#0e0f19",T.fillRect(I,R,P*5.5,O),T.font="12px Arial",T.textBaseline="top",T.textAlign="right";for(var z in V){var Y=V[z];T.fillStyle="#aaa",T.fillText(z,I+P,R+8),T.fillStyle="#eee",T.fillText(Y,I+P,R+26),I+=P}},i.performance=function(v,T){var _=v.engine,A=v.timing,N=A.deltaHistory,C=A.elapsedHistory,D=A.timestampElapsedHistory,P=A.engineDeltaHistory,O=A.engineElapsedHistory,I=_.timing.lastDelta,R=b(N),B=b(C),V=b(P),z=b(O),Y=b(D),L=Y/R||0,q=1e3/R||0,K=4,M=12,G=60,ae=34,ne=10,X=69;T.fillStyle="#0e0f19",T.fillRect(0,50,M*4+G*5+22,ae),i.status(T,ne,X,G,K,N.length,Math.round(q)+" fps",q/i._goodFps,function(te){return N[te]/R-1}),i.status(T,ne+M+G,X,G,K,P.length,I.toFixed(2)+" dt",i._goodDelta/I,function(te){return P[te]/V-1}),i.status(T,ne+(M+G)*2,X,G,K,O.length,z.toFixed(2)+" ut",1-z/i._goodFps,function(te){return O[te]/z-1}),i.status(T,ne+(M+G)*3,X,G,K,C.length,B.toFixed(2)+" rt",1-B/i._goodFps,function(te){return C[te]/B-1}),i.status(T,ne+(M+G)*4,X,G,K,D.length,L.toFixed(2)+" x",L*L*L,function(te){return(D[te]/N[te]/L||0)-1})},i.status=function(v,T,_,A,N,C,D,P,O){v.strokeStyle="#888",v.fillStyle="#444",v.lineWidth=1,v.fillRect(T,_+7,A,1),v.beginPath(),v.moveTo(T,_+7-N*o.clamp(.4*O(0),-2,2));for(var I=0;I<A;I+=1)v.lineTo(T+I,_+7-(I<C?N*o.clamp(.4*O(I),-2,2):0));v.stroke(),v.fillStyle="hsl("+o.clamp(25+95*P,0,120)+",100%,60%)",v.fillRect(T,_-7,4,4),v.font="12px Arial",v.textBaseline="middle",v.textAlign="right",v.fillStyle="#eee",v.fillText(D,T+A,_-5)},i.constraints=function(v,T){for(var _=T,A=0;A<v.length;A++){var N=v[A];if(!(!N.render.visible||!N.pointA||!N.pointB)){var C=N.bodyA,D=N.bodyB,P,O;if(C?P=h.add(C.position,N.pointA):P=N.pointA,N.render.type==="pin")_.beginPath(),_.arc(P.x,P.y,3,0,2*Math.PI),_.closePath();else{if(D?O=h.add(D.position,N.pointB):O=N.pointB,_.beginPath(),_.moveTo(P.x,P.y),N.render.type==="spring")for(var I=h.sub(O,P),R=h.perp(h.normalise(I)),B=Math.ceil(o.clamp(N.length/5,12,20)),V,z=1;z<B;z+=1)V=z%2===0?1:-1,_.lineTo(P.x+I.x*(z/B)+R.x*V*4,P.y+I.y*(z/B)+R.y*V*4);_.lineTo(O.x,O.y)}N.render.lineWidth&&(_.lineWidth=N.render.lineWidth,_.strokeStyle=N.render.strokeStyle,_.stroke()),N.render.anchors&&(_.fillStyle=N.render.strokeStyle,_.beginPath(),_.arc(P.x,P.y,3,0,2*Math.PI),_.arc(O.x,O.y,3,0,2*Math.PI),_.closePath(),_.fill())}}},i.bodies=function(v,T,_){var A=_;v.engine;var N=v.options,C=N.showInternalEdges||!N.wireframes,D,P,O,I;for(O=0;O<T.length;O++)if(D=T[O],!!D.render.visible){for(I=D.parts.length>1?1:0;I<D.parts.length;I++)if(P=D.parts[I],!!P.render.visible){if(N.showSleeping&&D.isSleeping?A.globalAlpha=.5*P.render.opacity:P.render.opacity!==1&&(A.globalAlpha=P.render.opacity),P.render.sprite&&P.render.sprite.texture&&!N.wireframes){var R=P.render.sprite,B=E(v,R.texture);A.translate(P.position.x,P.position.y),A.rotate(P.angle),A.drawImage(B,B.width*-R.xOffset*R.xScale,B.height*-R.yOffset*R.yScale,B.width*R.xScale,B.height*R.yScale),A.rotate(-P.angle),A.translate(-P.position.x,-P.position.y)}else{if(P.circleRadius)A.beginPath(),A.arc(P.position.x,P.position.y,P.circleRadius,0,2*Math.PI);else{A.beginPath(),A.moveTo(P.vertices[0].x,P.vertices[0].y);for(var V=1;V<P.vertices.length;V++)!P.vertices[V-1].isInternal||C?A.lineTo(P.vertices[V].x,P.vertices[V].y):A.moveTo(P.vertices[V].x,P.vertices[V].y),P.vertices[V].isInternal&&!C&&A.moveTo(P.vertices[(V+1)%P.vertices.length].x,P.vertices[(V+1)%P.vertices.length].y);A.lineTo(P.vertices[0].x,P.vertices[0].y),A.closePath()}N.wireframes?(A.lineWidth=1,A.strokeStyle="#bbb",A.stroke()):(A.fillStyle=P.render.fillStyle,P.render.lineWidth&&(A.lineWidth=P.render.lineWidth,A.strokeStyle=P.render.strokeStyle,A.stroke()),A.fill())}A.globalAlpha=1}}},i.bodyWireframes=function(v,T,_){var A=_,N=v.options.showInternalEdges,C,D,P,O,I;for(A.beginPath(),P=0;P<T.length;P++)if(C=T[P],!!C.render.visible)for(I=C.parts.length>1?1:0;I<C.parts.length;I++){for(D=C.parts[I],A.moveTo(D.vertices[0].x,D.vertices[0].y),O=1;O<D.vertices.length;O++)!D.vertices[O-1].isInternal||N?A.lineTo(D.vertices[O].x,D.vertices[O].y):A.moveTo(D.vertices[O].x,D.vertices[O].y),D.vertices[O].isInternal&&!N&&A.moveTo(D.vertices[(O+1)%D.vertices.length].x,D.vertices[(O+1)%D.vertices.length].y);A.lineTo(D.vertices[0].x,D.vertices[0].y)}A.lineWidth=1,A.strokeStyle="#bbb",A.stroke()},i.bodyConvexHulls=function(v,T,_){var A=_,N,C,D;for(A.beginPath(),C=0;C<T.length;C++)if(N=T[C],!(!N.render.visible||N.parts.length===1)){for(A.moveTo(N.vertices[0].x,N.vertices[0].y),D=1;D<N.vertices.length;D++)A.lineTo(N.vertices[D].x,N.vertices[D].y);A.lineTo(N.vertices[0].x,N.vertices[0].y)}A.lineWidth=1,A.strokeStyle="rgba(255,255,255,0.2)",A.stroke()},i.vertexNumbers=function(v,T,_){var A=_,N,C,D;for(N=0;N<T.length;N++){var P=T[N].parts;for(D=P.length>1?1:0;D<P.length;D++){var O=P[D];for(C=0;C<O.vertices.length;C++)A.fillStyle="rgba(255,255,255,0.2)",A.fillText(N+"_"+C,O.position.x+(O.vertices[C].x-O.position.x)*.8,O.position.y+(O.vertices[C].y-O.position.y)*.8)}}},i.mousePosition=function(v,T,_){var A=_;A.fillStyle="rgba(255,255,255,0.8)",A.fillText(T.position.x+" "+T.position.y,T.position.x+5,T.position.y-5)},i.bodyBounds=function(v,T,_){var A=_;v.engine;var N=v.options;A.beginPath();for(var C=0;C<T.length;C++){var D=T[C];if(D.render.visible)for(var P=T[C].parts,O=P.length>1?1:0;O<P.length;O++){var I=P[O];A.rect(I.bounds.min.x,I.bounds.min.y,I.bounds.max.x-I.bounds.min.x,I.bounds.max.y-I.bounds.min.y)}}N.wireframes?A.strokeStyle="rgba(255,255,255,0.08)":A.strokeStyle="rgba(0,0,0,0.1)",A.lineWidth=1,A.stroke()},i.bodyAxes=function(v,T,_){var A=_;v.engine;var N=v.options,C,D,P,O;for(A.beginPath(),D=0;D<T.length;D++){var I=T[D],R=I.parts;if(I.render.visible)if(N.showAxes)for(P=R.length>1?1:0;P<R.length;P++)for(C=R[P],O=0;O<C.axes.length;O++){var B=C.axes[O];A.moveTo(C.position.x,C.position.y),A.lineTo(C.position.x+B.x*20,C.position.y+B.y*20)}else for(P=R.length>1?1:0;P<R.length;P++)for(C=R[P],O=0;O<C.axes.length;O++)A.moveTo(C.position.x,C.position.y),A.lineTo((C.vertices[0].x+C.vertices[C.vertices.length-1].x)/2,(C.vertices[0].y+C.vertices[C.vertices.length-1].y)/2)}N.wireframes?(A.strokeStyle="indianred",A.lineWidth=1):(A.strokeStyle="rgba(255, 255, 255, 0.4)",A.globalCompositeOperation="overlay",A.lineWidth=2),A.stroke(),A.globalCompositeOperation="source-over"},i.bodyPositions=function(v,T,_){var A=_;v.engine;var N=v.options,C,D,P,O;for(A.beginPath(),P=0;P<T.length;P++)if(C=T[P],!!C.render.visible)for(O=0;O<C.parts.length;O++)D=C.parts[O],A.arc(D.position.x,D.position.y,3,0,2*Math.PI,!1),A.closePath();for(N.wireframes?A.fillStyle="indianred":A.fillStyle="rgba(0,0,0,0.5)",A.fill(),A.beginPath(),P=0;P<T.length;P++)C=T[P],C.render.visible&&(A.arc(C.positionPrev.x,C.positionPrev.y,2,0,2*Math.PI,!1),A.closePath());A.fillStyle="rgba(255,165,0,0.8)",A.fill()},i.bodyVelocity=function(v,T,_){var A=_;A.beginPath();for(var N=0;N<T.length;N++){var C=T[N];if(C.render.visible){var D=a.getVelocity(C);A.moveTo(C.position.x,C.position.y),A.lineTo(C.position.x+D.x,C.position.y+D.y)}}A.lineWidth=3,A.strokeStyle="cornflowerblue",A.stroke()},i.bodyIds=function(v,T,_){var A=_,N,C;for(N=0;N<T.length;N++)if(T[N].render.visible){var D=T[N].parts;for(C=D.length>1?1:0;C<D.length;C++){var P=D[C];A.font="12px Arial",A.fillStyle="rgba(255,255,255,0.5)",A.fillText(P.id,P.position.x+10,P.position.y-10)}}},i.collisions=function(v,T,_){var A=_,N=v.options,C,D,P,O;for(A.beginPath(),P=0;P<T.length;P++)if(C=T[P],!!C.isActive)for(D=C.collision,O=0;O<C.activeContacts.length;O++){var I=C.activeContacts[O],R=I.vertex;A.rect(R.x-1.5,R.y-1.5,3.5,3.5)}for(N.wireframes?A.fillStyle="rgba(255,255,255,0.7)":A.fillStyle="orange",A.fill(),A.beginPath(),P=0;P<T.length;P++)if(C=T[P],!!C.isActive&&(D=C.collision,C.activeContacts.length>0)){var B=C.activeContacts[0].vertex.x,V=C.activeContacts[0].vertex.y;C.activeContacts.length===2&&(B=(C.activeContacts[0].vertex.x+C.activeContacts[1].vertex.x)/2,V=(C.activeContacts[0].vertex.y+C.activeContacts[1].vertex.y)/2),D.bodyB===D.supports[0].body||D.bodyA.isStatic===!0?A.moveTo(B-D.normal.x*8,V-D.normal.y*8):A.moveTo(B+D.normal.x*8,V+D.normal.y*8),A.lineTo(B,V)}N.wireframes?A.strokeStyle="rgba(255,165,0,0.7)":A.strokeStyle="orange",A.lineWidth=1,A.stroke()},i.separations=function(v,T,_){var A=_,N=v.options,C,D,P,O,I;for(A.beginPath(),I=0;I<T.length;I++)if(C=T[I],!!C.isActive){D=C.collision,P=D.bodyA,O=D.bodyB;var R=1;!O.isStatic&&!P.isStatic&&(R=.5),O.isStatic&&(R=0),A.moveTo(O.position.x,O.position.y),A.lineTo(O.position.x-D.penetration.x*R,O.position.y-D.penetration.y*R),R=1,!O.isStatic&&!P.isStatic&&(R=.5),P.isStatic&&(R=0),A.moveTo(P.position.x,P.position.y),A.lineTo(P.position.x+D.penetration.x*R,P.position.y+D.penetration.y*R)}N.wireframes?A.strokeStyle="rgba(255,165,0,0.5)":A.strokeStyle="orange",A.stroke()},i.inspector=function(v,T){v.engine;var _=v.selected,A=v.render,N=A.options,C;if(N.hasBounds){var D=A.bounds.max.x-A.bounds.min.x,P=A.bounds.max.y-A.bounds.min.y,O=D/A.options.width,I=P/A.options.height;T.scale(1/O,1/I),T.translate(-A.bounds.min.x,-A.bounds.min.y)}for(var R=0;R<_.length;R++){var B=_[R].data;switch(T.translate(.5,.5),T.lineWidth=1,T.strokeStyle="rgba(255,165,0,0.9)",T.setLineDash([1,2]),B.type){case"body":C=B.bounds,T.beginPath(),T.rect(Math.floor(C.min.x-3),Math.floor(C.min.y-3),Math.floor(C.max.x-C.min.x+6),Math.floor(C.max.y-C.min.y+6)),T.closePath(),T.stroke();break;case"constraint":var V=B.pointA;B.bodyA&&(V=B.pointB),T.beginPath(),T.arc(V.x,V.y,10,0,2*Math.PI),T.closePath(),T.stroke();break}T.setLineDash([]),T.translate(-.5,-.5)}v.selectStart!==null&&(T.translate(.5,.5),T.lineWidth=1,T.strokeStyle="rgba(255,165,0,0.6)",T.fillStyle="rgba(255,165,0,0.1)",C=v.selectBounds,T.beginPath(),T.rect(Math.floor(C.min.x),Math.floor(C.min.y),Math.floor(C.max.x-C.min.x),Math.floor(C.max.y-C.min.y)),T.closePath(),T.stroke(),T.fill(),T.translate(-.5,-.5)),N.hasBounds&&T.setTransform(1,0,0,1,0,0)};var g=function(v,T){var _=v.engine,A=v.timing,N=A.historySize,C=_.timing.timestamp;A.delta=T-A.lastTime||i._goodDelta,A.lastTime=T,A.timestampElapsed=C-A.lastTimestamp||0,A.lastTimestamp=C,A.deltaHistory.unshift(A.delta),A.deltaHistory.length=Math.min(A.deltaHistory.length,N),A.engineDeltaHistory.unshift(_.timing.lastDelta),A.engineDeltaHistory.length=Math.min(A.engineDeltaHistory.length,N),A.timestampElapsedHistory.unshift(A.timestampElapsed),A.timestampElapsedHistory.length=Math.min(A.timestampElapsedHistory.length,N),A.engineElapsedHistory.unshift(_.timing.lastElapsed),A.engineElapsedHistory.length=Math.min(A.engineElapsedHistory.length,N),A.elapsedHistory.unshift(A.lastElapsed),A.elapsedHistory.length=Math.min(A.elapsedHistory.length,N)},b=function(v){for(var T=0,_=0;_<v.length;_+=1)T+=v[_];return T/v.length||0},y=function(v,T){var _=document.createElement("canvas");return _.width=v,_.height=T,_.oncontextmenu=function(){return!1},_.onselectstart=function(){return!1},_},w=function(v){var T=v.getContext("2d"),_=window.devicePixelRatio||1,A=T.webkitBackingStorePixelRatio||T.mozBackingStorePixelRatio||T.msBackingStorePixelRatio||T.oBackingStorePixelRatio||T.backingStorePixelRatio||1;return _/A},E=function(v,T){var _=v.textures[T];return _||(_=v.textures[T]=new Image,_.src=T,_)},S=function(v,T){var _=T;/(jpg|gif|png)$/.test(T)&&(_="url("+T+")"),v.canvas.style.background=_,v.canvas.style.backgroundSize="contain",v.currentBackground=T}})()}),(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 h;u=function(f){h=setTimeout(function(){f(l.now())},1e3/60)},c=function(){clearTimeout(h)}}i.create=function(f){var d={fps:60,deltaSampleSize:60,counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,frameRequestId:null,isFixed:!1,enabled:!0},m=l.extend(d,f);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(f,d){return typeof f.positionIterations<"u"&&(d=f,f=i.create()),(function m(g){f.frameRequestId=u(m),g&&f.enabled&&i.tick(f,d,g)})(),f},i.tick=function(f,d,m){var g=d.timing,b;f.isFixed?b=f.delta:(b=m-f.timePrev||f.delta,f.timePrev=m,f.deltaHistory.push(b),f.deltaHistory=f.deltaHistory.slice(-f.deltaSampleSize),b=Math.min.apply(null,f.deltaHistory),b=b<f.deltaMin?f.deltaMin:b,b=b>f.deltaMax?f.deltaMax:b,f.delta=b);var y={timestamp:g.timestamp};a.trigger(f,"beforeTick",y),f.frameCounter+=1,m-f.counterTimestamp>=1e3&&(f.fps=f.frameCounter*((m-f.counterTimestamp)/1e3),f.counterTimestamp=m,f.frameCounter=0),a.trigger(f,"tick",y),a.trigger(f,"beforeUpdate",y),o.update(d,b),a.trigger(f,"afterUpdate",y),a.trigger(f,"afterTick",y)},i.stop=function(f){c(f.frameRequestId)},i.start=function(f,d){i.run(f,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,h,f,d,m,g,b,y,w,E=[],S,v,T=0,_=0,A=0;l=l||15;var N=function(D,P,O){var I=O%2===1&&O>1;if(!y||D!=y.x||P!=y.y){y&&I?(S=y.x,v=y.y):(S=0,v=0);var R={x:S+D,y:v+P};(I||!y)&&(y=R),E.push(R),_=S+D,A=v+P}},C=function(D){var P=D.pathSegTypeAsLetter.toUpperCase();if(P!=="Z"){switch(P){case"M":case"L":case"T":case"C":case"S":case"Q":_=D.x,A=D.y;break;case"H":_=D.x;break;case"V":A=D.y;break}N(_,A,D.pathSegType)}};for(i._svgPathToAbsolute(o),h=o.getTotalLength(),m=[],u=0;u<o.pathSegList.numberOfItems;u+=1)m.push(o.pathSegList.getItem(u));for(g=m.concat();T<h;){if(w=o.getPathSegAtLength(T),d=m[w],d!=b){for(;g.length&&g[0]!=d;)C(g.shift());b=d}switch(d.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":f=o.getPointAtLength(T),N(f.x,f.y,0);break}T+=l}for(u=0,c=g.length;u<c;++u)C(g[u]);return E},i._svgPathToAbsolute=function(o){for(var l,u,c,h,f,d,m=o.pathSegList,g=0,b=0,y=m.numberOfItems,w=0;w<y;++w){var E=m.getItem(w),S=E.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(S))"x"in E&&(g=E.x),"y"in E&&(b=E.y);else switch("x1"in E&&(c=g+E.x1),"x2"in E&&(f=g+E.x2),"y1"in E&&(h=b+E.y1),"y2"in E&&(d=b+E.y2),"x"in E&&(g+=E.x),"y"in E&&(b+=E.y),S){case"m":m.replaceItem(o.createSVGPathSegMovetoAbs(g,b),w);break;case"l":m.replaceItem(o.createSVGPathSegLinetoAbs(g,b),w);break;case"h":m.replaceItem(o.createSVGPathSegLinetoHorizontalAbs(g),w);break;case"v":m.replaceItem(o.createSVGPathSegLinetoVerticalAbs(b),w);break;case"c":m.replaceItem(o.createSVGPathSegCurvetoCubicAbs(g,b,c,h,f,d),w);break;case"s":m.replaceItem(o.createSVGPathSegCurvetoCubicSmoothAbs(g,b,f,d),w);break;case"q":m.replaceItem(o.createSVGPathSegCurvetoQuadraticAbs(g,b,c,h),w);break;case"t":m.replaceItem(o.createSVGPathSegCurvetoQuadraticSmoothAbs(g,b),w);break;case"a":m.replaceItem(o.createSVGPathSegArcAbs(g,b,E.r1,E.r2,E.angle,E.largeArcFlag,E.sweepFlag),w);break;case"z":case"Z":g=l,b=u;break}(S=="M"||S=="m")&&(l=g,u=b)}}})()}),(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})()})])})})(Ps)),Ps.exports}var Cy=Ay();const pn=Zl(Cy);{const e=pn.Resolver;e&&typeof e._restingThresh=="number"&&(e._restingThresh=1.4)}const _y=6,Ht=28,gn=.92,Ga=1.12,Ny=34;function Uc(e,t,n){return Math.hypot(t-e.startX,n-e.startY)<_y?"click":"drag"}function Iy(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 Ry(e,t){return e*Math.exp(-t/90)}function My(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 jm=4e-5,Py=5e-4;function Hm(e,t,n){return Math.sin(n*37e-5+t*.0013)*.6+Math.sin(n*19e-5+e*7e-4+1.7)*.4}function Um(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 zm(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 Zr=120,Ly=.9,zc=.7,Dy=.09,Oy=2.2,Fy=2,Ka=Ht*2.45,By=.006,Xa=22,Qa=.06;function jy(e){var O;const t=e.ballRadius??Ht,n=Um(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(I=>{var z,Y;const R=((z=I.spawn)==null?void 0:z.x)??I.x,B=((Y=I.spawn)==null?void 0:Y.y)??I.y,V=s.circle(R,B,t,{restitution:.5,friction:.01,frictionAir:.03*n.airDrag,density:I.isExam?.0016:.001,inertia:1/0,isStatic:!!I.locked,collisionFilter:{group:0,category:2,mask:6}});return{nodeId:I.id,body:V,layoutX:I.x,layoutY:I.y,isExam:!!I.isExam,snow:0,field:0,squash:0,squashAngle:0}});for(const I of c){a.add(u.world,I.body);const R=(O=e.nodes.find(B=>B.id===I.nodeId))==null?void 0:O.spawn;R&&(R.vx!==void 0||R.vy!==void 0)&&i.setVelocity(I.body,{x:R.vx??0,y:R.vy??0})}const h=Zr/2,f={isStatic:!0,restitution:.4,friction:.05,collisionFilter:{category:4,mask:2}},d=(I,R)=>({x:Math.min(e.width-t,Math.max(t,I)),y:Math.min(e.height-t,Math.max(t,R))});a.add(u.world,[s.rectangle(e.width/2,-h,e.width*3,Zr,f),s.rectangle(e.width/2,e.height+h,e.width*3,Zr,f),s.rectangle(-h,e.height/2,Zr,e.height*3,f),s.rectangle(e.width+h,e.height/2,Zr,e.height*3,f)]);const m=I=>({x:I.body.position.x,y:I.body.position.y+t*gn}),g=[];function b(I,R,B,V,z){return"body"in I?o.create({bodyA:I.body,pointA:I.offset,bodyB:R,pointB:B,length:V,stiffness:z,damping:.05}):o.create({pointA:I.point,bodyB:R,pointB:B,length:V,stiffness:z,damping:.05})}function y(I,R,B,V){const z={x:B.body.position.x,y:B.body.position.y+t*gn},Y=z.x-I.x,L=z.y-I.y,q=Math.max(60,Math.hypot(Y,L)),K=Math.max(5,Math.min(14,Math.round(q/Ny))),M=q*Ga/K,G=[];let ae=R?{body:R,offset:{x:I.x-R.position.x,y:I.y-R.position.y}}:{point:I},ne=!0;for(let X=1;X<K;X++){const te=X/K,ue=Math.sin(Math.PI*te)*q*(Ga-1)*.85,ge=s.circle(I.x+Y*te,I.y+L*te+ue,3.5,{density:7e-4,frictionAir:.1*n.airDrag,collisionFilter:{category:8,mask:0}});G.push(ge),a.add(u.world,ge),a.add(u.world,b(ae,ge,void 0,M,ne?zc:Ly)),ne=!1,ae={body:ge,offset:{x:0,y:0}}}a.add(u.world,b(ae,B.body,{x:0,y:t*gn},M,zc)),g.push({from:V,to:B.nodeId,restLen:q*Ga,particles:G})}const w=c[0],E=w?{x:e.anchorKnotX??w.layoutX,y:Qs}:{x:e.width/2,y:Qs};w&&y(E,null,w,"__anchor");for(let I=0;I<c.length-1;I++){const R=c[I],B=c[I+1];y(m(R),R.body,B,R.nodeId)}const S=c[c.length-1],v=e.nextKnot&&(S!=null&&S.isExam)?e.nextKnot:void 0;v&&S&&y(v,null,S,"__next");const T=new Map;for(const I of c){let R=0;for(const V of g)if(V.from===I.nodeId||V.to===I.nodeId)for(const z of V.particles)R+=z.mass*.5;const B=Math.min(.25,R/I.body.mass);T.set(I.nodeId,(1+B)*(.96+zm(I.nodeId)*.08))}let _=0,A=1;l.on(u,"beforeUpdate",()=>{const I=u.timing.timestamp;_*=.97,n.gust>0&&Math.random()<.0025*n.gust&&(_=n.gust*(.6+Math.random()*.4),A=Math.random()<.5?-1:1);for(const R of c){const B=R.body.mass,V=u.gravity.y*u.gravity.scale,z=Hm(R.body.position.x,R.body.position.y,I)*n.wind*jm*B+A*_*Py*B;let Y=-B*V*(T.get(R.nodeId)??1);n.rainRate>0&&Math.random()<n.rainRate&&(Y+=B*V*.35,i.applyForce(R.body,R.body.position,{x:(Math.random()-.5)*B*V*.3,y:0})),i.applyForce(R.body,R.body.position,{x:z,y:Y})}});const N=[],C=(I,R,B,V)=>{if(I.snow<=Qa)return;const z=Math.max(1,Math.min(V,Math.round(I.snow*V)+1));for(let Y=0;Y<z;Y++){const L=-(.35+Math.random()*1.9),q=t*(.55+Math.random()*.45);N.push({x:I.body.position.x+Math.cos(L)*q,y:I.body.position.y+Math.sin(L)*q,vx:I.body.velocity.x*.75+R.x*(.5+Math.random()*1.8)+(Math.random()-.5)*1.2,vy:I.body.velocity.y*.75+R.y*(.5+Math.random()*1.8)-.6-Math.random()*.8,amount:.02+Math.min(.05,B*.004)})}I.snow=Math.max(Qa*.5,I.snow-z*(.03+Math.min(.07,B*.005))),N.length>96&&N.splice(0,N.length-96)},D=[];l.on(u,"collisionStart",I=>{var R;for(const B of I.pairs){const{bodyA:V,bodyB:z}=B,Y=c.find(ne=>ne.body===V),L=c.find(ne=>ne.body===z);if(!Y&&!L)continue;const q={x:V.velocity.x-z.velocity.x,y:V.velocity.y-z.velocity.y},K=Math.hypot(q.x,q.y);if(K<Oy)continue;const M=B.collision.normal,G=(R=B.collision.supports)==null?void 0:R[0];D.push(G?{x:G.x,y:G.y,speed:K}:{x:(V.position.x+z.position.x)/2,y:(V.position.y+z.position.y)/2,speed:K}),D.length>64&&D.shift();const ae=Math.min(.32,K*.028);Y&&ae>Y.squash&&(Y.squash=ae,Y.squashAngle=Math.atan2(M.y,M.x)),L&&ae>L.squash&&(L.squash=ae,L.squashAngle=Math.atan2(-M.y,-M.x)),Y&&C(Y,{x:M.x,y:M.y},K,5),L&&C(L,{x:-M.x,y:-M.y},K,5)}}),l.on(u,"afterUpdate",()=>{if(!(n.snowRate<=0))for(const I of c)I.snow=Math.min(1,I.snow+n.snowRate)});let P=null;return{balls:c,links:g,anchor:E,nextKnot:v,ball(I){return c.find(R=>R.nodeId===I)},step(I){r.update(u,Math.min(33,Math.max(8,I)));for(let R=0;R<c.length;R++){const B=c[R];for(let V=R+1;V<c.length;V++){const z=c[V],Y=z.body.position.x-B.body.position.x,L=z.body.position.y-B.body.position.y,q=Y*Y+L*L;if(q>=Ka*Ka||q<.01)continue;const K=Math.sqrt(q),M=(K-2*t)/(Ka-2*t),G=M<=0?1:M>=1?0:1-M,ne=Math.hypot(B.body.velocity.x-z.body.velocity.x,B.body.velocity.y-z.body.velocity.y)<1.2?By*G*G:0,X=Y/K,te=L/K;B.body.isStatic||i.applyForce(B.body,B.body.position,{x:-X*ne*B.body.mass,y:-te*ne*B.body.mass}),z.body.isStatic||i.applyForce(z.body,z.body.position,{x:X*ne*z.body.mass,y:te*ne*z.body.mass}),B.field=Math.max(B.field,G),z.field=Math.max(z.field,G)}}for(const R of c)R.field*=.88;for(const R of c){if(R.body.isStatic)continue;const B=R.body.velocity,V=Math.hypot(B.x,B.y);V>Xa&&i.setVelocity(R.body,{x:B.x/V*Xa,y:B.y/V*Xa})}for(let R=0;R<c.length;R++){const B=c[R];for(let V=R+1;V<c.length;V++){const z=c[V];let Y=z.body.position.x-B.body.position.x,L=z.body.position.y-B.body.position.y,q=Math.hypot(Y,L);if(q>=t*2)continue;q<.01&&(Y=1,L=0,q=1);const K=t*2-q+.05,M=Y/q,G=L/q;B.body.isStatic&&z.body.isStatic||(B.body.isStatic?i.setPosition(z.body,{x:z.body.position.x+M*K,y:z.body.position.y+G*K}):z.body.isStatic?i.setPosition(B.body,{x:B.body.position.x-M*K,y:B.body.position.y-G*K}):(i.setPosition(B.body,{x:B.body.position.x-M*K/2,y:B.body.position.y-G*K/2}),i.setPosition(z.body,{x:z.body.position.x+M*K/2,y:z.body.position.y+G*K/2})))}}for(const R of c){const B=Math.hypot(R.body.velocity.x,R.body.velocity.y);R.snow>Qa&&B>Fy&&C(R,{x:R.body.velocity.x/B,y:R.body.velocity.y/B},B,2)}for(const R of c){if(R.body.isStatic)continue;const B=R.body.position.x,V=R.body.position.y,z=Math.min(e.width-t,Math.max(t,B)),Y=Math.min(e.height-t,Math.max(t,V));(z!==B||Y!==V)&&(i.setPosition(R.body,{x:z,y:Y}),i.setVelocity(R.body,{x:B<t||B>e.width-t?0:R.body.velocity.x,y:V<t||V>e.height-t?0:R.body.velocity.y}))}},beginDrag(I,R,B){this.endDrag();const V=this.ball(I);if(!V)return;const z=o.create({pointA:d(R,B),bodyB:V.body,length:0,stiffness:Dy,damping:.12});a.add(u.world,z),P={constraint:z,nodeId:I}},moveDrag(I,R){if(!P)return;const B=d(I,R);P.constraint.pointA=B},endDrag(){P&&(a.remove(u.world,P.constraint),P=null)},isDragging(){return P!==null},drainImpacts(){const I=D.slice();return D.length=0,I},drainFlakes(){const I=N.slice();return N.length=0,I},dispose(){this.endDrag(),l.off(u,"beforeUpdate"),l.off(u,"afterUpdate"),l.off(u,"collisionStart"),a.clear(u.world,!1),r.clear(u)}}}const Qs=-12;function ms(e,t,n=20){return t<=n*2?t/2:n+zm(e)*(t-n*2)}function Hy(e,t,n,r=Ht){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 Jn=(e,t,n)=>e+(t-e)*n,ya=(e,t,n)=>e<t?t:e>n?n:e,Mi=e=>e<0?0:e>1?1:e*e*(3-2*e);function er(e,t,n){return[Jn(e[0],t[0],n),Jn(e[1],t[1],n),Jn(e[2],t[2],n)]}const Za=e=>`rgb(${e[0]|0},${e[1]|0},${e[2]|0})`,Mr=(e,t)=>`rgba(${e[0]|0},${e[1]|0},${e[2]|0},${t})`;function va(){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 Ea(e,t){return e.map(n=>({t:n.t,top:t(n.top),mid:t(n.mid),hor:t(n.hor)}))}const Ja=()=>Ea(va(),e=>[e[0]*1,e[1]*1.15,e[2]*.7]),ps=()=>Ea(va(),e=>[e[0]*.75,e[1]*1,Math.min(255,e[2]*1.25)]),eo=()=>Ea(va(),e=>[Math.min(255,e[0]*1.35),e[1]*.8,e[2]*.55]),Vc=()=>Ea(va(),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]}),to={far:[28,50,36],near:[56,110,52],snowy:!1},gs={far:[20,48,30],near:[34,82,40],snowy:!1},no={far:[54,36,24],near:[128,78,36],snowy:!1},qc={far:[60,66,82],near:[232,236,244],snowy:!0};function jt(e){return t=>{let n=e;return t>.3&&t<.5?n=Jn(n,Math.min(1,n+.2),Mi((t-.3)/.2)):t>=.5&&t<.74?n=Math.min(1,n+.15):t>=.74&&t<.84&&(n=Jn(n,Math.max(0,n-.3),Mi((t-.74)/.1))),ya(n,0,1)}}const Vm={"spring|clear":{season:"spring",weather:"clear",sky:Ja(),cloudCover:jt(.1),particles:"none",lightning:!1,fogAlpha:0,ground:to},"spring|cloudy":{season:"spring",weather:"cloudy",sky:Ja(),cloudCover:jt(.5),particles:"none",lightning:!1,fogAlpha:0,ground:to},"spring|rain":{season:"spring",weather:"rain",sky:Ja(),cloudCover:jt(.85),particles:"rain",lightning:!1,fogAlpha:0,ground:to},"summer|clear":{season:"summer",weather:"clear",sky:ps(),cloudCover:jt(.1),particles:"none",lightning:!1,fogAlpha:0,ground:gs},"summer|cloudy":{season:"summer",weather:"cloudy",sky:ps(),cloudCover:jt(.5),particles:"none",lightning:!1,fogAlpha:0,ground:gs},"summer|rain":{season:"summer",weather:"rain",sky:ps(),cloudCover:jt(.85),particles:"rain",lightning:!1,fogAlpha:0,ground:gs},"summer|storm":{season:"summer",weather:"storm",sky:ps(),cloudCover:jt(1),particles:"rain",lightning:!0,fogAlpha:0,ground:gs},"autumn|clear":{season:"autumn",weather:"clear",sky:eo(),cloudCover:jt(.15),particles:"none",lightning:!1,fogAlpha:0,ground:no,sunTint:[255,180,110]},"autumn|cloudy":{season:"autumn",weather:"cloudy",sky:eo(),cloudCover:jt(.55),particles:"none",lightning:!1,fogAlpha:0,ground:no},"autumn|storm":{season:"autumn",weather:"storm",sky:eo(),cloudCover:jt(1),particles:"rain",lightning:!0,fogAlpha:0,ground:no},"winter|clear":{season:"winter",weather:"clear",sky:Vc(),cloudCover:jt(.2),particles:"none",lightning:!1,fogAlpha:0,ground:qc,sunTint:[220,230,245]},"winter|snow":{season:"winter",weather:"snow",sky:Vc(),cloudCover:jt(.9),particles:"snow",lightning:!1,fogAlpha:.2,ground:qc}},$c=Object.keys(Vm);function Uy(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 zy(e){const t=`${e??"none"}:${Math.floor(performance.now()/1e3)}`;return $c[Uy(t)%$c.length]}function Vy(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=Mi(ya((e-r.t)/(s.t-r.t||1),0,1));return{top:er(r.top,s.top,i),mid:er(r.mid,s.mid,i),hor:er(r.hor,s.hor,i)}}function qy(e,t,n,r,s){if(e<r||e>s)return null;const i=(e-r)/(s-r),a=Jn(.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 $y(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=Jn(.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 qm(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 Wc(e,t){const n=qm(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 Wy(){const e=qm(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 Yy(e,t,n,r){const s=e.createLinearGradient(0,0,0,r);s.addColorStop(0,Za(t.top)),s.addColorStop(.55,Za(t.mid)),s.addColorStop(1,Za(t.hor)),e.fillStyle=s,e.fillRect(0,0,n,r)}function Gy(e,t,n,r,s,i){let a=0;if(t<.22?a=Mi(1-t/.22):t>.8&&(a=Mi((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 Ky(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?er(n,[255,214,150],.5):[255,214,150];l.addColorStop(0,"rgba(255,252,238,1)"),l.addColorStop(.7,Mr(u,1)),l.addColorStop(1,Mr(c,.9)),e.fillStyle=l,e.beginPath(),e.arc(r,s,a,0,Math.PI*2),e.fill()}function Xy(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 Qy(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=Mr([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=Mr(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 Zy(e,t,n,r,s,i,a,o,l){const u=a(t);if(u<.02)return;const c=er(o.hor,[255,255,255],.35),h=er(o.mid,[20,20,30],.45),f=l?h:c;for(let d=0;d<n.length;d++){const m=n[d],g=(m.x+i*m.speed)%1.2-.1,b=m.y+Math.sin(i*1e-4+m.seed)*m.drift;d/n.length<u&&Qy(e,g*r,b*s,m.s,f,ya(u*.92,0,.92))}}const yr=[];let Wn=[];const ui=[];let Yn=[];const bs=[],Jr=[];let ci=[];function Jy(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))),h=n-r-a,f=(c+h)/2;e.save(),e.beginPath(),e.moveTo(l,c),e.bezierCurveTo(l,f,t-r*.3,h,t,h),e.bezierCurveTo(t+r*.3,h,u,f,u,c),e.quadraticCurveTo(t,n-r*.78,l,c),e.closePath();const d=e.createLinearGradient(0,h,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 ro(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 e2(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 t2(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 $m(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 n2(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 h=0;h<l;h++){const f=o.prog-o.len*(h/l),d=o.prog-o.len*((h+1)/l),m=ro(t,n,r,f,o.theta),g=ro(t,n,r,d,o.theta),b=(1-h/l)*.42;e.strokeStyle=`rgba(200,228,250,${b})`,e.lineWidth=o.thick*(1-h/l*.7),e.lineCap="round",e.beginPath(),e.moveTo(m.x,m.y),e.lineTo(g.x,g.y),e.stroke()}const u=ro(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 r2(e,t,n,r){for(;yr.length<t.length;)yr.push([]);for(;Wn.length<t.length;)Wn.push(0);for(;ci.length<t.length;)ci.push(.3);for(;ui.length<t.length;)ui.push([]);for(;Yn.length<t.length;)Yn.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,(ci[s]??.3)+8e-4);ci[s]=a,Jy(e,i.x,i.y,i.r,a)}else if(n.particles==="rain"){if(e2(e,i.x,i.y,i.r),Wn[s]=Wn[s]-1,Wn[s]<=0&&yr[s].length<3){const a=Math.random()<.5?-1:1;yr[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}),Wn[s]=40+Math.random()*60}if(n2(e,i.x,i.y,i.r,yr[s]),Yn[s]=Yn[s]-1,Yn[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 h=o<0?-1:1;ui[s].push({x:a,y:l,vx:h*(.5+Math.random()*2)*(Math.random()<.5?-1:1),vy:-(1.5+Math.random()*2.5),life:18+Math.floor(Math.random()*14)})}Yn[s]=30+Math.floor(Math.random()*50)}$m(e,ui[s])}}}function i2(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 s2(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 a2(e,t,n,r,s){const i=e.createLinearGradient(0,n*.4,0,n),a=er(s.hor,[255,255,255],.3);i.addColorStop(0,Mr(a,0)),i.addColorStop(1,Mr(a,r)),e.fillStyle=i,e.fillRect(0,n*.4,t,n*.6)}let pr=0,Yc=0;function o2(e,t,n,r,s){if(s>Yc&&(pr=1,Yc=s+1400+Math.random()*2600),pr*=.86,pr<.02){pr=0;return}if(e.fillStyle=`rgba(255,255,255,${pr*.5})`,e.fillRect(0,0,t,n),pr>.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 l2(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=Wc(1,1);const h=Wy();let f=[],d=[],m=0,g=0,b=!0;const y=performance.now(),w=window.matchMedia("(prefers-reduced-motion: reduce)").matches;function E(){const N=a.getBoundingClientRect();if(u=Math.min(window.devicePixelRatio||1,2),o=Math.max(1,N.width),l=Math.max(1,N.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=Wc(o,l),r.particles==="rain"&&f.length===0){const C=r.weather==="storm",D=C?140:70;for(let P=0;P<D;P++)f.push({x:Math.random(),y:Math.random(),len:C?12+Math.random()*14:6+Math.random()*8,v:C?.9+Math.random()*.4:.5+Math.random()*.3})}if(r.particles==="snow"&&d.length===0)for(let C=0;C<120;C++)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 S(){const N=t.scrollHeight-t.clientHeight;m=N>0?ya(t.scrollTop/N,0,1):0}function v(N){if(!b)return;const C=m,D=w?0:(N-y)/1e3,P=Vy(C,r.sky);Yy(i,P,o,l),Gy(i,C,c,o,l,D),Xy(i,$y(C,o,l,.92,.08)),Ky(i,qy(C,o,l,.16,.88),r.sunTint),Zy(i,C,h,o,l,N,r.cloudCover,P,r.weather==="storm"),r.particles==="rain"&&i2(i,o,l,f,r.weather==="storm"),r.particles==="snow"&&s2(i,o,l,d,N),r.fogAlpha>0&&a2(i,o,l,r.fogAlpha,P),r.lightning&&o2(i,o,l,!0,N),w||(g=requestAnimationFrame(v))}const T=()=>S(),_=new ResizeObserver(()=>{E(),S()});_.observe(a),E(),S();let A;if(w){let N=!1;A=()=>{S(),N||(N=!0,requestAnimationFrame(()=>{N=!1,v(performance.now())}))},t.addEventListener("scroll",A,{passive:!0}),v(performance.now())}else A=T,t.addEventListener("scroll",A,{passive:!0}),g=requestAnimationFrame(v);return()=>{b=!1,cancelAnimationFrame(g),_.disconnect(),t.removeEventListener("scroll",A)}}function u2(e,t,n,r,s,i){const a=()=>{yr.length=0,ci.length=0,Wn.length=0,ui.length=0,Yn.length=0,bs.length=0,Jr.length=0;const w=e.getContext("2d");w&&w.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,h=0,f=1,d=0,m=!0;function g(){const w=t.getBoundingClientRect();f=Math.min(window.devicePixelRatio||1,2),c=Math.max(1,w.width),h=Math.max(1,w.height),e.width=Math.floor(c*f),e.height=Math.floor(h*f),e.style.width=c+"px",e.style.height=h+"px",u.setTransform(f,0,0,f,0,0)}function b(w){if(!m)return;u.clearRect(0,0,c,h);const E=r();if(r2(u,E,n),s){for(const S of s()){const v=3+Math.min(5,Math.floor(S.speed/3));for(let T=0;T<v;T++)bs.push({x:S.x,y:S.y,vx:(Math.random()-.5)*3.2,vy:-(1.5+Math.random()*2.5),life:16+Math.floor(Math.random()*12)})}bs.length>0&&$m(u,bs)}if(i){for(const S of i()){const v=1+Math.min(2,Math.round(S.amount*40));for(let T=0;T<v;T++){const _=55+Math.floor(Math.random()*40);Jr.push({x:S.x+(Math.random()-.5)*8,y:S.y+(Math.random()-.5)*6,vx:S.vx*.6+(Math.random()-.5)*.8,vy:S.vy*.6-Math.random()*.5,life:_,maxLife:_,r:1.2+Math.random()*2.2})}}for(;Jr.length>240;)Jr.shift();t2(u,Jr)}d=requestAnimationFrame(b)}const y=new ResizeObserver(g);return y.observe(t),g(),d=requestAnimationFrame(b),()=>{m=!1,cancelAnimationFrame(d),y.disconnect(),a()}}const c2=k.lazy(()=>_e(()=>import("./CourseSearchPanel-ErS8Zlba.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.CourseSearchPanel})));function d2(e){const t=$e(),[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=!Jl(),h=k.useRef([]),f=k.useRef(I=>{h.current.push(...I),h.current.length>64&&h.current.splice(0,h.current.length-64)}).current,d=k.useRef([]),m=k.useRef(new Map),g=k.useRef(I=>{d.current.push(...I),d.current.length>96&&d.current.splice(0,d.current.length-96)}).current,b=e.sections.filter(I=>(I.world??"study")===s),y=e.sections.some(I=>I.world==="practice"),[w,E]=k.useState(null);k.useEffect(()=>{E(zy(e.courseId))},[e.courseId]);const S=w?Vm[w]??null:null;k.useEffect(()=>(wc({nav:a.current,visible:n==="map",weather:(S==null?void 0:S.weather)??"clear"}),()=>{wc({visible:!1,nav:null})}),[n,S,a]);const[v,T]=k.useState(!1);k.useEffect(()=>{if(!e.selectedNodeId)return;const I=o.current;if(!I)return;const R=I.querySelector(`[data-node-id="${CSS.escape(e.selectedNodeId)}"]`);if(!R)return;const B=I.getBoundingClientRect(),V=R.getBoundingClientRect();(V.top<B.top+60||V.bottom>B.bottom-60)&&R.scrollIntoView({behavior:"smooth",block:"center"})},[e.selectedNodeId]);const _=k.useRef(null);k.useEffect(()=>{T(!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[A,N]=k.useState(null),[C,D]=k.useState(!1),P=k.useRef({}),O=k.useRef(null);return k.useEffect(()=>{var V,z;const I=P.current,R={};let B=null;for(const Y of e.tree){const L=((V=e.progressMap[Y.id])==null?void 0:V.status)??"locked";R[Y.id]=L,I[Y.id]==="locked"&&L!=="locked"&&!B&&(B=Y.id)}if(B&&Object.keys(I).length>0){const Y=(z=a.current)==null?void 0:z.querySelector(`[data-testid="map-node-${B.slice(0,8)}"], [data-testid="exam-node-${B.slice(0,8)}"]`),L=Y==null?void 0:Y.getBoundingClientRect(),q=!!L&&L.width>0&&L.left>=0&&L.right<=window.innerWidth&&L.top>=0;Ar("unlock",q?{origin:{x:L.left+L.width/2,y:L.top+4}}:void 0)}P.current=R},[e.tree,e.progressMap]),p.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:[S&&p.jsxs(p.Fragment,{children:[p.jsx(f2,{scrollRef:o,navRef:a,preset:S}),p.jsx(m2,{scrollRef:o,navRef:a,preset:S,getImpacts:()=>h.current.splice(0),getFlakes:()=>d.current.splice(0),orbSnowRef:m})]}),p.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:[p.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:[p.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:[p.jsx(wm,{className:"w-3 h-3"})," ",t("map.tab.map")]}),p.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:[p.jsx(Vi,{className:"w-3 h-3"})," ",t("map.tab.import")]})]}),n==="map"&&p.jsxs("div",{className:"relative 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:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[e.courseId&&e.courses.length>0?p.jsxs("button",{type:"button","data-testid":"map-course-switch",onClick:()=>D(I=>!I),"data-tooltip":t("map.course.switch"),className:"flex-1 min-w-0 flex items-center gap-1 text-left rounded-md px-1 -mx-1 py-0.5 hover:bg-white/10 motion-safe:transition-colors",children:[p.jsx("h2",{className:"text-body font-extrabold text-white truncate flex-1","data-tooltip":e.courseTitle??"",children:e.courseTitle??t("map.course.none")}),p.jsx(pa,{className:`w-3.5 h-3.5 shrink-0 text-white/50 motion-safe:transition-transform ${C?"rotate-180":""}`})]}):p.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&&p.jsx(v2,{available:e.availableLanguages,current:e.currentLocale,onChange:e.onLocaleChange}),e.courseId&&p.jsx("button",{onClick:I=>{const R=I.currentTarget.getBoundingClientRect();N({id:e.courseId,title:e.courseTitle??"",rect:R})},"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:p.jsx(Nm,{className:"w-3 h-3"})})]}),C&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"fixed inset-0 z-40","data-noswipe":"",onClick:()=>D(!1)}),p.jsx("div",{className:"absolute left-3 right-3 top-full mt-1 z-50 rounded-lg border border-white/10 bg-[#141a26]/95 backdrop-blur-xl shadow-elevated overflow-hidden","data-testid":"map-course-menu",children:e.courses.map(I=>{const R=I.id===e.courseId;return p.jsxs("button",{type:"button","data-testid":`map-course-option-${I.id}`,onClick:()=>{e.onSelectCourse(I.id),D(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-left text-label transition-colors ${R?"text-brand bg-brand/10 font-bold":"text-white/80 hover:bg-white/10"}`,children:[p.jsx("span",{className:"flex-1 truncate",children:I.title}),R&&p.jsx(xn,{className:"w-3.5 h-3.5 shrink-0"})]},I.id)})})]}),p.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[p.jsx("div",{className:"flex-1 h-2.5 bg-black/40 rounded-full overflow-hidden ring-1 ring-white/10",children:p.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${l>=100?"bg-gold":"bg-brand"}`,style:{width:`${Math.max(3,l)}%`}})}),p.jsxs("span",{className:"text-label font-extrabold tabular-nums text-white drop-shadow-[0_1px_3px_rgba(0,0,0,0.6)]",children:[l,"%"]})]}),p.jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1.5 text-caption",children:[p.jsxs("button",{onClick:()=>T(!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:[p.jsx(ey,{className:"w-3 h-3 text-white/50"}),p.jsx("span",{className:"font-bold text-white/60",children:t("map.search.label")})]}),p.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:[p.jsx(Jt,{className:`w-3 h-3 ${e.dueCount>0?"text-review":"text-white/50"}`}),p.jsx("span",{className:`font-bold ${e.dueCount>0?"text-review":"text-white/60"}`,children:t("map.review.label")}),e.dueCount>0&&p.jsx("span",{className:"font-extrabold text-review tabular-nums",children:e.dueCount})]})]}),y&&p.jsxs("div",{className:"flex gap-1 mt-1.5 p-0.5 rounded-lg bg-black/30",children:[p.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:[p.jsx(Jt,{className:"w-3 h-3"})," ",t("map.world.study")]}),p.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:[p.jsx(Mm,{className:"w-3 h-3"})," ",t("map.world.practice")]})]})]})]}),p.jsx("div",{className:"absolute inset-0 overflow-hidden z-10",children:p.jsxs("div",{className:"flex h-full transition-transform duration-300",style:{transform:n==="map"?"translateX(0)":"translateX(-50%)",width:"200%"},children:[p.jsx("div",{className:"w-1/2 h-full relative",children:p.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:I=>{O.current={x:I.clientX,y:I.clientY}},onClick:I=>{const R=O.current;O.current=null,!(!R||Math.hypot(I.clientX-R.x,I.clientY-R.y)>6)&&(I.target.closest("button, a, input, textarea, select")||Qo(I.clientX,I.clientY))},children:p.jsxs("div",{className:`map-sky-content ${S?`env-${S.season} env-${S.weather}`:""}`,children:[e.streaming&&p.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:[p.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?p.jsxs("div",{className:"text-center text-label text-white/60 mt-8 px-4 flex items-center justify-center gap-2",children:[p.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),t("map.generating")]}):p.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:[p.jsx("div",{className:"text-3xl mb-2 group-hover:scale-110 transition-transform",children:"🗺️"}),p.jsx("div",{className:"text-body font-bold text-white/90 mb-1",children:t("map.empty.cta.title")}),p.jsx("div",{className:"text-label text-white/60 leading-relaxed",children:t("map.empty.cta.desc")}),p.jsx("div",{className:"mt-2 text-caption text-brand font-bold",children:t("map.empty.cta.btn")})]}):b.length===0?p.jsx("div",{className:"text-center text-label text-white/60 mt-8 px-4",children:t(s==="practice"?"map.empty.practice":"map.generating")}):p.jsx("div",{className:"space-y-6 pt-2",children:b.map((I,R)=>p.jsx(p2,{section:I,sectionIndex:R,tree:e.tree,progressMap:e.progressMap,selectedNodeId:e.selectedNodeId,dueNodeIds:e.dueNodeIds,streamingNodeIds:e.streamingNodeIds,onJumpNode:e.onJumpNode,nextCueNodeId:e.nextCueNodeId,physics:c,physicsWeather:(S==null?void 0:S.weather)??"clear",scrollRef:o,navRef:a,onImpacts:f,onFlakes:g,orbSnowRef:m},I.id))})]})})}),p.jsx("div",{className:"w-1/2 h-full overflow-y-auto px-3 pt-20 pb-3 space-y-2.5",children:p.jsx(h2,{courses:e.courses,selectedCourseId:e.courseId,onSelectCourse:I=>{e.onSelectCourse(I),r("map")},onDeleteCourse:(I,R,B)=>N({id:I,title:R,rect:B}),onCoursesChanged:e.onCoursesChanged})})]})}),v&&e.courseId&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(c2,{sections:e.sections,tree:e.tree,progressMap:e.progressMap,selectedNodeId:e.selectedNodeId,onJump:I=>{i(I.world??"study"),T(!1),Zo(null,null,I.id),e.onJumpNode(I.id)},onClose:()=>T(!1)})}),A&&p.jsx(Fm,{anchorRect:A.rect,message:`${A.title} — ${t("import.delete.confirm")}`,danger:!0,confirmLabel:t("import.delete"),testid:"course-delete-confirm",onConfirm:()=>{e.onDeleteCourse(A.id),N(null)},onCancel:()=>N(null)})]})}function h2({courses:e,selectedCourseId:t,onSelectCourse:n,onDeleteCourse:r,onCoursesChanged:s}){const i=$e(),[a,o]=k.useState("url"),[l,u]=k.useState(!1),[c,h]=k.useState(""),[f,d]=k.useState(""),m=k.useRef(null),g=k.useRef(null),b=k.useRef(null),[y,w]=k.useState(""),[E,S]=k.useState(""),[v,T]=k.useState(!1),[_,A]=k.useState(null),[N,C]=k.useState(null),[D,P]=k.useState(null),[O,I]=k.useState(null),[R,B]=k.useState([]),[,V]=k.useState(0),z=k.useRef(null);k.useEffect(()=>{const Z=se.on("import:progress",be=>{B(ve=>{const Fe=/\d+\/\d+/.test(be),je=ve[ve.length-1];if(Fe&&je&&je.status==="working"){const Oe=[...ve];return Oe[Oe.length-1]={...je,msg:be},Oe}const Se=ve.map(Oe=>Oe.status==="working"?{...Oe,status:"done"}:Oe);return Se.push({msg:be,status:"working",ts:Date.now()}),Se})}),re=setInterval(()=>V(be=>be+1),1e3);return()=>{Z(),clearInterval(re)}},[]),k.useEffect(()=>se.on("import:done",re=>{T(!1),Bt(!1),re.cancelled||Hb(re.ok),P(re.ok?null:re.planId??null),re.ok?(C(`${i("import.success.folder")}: ${re.title??""}${re.reused?`(${i("import.success.reused")})`:""}`),I(re.courseId?{courseId:re.courseId,packable:re.packable??!1}:null),s()):re.cancelled?(B([]),A(null),C(i("import.cancelled"))):A(re.error??"导入失败")}),[s,i]),k.useEffect(()=>{const Z=z.current;Z&&(Z.scrollTop=Z.scrollHeight)},[R]);const Y=async()=>{if(!(!c.trim()||v)){A(null),C(null),B([]);try{await se.importUrl(c.trim()),T(!0),Bt(!0)}catch(Z){A(Z instanceof Error?Z.message:String(Z))}}},L=async()=>{if(!(!y.trim()||v)){A(null),C(null),B([]);try{await se.importText({name:E.trim()||void 0,text:y.trim()}),T(!0),Bt(!0)}catch(Z){A(Z instanceof Error?Z.message:String(Z))}}},q=async()=>{var re;if(v)return;if(A(null),C(null),B([]),!fn){(re=g.current)==null||re.click();return}await se.importEpub().catch(be=>(A(be instanceof Error?be.message:String(be)),null))&&(T(!0),Bt(!0))},K=async Z=>{if(!(!Z||v)){A(null),C(null),B([]);try{const re=new Uint8Array(await Z.arrayBuffer());let be="";for(let Fe=0;Fe<re.length;Fe+=32768)be+=String.fromCharCode(...re.subarray(Fe,Fe+32768));await se.importEpub({fileName:Z.name,contentBase64:btoa(be)})&&T(!0),Bt(!0)}catch(re){A(re instanceof Error?re.message:String(re))}}},M=async()=>{if(v)return;if(A(null),C(null),B([]),!fn){const re=f.trim();if(!re){A(i("import.folder.pathRequired"));return}try{await se.importLocalFolder(re)&&T(!0),Bt(!0)}catch(be){A(be instanceof Error?be.message:String(be))}return}await se.importLocalFolder()&&(T(!0),Bt(!0))},G=async()=>{var re;if(v)return;if(A(null),C(null),B([]),!fn){(re=m.current)==null||re.click();return}await se.importPack().catch(be=>(A(be instanceof Error?be.message:String(be)),null))&&(T(!0),Bt(!0))},ae=async Z=>{if(!(!Z||v)){A(null),C(null),B([]);try{const re=await Z.text();await se.importPack({fileName:Z.name,content:re})&&T(!0),Bt(!0)}catch(re){A(re instanceof Error?re.message:String(re))}}},ne=async()=>{var re;if(v)return;if(A(null),C(null),B([]),!fn){(re=b.current)==null||re.click();return}await se.importAudio().catch(be=>(A(be instanceof Error?be.message:String(be)),null))&&(T(!0),Bt(!0))},X=async Z=>{if(!(!Z||Z.length===0||v)){A(null),C(null),B([]);try{const re=[];for(const ve of Array.from(Z)){const Fe=new Uint8Array(await ve.arrayBuffer());let je="";for(let Se=0;Se<Fe.length;Se+=32768)je+=String.fromCharCode(...Fe.subarray(Se,Se+32768));re.push({fileName:ve.name,contentBase64:btoa(je)})}await se.importAudio(re)&&T(!0),Bt(!0)}catch(re){A(re instanceof Error?re.message:String(re))}}},te=async Z=>{if(!v){A(null),B([]);try{await se.importResume(Z),T(!0),Bt(!0)}catch(re){A(re instanceof Error?re.message:String(re))}}},ue=async Z=>{try{const re=await se.exportPack(Z);re!=null&&re.content&&re.fileName?(ge(re.fileName,re.content),C(i("import.pack.exported",{path:re.fileName}))):re!=null&&re.path&&C(i("import.pack.exported",{path:re.path}))}catch(re){A(re instanceof Error?re.message:String(re))}},ge=(Z,re)=>{const be=new Blob([re],{type:"application/json"}),ve=URL.createObjectURL(be),Fe=document.createElement("a");Fe.href=ve,Fe.download=Z,Fe.click(),setTimeout(()=>URL.revokeObjectURL(ve),5e3)};return p.jsxs(p.Fragment,{children:[e.length===0?p.jsxs("div",{className:"text-center py-10",children:[p.jsx("div",{className:"text-3xl mb-2 opacity-30",children:"📚"}),p.jsx("p",{className:"text-label text-white/45 leading-relaxed",children:i("import.empty")})]}):p.jsx("div",{className:"space-y-2","data-testid":"course-list",children:e.map(Z=>{const re=Z.id===t;return p.jsxs("div",{"data-testid":"course-row",className:`relative rounded-xl transition-all duration-150 group ${re?"bg-brand/12 ring-1 ring-brand/40":"bg-white/5 hover:bg-white/10 hover:-translate-y-0.5"}`,children:[p.jsx("button",{onClick:()=>n(Z.id),className:"w-full text-left p-3",children:p.jsxs("div",{className:"flex items-start justify-between gap-2",children:[p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:`text-body font-bold truncate ${re?"text-brand":"text-white/90"}`,children:Z.title}),p.jsx("div",{className:"text-caption text-white/40 truncate mt-0.5",children:Z.repoName})]}),re&&p.jsx("span",{className:"shrink-0 w-5 h-5 rounded-full bg-brand flex items-center justify-center",children:p.jsx(xn,{className:"w-3 h-3 text-white"})})]})}),p.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:[p.jsxs("button",{onClick:be=>{be.stopPropagation(),A(null),C(null),se.exportPack(Z.id).then(ve=>{ve!=null&&ve.content&&ve.fileName?(ge(ve.fileName,ve.content),C(i("import.pack.exported",{path:ve.fileName}))):ve!=null&&ve.path&&C(i("import.pack.exported",{path:ve.path}))}).catch(ve=>{A(ve instanceof Error?ve.message:String(ve))})},"data-testid":"course-row-export",className:"text-caption text-white/40 hover:text-brand flex items-center gap-0.5",children:[p.jsx(Dc,{className:"w-2.5 h-2.5"})," ",i("import.export")]}),p.jsxs("button",{onClick:be=>{be.stopPropagation();const ve=be.currentTarget.getBoundingClientRect();r(Z.id,Z.title,ve)},"data-testid":"course-row-delete",className:"text-caption text-white/40 hover:text-warning flex items-center gap-0.5",children:[p.jsx(Nm,{className:"w-2.5 h-2.5"})," ",i("import.delete")]})]})]},Z.id)})}),p.jsxs("div",{className:e.length>0?"mt-6":"",children:[p.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:[p.jsx(Cm,{className:`w-4 h-4 transition-transform ${l?"rotate-45":""}`})," ",i("import.cta")]}),l&&p.jsxs("div",{className:"mt-3 space-y-3",children:[v?p.jsxs("div",{className:"rounded-xl bg-black/30 border border-brand/30 p-4","data-testid":"import-progress",children:[p.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[p.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin shrink-0"}),p.jsx("span",{className:"text-body font-bold text-white/90",children:i("import.progress.title")}),p.jsx("button",{onClick:()=>{se.importCancel()},"data-testid":"import-cancel-btn",className:"ml-auto text-caption text-white/50 hover:text-warning transition-colors",children:i("import.progress.cancel")})]}),p.jsx("div",{className:"text-caption text-white/40 mb-2.5",children:i("import.progress.note")}),(a==="url"?c.trim():a==="markdown"&&E.trim())?p.jsx("div",{className:"text-caption text-white/40 font-mono truncate mb-2.5",children:a==="url"?c.trim():E.trim()}):null,p.jsx("div",{ref:z,className:"space-y-1.5 max-h-[40vh] overflow-y-auto pr-1",children:R.length===0?p.jsx("div",{className:"text-caption text-white/50 py-1",children:i("import.progress.starting")}):R.map((Z,re)=>p.jsxs("div",{className:"flex items-start gap-1.5 text-caption",children:[Z.status==="done"?p.jsx(xn,{className:"w-3 h-3 text-brand shrink-0 mt-px"}):p.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"}),p.jsxs("span",{className:Z.status==="done"?"text-white/40":"text-white/90",children:[Z.msg,Z.status==="working"&&p.jsxs("span",{className:"text-white/35 ml-1",children:["(",i("import.progress.elapsed",{s:Math.floor((Date.now()-Z.ts)/1e3)}),")"]})]})]},re))})]}):p.jsxs(p.Fragment,{children:[p.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:Ux},{k:"markdown",label:i("import.tab.md"),icon:Vi},{k:"folder",label:i("import.tab.folder"),icon:Px},{k:"epub",label:i("import.tab.epub"),icon:Jt},{k:"audio",label:i("import.tab.audio"),icon:Ms},{k:"pack",label:i("import.tab.pack"),icon:Dc}].map(({k:Z,label:re,icon:be})=>p.jsxs("button",{onClick:()=>o(Z),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===Z?"bg-brand/15 text-brand":"text-white/50 hover:text-white/80"}`,children:[p.jsx(be,{className:"w-3 h-3 shrink-0"}),p.jsx("span",{className:"whitespace-nowrap",style:{fontSize:"clamp(0.75rem, 4cqi, 0.875rem)"},children:re})]},Z))}),a==="url"?p.jsxs("section",{className:"space-y-2","data-testid":"import-url-section",children:[p.jsx("input",{type:"text",value:c,onChange:Z=>h(Z.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"}),p.jsx("p",{className:"text-caption text-white/45 leading-relaxed",children:i("import.url.desc")}),p.jsx("button",{onClick:Y,disabled:!c.trim()||v,"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"?p.jsxs("section",{className:"space-y-2","data-testid":"import-md-section",children:[p.jsx("input",{type:"text",value:E,onChange:Z=>S(Z.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"}),p.jsx("textarea",{value:y,onChange:Z=>w(Z.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"}),p.jsx("button",{onClick:L,disabled:!y.trim()||v,"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"?p.jsxs("section",{className:"space-y-2","data-testid":"import-folder-section",children:[p.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.folder.desc")}),!fn&&p.jsx("input",{type:"text",value:f,onChange:Z=>d(Z.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"}),p.jsx("button",{onClick:M,disabled:v||!fn&&!f.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"?p.jsxs("section",{className:"space-y-2","data-testid":"import-epub-section",children:[p.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.epub.desc")}),!fn&&p.jsx("input",{ref:g,type:"file",accept:".epub,application/epub+zip",className:"hidden","data-testid":"import-epub-file",onChange:Z=>{var re;K((re=Z.target.files)==null?void 0:re[0]),Z.currentTarget.value=""}}),p.jsx("button",{onClick:q,disabled:v,"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"?p.jsxs("section",{className:"space-y-2","data-testid":"import-audio-section",children:[p.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.audio.desc")}),!fn&&p.jsx("input",{ref:b,type:"file",multiple:!0,accept:".wav,.mp3,.m4a,.flac,.aac,.ogg,.opus,audio/*",className:"hidden","data-testid":"import-audio-file",onChange:Z=>{X(Z.target.files),Z.currentTarget.value=""}}),p.jsx("button",{onClick:ne,disabled:v,"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")})]}):p.jsxs("section",{className:"space-y-2","data-testid":"import-pack-section",children:[p.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.pack.desc")}),!fn&&p.jsx("input",{ref:m,type:"file",accept:".json,application/json",className:"hidden","data-testid":"import-pack-file",onChange:Z=>{var re;ae((re=Z.target.files)==null?void 0:re[0]),Z.currentTarget.value=""}}),p.jsx("button",{onClick:G,disabled:v,"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")})]})]}),_&&p.jsxs("div",{className:"border border-warning/40 text-warning-light text-label rounded-lg p-2 whitespace-pre-wrap","data-testid":"import-error",children:[_,D&&p.jsx("button",{onClick:()=>void te(D),disabled:v,"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")})]}),N&&p.jsxs("div",{className:"border border-brand/30 text-brand text-label rounded-lg p-2","data-testid":"import-success",children:[p.jsx(xn,{className:"inline-block w-3.5 h-3.5 mr-1 align-[-3px]"}),N,(O==null?void 0:O.packable)&&p.jsx("button",{onClick:()=>void ue(O.courseId),disabled:v,"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 f2({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:l2(s,i,a,n)},[e,t,n]),p.jsx("canvas",{ref:r,className:"map-sky-canvas","aria-hidden":"true"})}function m2({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,h=null;const f=()=>{c=null,h=null},d=new MutationObserver(f);d.observe(u,{childList:!0,subtree:!0}),window.addEventListener("resize",f);const g=u2(o,l,n,()=>{var w,E;c||(c=Array.from(u.querySelectorAll(".lesson-bubble")));const b=h??l.getBoundingClientRect();h=b;const y=[];for(const S of c){const v=S.getBoundingClientRect();if(v.bottom<b.top||v.top>b.bottom)continue;const T=(w=S.closest("[data-node-id]"))==null?void 0:w.getAttribute("data-node-id"),_=T?(E=i==null?void 0:i.current)==null?void 0:E.get(T):void 0;y.push({x:v.left-b.left+v.width/2,y:v.top-b.top+v.height/2,r:v.width/2,..._!==void 0?{snow:_}:{}})}return y},r,s);return()=>{g(),d.disconnect(),window.removeEventListener("resize",f)}},[e,t,n,r,s]),p.jsx("canvas",{ref:a,className:"map-orb-weather-canvas","aria-hidden":"true"})}function p2({section:e,sectionIndex:t,tree:n,progressMap:r,selectedNodeId:s,nextCueNodeId:i,dueNodeIds:a,streamingNodeIds:o,onJumpNode:l,physics:u,physicsWeather:c,scrollRef:h,navRef:f,onImpacts:d,onFlakes:m,orbSnowRef:g}){const b=n.filter(X=>X.parentId===e.id).sort((X,te)=>X.orderIdx-te.orderIdx),y=b.filter(X=>X.type==="lesson"),w=y.length>0&&y.every(X=>{var te;return(((te=r[X.id])==null?void 0:te.mastery)??0)>=hy}),E=k.useRef(null),[S,v]=k.useState(268);k.useEffect(()=>{if(!E.current)return;const X=()=>{var ge;const ue=((ge=E.current)==null?void 0:ge.clientWidth)??268;v(ue>0?ue:268)};X();const te=new ResizeObserver(X);return te.observe(E.current),()=>te.disconnect()},[]);const T=Ty(b.length,S,e.id),_=T.height,A=110,N=76,C=k.useRef(null),D=k.useRef(new Map),P=k.useRef(0),O=k.useRef(null),I=k.useRef(0),R=b.map(X=>X.id).join(","),B=b.map(X=>{var te;return(X.type==="exam"?!w:(((te=r[X.id])==null?void 0:te.status)??"locked")==="locked")?1:0}).join("");k.useEffect(()=>{var Be,Q;if(!u||b.length===0||S<=0)return;const X=E.current,te=h.current;if(!X||!te)return;let ue;const ge=b[b.length-1];if((ge==null?void 0:ge.type)==="exam"){const ee=(Q=(Be=X.closest("section"))==null?void 0:Be.nextElementSibling)==null?void 0:Q.querySelector(".map-signpost");ee&&(ue={x:ms(`${e.id}:next`,S),y:ee.getBoundingClientRect().top-X.getBoundingClientRect().top})}const Z=jy({nodes:T.nodes.map((ee,he)=>{const Te=b[he];return{id:Te.id,x:ee.x,y:ee.y,isExam:Te.type==="exam",locked:V(Te),spawn:(()=>{const Re=D.current.get(Te.id);return Re?Hy(Re,P.current,S):void 0})()}}),width:S,height:T.height+40,weather:c,anchorKnotX:ms(`${e.id}:knot`,S),nextKnot:ue});C.current=Z,Bb(e.id,Z,X);const re=X.querySelector("[data-next-knot]");re&&(Z.nextKnot?(re.setAttribute("cx",String(Z.nextKnot.x)),re.setAttribute("cy",String(Z.nextKnot.y))):re.setAttribute("opacity","0"));const be=X.querySelector("[data-exam-rope]");be&&!Z.nextKnot&&be.setAttribute("opacity","0");const ve=new Map;for(const ee of X.querySelectorAll("[data-node-id]"))ee.dataset.nodeId&&ve.set(ee.dataset.nodeId,ee);const Fe=Array.from(X.querySelectorAll("[data-rope]")),je=Array.from(X.querySelectorAll("[data-pulse]")),Se=Array.from(X.querySelectorAll("[data-field]"));let Oe=!0;const st=new IntersectionObserver(ee=>{for(const he of ee)Oe=he.isIntersecting},{root:te,rootMargin:"200px 0px 200px 0px"});st.observe(X);const pt=520,me=[];let rt=0,ie=performance.now();const Ie=ee=>{var dt;rt=requestAnimationFrame(Ie);const he=Math.min(50,ee-ie);if(ie=ee,!Oe)return;Z.step(he);for(const xe of Z.balls){const De=ve.get(xe.nodeId);De&&(De.style.transform=My(xe.body.position.x-xe.layoutX,xe.body.position.y-xe.layoutY,xe.squash,xe.squashAngle)),xe.squash=Ry(xe.squash,he),(dt=g.current)==null||dt.set(xe.nodeId,xe.snow)}const Te=xe=>{if(xe==="__anchor")return Z.anchor;if(xe==="__next")return Z.nextKnot??Z.anchor;const De=Z.ball(xe);if(De)return{x:De.body.position.x,y:De.body.position.y+Ht*gn};const Ve=b.findIndex(We=>We.id===xe),pe=Ve>=0?T.nodes[Ve]:void 0;return pe?{x:pe.x,y:pe.y+Ht*gn}:{x:0,y:0}};for(let xe=0;xe<Z.links.length&&xe<Fe.length;xe++){const De=Z.links[xe],Ve=[Te(De.from)];for(const pe of De.particles)Ve.push({x:pe.position.x,y:pe.position.y});Ve.push(Te(De.to)),Fe[xe].setAttribute("d",Iy(Ve))}for(let xe=0;xe<Z.balls.length&&xe<Se.length;xe++){const De=Z.balls[xe],Ve=Se[xe];De.field>.03?(Ve.setAttribute("cx",String(De.body.position.x)),Ve.setAttribute("cy",String(De.body.position.y)),Ve.setAttribute("r",String(Ht+4+De.field*5)),Ve.setAttribute("opacity",String((.3*De.field).toFixed(3)))):Ve.setAttribute("opacity","0")}const Re=Z.drainImpacts();for(const xe of Re)me.push({x:xe.x,y:xe.y,t0:ee,s:Math.min(1,xe.speed/14)});for(let xe=me.length-1;xe>=0;xe--)ee-me[xe].t0>pt&&me.splice(xe,1);for(let xe=0;xe<je.length;xe++){const De=me[xe],Ve=je[xe];if(!De){Ve.setAttribute("opacity","0");continue}const pe=(ee-De.t0)/pt;Ve.setAttribute("cx",String(De.x)),Ve.setAttribute("cy",String(De.y)),Ve.setAttribute("r",String(6+pe*(14+De.s*14))),Ve.setAttribute("opacity",String(.55*(1-pe))),Ve.setAttribute("stroke-width",String(2+De.s*1.5))}const Ze=Z.drainFlakes();if((Re.length>0||Ze.length>0)&&f.current){const xe=X.getBoundingClientRect(),De=f.current.getBoundingClientRect(),Ve=pe=>({x:pe.x+xe.left-De.left,y:pe.y+xe.top-De.top});Re.length>0&&d(Re.map(pe=>({...Ve(pe),speed:pe.speed}))),Ze.length>0&&m(Ze.map(pe=>({...Ve(pe),vx:pe.vx,vy:pe.vy,amount:pe.amount})))}};return rt=requestAnimationFrame(Ie),()=>{cancelAnimationFrame(rt),st.disconnect();for(const ee of Z.balls)D.current.set(ee.nodeId,{x:ee.body.position.x,y:ee.body.position.y,vx:ee.body.velocity.x,vy:ee.body.velocity.y});P.current=S,jb(e.id),Z.dispose(),C.current=null;for(const ee of ve.values())ee.style.transform=""}},[u,S,R,B,e.id,c]);const V=X=>{var te;return X?X.type==="exam"?!w:(((te=r[X.id])==null?void 0:te.status)??"locked")==="locked":!0},z=(X,te)=>{if(!(!C.current||X.button!==0||V(b.find(Z=>Z.id===te))||!E.current)){try{X.currentTarget.setPointerCapture(X.pointerId)}catch{}I.current=0,O.current={track:{startX:X.clientX,startY:X.clientY},id:X.pointerId,dragging:!1,nodeId:te}}},Y=X=>{const te=O.current,ue=C.current;if(!te||!ue||X.pointerId!==te.id)return;const ge=E.current;if(!ge||(!te.dragging&&Uc(te.track,X.clientX,X.clientY)==="drag"&&(te.dragging=!0,X.currentTarget.style.zIndex="40",ue.beginDrag(te.nodeId,X.clientX-ge.getBoundingClientRect().left,X.clientY-ge.getBoundingClientRect().top)),!te.dragging))return;const Z=ge.getBoundingClientRect();ue.moveDrag(X.clientX-Z.left,X.clientY-Z.top)},L=X=>{var ue;const te=O.current;if(!(!te||X.pointerId!==te.id)){if((ue=C.current)==null||ue.endDrag(),X.currentTarget.style.zIndex="",Uc(te.track,X.clientX,X.clientY)==="drag")I.current=Date.now()+300;else{const ge=b.find(Z=>Z.id===te.nodeId);ge&&Date.now()>=I.current&&!V(ge)&&(Zo(X.clientX,X.clientY,ge.id),l(ge.id))}O.current=null}},q=X=>{const te=b[X],ue=te?r[te.id]:void 0,ge=(ue==null?void 0:ue.status)==="mastered"||(ue==null?void 0:ue.status)==="in_progress"||(ue==null?void 0:ue.status)==="available";return{stroke:ge?"var(--brand)":"var(--ink-faint)",strokeWidth:ge?4:2.5,strokeOpacity:ge?.6:.5,strokeDasharray:ge?"none":"3 7"}},K=T.nodes[0]?{x:ms(`${e.id}:knot`,S),y:Qs}:{x:S/2,y:Qs},M=b[b.length-1],G=(M==null?void 0:M.type)==="exam",ae=T.nodes[T.nodes.length-1],ne=G&&ae?{x:ms(`${e.id}:next`,S),y:_+24}:void 0;return p.jsxs("section",{"data-testid":`map-section-${e.id.slice(0,8)}`,className:"py-3 px-2",children:[p.jsxs("div",{className:"map-signpost flex items-center gap-2 mb-3 px-2.5 py-1.5 rounded-lg shadow-sm",children:[p.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}),p.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})]}),p.jsxs("div",{ref:E,className:"relative",style:{minHeight:_},children:[p.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",style:{height:_,overflow:"visible"},children:u?p.jsxs(p.Fragment,{children:[T.nodes[0]&&p.jsx("circle",{cx:K.x,cy:K.y,r:3.5,fill:"#ffc800",opacity:.9}),T.nodes[0]&&p.jsx("path",{"data-rope":0,d:`M ${K.x} ${K.y} L ${T.nodes[0].x} ${T.nodes[0].y+Ht*gn}`,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",style:q(0)}),T.segments.map((X,te)=>p.jsx("path",{"data-rope":te+1,d:`M ${X.from.x} ${X.from.y+Ht*gn} L ${X.to.x} ${X.to.y+Ht*gn}`,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",style:q(X.index)},X.index)),ne&&ae&&p.jsxs(p.Fragment,{children:[p.jsx("path",{"data-rope":T.segments.length+1,"data-exam-rope":!0,d:`M ${ne.x} ${ne.y} L ${ae.x} ${ae.y+Ht*gn}`,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",style:q(b.length-1)}),p.jsx("circle",{"data-next-knot":!0,cx:ne.x,cy:ne.y,r:3.5,fill:"#ffc800",opacity:.9})]}),Array.from({length:8},(X,te)=>p.jsx("circle",{"data-pulse":te,cx:0,cy:0,r:0,fill:"none",stroke:"white",opacity:0},te)),b.map((X,te)=>p.jsx("circle",{"data-field":te,cx:0,cy:0,r:0,fill:"none",stroke:"#1cb0f6",strokeWidth:2,opacity:0},`f-${X.id}`))]}):T.segments.map(X=>{const te=g2(b[X.index],r);return p.jsx("path",{d:wy(X),stroke:te?"var(--brand)":"var(--ink-faint)",strokeWidth:te?4:2.5,strokeOpacity:te?.6:.5,fill:"none",strokeLinecap:"round",strokeDasharray:te?"none":"3 7",style:te?{pathLength:1,animation:"path-draw 600ms var(--ease-out-expo)"}:void 0},X.index)})}),b.map((X,te)=>{const ue=T.nodes[te];if(!ue)return null;const ge=nl(X.id),Z=`${ge%40/10}s`,re=`${5+ge%30/10}s`;return p.jsx("div",{"data-node-id":X.id,"data-noswipe":"",className:u?`absolute hover:z-30 will-change-transform ${V(X)?"cursor-not-allowed":"cursor-grab active:cursor-grabbing"}`:"absolute balloon-bob hover:z-30",style:{left:ue.x-A/2,top:ue.y-N/2+10,width:A,...u?{touchAction:"pan-y"}:{"--bob-delay":Z,"--bob-duration":re}},onPointerDown:u?be=>z(be,X.id):void 0,onPointerMove:u?Y:void 0,onPointerUp:u?L:void 0,onPointerCancel:u?L:void 0,children:p.jsx(b2,{lesson:X,progress:r[X.id],isSelected:X.id===s,isNextCue:X.id===i,isDue:a.has(X.id),isStreaming:o.includes(X.id),chapterLessonsMastered:w,onClick:()=>{Date.now()<I.current||(Zo(null,null,X.id),l(X.id))}})},X.id)})]})]})}function g2(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 b2({lesson:e,progress:t,isSelected:n,isNextCue:r,isDue:s,isStreaming:i,chapterLessonsMastered:a,onClick:o}){const l=$e(),u=(t==null?void 0:t.status)??"locked",c=(t==null?void 0:t.crownLevel)??0,h=e.type==="exam",f=Math.min(3,c),d=h?!a:u==="locked",m=h&&d,g=!h&&(u==="in_progress"||u==="mastered"),b=u==="mastered"?100:u==="in_progress"?Math.round(((t==null?void 0:t.mastery)??0)*100):0;return p.jsxs("div",{className:"group relative flex flex-col items-center w-full",children:[p.jsxs("button",{onClick:()=>!d&&o(),disabled:d,"data-testid":`${h?"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 ${h?m?"lesson-bubble exam-bubble-locked":y2(c>0):x2(u)} ${d?"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":""} ${r?"next-cue":""}`,title:void 0,"data-tooltip":m?`🔒 ${e.title}${l("node.locked.chapterHint")}`:h?`🎯 ${e.title}`:d?`🔒 ${e.title}`:s?`📖 ${e.title}${l("node.due.hint")}`:e.title,children:[i&&p.jsx(Tm,{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":l("thread.streamingBadge"),"data-testid":`node-streaming-${e.id.slice(0,8)}`}),g&&p.jsxs("svg",{className:"absolute inset-0 w-full h-full -rotate-90 pointer-events-none",viewBox:"0 0 56 56","aria-hidden":"true",children:[p.jsx("circle",{cx:"28",cy:"28",r:"25",fill:"none",stroke:"rgb(255 255 255 / 0.2)",strokeWidth:"2.5"}),p.jsx("circle",{cx:"28",cy:"28",r:"25",fill:"none",stroke:u==="mastered"?"#ffc800":"white",strokeWidth:"2.5",strokeLinecap:"round",strokeDasharray:`${b/100*157} 157`,className:"transition-all duration-500"})]}),h?m?p.jsx("span",{"aria-label":"exam-locked",className:"relative z-10 opacity-60",children:"🔒"}):p.jsx(ay,{"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}):d?p.jsx("span",{"aria-label":"locked",className:"relative z-10 opacity-50",children:"🔒"}):u==="mastered"?p.jsx("span",{"aria-label":"mastered",className:"relative z-10 drop-shadow-lg crown-sparkle",children:"👑"}):u==="in_progress"?p.jsx(Jt,{"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}):p.jsx("span",{"aria-label":"available",className:"relative z-10 drop-shadow",children:"⭐"}),s&&!d&&!h&&p.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:"!"})]}),h&&p.jsx("div",{className:"flex gap-0.5 mt-1","data-testid":`map-stars-${e.id.slice(0,8)}`,children:[0,1,2].map(y=>p.jsx("span",{className:`text-caption ${y<f?"text-gold":"text-white/25"}`,children:"★"},y))}),n&&p.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 x2(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 y2(e){return e?"lesson-bubble exam-bubble-passed":"lesson-bubble exam-bubble"}function v2({available:e,current:t,onChange:n}){const r=$e(),[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 p.jsxs("div",{className:"relative shrink-0",children:[p.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:[p.jsx(Dx,{className:"w-3 h-3"}),o]}),s&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>i(!1)}),p.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:[p.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=>p.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 E2=500,zn=8;function k2(){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(b=>{o()||r(y=>y.mode==="cursor"?{...y,x:b.clientX,y:b.clientY}:y)},[o]),u=k.useCallback(b=>{var E;if(o())return;const y=(E=b.target)==null?void 0:E.closest("[data-tooltip]"),w=y==null?void 0:y.getAttribute("data-tooltip");if(w){t(w),r({mode:"cursor",x:b.clientX,y:b.clientY});return}t(null)},[o]),c=k.useCallback(b=>{var w,E;if(o())return;((E=(w=b.target)==null?void 0:w.closest)==null?void 0:E.call(w,"[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 b=null;const y=()=>{b&&(clearTimeout(b),b=null)},w=T=>{var C;if(!o()||T.touches.length!==1)return y();const _=(C=T.target)==null?void 0:C.closest("[data-tooltip]"),A=_==null?void 0:_.getAttribute("data-tooltip");if(!A||!_)return y();const N=_;y(),b=setTimeout(()=>{N.isConnected&&(t(A),r({mode:"rect",x:0,y:0,rect:N.getBoundingClientRect()}))},E2)},E=()=>{y(),t(T=>T&&null)},S=()=>y(),v=()=>{y(),t(null)};return document.addEventListener("touchstart",w,{passive:!0}),document.addEventListener("touchend",E,{passive:!0}),document.addEventListener("touchmove",S,{passive:!0}),document.addEventListener("touchcancel",v,{passive:!0}),()=>{y(),document.removeEventListener("touchstart",w),document.removeEventListener("touchend",E),document.removeEventListener("touchmove",S),document.removeEventListener("touchcancel",v)}},[o]),k.useLayoutEffect(()=>{a.current&&e&&i({w:a.current.offsetWidth,h:a.current.offsetHeight})},[e]),!e)return null;const h=window.innerWidth,f=window.innerHeight;let d,m,g;if(n.mode==="rect"&&n.rect){const b=n.rect;d=b.left+b.width/2-s.w/2,m=b.top-s.h-6,g="none",m<zn&&(m=b.bottom+6)}else d=n.x,m=n.y-6,g="translate(0, -100%)";return d=Math.min(Math.max(d,zn),Math.max(zn,h-s.w-zn)),m=Math.min(Math.max(m,zn),Math.max(zn,f-s.h-zn)),Lm.createPortal(p.jsx("div",{ref:a,style:{position:"fixed",left:d,top:m,transform:g,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 FP(){}function Gc(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 Wm(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const T2=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,w2=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,S2={};function Kc(e,t){return(S2.jsx?w2:T2).test(e)}const A2=/[ \t\n\f\r]/g;function C2(e){return typeof e=="object"?e.type==="text"?Xc(e.value):!1:Xc(e)}function Xc(e){return e.replace(A2,"")===""}class qi{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}qi.prototype.normal={};qi.prototype.property={};qi.prototype.space=void 0;function Ym(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new qi(n,r,t)}function Pi(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 _2=0;const Le=cr(),ft=cr(),rl=cr(),de=cr(),Je=cr(),tr=cr(),Ot=cr();function cr(){return 2**++_2}const il=Object.freeze(Object.defineProperty({__proto__:null,boolean:Le,booleanish:ft,commaOrSpaceSeparated:Ot,commaSeparated:tr,number:de,overloadedBoolean:rl,spaceSeparated:Je},Symbol.toStringTag,{value:"Module"})),io=Object.keys(il);class lu extends Pt{constructor(t,n,r,s){let i=-1;if(super(t,n),Qc(this,"space",s),typeof r=="number")for(;++i<io.length;){const a=io[i];Qc(this,io[i],(r&il[a])===il[a])}}}lu.prototype.defined=!0;function Qc(e,t,n){n&&(e[t]=n)}function Fr(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new lu(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Pi(r)]=r,n[Pi(i.attribute)]=r}return new qi(t,n,e.space)}const Gm=Fr({properties:{ariaActiveDescendant:null,ariaAtomic:ft,ariaAutoComplete:null,ariaBusy:ft,ariaChecked:ft,ariaColCount:de,ariaColIndex:de,ariaColSpan:de,ariaControls:Je,ariaCurrent:null,ariaDescribedBy:Je,ariaDetails:null,ariaDisabled:ft,ariaDropEffect:Je,ariaErrorMessage:null,ariaExpanded:ft,ariaFlowTo:Je,ariaGrabbed:ft,ariaHasPopup:null,ariaHidden:ft,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Je,ariaLevel:de,ariaLive:null,ariaModal:ft,ariaMultiLine:ft,ariaMultiSelectable:ft,ariaOrientation:null,ariaOwns:Je,ariaPlaceholder:null,ariaPosInSet:de,ariaPressed:ft,ariaReadOnly:ft,ariaRelevant:null,ariaRequired:ft,ariaRoleDescription:Je,ariaRowCount:de,ariaRowIndex:de,ariaRowSpan:de,ariaSelected:ft,ariaSetSize:de,ariaSort:null,ariaValueMax:de,ariaValueMin:de,ariaValueNow:de,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Km(e,t){return t in e?e[t]:t}function Xm(e,t){return Km(e,t.toLowerCase())}const N2=Fr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:tr,acceptCharset:Je,accessKey:Je,action:null,allow:null,allowFullScreen:Le,allowPaymentRequest:Le,allowUserMedia:Le,alpha:Le,alt:null,as:null,async:Le,autoCapitalize:null,autoComplete:Je,autoFocus:Le,autoPlay:Le,blocking:Je,capture:null,charSet:null,checked:Le,cite:null,className:Je,closedBy:null,colorSpace:null,cols:de,colSpan:de,command:null,commandFor:null,content:null,contentEditable:ft,controls:Le,controlsList:Je,coords:de|tr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Le,defer:Le,dir:null,dirName:null,disabled:Le,download:rl,draggable:ft,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Le,formTarget:null,headers:Je,height:de,hidden:rl,high:de,href:null,hrefLang:null,htmlFor:Je,httpEquiv:Je,id:null,imageSizes:null,imageSrcSet:null,inert:Le,inputMode:null,integrity:null,is:null,isMap:Le,itemId:null,itemProp:Je,itemRef:Je,itemScope:Le,itemType:Je,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Le,low:de,manifest:null,max:null,maxLength:de,media:null,method:null,min:null,minLength:de,multiple:Le,muted:Le,name:null,nonce:null,noModule:Le,noValidate:Le,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:Le,optimum:de,pattern:null,ping:Je,placeholder:null,playsInline:Le,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Le,referrerPolicy:null,rel:Je,required:Le,reversed:Le,rows:de,rowSpan:de,sandbox:Je,scope:null,scoped:Le,seamless:Le,selected:Le,shadowRootClonable:Le,shadowRootCustomElementRegistry:Le,shadowRootDelegatesFocus:Le,shadowRootMode:null,shadowRootSerializable:Le,shape:null,size:de,sizes:null,slot:null,span:de,spellCheck:ft,src:null,srcDoc:null,srcLang:null,srcSet:null,start:de,step:null,style:null,tabIndex:de,target:null,title:null,translate:null,type:null,typeMustMatch:Le,useMap:null,value:ft,width:de,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Je,axis:null,background:null,bgColor:null,border:de,borderColor:null,bottomMargin:de,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Le,declare:Le,event:null,face:null,frame:null,frameBorder:null,hSpace:de,leftMargin:de,link:null,longDesc:null,lowSrc:null,marginHeight:de,marginWidth:de,noResize:Le,noHref:Le,noShade:Le,noWrap:Le,object:null,profile:null,prompt:null,rev:null,rightMargin:de,rules:null,scheme:null,scrolling:ft,standby:null,summary:null,text:null,topMargin:de,valueType:null,version:null,vAlign:null,vLink:null,vSpace:de,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Le,disablePictureInPicture:Le,disableRemotePlayback:Le,exportParts:tr,part:Je,prefix:null,property:null,results:de,security:null,unselectable:null},space:"html",transform:Xm}),I2=Fr({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:Ot,accentHeight:de,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:de,amplitude:de,arabicForm:null,ascent:de,attributeName:null,attributeType:null,azimuth:de,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:de,by:null,calcMode:null,capHeight:de,className:Je,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:de,diffuseConstant:de,direction:null,display:null,dur:null,divisor:de,dominantBaseline:null,download:Le,dx:null,dy:null,edgeMode:null,editable:null,elevation:de,enableBackground:null,end:null,event:null,exponent:de,externalResourcesRequired:null,fill:null,fillOpacity:de,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:tr,g2:tr,glyphName:tr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:de,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:de,horizOriginX:de,horizOriginY:de,id:null,ideographic:de,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:de,k:de,k1:de,k2:de,k3:de,k4:de,kernelMatrix:Ot,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:de,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:de,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:de,overlineThickness:de,paintOrder:null,panose1:null,path:null,pathLength:de,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Je,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:de,pointsAtY:de,pointsAtZ:de,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ot,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ot,rev:Ot,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ot,requiredFeatures:Ot,requiredFonts:Ot,requiredFormats:Ot,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:de,specularExponent:de,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:de,strikethroughThickness:de,string:null,stroke:null,strokeDashArray:Ot,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:de,strokeOpacity:de,strokeWidth:null,style:null,surfaceScale:de,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ot,tabIndex:de,tableValues:null,target:null,targetX:de,targetY:de,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ot,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:de,underlineThickness:de,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:de,values:null,vAlphabetic:de,vMathematical:de,vectorEffect:null,vHanging:de,vIdeographic:de,version:null,vertAdvY:de,vertOriginX:de,vertOriginY:de,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:de,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Km}),Qm=Fr({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()}}),Zm=Fr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Xm}),Jm=Fr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),R2={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"},M2=/[A-Z]/g,Zc=/-[a-z]/g,P2=/^data[-\w.:]+$/i;function ka(e,t){const n=Pi(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"&&P2.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(Zc,D2);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!Zc.test(i)){let a=i.replace(M2,L2);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=lu}return new s(r,t)}function L2(e){return"-"+e.toLowerCase()}function D2(e){return e.charAt(1).toUpperCase()}const $i=Ym([Gm,N2,Qm,Zm,Jm],"html"),Rn=Ym([Gm,I2,Qm,Zm,Jm],"svg");function Jc(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function ep(e){return e.join(" ").trim()}var gr={},so,ed;function O2(){if(ed)return so;ed=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=`
508
+ */var Sy=Ps.exports,Hc;function Ay(){return Hc||(Hc=1,(function(e,t){(function(r,s){e.exports=s()})(Sy,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 h=arguments[c];if(h)for(var f in h)u&&h[f]&&h[f].constructor===Object&&(!a[f]||a[f].constructor===Object)?(a[f]=a[f]||{},s.extend(a[f],u,h[f])):a[f]=h[f]}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 h=o.split(".").slice(u,c);return s.get(a,o,0,-1)[h[h.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 h=u[a]||[];l[a]=!0;for(var f=0;f<h.length;f+=1){var d=h[f];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,h=new Array(arguments.length),f=0,d=arguments.length;f<d;f++)h[f]=arguments[f];for(f=0;f<a.length;f+=1){var m=a[f].apply(c,h);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 Tc<"u"&&(a=Tc.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 h=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=h,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=[],h=0;h<l.length;h++){var f=l[h],d={x:f.x,y:f.y,index:h,body:u,isInternal:!1};c.push(d)}return c},i.fromPath=function(l,u){var c=/L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/ig,h=[];return l.replace(c,function(f,d,m){h.push({x:parseFloat(d),y:parseFloat(m)})}),i.create(h,u)},i.centre=function(l){for(var u=i.area(l,!0),c={x:0,y:0},h,f,d,m=0;m<l.length;m++)d=(m+1)%l.length,h=a.cross(l[m],l[d]),f=a.mult(a.add(l[m],l[d]),h),c=a.add(c,f);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,h=l.length-1,f=0;f<l.length;f++)c+=(l[h].x-l[f].x)*(l[h].y+l[f].y),h=f;return u?c/2:Math.abs(c)/2},i.inertia=function(l,u){for(var c=0,h=0,f=l,d,m,g=0;g<f.length;g++)m=(g+1)%f.length,d=Math.abs(a.cross(f[m],f[g])),c+=d*(a.dot(f[m],f[m])+a.dot(f[m],f[g])+a.dot(f[g],f[g])),h+=d;return u/6*(c/h)},i.translate=function(l,u,c){c=typeof c<"u"?c:1;var h=l.length,f=u.x*c,d=u.y*c,m;for(m=0;m<h;m++)l[m].x+=f,l[m].y+=d;return l},i.rotate=function(l,u,c){if(u!==0){var h=Math.cos(u),f=Math.sin(u),d=c.x,m=c.y,g=l.length,b,y,w,E;for(E=0;E<g;E++)b=l[E],y=b.x-d,w=b.y-m,b.x=d+(y*h-w*f),b.y=m+(y*f+w*h);return l}},i.contains=function(l,u){for(var c=u.x,h=u.y,f=l.length,d=l[f-1],m,g=0;g<f;g++){if(m=l[g],(c-d.x)*(m.y-d.y)+(h-d.y)*(d.x-m.x)>0)return!1;d=m}return!0},i.scale=function(l,u,c,h){if(u===1&&c===1)return l;h=h||i.centre(l);for(var f,d,m=0;m<l.length;m++)f=l[m],d=a.sub(f,h),l[m].x=h.x+d.x*u,l[m].y=h.y+d.y*c;return l},i.chamfer=function(l,u,c,h,f){typeof u=="number"?u=[u]:u=u||[8],c=typeof c<"u"?c:-1,h=h||2,f=f||14;for(var d=[],m=0;m<l.length;m++){var g=l[m-1>=0?m-1:l.length-1],b=l[m],y=l[(m+1)%l.length],w=u[m<u.length?m:u.length-1];if(w===0){d.push(b);continue}var E=a.normalise({x:b.y-g.y,y:g.x-b.x}),S=a.normalise({x:y.y-b.y,y:b.x-y.x}),v=Math.sqrt(2*Math.pow(w,2)),T=a.mult(o.clone(E),w),_=a.normalise(a.mult(a.add(E,S),.5)),A=a.sub(b,a.mult(_,v)),N=c;c===-1&&(N=Math.pow(w,.32)*1.75),N=o.clamp(N,h,f),N%2===1&&(N+=1);for(var C=Math.acos(a.dot(E,S)),D=C/N,P=0;P<N;P++)d.push(a.add(a.rotate(T,D*P),A))}return d},i.clockwiseSort=function(l){var u=i.mean(l);return l.sort(function(c,h){return a.angle(u,c)-a.angle(u,h)}),l},i.isConvex=function(l){var u=0,c=l.length,h,f,d,m;if(c<3)return null;for(h=0;h<c;h++)if(f=(h+1)%c,d=(h+2)%c,m=(l[f].x-l[h].x)*(l[d].y-l[f].y),m-=(l[f].y-l[h].y)*(l[d].x-l[f].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=[],h,f;for(l=l.slice(0),l.sort(function(d,m){var g=d.x-m.x;return g!==0?g:d.y-m.y}),f=0;f<l.length;f+=1){for(h=l[f];c.length>=2&&a.cross3(c[c.length-2],c[c.length-1],h)<=0;)c.pop();c.push(h)}for(f=l.length-1;f>=0;f-=1){for(h=l[f];u.length>=2&&a.cross3(u[u.length-2],u[u.length-1],h)<=0;)u.pop();u.push(h)}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),h=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},g=u.extend(m,d);return f(g,d),g},i.nextGroup=function(d){return d?i._nextNonCollidingGroupId--:i._nextCollidingGroupId++},i.nextCategory=function(){return i._nextCategory=i._nextCategory<<1,i._nextCategory};var f=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),h.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 g=d.isStatic?"#14151f":u.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),b=d.isStatic?"#555":"#ccc",y=d.isStatic&&d.render.fillStyle===null?1:0;d.render.fillStyle=d.render.fillStyle||g,d.render.strokeStyle=d.render.strokeStyle||b,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,g){var b;typeof m=="string"&&(b=m,m={},m[b]=g);for(b in m)if(Object.prototype.hasOwnProperty.call(m,b))switch(g=m[b],b){case"isStatic":i.setStatic(d,g);break;case"isSleeping":l.set(d,g);break;case"mass":i.setMass(d,g);break;case"density":i.setDensity(d,g);break;case"inertia":i.setInertia(d,g);break;case"vertices":i.setVertices(d,g);break;case"position":i.setPosition(d,g);break;case"angle":i.setAngle(d,g);break;case"velocity":i.setVelocity(d,g);break;case"angularVelocity":i.setAngularVelocity(d,g);break;case"speed":i.setSpeed(d,g);break;case"angularSpeed":i.setAngularSpeed(d,g);break;case"parts":i.setParts(d,g);break;case"centre":i.setCentre(d,g);break;default:d[b]=g}},i.setStatic=function(d,m){for(var g=0;g<d.parts.length;g++){var b=d.parts[g];b.isStatic=m,m?(b._original={restitution:b.restitution,friction:b.friction,mass:b.mass,inertia:b.inertia,density:b.density,inverseMass:b.inverseMass,inverseInertia:b.inverseInertia},b.restitution=0,b.friction=1,b.mass=b.inertia=b.density=1/0,b.inverseMass=b.inverseInertia=0,b.positionPrev.x=b.position.x,b.positionPrev.y=b.position.y,b.anglePrev=b.angle,b.angularVelocity=0,b.speed=0,b.angularSpeed=0,b.motion=0):b._original&&(b.restitution=b._original.restitution,b.friction=b._original.friction,b.mass=b._original.mass,b.inertia=b._original.inertia,b.density=b._original.density,b.inverseMass=b._original.inverseMass,b.inverseInertia=b._original.inverseInertia,b._original=null)}},i.setMass=function(d,m){var g=d.inertia/(d.mass/6);d.inertia=g*(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=h.fromVertices(d.vertices),d.area=a.area(d.vertices),i.setMass(d,d.density*d.area);var g=a.centre(d.vertices);a.translate(d.vertices,g,-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,g){var b;for(m=m.slice(0),d.parts.length=0,d.parts.push(d),d.parent=d,b=0;b<m.length;b++){var y=m[b];y!==d&&(y.parent=d,d.parts.push(y))}if(d.parts.length!==1){if(g=typeof g<"u"?g:!0,g){var w=[];for(b=0;b<m.length;b++)w=w.concat(m[b].vertices);a.clockwiseSort(w);var E=a.hull(w),S=a.centre(E);i.setVertices(d,E),a.translate(d.vertices,S)}var v=i._totalProperties(d);d.area=v.area,d.parent=d,d.position.x=v.centre.x,d.position.y=v.centre.y,d.positionPrev.x=v.centre.x,d.positionPrev.y=v.centre.y,i.setMass(d,v.mass),i.setInertia(d,v.inertia),i.setPosition(d,v.centre)}},i.setCentre=function(d,m,g){g?(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,g){var b=o.sub(m,d.position);g?(d.positionPrev.x=d.position.x,d.positionPrev.y=d.position.y,d.velocity.x=b.x,d.velocity.y=b.y,d.speed=o.magnitude(b)):(d.positionPrev.x+=b.x,d.positionPrev.y+=b.y);for(var y=0;y<d.parts.length;y++){var w=d.parts[y];w.position.x+=b.x,w.position.y+=b.y,a.translate(w.vertices,b),c.update(w.bounds,w.vertices,d.velocity)}},i.setAngle=function(d,m,g){var b=m-d.angle;g?(d.anglePrev=d.angle,d.angularVelocity=b,d.angularSpeed=Math.abs(b)):d.anglePrev+=b;for(var y=0;y<d.parts.length;y++){var w=d.parts[y];w.angle+=b,a.rotate(w.vertices,b,d.position),h.rotate(w.axes,b),c.update(w.bounds,w.vertices,d.velocity),y>0&&o.rotateAbout(w.position,b,d.position,w.position)}},i.setVelocity=function(d,m){var g=d.deltaTime/i._baseDelta;d.positionPrev.x=d.position.x-m.x*g,d.positionPrev.y=d.position.y-m.y*g,d.velocity.x=(d.position.x-d.positionPrev.x)/g,d.velocity.y=(d.position.y-d.positionPrev.y)/g,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 g=d.deltaTime/i._baseDelta;d.anglePrev=d.angle-m*g,d.angularVelocity=(d.angle-d.anglePrev)/g,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,g){i.setPosition(d,o.add(d.position,m),g)},i.rotate=function(d,m,g,b){if(!g)i.setAngle(d,d.angle+m,b);else{var y=Math.cos(m),w=Math.sin(m),E=d.position.x-g.x,S=d.position.y-g.y;i.setPosition(d,{x:g.x+(E*y-S*w),y:g.y+(E*w+S*y)},b),i.setAngle(d,d.angle+m,b)}},i.scale=function(d,m,g,b){var y=0,w=0;b=b||d.position;for(var E=0;E<d.parts.length;E++){var S=d.parts[E];a.scale(S.vertices,m,g,b),S.axes=h.fromVertices(S.vertices),S.area=a.area(S.vertices),i.setMass(S,d.density*S.area),a.translate(S.vertices,{x:-S.position.x,y:-S.position.y}),i.setInertia(S,i._inertiaScale*a.inertia(S.vertices,S.mass)),a.translate(S.vertices,{x:S.position.x,y:S.position.y}),E>0&&(y+=S.area,w+=S.inertia),S.position.x=b.x+(S.position.x-b.x)*m,S.position.y=b.y+(S.position.y-b.y)*g,c.update(S.bounds,S.vertices,d.velocity)}d.parts.length>1&&(d.area=y,d.isStatic||(i.setMass(d,d.density*y),i.setInertia(d,w))),d.circleRadius&&(m===g?d.circleRadius*=m:d.circleRadius=null)},i.update=function(d,m){m=(typeof m<"u"?m:1e3/60)*d.timeScale;var g=m*m,b=i._timeCorrection?m/(d.deltaTime||m):1,y=1-d.frictionAir*(m/u._baseDelta),w=(d.position.x-d.positionPrev.x)*b,E=(d.position.y-d.positionPrev.y)*b;d.velocity.x=w*y+d.force.x/d.mass*g,d.velocity.y=E*y+d.force.y/d.mass*g,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*b+d.torque/d.inertia*g,d.anglePrev=d.angle,d.angle+=d.angularVelocity;for(var S=0;S<d.parts.length;S++){var v=d.parts[S];a.translate(v.vertices,d.velocity),S>0&&(v.position.x+=d.velocity.x,v.position.y+=d.velocity.y),d.angularVelocity!==0&&(a.rotate(v.vertices,d.angularVelocity,d.position),h.rotate(v.axes,d.angularVelocity),S>0&&o.rotateAbout(v.position,d.angularVelocity,d.position,v.position)),c.update(v.bounds,v.vertices,d.velocity)}},i.updateVelocities=function(d){var m=i._baseDelta/d.deltaTime,g=d.velocity;g.x=(d.position.x-d.positionPrev.x)*m,g.y=(d.position.y-d.positionPrev.y)*m,d.speed=Math.sqrt(g.x*g.x+g.y*g.y),d.angularVelocity=(d.angle-d.anglePrev)*m,d.angularSpeed=Math.abs(d.angularVelocity)},i.applyForce=function(d,m,g){var b={x:m.x-d.position.x,y:m.y-d.position.y};d.force.x+=g.x,d.force.y+=g.y,d.torque+=b.x*g.y-b.y*g.x},i._totalProperties=function(d){for(var m={mass:0,area:0,inertia:0,centre:{x:0,y:0}},g=d.parts.length===1?0:1;g<d.parts.length;g++){var b=d.parts[g],y=b.mass!==1/0?b.mass:1;m.mass+=y,m.area+=b.area,m.inertia+=b.inertia,m.centre=o.add(m.centre,o.mult(b.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(" "),h,f=0;f<c.length;f++)h=c[f],o.events=o.events||{},o.events[h]=o.events[h]||[],o.events[h].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(" "),h=0;h<c.length;h++){var f=o.events[c[h]],d=[];if(u&&f)for(var m=0;m<f.length;m++)f[m]!==u&&d.push(f[m]);o.events[c[h]]=d}},i.trigger=function(o,l,u){var c,h,f,d,m=o.events;if(m&&a.keys(m).length>0){u||(u={}),c=l.split(" ");for(var g=0;g<c.length;g++)if(h=c[g],f=m[h],f){d=a.clone(u,!1),d.name=h,d.source=o;for(var b=0;b<f.length;b++)f[b].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,h,f,d){if(c.isModified=h,h&&c.cache&&(c.cache.allBodies=null,c.cache.allConstraints=null,c.cache.allComposites=null),f&&c.parent&&i.setModified(c.parent,h,f,d),d)for(var m=0;m<c.composites.length;m++){var g=c.composites[m];i.setModified(g,h,f,d)}},i.add=function(c,h){var f=[].concat(h);a.trigger(c,"beforeAdd",{object:h});for(var d=0;d<f.length;d++){var m=f[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:h}),c},i.remove=function(c,h,f){var d=[].concat(h);a.trigger(c,"beforeRemove",{object:h});for(var m=0;m<d.length;m++){var g=d[m];switch(g.type){case"body":i.removeBody(c,g,f);break;case"constraint":i.removeConstraint(c,g,f);break;case"composite":i.removeComposite(c,g,f);break;case"mouseConstraint":i.removeConstraint(c,g.constraint);break}}return a.trigger(c,"afterRemove",{object:h}),c},i.addComposite=function(c,h){return c.composites.push(h),h.parent=c,i.setModified(c,!0,!0,!1),c},i.removeComposite=function(c,h,f){var d=o.indexOf(c.composites,h);if(d!==-1&&i.removeCompositeAt(c,d),f)for(var m=0;m<c.composites.length;m++)i.removeComposite(c.composites[m],h,!0);return c},i.removeCompositeAt=function(c,h){return c.composites.splice(h,1),i.setModified(c,!0,!0,!1),c},i.addBody=function(c,h){return c.bodies.push(h),i.setModified(c,!0,!0,!1),c},i.removeBody=function(c,h,f){var d=o.indexOf(c.bodies,h);if(d!==-1&&i.removeBodyAt(c,d),f)for(var m=0;m<c.composites.length;m++)i.removeBody(c.composites[m],h,!0);return c},i.removeBodyAt=function(c,h){return c.bodies.splice(h,1),i.setModified(c,!0,!0,!1),c},i.addConstraint=function(c,h){return c.constraints.push(h),i.setModified(c,!0,!0,!1),c},i.removeConstraint=function(c,h,f){var d=o.indexOf(c.constraints,h);if(d!==-1&&i.removeConstraintAt(c,d),f)for(var m=0;m<c.composites.length;m++)i.removeConstraint(c.composites[m],h,!0);return c},i.removeConstraintAt=function(c,h){return c.constraints.splice(h,1),i.setModified(c,!0,!0,!1),c},i.clear=function(c,h,f){if(f)for(var d=0;d<c.composites.length;d++)i.clear(c.composites[d],h,!0);return h?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 h=[].concat(c.bodies),f=0;f<c.composites.length;f++)h=h.concat(i.allBodies(c.composites[f]));return c.cache&&(c.cache.allBodies=h),h},i.allConstraints=function(c){if(c.cache&&c.cache.allConstraints)return c.cache.allConstraints;for(var h=[].concat(c.constraints),f=0;f<c.composites.length;f++)h=h.concat(i.allConstraints(c.composites[f]));return c.cache&&(c.cache.allConstraints=h),h},i.allComposites=function(c){if(c.cache&&c.cache.allComposites)return c.cache.allComposites;for(var h=[].concat(c.composites),f=0;f<c.composites.length;f++)h=h.concat(i.allComposites(c.composites[f]));return c.cache&&(c.cache.allComposites=h),h},i.get=function(c,h,f){var d,m;switch(f){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(g){return g.id.toString()===h.toString()}),m.length===0?null:m[0]):null},i.move=function(c,h,f){return i.remove(c,h),i.add(f,h),c},i.rebase=function(c){for(var h=i.allBodies(c).concat(i.allConstraints(c)).concat(i.allComposites(c)),f=0;f<h.length;f++)h[f].id=o.nextId();return c},i.translate=function(c,h,f){for(var d=f?i.allBodies(c):c.bodies,m=0;m<d.length;m++)u.translate(d[m],h);return c},i.rotate=function(c,h,f,d){for(var m=Math.cos(h),g=Math.sin(h),b=d?i.allBodies(c):c.bodies,y=0;y<b.length;y++){var w=b[y],E=w.position.x-f.x,S=w.position.y-f.y;u.setPosition(w,{x:f.x+(E*m-S*g),y:f.y+(E*g+S*m)}),u.rotate(w,h)}return c},i.scale=function(c,h,f,d,m){for(var g=m?i.allBodies(c):c.bodies,b=0;b<g.length;b++){var y=g[b],w=y.position.x-d.x,E=y.position.y-d.y;u.setPosition(y,{x:d.x+w*h,y:d.y+E*f}),u.scale(y,h,f)}return c},i.bounds=function(c){for(var h=i.allBodies(c),f=[],d=0;d<h.length;d+=1){var m=h[d];f.push(m.bounds.min,m.bounds.max)}return l.create(f)}})()}),(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 h=c/l._baseDelta,f=i._motionSleepThreshold,d=0;d<u.length;d++){var m=u[d],g=a.getSpeed(m),b=a.getAngularSpeed(m),y=g*g+b*b;if(m.force.x!==0||m.force.y!==0){i.set(m,!1);continue}var w=Math.min(m.motion,y),E=Math.max(m.motion,y);m.motion=i._minBias*w+(1-i._minBias)*E,m.sleepThreshold>0&&m.motion<f?(m.sleepCounter+=1,m.sleepCounter>=m.sleepThreshold/h&&i.set(m,!0)):m.sleepCounter>0&&(m.sleepCounter-=1)}},i.afterCollisions=function(u){for(var c=i._motionSleepThreshold,h=0;h<u.length;h++){var f=u[h];if(f.isActive){var d=f.collision,m=d.bodyA.parent,g=d.bodyB.parent;if(!(m.isSleeping&&g.isSleeping||m.isStatic||g.isStatic)&&(m.isSleeping||g.isSleeping)){var b=m.isSleeping&&!m.isStatic?m:g,y=b===m?g:m;!b.isStatic&&y.motion>c&&i.set(b,!1)}}}},i.set=function(u,c){var h=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,h||o.trigger(u,"sleepStart")):(u.isSleeping=!1,u.sleepCounter=0,h&&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(h,f){return{pair:null,collided:!1,bodyA:h,bodyB:f,parentA:h.parent,parentB:f.parent,depth:0,normal:{x:0,y:0},tangent:{x:0,y:0},penetration:{x:0,y:0},supports:[]}},i.collides=function(h,f,d){if(i._overlapAxes(u,h.vertices,f.vertices,h.axes),u.overlap<=0||(i._overlapAxes(c,f.vertices,h.vertices,f.axes),c.overlap<=0))return null;var m=d&&d.table[o.id(h,f)],g;m?g=m.collision:(g=i.create(h,f),g.collided=!0,g.bodyA=h.id<f.id?h:f,g.bodyB=h.id<f.id?f:h,g.parentA=g.bodyA.parent,g.parentB=g.bodyB.parent),h=g.bodyA,f=g.bodyB;var b;u.overlap<c.overlap?b=u:b=c;var y=g.normal,w=g.supports,E=b.axis,S=E.x,v=E.y;S*(f.position.x-h.position.x)+v*(f.position.y-h.position.y)<0?(y.x=S,y.y=v):(y.x=-S,y.y=-v),g.tangent.x=-y.y,g.tangent.y=y.x,g.depth=b.overlap,g.penetration.x=y.x*g.depth,g.penetration.y=y.y*g.depth;var T=i._findSupports(h,f,y,1),_=0;if(a.contains(h.vertices,T[0])&&(w[_++]=T[0]),a.contains(h.vertices,T[1])&&(w[_++]=T[1]),_<2){var A=i._findSupports(f,h,y,-1);a.contains(f.vertices,A[0])&&(w[_++]=A[0]),_<2&&a.contains(f.vertices,A[1])&&(w[_++]=A[1])}return _===0&&(w[_++]=T[0]),w.length=_,g},i._overlapAxes=function(h,f,d,m){var g=f.length,b=d.length,y=f[0].x,w=f[0].y,E=d[0].x,S=d[0].y,v=m.length,T=Number.MAX_VALUE,_=0,A,N,C,D,P,O;for(P=0;P<v;P++){var I=m[P],R=I.x,B=I.y,V=y*R+w*B,z=E*R+S*B,Y=V,L=z;for(O=1;O<g;O+=1)D=f[O].x*R+f[O].y*B,D>Y?Y=D:D<V&&(V=D);for(O=1;O<b;O+=1)D=d[O].x*R+d[O].y*B,D>L?L=D:D<z&&(z=D);if(N=Y-z,C=L-V,A=N<C?N:C,A<T&&(T=A,_=P,A<=0))break}h.axis=m[_],h.overlap=T},i._projectToAxis=function(h,f,d){for(var m=f[0].x*d.x+f[0].y*d.y,g=m,b=1;b<f.length;b+=1){var y=f[b].x*d.x+f[b].y*d.y;y>g?g=y:y<m&&(m=y)}h.min=m,h.max=g},i._findSupports=function(h,f,d,m){var g=f.vertices,b=g.length,y=h.position.x,w=h.position.y,E=d.x*m,S=d.y*m,v=Number.MAX_VALUE,T,_,A,N,C;for(C=0;C<b;C+=1)_=g[C],N=E*(y-_.x)+S*(w-_.y),N<v&&(v=N,T=_);return A=g[(b+T.index-1)%b],v=E*(y-A.x)+S*(w-A.y),_=g[(T.index+1)%b],E*(y-_.x)+S*(w-_.y)<v?(l[0]=T,l[1]=_,l):(l[0]=T,l[1]=A,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,h={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(h,o,l),h},i.update=function(o,l,u){var c=o.contacts,h=l.supports,f=o.activeContacts,d=l.parentA,m=l.parentB,g=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,f.length=0;for(var b=0;b<h.length;b++){var y=h[b],w=y.body===d?y.index:g+y.index,E=c[w];E?f.push(E):f.push(c[w]=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),h=s(0);(function(){i._warming=.4,i._torqueDampen=1,i._minLength=1e-6,i.create=function(f){var d=f;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,g=d.bodyB?o.add(d.bodyB.position,d.pointB):d.pointB,b=o.magnitude(o.sub(m,g));d.length=typeof d.length<"u"?d.length:b,d.id=d.id||h.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=h.extend(y,d.render),d},i.preSolveAll=function(f){for(var d=0;d<f.length;d+=1){var m=f[d],g=m.constraintImpulse;m.isStatic||g.x===0&&g.y===0&&g.angle===0||(m.position.x+=g.x,m.position.y+=g.y,m.angle+=g.angle)}},i.solveAll=function(f,d){for(var m=h.clamp(d/h._baseDelta,0,1),g=0;g<f.length;g+=1){var b=f[g],y=!b.bodyA||b.bodyA&&b.bodyA.isStatic,w=!b.bodyB||b.bodyB&&b.bodyB.isStatic;(y||w)&&i.solve(f[g],m)}for(g=0;g<f.length;g+=1)b=f[g],y=!b.bodyA||b.bodyA&&b.bodyA.isStatic,w=!b.bodyB||b.bodyB&&b.bodyB.isStatic,!y&&!w&&i.solve(f[g],m)},i.solve=function(f,d){var m=f.bodyA,g=f.bodyB,b=f.pointA,y=f.pointB;if(!(!m&&!g)){m&&!m.isStatic&&(o.rotate(b,m.angle-f.angleA,b),f.angleA=m.angle),g&&!g.isStatic&&(o.rotate(y,g.angle-f.angleB,y),f.angleB=g.angle);var w=b,E=y;if(m&&(w=o.add(m.position,b)),g&&(E=o.add(g.position,y)),!(!w||!E)){var S=o.sub(w,E),v=o.magnitude(S);v<i._minLength&&(v=i._minLength);var T=(v-f.length)/v,_=f.stiffness>=1||f.length===0,A=_?f.stiffness*d:f.stiffness*d*d,N=f.damping*d,C=o.mult(S,T*A),D=(m?m.inverseMass:0)+(g?g.inverseMass:0),P=(m?m.inverseInertia:0)+(g?g.inverseInertia:0),O=D+P,I,R,B,V,z;if(N>0){var Y=o.create();B=o.div(S,v),z=o.sub(g&&o.sub(g.position,g.positionPrev)||Y,m&&o.sub(m.position,m.positionPrev)||Y),V=o.dot(B,z)}m&&!m.isStatic&&(R=m.inverseMass/D,m.constraintImpulse.x-=C.x*R,m.constraintImpulse.y-=C.y*R,m.position.x-=C.x*R,m.position.y-=C.y*R,N>0&&(m.positionPrev.x-=N*B.x*V*R,m.positionPrev.y-=N*B.y*V*R),I=o.cross(b,C)/O*i._torqueDampen*m.inverseInertia*(1-f.angularStiffness),m.constraintImpulse.angle-=I,m.angle-=I),g&&!g.isStatic&&(R=g.inverseMass/D,g.constraintImpulse.x+=C.x*R,g.constraintImpulse.y+=C.y*R,g.position.x+=C.x*R,g.position.y+=C.y*R,N>0&&(g.positionPrev.x+=N*B.x*V*R,g.positionPrev.y+=N*B.y*V*R),I=o.cross(y,C)/O*i._torqueDampen*g.inverseInertia*(1-f.angularStiffness),g.constraintImpulse.angle+=I,g.angle+=I)}}},i.postSolveAll=function(f){for(var d=0;d<f.length;d++){var m=f[d],g=m.constraintImpulse;if(!(m.isStatic||g.x===0&&g.y===0&&g.angle===0)){l.set(m,!1);for(var b=0;b<m.parts.length;b++){var y=m.parts[b];a.translate(y.vertices,g),b>0&&(y.position.x+=g.x,y.position.y+=g.y),g.angle!==0&&(a.rotate(y.vertices,g.angle,m.position),c.rotate(y.axes,g.angle),b>0&&o.rotateAbout(y.position,g.angle,m.position,y.position)),u.update(y.bounds,y.vertices,m.velocity)}g.angle*=i._warming,g.x*=i._warming,g.y*=i._warming}}},i.pointAWorld=function(f){return{x:(f.bodyA?f.bodyA.position.x:0)+(f.pointA?f.pointA.x:0),y:(f.bodyA?f.bodyA.position.y:0)+(f.pointA?f.pointA.y:0)}},i.pointBWorld=function(f){return{x:(f.bodyB?f.bodyB.position.x:0)+(f.pointB?f.pointB.x:0),y:(f.bodyB?f.bodyB.position.y:0)+(f.pointB?f.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 h=(c+1)%l.length,f=a.normalise({x:l[h].y-l[c].y,y:l[c].x-l[h].x}),d=f.y===0?1/0:f.x/f.y;d=d.toFixed(3).toString(),u[d]=f}return o.values(u)},i.rotate=function(l,u){if(u!==0)for(var c=Math.cos(u),h=Math.sin(u),f=0;f<l.length;f++){var d=l[f],m;m=d.x*c-d.y*h,d.y=d.x*h+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(h,f,d,m,g){g=g||{};var b={label:"Rectangle Body",position:{x:h,y:f},vertices:a.fromPath("L 0 0 L "+d+" 0 L "+d+" "+m+" L 0 "+m)};if(g.chamfer){var y=g.chamfer;b.vertices=a.chamfer(b.vertices,y.radius,y.quality,y.qualityMin,y.qualityMax),delete g.chamfer}return l.create(o.extend({},b,g))},i.trapezoid=function(h,f,d,m,g,b){b=b||{},g*=.5;var y=(1-g*2)*d,w=d*g,E=w+y,S=E+w,v;g<.5?v="L 0 0 L "+w+" "+-m+" L "+E+" "+-m+" L "+S+" 0":v="L 0 0 L "+E+" "+-m+" L "+S+" 0";var T={label:"Trapezoid Body",position:{x:h,y:f},vertices:a.fromPath(v)};if(b.chamfer){var _=b.chamfer;T.vertices=a.chamfer(T.vertices,_.radius,_.quality,_.qualityMin,_.qualityMax),delete b.chamfer}return l.create(o.extend({},T,b))},i.circle=function(h,f,d,m,g){m=m||{};var b={label:"Circle Body",circleRadius:d};g=g||25;var y=Math.ceil(Math.max(10,Math.min(g,d)));return y%2===1&&(y+=1),i.polygon(h,f,y,d,o.extend({},b,m))},i.polygon=function(h,f,d,m,g){if(g=g||{},d<3)return i.circle(h,f,m,g);for(var b=2*Math.PI/d,y="",w=b*.5,E=0;E<d;E+=1){var S=w+E*b,v=Math.cos(S)*m,T=Math.sin(S)*m;y+="L "+v.toFixed(3)+" "+T.toFixed(3)+" "}var _={label:"Polygon Body",position:{x:h,y:f},vertices:a.fromPath(y)};if(g.chamfer){var A=g.chamfer;_.vertices=a.chamfer(_.vertices,A.radius,A.quality,A.qualityMin,A.qualityMax),delete g.chamfer}return l.create(o.extend({},_,g))},i.fromVertices=function(h,f,d,m,g,b,y,w){var E=o.getDecomp(),S,v,T,_,A,N,C,D,P,O,I;for(S=!!(E&&E.quickDecomp),m=m||{},T=[],g=typeof g<"u"?g:!1,b=typeof b<"u"?b:.01,y=typeof y<"u"?y:10,w=typeof w<"u"?w:.01,o.isArray(d[0])||(d=[d]),O=0;O<d.length;O+=1)if(N=d[O],_=a.isConvex(N),A=!_,A&&!S&&o.warnOnce("Bodies.fromVertices: Install the 'poly-decomp' library and use Common.setDecomp or provide 'decomp' as a global to decompose concave vertices."),_||!S)_?N=a.clockwiseSort(N):N=a.hull(N),T.push({position:{x:h,y:f},vertices:N});else{var R=N.map(function(ne){return[ne.x,ne.y]});E.makeCCW(R),b!==!1&&E.removeCollinearPoints(R,b),w!==!1&&E.removeDuplicatePoints&&E.removeDuplicatePoints(R,w);var B=E.quickDecomp(R);for(C=0;C<B.length;C++){var V=B[C],z=V.map(function(ne){return{x:ne[0],y:ne[1]}});y>0&&a.area(z)<y||T.push({position:a.centre(z),vertices:z})}}for(C=0;C<T.length;C++)T[C]=l.create(o.extend(T[C],m));if(g){var Y=5;for(C=0;C<T.length;C++){var L=T[C];for(D=C+1;D<T.length;D++){var q=T[D];if(u.overlaps(L.bounds,q.bounds)){var K=L.vertices,M=q.vertices;for(P=0;P<L.vertices.length;P++)for(I=0;I<q.vertices.length;I++){var G=c.magnitudeSquared(c.sub(K[(P+1)%K.length],M[I])),ae=c.magnitudeSquared(c.sub(K[P],M[(I+1)%M.length]));G<Y&&ae<Y&&(K[P].isInternal=!0,M[I].isInternal=!0)}}}}}return T.length>1?(v=l.create(o.extend({parts:T.slice(0)},m)),l.setPosition(v,{x:h,y:f}),v):T[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,h=l.bodies,f=h.length,d=i.canCollide,m=o.collides,g,b;for(h.sort(i._compareBoundsX),g=0;g<f;g++){var y=h[g],w=y.bounds,E=y.bounds.max.x,S=y.bounds.max.y,v=y.bounds.min.y,T=y.isStatic||y.isSleeping,_=y.parts.length,A=_===1;for(b=g+1;b<f;b++){var N=h[b],C=N.bounds;if(C.min.x>E)break;if(!(S<C.min.y||v>C.max.y)&&!(T&&(N.isStatic||N.isSleeping))&&d(y.collisionFilter,N.collisionFilter)){var D=N.parts.length;if(A&&D===1){var P=m(y,N,c);P&&u.push(P)}else for(var O=_>1?1:0,I=D>1?1:0,R=O;R<_;R++)for(var B=y.parts[R],w=B.bounds,V=I;V<D;V++){var z=N.parts[V],C=z.bounds;if(!(w.min.x>C.max.x||w.max.x<C.min.x||w.max.y<C.min.y||w.min.y>C.max.y)){var P=m(B,z,c);P&&u.push(P)}}}}}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),h=u.changedTouches;h&&(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),h=u.changedTouches;h?(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),h=u.changedTouches;h&&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(),h=document.documentElement||document.body.parentNode||document.body,f=window.pageXOffset!==void 0?window.pageXOffset:h.scrollLeft,d=window.pageYOffset!==void 0?window.pageYOffset:h.scrollTop,m=o.changedTouches,g,b;return m?(g=m[0].pageX-c.left-f,b=m[0].pageY-c.top-d):(g=o.pageX-c.left-f,b=o.pageY-c.top-d),{x:g/(l.clientWidth/(l.width||l.clientWidth)*u),y:b/(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),h=[],f=0;f<c.length;f+=1)if(c[f]!==o.name){var d=i.resolve(c[f]);if(!d){h.push("❌ "+c[f]);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?(h.push("🔶 "+i.toString(d)),delete d._warned):h.push("✅ "+i.toString(d)),o.used.push(d.name))}h.length>0&&a.info(h.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(f){i.isPlugin(f)&&i.register(f);var d=i.dependencyParse(f),m=i.resolve(f);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(f),"used by",i.toString(u),"could not be resolved."),o._warned=!0),d.name});for(var h=0;h<l[c].length;h+=1)i.dependencies(l[c][h],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]),h=Number(u[5]),f=Number(u[6]);return{isRange:!!(u[1]||u[2]),version:u[3],range:o,operator:u[1]||u[2]||"",major:c,minor:h,patch:f,parts:[c,h,f],prerelease:u[7],number:c*1e8+h*1e4+f}},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),h=s(6),f=s(10),d=s(0),m=s(4);(function(){i.create=function(g){g=g||{};var b={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(b,g);return y.world=g.world||h.create({label:"World"}),y.pairs=g.pairs||u.create(),y.detector=g.detector||l.create(),y.grid={buckets:[]},y.world.gravity=y.gravity,y.broadphase=y.grid,y.metrics={},y},i.update=function(g,b){var y=d.now(),w=g.world,E=g.detector,S=g.pairs,v=g.timing,T=v.timestamp,_;b=typeof b<"u"?b:d._baseDelta,b*=v.timeScale,v.timestamp+=b,v.lastDelta=b;var A={timestamp:v.timestamp,delta:b};c.trigger(g,"beforeUpdate",A);var N=h.allBodies(w),C=h.allConstraints(w);for(w.isModified&&(l.setBodies(E,N),h.setModified(w,!1,!1,!0)),g.enableSleeping&&a.update(N,b),i._bodiesApplyGravity(N,g.gravity),b>0&&i._bodiesUpdate(N,b),f.preSolveAll(N),_=0;_<g.constraintIterations;_++)f.solveAll(C,b);f.postSolveAll(N),E.pairs=g.pairs;var D=l.collisions(E);u.update(S,D,T),g.enableSleeping&&a.afterCollisions(S.list),S.collisionStart.length>0&&c.trigger(g,"collisionStart",{pairs:S.collisionStart});var P=d.clamp(20/g.positionIterations,0,1);for(o.preSolvePosition(S.list),_=0;_<g.positionIterations;_++)o.solvePosition(S.list,b,P);for(o.postSolvePosition(N),f.preSolveAll(N),_=0;_<g.constraintIterations;_++)f.solveAll(C,b);for(f.postSolveAll(N),o.preSolveVelocity(S.list),_=0;_<g.velocityIterations;_++)o.solveVelocity(S.list,b);return i._bodiesUpdateVelocities(N),S.collisionActive.length>0&&c.trigger(g,"collisionActive",{pairs:S.collisionActive}),S.collisionEnd.length>0&&c.trigger(g,"collisionEnd",{pairs:S.collisionEnd}),i._bodiesClearForces(N),c.trigger(g,"afterUpdate",A),g.timing.lastElapsed=d.now()-y,g},i.merge=function(g,b){if(d.extend(g,b),b.world){g.world=b.world,i.clear(g);for(var y=h.allBodies(g.world),w=0;w<y.length;w++){var E=y[w];a.set(E,!1),E.id=d.nextId()}}},i.clear=function(g){u.clear(g.pairs),l.clear(g.detector)},i._bodiesClearForces=function(g){for(var b=g.length,y=0;y<b;y++){var w=g[y];w.force.x=0,w.force.y=0,w.torque=0}},i._bodiesApplyGravity=function(g,b){var y=typeof b.scale<"u"?b.scale:.001,w=g.length;if(!(b.x===0&&b.y===0||y===0))for(var E=0;E<w;E++){var S=g[E];S.isStatic||S.isSleeping||(S.force.y+=S.mass*b.y*y,S.force.x+=S.mass*b.x*y)}},i._bodiesUpdate=function(g,b){for(var y=g.length,w=0;w<y;w++){var E=g[w];E.isStatic||E.isSleeping||m.update(E,b)}},i._bodiesUpdateVelocities=function(g){for(var b=g.length,y=0;y<b;y++)m.updateVelocities(g[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,h,f,d=u.length;for(c=0;c<d;c++)h=u[c],h.isActive&&(f=h.activeContacts.length,h.collision.parentA.totalContacts+=f,h.collision.parentB.totalContacts+=f)},i.solvePosition=function(u,c,h){var f,d,m,g,b,y,w,E,S=i._positionDampen*(h||1),v=o.clamp(c/o._baseDelta,0,1),T=u.length;for(f=0;f<T;f++)d=u[f],!(!d.isActive||d.isSensor)&&(m=d.collision,g=m.parentA,b=m.parentB,y=m.normal,d.separation=y.x*(b.positionImpulse.x+m.penetration.x-g.positionImpulse.x)+y.y*(b.positionImpulse.y+m.penetration.y-g.positionImpulse.y));for(f=0;f<T;f++)d=u[f],!(!d.isActive||d.isSensor)&&(m=d.collision,g=m.parentA,b=m.parentB,y=m.normal,E=d.separation-d.slop*v,(g.isStatic||b.isStatic)&&(E*=2),g.isStatic||g.isSleeping||(w=S/g.totalContacts,g.positionImpulse.x+=y.x*E*w,g.positionImpulse.y+=y.y*E*w),b.isStatic||b.isSleeping||(w=S/b.totalContacts,b.positionImpulse.x-=y.x*E*w,b.positionImpulse.y-=y.y*E*w))},i.postSolvePosition=function(u){for(var c=i._positionWarming,h=u.length,f=a.translate,d=l.update,m=0;m<h;m++){var g=u[m],b=g.positionImpulse,y=b.x,w=b.y,E=g.velocity;if(g.totalContacts=0,y!==0||w!==0){for(var S=0;S<g.parts.length;S++){var v=g.parts[S];f(v.vertices,b),d(v.bounds,v.vertices,E),v.position.x+=y,v.position.y+=w}g.positionPrev.x+=y,g.positionPrev.y+=w,y*E.x+w*E.y<0?(b.x=0,b.y=0):(b.x*=c,b.y*=c)}}},i.preSolveVelocity=function(u){var c=u.length,h,f;for(h=0;h<c;h++){var d=u[h];if(!(!d.isActive||d.isSensor)){var m=d.activeContacts,g=m.length,b=d.collision,y=b.parentA,w=b.parentB,E=b.normal,S=b.tangent;for(f=0;f<g;f++){var v=m[f],T=v.vertex,_=v.normalImpulse,A=v.tangentImpulse;if(_!==0||A!==0){var N=E.x*_+S.x*A,C=E.y*_+S.y*A;y.isStatic||y.isSleeping||(y.positionPrev.x+=N*y.inverseMass,y.positionPrev.y+=C*y.inverseMass,y.anglePrev+=y.inverseInertia*((T.x-y.position.x)*C-(T.y-y.position.y)*N)),w.isStatic||w.isSleeping||(w.positionPrev.x-=N*w.inverseMass,w.positionPrev.y-=C*w.inverseMass,w.anglePrev-=w.inverseInertia*((T.x-w.position.x)*C-(T.y-w.position.y)*N))}}}}},i.solveVelocity=function(u,c){var h=c/o._baseDelta,f=h*h,d=f*h,m=-i._restingThresh*h,g=i._restingThreshTangent,b=i._frictionNormalMultiplier*h,y=i._frictionMaxStatic,w=u.length,E,S,v,T;for(v=0;v<w;v++){var _=u[v];if(!(!_.isActive||_.isSensor)){var A=_.collision,N=A.parentA,C=A.parentB,D=N.velocity,P=C.velocity,O=A.normal.x,I=A.normal.y,R=A.tangent.x,B=A.tangent.y,V=_.activeContacts,z=V.length,Y=1/z,L=N.inverseMass+C.inverseMass,q=_.friction*_.frictionStatic*b;for(D.x=N.position.x-N.positionPrev.x,D.y=N.position.y-N.positionPrev.y,P.x=C.position.x-C.positionPrev.x,P.y=C.position.y-C.positionPrev.y,N.angularVelocity=N.angle-N.anglePrev,C.angularVelocity=C.angle-C.anglePrev,T=0;T<z;T++){var K=V[T],M=K.vertex,G=M.x-N.position.x,ae=M.y-N.position.y,ne=M.x-C.position.x,X=M.y-C.position.y,te=D.x-ae*N.angularVelocity,ue=D.y+G*N.angularVelocity,ge=P.x-X*C.angularVelocity,Z=P.y+ne*C.angularVelocity,re=te-ge,be=ue-Z,ve=O*re+I*be,Fe=R*re+B*be,je=_.separation+ve,Se=Math.min(je,1);Se=je<0?0:Se;var Oe=Se*q;Fe<-Oe||Fe>Oe?(S=Fe>0?Fe:-Fe,E=_.friction*(Fe>0?1:-1)*d,E<-S?E=-S:E>S&&(E=S)):(E=Fe,S=y);var st=G*I-ae*O,pt=ne*I-X*O,me=Y/(L+N.inverseInertia*st*st+C.inverseInertia*pt*pt),rt=(1+_.restitution)*ve*me;if(E*=me,ve<m)K.normalImpulse=0;else{var ie=K.normalImpulse;K.normalImpulse+=rt,K.normalImpulse>0&&(K.normalImpulse=0),rt=K.normalImpulse-ie}if(Fe<-g||Fe>g)K.tangentImpulse=0;else{var Ie=K.tangentImpulse;K.tangentImpulse+=E,K.tangentImpulse<-S&&(K.tangentImpulse=-S),K.tangentImpulse>S&&(K.tangentImpulse=S),E=K.tangentImpulse-Ie}var Be=O*rt+R*E,Q=I*rt+B*E;N.isStatic||N.isSleeping||(N.positionPrev.x+=Be*N.inverseMass,N.positionPrev.y+=Q*N.inverseMass,N.anglePrev+=(G*Q-ae*Be)*N.inverseInertia),C.isStatic||C.isSleeping||(C.positionPrev.x-=Be*C.inverseMass,C.positionPrev.y-=Q*C.inverseMass,C.anglePrev-=(ne*Q-X*Be)*C.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 h=l.list,f=h.length,d=l.table,m=u.length,g=l.collisionStart,b=l.collisionEnd,y=l.collisionActive,w,E,S,v;for(g.length=0,b.length=0,y.length=0,v=0;v<f;v++)h[v].confirmedActive=!1;for(v=0;v<m;v++)w=u[v],S=w.pair,S?(S.isActive?y.push(S):g.push(S),a.update(S,w,c),S.confirmedActive=!0):(S=a.create(w,c),d[S.id]=S,g.push(S),h.push(S));var T=[];for(f=h.length,v=0;v<f;v++)S=h[v],S.confirmedActive||(a.setActive(S,!1,c),b.push(S),!S.collision.bodyA.isSleeping&&!S.collision.bodyB.isSleeping&&T.push(v));for(v=0;v<T.length;v++)E=T[v]-v,S=h[E],h.splice(E,1),delete d[S.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),h=l.deprecated;(function(){i.stack=function(f,d,m,g,b,y,w){for(var E=a.create({label:"Stack"}),S=f,v=d,T,_=0,A=0;A<g;A++){for(var N=0,C=0;C<m;C++){var D=w(S,v,C,A,T,_);if(D){var P=D.bounds.max.y-D.bounds.min.y,O=D.bounds.max.x-D.bounds.min.x;P>N&&(N=P),u.translate(D,{x:O*.5,y:P*.5}),S=D.bounds.max.x+b,a.addBody(E,D),T=D,_+=1}else S+=b}v+=N+y,S=f}return E},i.chain=function(f,d,m,g,b,y){for(var w=f.bodies,E=1;E<w.length;E++){var S=w[E-1],v=w[E],T=S.bounds.max.y-S.bounds.min.y,_=S.bounds.max.x-S.bounds.min.x,A=v.bounds.max.y-v.bounds.min.y,N=v.bounds.max.x-v.bounds.min.x,C={bodyA:S,pointA:{x:_*d,y:T*m},bodyB:v,pointB:{x:N*g,y:A*b}},D=l.extend(C,y);a.addConstraint(f,o.create(D))}return f.label+=" Chain",f},i.mesh=function(f,d,m,g,b){var y=f.bodies,w,E,S,v,T;for(w=0;w<m;w++){for(E=1;E<d;E++)S=y[E-1+w*d],v=y[E+w*d],a.addConstraint(f,o.create(l.extend({bodyA:S,bodyB:v},b)));if(w>0)for(E=0;E<d;E++)S=y[E+(w-1)*d],v=y[E+w*d],a.addConstraint(f,o.create(l.extend({bodyA:S,bodyB:v},b))),g&&E>0&&(T=y[E-1+(w-1)*d],a.addConstraint(f,o.create(l.extend({bodyA:T,bodyB:v},b)))),g&&E<d-1&&(T=y[E+1+(w-1)*d],a.addConstraint(f,o.create(l.extend({bodyA:T,bodyB:v},b))))}return f.label+=" Mesh",f},i.pyramid=function(f,d,m,g,b,y,w){return i.stack(f,d,m,g,b,y,function(E,S,v,T,_,A){var N=Math.min(g,Math.ceil(m/2)),C=_?_.bounds.max.x-_.bounds.min.x:0;if(!(T>N)){T=N-T;var D=T,P=m-1-T;if(!(v<D||v>P)){A===1&&u.translate(_,{x:(v+(m%2===1?1:-1))*C,y:0});var O=_?v*C:0;return w(f+O+v*b,S,v,T,_,A)}}})},i.newtonsCradle=function(f,d,m,g,b){for(var y=a.create({label:"Newtons Cradle"}),w=0;w<m;w++){var E=1.9,S=c.circle(f+w*(g*E),d+b,g,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),v=o.create({pointA:{x:f+w*(g*E),y:d},bodyB:S});a.addBody(y,S),a.addConstraint(y,v)}return y},h(i,"newtonsCradle","Composites.newtonsCradle ➤ moved to newtonsCradle example"),i.car=function(f,d,m,g,b){var y=u.nextGroup(!0),w=20,E=-m*.5+w,S=m*.5-w,v=0,T=a.create({label:"Car"}),_=c.rectangle(f,d,m,g,{collisionFilter:{group:y},chamfer:{radius:g*.5},density:2e-4}),A=c.circle(f+E,d+v,b,{collisionFilter:{group:y},friction:.8}),N=c.circle(f+S,d+v,b,{collisionFilter:{group:y},friction:.8}),C=o.create({bodyB:_,pointB:{x:E,y:v},bodyA:A,stiffness:1,length:0}),D=o.create({bodyB:_,pointB:{x:S,y:v},bodyA:N,stiffness:1,length:0});return a.addBody(T,_),a.addBody(T,A),a.addBody(T,N),a.addConstraint(T,C),a.addConstraint(T,D),T},h(i,"car","Composites.car ➤ moved to car example"),i.softBody=function(f,d,m,g,b,y,w,E,S,v){S=l.extend({inertia:1/0},S),v=l.extend({stiffness:.2,render:{type:"line",anchors:!1}},v);var T=i.stack(f,d,m,g,b,y,function(_,A){return c.circle(_,A,E,S)});return i.mesh(T,m,g,w,v),T.label="Soft Body",T},h(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,h,f){var d,m,g,b=h.world,y=u.buckets,w,E,S=!1;for(d=0;d<c.length;d++){var v=c[d];if(!(v.isSleeping&&!f)&&!(b.bounds&&(v.bounds.max.x<b.bounds.min.x||v.bounds.min.x>b.bounds.max.x||v.bounds.max.y<b.bounds.min.y||v.bounds.min.y>b.bounds.max.y))){var T=i._getRegion(u,v);if(!v.region||T.id!==v.region.id||f){(!v.region||f)&&(v.region=T);var _=i._regionUnion(T,v.region);for(m=_.startCol;m<=_.endCol;m++)for(g=_.startRow;g<=_.endRow;g++){E=i._getBucketId(m,g),w=y[E];var A=m>=T.startCol&&m<=T.endCol&&g>=T.startRow&&g<=T.endRow,N=m>=v.region.startCol&&m<=v.region.endCol&&g>=v.region.startRow&&g<=v.region.endRow;!A&&N&&N&&w&&i._bucketRemoveBody(u,w,v),(v.region===T||A&&!N||f)&&(w||(w=i._createBucket(y,E)),i._bucketAddBody(u,w,v))}v.region=T,S=!0}}}S&&(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 h=Math.min(u.startCol,c.startCol),f=Math.max(u.endCol,c.endCol),d=Math.min(u.startRow,c.startRow),m=Math.max(u.endRow,c.endRow);return i._createRegion(h,f,d,m)},i._getRegion=function(u,c){var h=c.bounds,f=Math.floor(h.min.x/u.bucketWidth),d=Math.floor(h.max.x/u.bucketWidth),m=Math.floor(h.min.y/u.bucketHeight),g=Math.floor(h.max.y/u.bucketHeight);return i._createRegion(f,d,m,g)},i._createRegion=function(u,c,h,f){return{id:u+","+c+","+h+","+f,startCol:u,endCol:c,startRow:h,endRow:f}},i._getBucketId=function(u,c){return"C"+u+"R"+c},i._createBucket=function(u,c){var h=u[c]=[];return h},i._bucketAddBody=function(u,c,h){var f=u.pairs,d=a.id,m=c.length,g;for(g=0;g<m;g++){var b=c[g];if(!(h.id===b.id||h.isStatic&&b.isStatic)){var y=d(h,b),w=f[y];w?w[2]+=1:f[y]=[h,b,1]}}c.push(h)},i._bucketRemoveBody=function(u,c,h){var f=u.pairs,d=a.id,m;c.splice(o.indexOf(c,h),1);var g=c.length;for(m=0;m<g;m++){var b=f[d(h,c[m])];b&&(b[2]-=1)}},i._createActivePairsList=function(u){var c,h=u.pairs,f=o.keys(h),d=f.length,m=[],g;for(g=0;g<d;g++)c=h[f[g]],c[2]>0?m.push(c):delete h[f[g]];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),h=s(10),f=s(6),d=s(0),m=s(1);(function(){i.create=function(g,b){var y=(g?g.mouse:null)||(b?b.mouse:null);y||(g&&g.render&&g.render.canvas?y=l.create(g.render.canvas):b&&b.element?y=l.create(b.element):(y=l.create(),d.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var w=h.create({label:"Mouse Constraint",pointA:y.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,render:{strokeStyle:"#90EE90",lineWidth:3}}),E={type:"mouseConstraint",mouse:y,element:null,body:null,constraint:w,collisionFilter:{category:1,mask:4294967295,group:0}},S=d.extend(E,b);return u.on(g,"beforeUpdate",function(){var v=f.allBodies(g.world);i.update(S,v),i._triggerEvents(S)}),S},i.update=function(g,b){var y=g.mouse,w=g.constraint,E=g.body;if(y.button===0){if(w.bodyB)o.set(w.bodyB,!1),w.pointA=y.position;else for(var S=0;S<b.length;S++)if(E=b[S],m.contains(E.bounds,y.position)&&c.canCollide(E.collisionFilter,g.collisionFilter))for(var v=E.parts.length>1?1:0;v<E.parts.length;v++){var T=E.parts[v];if(a.contains(T.vertices,y.position)){w.pointA=y.position,w.bodyB=g.body=E,w.pointB={x:y.position.x-E.position.x,y:y.position.y-E.position.y},w.angleB=E.angle,o.set(E,!1),u.trigger(g,"startdrag",{mouse:y,body:E});break}}}else w.bodyB=g.body=null,w.pointB=null,E&&u.trigger(g,"enddrag",{mouse:y,body:E})},i._triggerEvents=function(g){var b=g.mouse,y=b.sourceEvents;y.mousemove&&u.trigger(g,"mousemove",{mouse:b}),y.mousedown&&u.trigger(g,"mousedown",{mouse:b}),y.mouseup&&u.trigger(g,"mouseup",{mouse:b}),l.clearSourceEvents(b)}})()}),(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(h,f){for(var d=[],m=f.length,g=h.bounds,b=o.collides,y=l.overlaps,w=0;w<m;w++){var E=f[w],S=E.parts.length,v=S===1?0:1;if(y(E.bounds,g))for(var T=v;T<S;T++){var _=E.parts[T];if(y(_.bounds,g)){var A=b(_,h);if(A){d.push(A);break}}}}return d},i.ray=function(h,f,d,m){m=m||1e-100;for(var g=a.angle(f,d),b=a.magnitude(a.sub(f,d)),y=(d.x+f.x)*.5,w=(d.y+f.y)*.5,E=u.rectangle(y,w,b,m,{angle:g}),S=i.collides(E,h),v=0;v<S.length;v+=1){var T=S[v];T.body=T.bodyB=T.bodyA}return S},i.region=function(h,f,d){for(var m=[],g=0;g<h.length;g++){var b=h[g],y=l.overlaps(b.bounds,f);(y&&!d||!y&&d)&&m.push(b)}return m},i.point=function(h,f){for(var d=[],m=0;m<h.length;m++){var g=h[m];if(l.contains(g.bounds,f))for(var b=g.parts.length===1?0:1;b<g.parts.length;b++){var y=g.parts[b];if(l.contains(y.bounds,f)&&c.contains(y.vertices,f)){d.push(g);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),h=s(2),f=s(14);(function(){var d,m;typeof window<"u"&&(d=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(v){window.setTimeout(function(){v(o.now())},1e3/60)},m=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),i._goodFps=30,i._goodDelta=1e3/60,i.create=function(v){var T={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:!!v.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(T,v);return _.canvas&&(_.canvas.width=_.options.width||_.canvas.width,_.canvas.height=_.options.height||_.canvas.height),_.mouse=v.mouse,_.engine=v.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(v){(function T(_){v.frameRequestId=d(T),g(v,_),i.world(v,_),(v.options.showStats||v.options.showDebug)&&i.stats(v,v.context,_),(v.options.showPerformance||v.options.showDebug)&&i.performance(v,v.context,_)})()},i.stop=function(v){m(v.frameRequestId)},i.setPixelRatio=function(v,T){var _=v.options,A=v.canvas;T==="auto"&&(T=w(A)),_.pixelRatio=T,A.setAttribute("data-pixel-ratio",T),A.width=_.width*T,A.height=_.height*T,A.style.width=_.width+"px",A.style.height=_.height+"px"},i.lookAt=function(v,T,_,A){A=typeof A<"u"?A:!0,T=o.isArray(T)?T:[T],_=_||{x:0,y:0};for(var N={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},C=0;C<T.length;C+=1){var D=T[C],P=D.bounds?D.bounds.min:D.min||D.position||D,O=D.bounds?D.bounds.max:D.max||D.position||D;P&&O&&(P.x<N.min.x&&(N.min.x=P.x),O.x>N.max.x&&(N.max.x=O.x),P.y<N.min.y&&(N.min.y=P.y),O.y>N.max.y&&(N.max.y=O.y))}var I=N.max.x-N.min.x+2*_.x,R=N.max.y-N.min.y+2*_.y,B=v.canvas.height,V=v.canvas.width,z=V/B,Y=I/R,L=1,q=1;Y>z?q=Y/z:L=z/Y,v.options.hasBounds=!0,v.bounds.min.x=N.min.x,v.bounds.max.x=N.min.x+I*L,v.bounds.min.y=N.min.y,v.bounds.max.y=N.min.y+R*q,A&&(v.bounds.min.x+=I*.5-I*L*.5,v.bounds.max.x+=I*.5-I*L*.5,v.bounds.min.y+=R*.5-R*q*.5,v.bounds.max.y+=R*.5-R*q*.5),v.bounds.min.x-=_.x,v.bounds.max.x-=_.x,v.bounds.min.y-=_.y,v.bounds.max.y-=_.y,v.mouse&&(f.setScale(v.mouse,{x:(v.bounds.max.x-v.bounds.min.x)/v.canvas.width,y:(v.bounds.max.y-v.bounds.min.y)/v.canvas.height}),f.setOffset(v.mouse,v.bounds.min))},i.startViewTransform=function(v){var T=v.bounds.max.x-v.bounds.min.x,_=v.bounds.max.y-v.bounds.min.y,A=T/v.options.width,N=_/v.options.height;v.context.setTransform(v.options.pixelRatio/A,0,0,v.options.pixelRatio/N,0,0),v.context.translate(-v.bounds.min.x,-v.bounds.min.y)},i.endViewTransform=function(v){v.context.setTransform(v.options.pixelRatio,0,0,v.options.pixelRatio,0,0)},i.world=function(v,T){var _=o.now(),A=v.engine,N=A.world,C=v.canvas,D=v.context,P=v.options,O=v.timing,I=l.allBodies(N),R=l.allConstraints(N),B=P.wireframes?P.wireframeBackground:P.background,V=[],z=[],Y,L={timestamp:A.timing.timestamp};if(c.trigger(v,"beforeRender",L),v.currentBackground!==B&&S(v,B),D.globalCompositeOperation="source-in",D.fillStyle="transparent",D.fillRect(0,0,C.width,C.height),D.globalCompositeOperation="source-over",P.hasBounds){for(Y=0;Y<I.length;Y++){var q=I[Y];u.overlaps(q.bounds,v.bounds)&&V.push(q)}for(Y=0;Y<R.length;Y++){var K=R[Y],M=K.bodyA,G=K.bodyB,ae=K.pointA,ne=K.pointB;M&&(ae=h.add(M.position,K.pointA)),G&&(ne=h.add(G.position,K.pointB)),!(!ae||!ne)&&(u.contains(v.bounds,ae)||u.contains(v.bounds,ne))&&z.push(K)}i.startViewTransform(v),v.mouse&&(f.setScale(v.mouse,{x:(v.bounds.max.x-v.bounds.min.x)/v.options.width,y:(v.bounds.max.y-v.bounds.min.y)/v.options.height}),f.setOffset(v.mouse,v.bounds.min))}else z=R,V=I,v.options.pixelRatio!==1&&v.context.setTransform(v.options.pixelRatio,0,0,v.options.pixelRatio,0,0);!P.wireframes||A.enableSleeping&&P.showSleeping?i.bodies(v,V,D):(P.showConvexHulls&&i.bodyConvexHulls(v,V,D),i.bodyWireframes(v,V,D)),P.showBounds&&i.bodyBounds(v,V,D),(P.showAxes||P.showAngleIndicator)&&i.bodyAxes(v,V,D),P.showPositions&&i.bodyPositions(v,V,D),P.showVelocity&&i.bodyVelocity(v,V,D),P.showIds&&i.bodyIds(v,V,D),P.showSeparations&&i.separations(v,A.pairs.list,D),P.showCollisions&&i.collisions(v,A.pairs.list,D),P.showVertexNumbers&&i.vertexNumbers(v,V,D),P.showMousePosition&&i.mousePosition(v,v.mouse,D),i.constraints(z,D),P.hasBounds&&i.endViewTransform(v),c.trigger(v,"afterRender",L),O.lastElapsed=o.now()-_},i.stats=function(v,T,_){for(var A=v.engine,N=A.world,C=l.allBodies(N),D=0,P=55,O=44,I=0,R=0,B=0;B<C.length;B+=1)D+=C[B].parts.length;var V={Part:D,Body:C.length,Cons:l.allConstraints(N).length,Comp:l.allComposites(N).length,Pair:A.pairs.list.length};T.fillStyle="#0e0f19",T.fillRect(I,R,P*5.5,O),T.font="12px Arial",T.textBaseline="top",T.textAlign="right";for(var z in V){var Y=V[z];T.fillStyle="#aaa",T.fillText(z,I+P,R+8),T.fillStyle="#eee",T.fillText(Y,I+P,R+26),I+=P}},i.performance=function(v,T){var _=v.engine,A=v.timing,N=A.deltaHistory,C=A.elapsedHistory,D=A.timestampElapsedHistory,P=A.engineDeltaHistory,O=A.engineElapsedHistory,I=_.timing.lastDelta,R=b(N),B=b(C),V=b(P),z=b(O),Y=b(D),L=Y/R||0,q=1e3/R||0,K=4,M=12,G=60,ae=34,ne=10,X=69;T.fillStyle="#0e0f19",T.fillRect(0,50,M*4+G*5+22,ae),i.status(T,ne,X,G,K,N.length,Math.round(q)+" fps",q/i._goodFps,function(te){return N[te]/R-1}),i.status(T,ne+M+G,X,G,K,P.length,I.toFixed(2)+" dt",i._goodDelta/I,function(te){return P[te]/V-1}),i.status(T,ne+(M+G)*2,X,G,K,O.length,z.toFixed(2)+" ut",1-z/i._goodFps,function(te){return O[te]/z-1}),i.status(T,ne+(M+G)*3,X,G,K,C.length,B.toFixed(2)+" rt",1-B/i._goodFps,function(te){return C[te]/B-1}),i.status(T,ne+(M+G)*4,X,G,K,D.length,L.toFixed(2)+" x",L*L*L,function(te){return(D[te]/N[te]/L||0)-1})},i.status=function(v,T,_,A,N,C,D,P,O){v.strokeStyle="#888",v.fillStyle="#444",v.lineWidth=1,v.fillRect(T,_+7,A,1),v.beginPath(),v.moveTo(T,_+7-N*o.clamp(.4*O(0),-2,2));for(var I=0;I<A;I+=1)v.lineTo(T+I,_+7-(I<C?N*o.clamp(.4*O(I),-2,2):0));v.stroke(),v.fillStyle="hsl("+o.clamp(25+95*P,0,120)+",100%,60%)",v.fillRect(T,_-7,4,4),v.font="12px Arial",v.textBaseline="middle",v.textAlign="right",v.fillStyle="#eee",v.fillText(D,T+A,_-5)},i.constraints=function(v,T){for(var _=T,A=0;A<v.length;A++){var N=v[A];if(!(!N.render.visible||!N.pointA||!N.pointB)){var C=N.bodyA,D=N.bodyB,P,O;if(C?P=h.add(C.position,N.pointA):P=N.pointA,N.render.type==="pin")_.beginPath(),_.arc(P.x,P.y,3,0,2*Math.PI),_.closePath();else{if(D?O=h.add(D.position,N.pointB):O=N.pointB,_.beginPath(),_.moveTo(P.x,P.y),N.render.type==="spring")for(var I=h.sub(O,P),R=h.perp(h.normalise(I)),B=Math.ceil(o.clamp(N.length/5,12,20)),V,z=1;z<B;z+=1)V=z%2===0?1:-1,_.lineTo(P.x+I.x*(z/B)+R.x*V*4,P.y+I.y*(z/B)+R.y*V*4);_.lineTo(O.x,O.y)}N.render.lineWidth&&(_.lineWidth=N.render.lineWidth,_.strokeStyle=N.render.strokeStyle,_.stroke()),N.render.anchors&&(_.fillStyle=N.render.strokeStyle,_.beginPath(),_.arc(P.x,P.y,3,0,2*Math.PI),_.arc(O.x,O.y,3,0,2*Math.PI),_.closePath(),_.fill())}}},i.bodies=function(v,T,_){var A=_;v.engine;var N=v.options,C=N.showInternalEdges||!N.wireframes,D,P,O,I;for(O=0;O<T.length;O++)if(D=T[O],!!D.render.visible){for(I=D.parts.length>1?1:0;I<D.parts.length;I++)if(P=D.parts[I],!!P.render.visible){if(N.showSleeping&&D.isSleeping?A.globalAlpha=.5*P.render.opacity:P.render.opacity!==1&&(A.globalAlpha=P.render.opacity),P.render.sprite&&P.render.sprite.texture&&!N.wireframes){var R=P.render.sprite,B=E(v,R.texture);A.translate(P.position.x,P.position.y),A.rotate(P.angle),A.drawImage(B,B.width*-R.xOffset*R.xScale,B.height*-R.yOffset*R.yScale,B.width*R.xScale,B.height*R.yScale),A.rotate(-P.angle),A.translate(-P.position.x,-P.position.y)}else{if(P.circleRadius)A.beginPath(),A.arc(P.position.x,P.position.y,P.circleRadius,0,2*Math.PI);else{A.beginPath(),A.moveTo(P.vertices[0].x,P.vertices[0].y);for(var V=1;V<P.vertices.length;V++)!P.vertices[V-1].isInternal||C?A.lineTo(P.vertices[V].x,P.vertices[V].y):A.moveTo(P.vertices[V].x,P.vertices[V].y),P.vertices[V].isInternal&&!C&&A.moveTo(P.vertices[(V+1)%P.vertices.length].x,P.vertices[(V+1)%P.vertices.length].y);A.lineTo(P.vertices[0].x,P.vertices[0].y),A.closePath()}N.wireframes?(A.lineWidth=1,A.strokeStyle="#bbb",A.stroke()):(A.fillStyle=P.render.fillStyle,P.render.lineWidth&&(A.lineWidth=P.render.lineWidth,A.strokeStyle=P.render.strokeStyle,A.stroke()),A.fill())}A.globalAlpha=1}}},i.bodyWireframes=function(v,T,_){var A=_,N=v.options.showInternalEdges,C,D,P,O,I;for(A.beginPath(),P=0;P<T.length;P++)if(C=T[P],!!C.render.visible)for(I=C.parts.length>1?1:0;I<C.parts.length;I++){for(D=C.parts[I],A.moveTo(D.vertices[0].x,D.vertices[0].y),O=1;O<D.vertices.length;O++)!D.vertices[O-1].isInternal||N?A.lineTo(D.vertices[O].x,D.vertices[O].y):A.moveTo(D.vertices[O].x,D.vertices[O].y),D.vertices[O].isInternal&&!N&&A.moveTo(D.vertices[(O+1)%D.vertices.length].x,D.vertices[(O+1)%D.vertices.length].y);A.lineTo(D.vertices[0].x,D.vertices[0].y)}A.lineWidth=1,A.strokeStyle="#bbb",A.stroke()},i.bodyConvexHulls=function(v,T,_){var A=_,N,C,D;for(A.beginPath(),C=0;C<T.length;C++)if(N=T[C],!(!N.render.visible||N.parts.length===1)){for(A.moveTo(N.vertices[0].x,N.vertices[0].y),D=1;D<N.vertices.length;D++)A.lineTo(N.vertices[D].x,N.vertices[D].y);A.lineTo(N.vertices[0].x,N.vertices[0].y)}A.lineWidth=1,A.strokeStyle="rgba(255,255,255,0.2)",A.stroke()},i.vertexNumbers=function(v,T,_){var A=_,N,C,D;for(N=0;N<T.length;N++){var P=T[N].parts;for(D=P.length>1?1:0;D<P.length;D++){var O=P[D];for(C=0;C<O.vertices.length;C++)A.fillStyle="rgba(255,255,255,0.2)",A.fillText(N+"_"+C,O.position.x+(O.vertices[C].x-O.position.x)*.8,O.position.y+(O.vertices[C].y-O.position.y)*.8)}}},i.mousePosition=function(v,T,_){var A=_;A.fillStyle="rgba(255,255,255,0.8)",A.fillText(T.position.x+" "+T.position.y,T.position.x+5,T.position.y-5)},i.bodyBounds=function(v,T,_){var A=_;v.engine;var N=v.options;A.beginPath();for(var C=0;C<T.length;C++){var D=T[C];if(D.render.visible)for(var P=T[C].parts,O=P.length>1?1:0;O<P.length;O++){var I=P[O];A.rect(I.bounds.min.x,I.bounds.min.y,I.bounds.max.x-I.bounds.min.x,I.bounds.max.y-I.bounds.min.y)}}N.wireframes?A.strokeStyle="rgba(255,255,255,0.08)":A.strokeStyle="rgba(0,0,0,0.1)",A.lineWidth=1,A.stroke()},i.bodyAxes=function(v,T,_){var A=_;v.engine;var N=v.options,C,D,P,O;for(A.beginPath(),D=0;D<T.length;D++){var I=T[D],R=I.parts;if(I.render.visible)if(N.showAxes)for(P=R.length>1?1:0;P<R.length;P++)for(C=R[P],O=0;O<C.axes.length;O++){var B=C.axes[O];A.moveTo(C.position.x,C.position.y),A.lineTo(C.position.x+B.x*20,C.position.y+B.y*20)}else for(P=R.length>1?1:0;P<R.length;P++)for(C=R[P],O=0;O<C.axes.length;O++)A.moveTo(C.position.x,C.position.y),A.lineTo((C.vertices[0].x+C.vertices[C.vertices.length-1].x)/2,(C.vertices[0].y+C.vertices[C.vertices.length-1].y)/2)}N.wireframes?(A.strokeStyle="indianred",A.lineWidth=1):(A.strokeStyle="rgba(255, 255, 255, 0.4)",A.globalCompositeOperation="overlay",A.lineWidth=2),A.stroke(),A.globalCompositeOperation="source-over"},i.bodyPositions=function(v,T,_){var A=_;v.engine;var N=v.options,C,D,P,O;for(A.beginPath(),P=0;P<T.length;P++)if(C=T[P],!!C.render.visible)for(O=0;O<C.parts.length;O++)D=C.parts[O],A.arc(D.position.x,D.position.y,3,0,2*Math.PI,!1),A.closePath();for(N.wireframes?A.fillStyle="indianred":A.fillStyle="rgba(0,0,0,0.5)",A.fill(),A.beginPath(),P=0;P<T.length;P++)C=T[P],C.render.visible&&(A.arc(C.positionPrev.x,C.positionPrev.y,2,0,2*Math.PI,!1),A.closePath());A.fillStyle="rgba(255,165,0,0.8)",A.fill()},i.bodyVelocity=function(v,T,_){var A=_;A.beginPath();for(var N=0;N<T.length;N++){var C=T[N];if(C.render.visible){var D=a.getVelocity(C);A.moveTo(C.position.x,C.position.y),A.lineTo(C.position.x+D.x,C.position.y+D.y)}}A.lineWidth=3,A.strokeStyle="cornflowerblue",A.stroke()},i.bodyIds=function(v,T,_){var A=_,N,C;for(N=0;N<T.length;N++)if(T[N].render.visible){var D=T[N].parts;for(C=D.length>1?1:0;C<D.length;C++){var P=D[C];A.font="12px Arial",A.fillStyle="rgba(255,255,255,0.5)",A.fillText(P.id,P.position.x+10,P.position.y-10)}}},i.collisions=function(v,T,_){var A=_,N=v.options,C,D,P,O;for(A.beginPath(),P=0;P<T.length;P++)if(C=T[P],!!C.isActive)for(D=C.collision,O=0;O<C.activeContacts.length;O++){var I=C.activeContacts[O],R=I.vertex;A.rect(R.x-1.5,R.y-1.5,3.5,3.5)}for(N.wireframes?A.fillStyle="rgba(255,255,255,0.7)":A.fillStyle="orange",A.fill(),A.beginPath(),P=0;P<T.length;P++)if(C=T[P],!!C.isActive&&(D=C.collision,C.activeContacts.length>0)){var B=C.activeContacts[0].vertex.x,V=C.activeContacts[0].vertex.y;C.activeContacts.length===2&&(B=(C.activeContacts[0].vertex.x+C.activeContacts[1].vertex.x)/2,V=(C.activeContacts[0].vertex.y+C.activeContacts[1].vertex.y)/2),D.bodyB===D.supports[0].body||D.bodyA.isStatic===!0?A.moveTo(B-D.normal.x*8,V-D.normal.y*8):A.moveTo(B+D.normal.x*8,V+D.normal.y*8),A.lineTo(B,V)}N.wireframes?A.strokeStyle="rgba(255,165,0,0.7)":A.strokeStyle="orange",A.lineWidth=1,A.stroke()},i.separations=function(v,T,_){var A=_,N=v.options,C,D,P,O,I;for(A.beginPath(),I=0;I<T.length;I++)if(C=T[I],!!C.isActive){D=C.collision,P=D.bodyA,O=D.bodyB;var R=1;!O.isStatic&&!P.isStatic&&(R=.5),O.isStatic&&(R=0),A.moveTo(O.position.x,O.position.y),A.lineTo(O.position.x-D.penetration.x*R,O.position.y-D.penetration.y*R),R=1,!O.isStatic&&!P.isStatic&&(R=.5),P.isStatic&&(R=0),A.moveTo(P.position.x,P.position.y),A.lineTo(P.position.x+D.penetration.x*R,P.position.y+D.penetration.y*R)}N.wireframes?A.strokeStyle="rgba(255,165,0,0.5)":A.strokeStyle="orange",A.stroke()},i.inspector=function(v,T){v.engine;var _=v.selected,A=v.render,N=A.options,C;if(N.hasBounds){var D=A.bounds.max.x-A.bounds.min.x,P=A.bounds.max.y-A.bounds.min.y,O=D/A.options.width,I=P/A.options.height;T.scale(1/O,1/I),T.translate(-A.bounds.min.x,-A.bounds.min.y)}for(var R=0;R<_.length;R++){var B=_[R].data;switch(T.translate(.5,.5),T.lineWidth=1,T.strokeStyle="rgba(255,165,0,0.9)",T.setLineDash([1,2]),B.type){case"body":C=B.bounds,T.beginPath(),T.rect(Math.floor(C.min.x-3),Math.floor(C.min.y-3),Math.floor(C.max.x-C.min.x+6),Math.floor(C.max.y-C.min.y+6)),T.closePath(),T.stroke();break;case"constraint":var V=B.pointA;B.bodyA&&(V=B.pointB),T.beginPath(),T.arc(V.x,V.y,10,0,2*Math.PI),T.closePath(),T.stroke();break}T.setLineDash([]),T.translate(-.5,-.5)}v.selectStart!==null&&(T.translate(.5,.5),T.lineWidth=1,T.strokeStyle="rgba(255,165,0,0.6)",T.fillStyle="rgba(255,165,0,0.1)",C=v.selectBounds,T.beginPath(),T.rect(Math.floor(C.min.x),Math.floor(C.min.y),Math.floor(C.max.x-C.min.x),Math.floor(C.max.y-C.min.y)),T.closePath(),T.stroke(),T.fill(),T.translate(-.5,-.5)),N.hasBounds&&T.setTransform(1,0,0,1,0,0)};var g=function(v,T){var _=v.engine,A=v.timing,N=A.historySize,C=_.timing.timestamp;A.delta=T-A.lastTime||i._goodDelta,A.lastTime=T,A.timestampElapsed=C-A.lastTimestamp||0,A.lastTimestamp=C,A.deltaHistory.unshift(A.delta),A.deltaHistory.length=Math.min(A.deltaHistory.length,N),A.engineDeltaHistory.unshift(_.timing.lastDelta),A.engineDeltaHistory.length=Math.min(A.engineDeltaHistory.length,N),A.timestampElapsedHistory.unshift(A.timestampElapsed),A.timestampElapsedHistory.length=Math.min(A.timestampElapsedHistory.length,N),A.engineElapsedHistory.unshift(_.timing.lastElapsed),A.engineElapsedHistory.length=Math.min(A.engineElapsedHistory.length,N),A.elapsedHistory.unshift(A.lastElapsed),A.elapsedHistory.length=Math.min(A.elapsedHistory.length,N)},b=function(v){for(var T=0,_=0;_<v.length;_+=1)T+=v[_];return T/v.length||0},y=function(v,T){var _=document.createElement("canvas");return _.width=v,_.height=T,_.oncontextmenu=function(){return!1},_.onselectstart=function(){return!1},_},w=function(v){var T=v.getContext("2d"),_=window.devicePixelRatio||1,A=T.webkitBackingStorePixelRatio||T.mozBackingStorePixelRatio||T.msBackingStorePixelRatio||T.oBackingStorePixelRatio||T.backingStorePixelRatio||1;return _/A},E=function(v,T){var _=v.textures[T];return _||(_=v.textures[T]=new Image,_.src=T,_)},S=function(v,T){var _=T;/(jpg|gif|png)$/.test(T)&&(_="url("+T+")"),v.canvas.style.background=_,v.canvas.style.backgroundSize="contain",v.currentBackground=T}})()}),(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 h;u=function(f){h=setTimeout(function(){f(l.now())},1e3/60)},c=function(){clearTimeout(h)}}i.create=function(f){var d={fps:60,deltaSampleSize:60,counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,frameRequestId:null,isFixed:!1,enabled:!0},m=l.extend(d,f);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(f,d){return typeof f.positionIterations<"u"&&(d=f,f=i.create()),(function m(g){f.frameRequestId=u(m),g&&f.enabled&&i.tick(f,d,g)})(),f},i.tick=function(f,d,m){var g=d.timing,b;f.isFixed?b=f.delta:(b=m-f.timePrev||f.delta,f.timePrev=m,f.deltaHistory.push(b),f.deltaHistory=f.deltaHistory.slice(-f.deltaSampleSize),b=Math.min.apply(null,f.deltaHistory),b=b<f.deltaMin?f.deltaMin:b,b=b>f.deltaMax?f.deltaMax:b,f.delta=b);var y={timestamp:g.timestamp};a.trigger(f,"beforeTick",y),f.frameCounter+=1,m-f.counterTimestamp>=1e3&&(f.fps=f.frameCounter*((m-f.counterTimestamp)/1e3),f.counterTimestamp=m,f.frameCounter=0),a.trigger(f,"tick",y),a.trigger(f,"beforeUpdate",y),o.update(d,b),a.trigger(f,"afterUpdate",y),a.trigger(f,"afterTick",y)},i.stop=function(f){c(f.frameRequestId)},i.start=function(f,d){i.run(f,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,h,f,d,m,g,b,y,w,E=[],S,v,T=0,_=0,A=0;l=l||15;var N=function(D,P,O){var I=O%2===1&&O>1;if(!y||D!=y.x||P!=y.y){y&&I?(S=y.x,v=y.y):(S=0,v=0);var R={x:S+D,y:v+P};(I||!y)&&(y=R),E.push(R),_=S+D,A=v+P}},C=function(D){var P=D.pathSegTypeAsLetter.toUpperCase();if(P!=="Z"){switch(P){case"M":case"L":case"T":case"C":case"S":case"Q":_=D.x,A=D.y;break;case"H":_=D.x;break;case"V":A=D.y;break}N(_,A,D.pathSegType)}};for(i._svgPathToAbsolute(o),h=o.getTotalLength(),m=[],u=0;u<o.pathSegList.numberOfItems;u+=1)m.push(o.pathSegList.getItem(u));for(g=m.concat();T<h;){if(w=o.getPathSegAtLength(T),d=m[w],d!=b){for(;g.length&&g[0]!=d;)C(g.shift());b=d}switch(d.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":f=o.getPointAtLength(T),N(f.x,f.y,0);break}T+=l}for(u=0,c=g.length;u<c;++u)C(g[u]);return E},i._svgPathToAbsolute=function(o){for(var l,u,c,h,f,d,m=o.pathSegList,g=0,b=0,y=m.numberOfItems,w=0;w<y;++w){var E=m.getItem(w),S=E.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(S))"x"in E&&(g=E.x),"y"in E&&(b=E.y);else switch("x1"in E&&(c=g+E.x1),"x2"in E&&(f=g+E.x2),"y1"in E&&(h=b+E.y1),"y2"in E&&(d=b+E.y2),"x"in E&&(g+=E.x),"y"in E&&(b+=E.y),S){case"m":m.replaceItem(o.createSVGPathSegMovetoAbs(g,b),w);break;case"l":m.replaceItem(o.createSVGPathSegLinetoAbs(g,b),w);break;case"h":m.replaceItem(o.createSVGPathSegLinetoHorizontalAbs(g),w);break;case"v":m.replaceItem(o.createSVGPathSegLinetoVerticalAbs(b),w);break;case"c":m.replaceItem(o.createSVGPathSegCurvetoCubicAbs(g,b,c,h,f,d),w);break;case"s":m.replaceItem(o.createSVGPathSegCurvetoCubicSmoothAbs(g,b,f,d),w);break;case"q":m.replaceItem(o.createSVGPathSegCurvetoQuadraticAbs(g,b,c,h),w);break;case"t":m.replaceItem(o.createSVGPathSegCurvetoQuadraticSmoothAbs(g,b),w);break;case"a":m.replaceItem(o.createSVGPathSegArcAbs(g,b,E.r1,E.r2,E.angle,E.largeArcFlag,E.sweepFlag),w);break;case"z":case"Z":g=l,b=u;break}(S=="M"||S=="m")&&(l=g,u=b)}}})()}),(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})()})])})})(Ps)),Ps.exports}var Cy=Ay();const pn=Zl(Cy);{const e=pn.Resolver;e&&typeof e._restingThresh=="number"&&(e._restingThresh=1.4)}const _y=6,Ht=28,gn=.92,Ga=1.12,Ny=34;function Uc(e,t,n){return Math.hypot(t-e.startX,n-e.startY)<_y?"click":"drag"}function Iy(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 Ry(e,t){return e*Math.exp(-t/90)}function My(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 jm=4e-5,Py=5e-4;function Hm(e,t,n){return Math.sin(n*37e-5+t*.0013)*.6+Math.sin(n*19e-5+e*7e-4+1.7)*.4}function Um(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 zm(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 Zr=120,Ly=.9,zc=.7,Dy=.09,Oy=2.2,Fy=2,Ka=Ht*2.45,By=.006,Xa=22,Qa=.06;function jy(e){var O;const t=e.ballRadius??Ht,n=Um(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(I=>{var z,Y;const R=((z=I.spawn)==null?void 0:z.x)??I.x,B=((Y=I.spawn)==null?void 0:Y.y)??I.y,V=s.circle(R,B,t,{restitution:.5,friction:.01,frictionAir:.03*n.airDrag,density:I.isExam?.0016:.001,inertia:1/0,isStatic:!!I.locked,collisionFilter:{group:0,category:2,mask:6}});return{nodeId:I.id,body:V,layoutX:I.x,layoutY:I.y,isExam:!!I.isExam,snow:0,field:0,squash:0,squashAngle:0}});for(const I of c){a.add(u.world,I.body);const R=(O=e.nodes.find(B=>B.id===I.nodeId))==null?void 0:O.spawn;R&&(R.vx!==void 0||R.vy!==void 0)&&i.setVelocity(I.body,{x:R.vx??0,y:R.vy??0})}const h=Zr/2,f={isStatic:!0,restitution:.4,friction:.05,collisionFilter:{category:4,mask:2}},d=(I,R)=>({x:Math.min(e.width-t,Math.max(t,I)),y:Math.min(e.height-t,Math.max(t,R))});a.add(u.world,[s.rectangle(e.width/2,-h,e.width*3,Zr,f),s.rectangle(e.width/2,e.height+h,e.width*3,Zr,f),s.rectangle(-h,e.height/2,Zr,e.height*3,f),s.rectangle(e.width+h,e.height/2,Zr,e.height*3,f)]);const m=I=>({x:I.body.position.x,y:I.body.position.y+t*gn}),g=[];function b(I,R,B,V,z){return"body"in I?o.create({bodyA:I.body,pointA:I.offset,bodyB:R,pointB:B,length:V,stiffness:z,damping:.05}):o.create({pointA:I.point,bodyB:R,pointB:B,length:V,stiffness:z,damping:.05})}function y(I,R,B,V){const z={x:B.body.position.x,y:B.body.position.y+t*gn},Y=z.x-I.x,L=z.y-I.y,q=Math.max(60,Math.hypot(Y,L)),K=Math.max(5,Math.min(14,Math.round(q/Ny))),M=q*Ga/K,G=[];let ae=R?{body:R,offset:{x:I.x-R.position.x,y:I.y-R.position.y}}:{point:I},ne=!0;for(let X=1;X<K;X++){const te=X/K,ue=Math.sin(Math.PI*te)*q*(Ga-1)*.85,ge=s.circle(I.x+Y*te,I.y+L*te+ue,3.5,{density:7e-4,frictionAir:.1*n.airDrag,collisionFilter:{category:8,mask:0}});G.push(ge),a.add(u.world,ge),a.add(u.world,b(ae,ge,void 0,M,ne?zc:Ly)),ne=!1,ae={body:ge,offset:{x:0,y:0}}}a.add(u.world,b(ae,B.body,{x:0,y:t*gn},M,zc)),g.push({from:V,to:B.nodeId,restLen:q*Ga,particles:G})}const w=c[0],E=w?{x:e.anchorKnotX??w.layoutX,y:Qs}:{x:e.width/2,y:Qs};w&&y(E,null,w,"__anchor");for(let I=0;I<c.length-1;I++){const R=c[I],B=c[I+1];y(m(R),R.body,B,R.nodeId)}const S=c[c.length-1],v=e.nextKnot&&(S!=null&&S.isExam)?e.nextKnot:void 0;v&&S&&y(v,null,S,"__next");const T=new Map;for(const I of c){let R=0;for(const V of g)if(V.from===I.nodeId||V.to===I.nodeId)for(const z of V.particles)R+=z.mass*.5;const B=Math.min(.25,R/I.body.mass);T.set(I.nodeId,(1+B)*(.96+zm(I.nodeId)*.08))}let _=0,A=1;l.on(u,"beforeUpdate",()=>{const I=u.timing.timestamp;_*=.97,n.gust>0&&Math.random()<.0025*n.gust&&(_=n.gust*(.6+Math.random()*.4),A=Math.random()<.5?-1:1);for(const R of c){const B=R.body.mass,V=u.gravity.y*u.gravity.scale,z=Hm(R.body.position.x,R.body.position.y,I)*n.wind*jm*B+A*_*Py*B;let Y=-B*V*(T.get(R.nodeId)??1);n.rainRate>0&&Math.random()<n.rainRate&&(Y+=B*V*.35,i.applyForce(R.body,R.body.position,{x:(Math.random()-.5)*B*V*.3,y:0})),i.applyForce(R.body,R.body.position,{x:z,y:Y})}});const N=[],C=(I,R,B,V)=>{if(I.snow<=Qa)return;const z=Math.max(1,Math.min(V,Math.round(I.snow*V)+1));for(let Y=0;Y<z;Y++){const L=-(.35+Math.random()*1.9),q=t*(.55+Math.random()*.45);N.push({x:I.body.position.x+Math.cos(L)*q,y:I.body.position.y+Math.sin(L)*q,vx:I.body.velocity.x*.75+R.x*(.5+Math.random()*1.8)+(Math.random()-.5)*1.2,vy:I.body.velocity.y*.75+R.y*(.5+Math.random()*1.8)-.6-Math.random()*.8,amount:.02+Math.min(.05,B*.004)})}I.snow=Math.max(Qa*.5,I.snow-z*(.03+Math.min(.07,B*.005))),N.length>96&&N.splice(0,N.length-96)},D=[];l.on(u,"collisionStart",I=>{var R;for(const B of I.pairs){const{bodyA:V,bodyB:z}=B,Y=c.find(ne=>ne.body===V),L=c.find(ne=>ne.body===z);if(!Y&&!L)continue;const q={x:V.velocity.x-z.velocity.x,y:V.velocity.y-z.velocity.y},K=Math.hypot(q.x,q.y);if(K<Oy)continue;const M=B.collision.normal,G=(R=B.collision.supports)==null?void 0:R[0];D.push(G?{x:G.x,y:G.y,speed:K}:{x:(V.position.x+z.position.x)/2,y:(V.position.y+z.position.y)/2,speed:K}),D.length>64&&D.shift();const ae=Math.min(.32,K*.028);Y&&ae>Y.squash&&(Y.squash=ae,Y.squashAngle=Math.atan2(M.y,M.x)),L&&ae>L.squash&&(L.squash=ae,L.squashAngle=Math.atan2(-M.y,-M.x)),Y&&C(Y,{x:M.x,y:M.y},K,5),L&&C(L,{x:-M.x,y:-M.y},K,5)}}),l.on(u,"afterUpdate",()=>{if(!(n.snowRate<=0))for(const I of c)I.snow=Math.min(1,I.snow+n.snowRate)});let P=null;return{balls:c,links:g,anchor:E,nextKnot:v,ball(I){return c.find(R=>R.nodeId===I)},step(I){r.update(u,Math.min(33,Math.max(8,I)));for(let R=0;R<c.length;R++){const B=c[R];for(let V=R+1;V<c.length;V++){const z=c[V],Y=z.body.position.x-B.body.position.x,L=z.body.position.y-B.body.position.y,q=Y*Y+L*L;if(q>=Ka*Ka||q<.01)continue;const K=Math.sqrt(q),M=(K-2*t)/(Ka-2*t),G=M<=0?1:M>=1?0:1-M,ne=Math.hypot(B.body.velocity.x-z.body.velocity.x,B.body.velocity.y-z.body.velocity.y)<1.2?By*G*G:0,X=Y/K,te=L/K;B.body.isStatic||i.applyForce(B.body,B.body.position,{x:-X*ne*B.body.mass,y:-te*ne*B.body.mass}),z.body.isStatic||i.applyForce(z.body,z.body.position,{x:X*ne*z.body.mass,y:te*ne*z.body.mass}),B.field=Math.max(B.field,G),z.field=Math.max(z.field,G)}}for(const R of c)R.field*=.88;for(const R of c){if(R.body.isStatic)continue;const B=R.body.velocity,V=Math.hypot(B.x,B.y);V>Xa&&i.setVelocity(R.body,{x:B.x/V*Xa,y:B.y/V*Xa})}for(let R=0;R<c.length;R++){const B=c[R];for(let V=R+1;V<c.length;V++){const z=c[V];let Y=z.body.position.x-B.body.position.x,L=z.body.position.y-B.body.position.y,q=Math.hypot(Y,L);if(q>=t*2)continue;q<.01&&(Y=1,L=0,q=1);const K=t*2-q+.05,M=Y/q,G=L/q;B.body.isStatic&&z.body.isStatic||(B.body.isStatic?i.setPosition(z.body,{x:z.body.position.x+M*K,y:z.body.position.y+G*K}):z.body.isStatic?i.setPosition(B.body,{x:B.body.position.x-M*K,y:B.body.position.y-G*K}):(i.setPosition(B.body,{x:B.body.position.x-M*K/2,y:B.body.position.y-G*K/2}),i.setPosition(z.body,{x:z.body.position.x+M*K/2,y:z.body.position.y+G*K/2})))}}for(const R of c){const B=Math.hypot(R.body.velocity.x,R.body.velocity.y);R.snow>Qa&&B>Fy&&C(R,{x:R.body.velocity.x/B,y:R.body.velocity.y/B},B,2)}for(const R of c){if(R.body.isStatic)continue;const B=R.body.position.x,V=R.body.position.y,z=Math.min(e.width-t,Math.max(t,B)),Y=Math.min(e.height-t,Math.max(t,V));(z!==B||Y!==V)&&(i.setPosition(R.body,{x:z,y:Y}),i.setVelocity(R.body,{x:B<t||B>e.width-t?0:R.body.velocity.x,y:V<t||V>e.height-t?0:R.body.velocity.y}))}},beginDrag(I,R,B){this.endDrag();const V=this.ball(I);if(!V)return;const z=o.create({pointA:d(R,B),bodyB:V.body,length:0,stiffness:Dy,damping:.12});a.add(u.world,z),P={constraint:z,nodeId:I}},moveDrag(I,R){if(!P)return;const B=d(I,R);P.constraint.pointA=B},endDrag(){P&&(a.remove(u.world,P.constraint),P=null)},isDragging(){return P!==null},drainImpacts(){const I=D.slice();return D.length=0,I},drainFlakes(){const I=N.slice();return N.length=0,I},dispose(){this.endDrag(),l.off(u,"beforeUpdate"),l.off(u,"afterUpdate"),l.off(u,"collisionStart"),a.clear(u.world,!1),r.clear(u)}}}const Qs=-12;function ms(e,t,n=20){return t<=n*2?t/2:n+zm(e)*(t-n*2)}function Hy(e,t,n,r=Ht){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 Jn=(e,t,n)=>e+(t-e)*n,ya=(e,t,n)=>e<t?t:e>n?n:e,Mi=e=>e<0?0:e>1?1:e*e*(3-2*e);function er(e,t,n){return[Jn(e[0],t[0],n),Jn(e[1],t[1],n),Jn(e[2],t[2],n)]}const Za=e=>`rgb(${e[0]|0},${e[1]|0},${e[2]|0})`,Mr=(e,t)=>`rgba(${e[0]|0},${e[1]|0},${e[2]|0},${t})`;function va(){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 Ea(e,t){return e.map(n=>({t:n.t,top:t(n.top),mid:t(n.mid),hor:t(n.hor)}))}const Ja=()=>Ea(va(),e=>[e[0]*1,e[1]*1.15,e[2]*.7]),ps=()=>Ea(va(),e=>[e[0]*.75,e[1]*1,Math.min(255,e[2]*1.25)]),eo=()=>Ea(va(),e=>[Math.min(255,e[0]*1.35),e[1]*.8,e[2]*.55]),Vc=()=>Ea(va(),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]}),to={far:[28,50,36],near:[56,110,52],snowy:!1},gs={far:[20,48,30],near:[34,82,40],snowy:!1},no={far:[54,36,24],near:[128,78,36],snowy:!1},qc={far:[60,66,82],near:[232,236,244],snowy:!0};function jt(e){return t=>{let n=e;return t>.3&&t<.5?n=Jn(n,Math.min(1,n+.2),Mi((t-.3)/.2)):t>=.5&&t<.74?n=Math.min(1,n+.15):t>=.74&&t<.84&&(n=Jn(n,Math.max(0,n-.3),Mi((t-.74)/.1))),ya(n,0,1)}}const Vm={"spring|clear":{season:"spring",weather:"clear",sky:Ja(),cloudCover:jt(.1),particles:"none",lightning:!1,fogAlpha:0,ground:to},"spring|cloudy":{season:"spring",weather:"cloudy",sky:Ja(),cloudCover:jt(.5),particles:"none",lightning:!1,fogAlpha:0,ground:to},"spring|rain":{season:"spring",weather:"rain",sky:Ja(),cloudCover:jt(.85),particles:"rain",lightning:!1,fogAlpha:0,ground:to},"summer|clear":{season:"summer",weather:"clear",sky:ps(),cloudCover:jt(.1),particles:"none",lightning:!1,fogAlpha:0,ground:gs},"summer|cloudy":{season:"summer",weather:"cloudy",sky:ps(),cloudCover:jt(.5),particles:"none",lightning:!1,fogAlpha:0,ground:gs},"summer|rain":{season:"summer",weather:"rain",sky:ps(),cloudCover:jt(.85),particles:"rain",lightning:!1,fogAlpha:0,ground:gs},"summer|storm":{season:"summer",weather:"storm",sky:ps(),cloudCover:jt(1),particles:"rain",lightning:!0,fogAlpha:0,ground:gs},"autumn|clear":{season:"autumn",weather:"clear",sky:eo(),cloudCover:jt(.15),particles:"none",lightning:!1,fogAlpha:0,ground:no,sunTint:[255,180,110]},"autumn|cloudy":{season:"autumn",weather:"cloudy",sky:eo(),cloudCover:jt(.55),particles:"none",lightning:!1,fogAlpha:0,ground:no},"autumn|storm":{season:"autumn",weather:"storm",sky:eo(),cloudCover:jt(1),particles:"rain",lightning:!0,fogAlpha:0,ground:no},"winter|clear":{season:"winter",weather:"clear",sky:Vc(),cloudCover:jt(.2),particles:"none",lightning:!1,fogAlpha:0,ground:qc,sunTint:[220,230,245]},"winter|snow":{season:"winter",weather:"snow",sky:Vc(),cloudCover:jt(.9),particles:"snow",lightning:!1,fogAlpha:.2,ground:qc}},$c=Object.keys(Vm);function Uy(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 zy(e){const t=`${e??"none"}:${Math.floor(performance.now()/1e3)}`;return $c[Uy(t)%$c.length]}function Vy(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=Mi(ya((e-r.t)/(s.t-r.t||1),0,1));return{top:er(r.top,s.top,i),mid:er(r.mid,s.mid,i),hor:er(r.hor,s.hor,i)}}function qy(e,t,n,r,s){if(e<r||e>s)return null;const i=(e-r)/(s-r),a=Jn(.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 $y(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=Jn(.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 qm(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 Wc(e,t){const n=qm(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 Wy(){const e=qm(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 Yy(e,t,n,r){const s=e.createLinearGradient(0,0,0,r);s.addColorStop(0,Za(t.top)),s.addColorStop(.55,Za(t.mid)),s.addColorStop(1,Za(t.hor)),e.fillStyle=s,e.fillRect(0,0,n,r)}function Gy(e,t,n,r,s,i){let a=0;if(t<.22?a=Mi(1-t/.22):t>.8&&(a=Mi((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 Ky(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?er(n,[255,214,150],.5):[255,214,150];l.addColorStop(0,"rgba(255,252,238,1)"),l.addColorStop(.7,Mr(u,1)),l.addColorStop(1,Mr(c,.9)),e.fillStyle=l,e.beginPath(),e.arc(r,s,a,0,Math.PI*2),e.fill()}function Xy(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 Qy(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=Mr([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=Mr(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 Zy(e,t,n,r,s,i,a,o,l){const u=a(t);if(u<.02)return;const c=er(o.hor,[255,255,255],.35),h=er(o.mid,[20,20,30],.45),f=l?h:c;for(let d=0;d<n.length;d++){const m=n[d],g=(m.x+i*m.speed)%1.2-.1,b=m.y+Math.sin(i*1e-4+m.seed)*m.drift;d/n.length<u&&Qy(e,g*r,b*s,m.s,f,ya(u*.92,0,.92))}}const yr=[];let Wn=[];const ui=[];let Yn=[];const bs=[],Jr=[];let ci=[];function Jy(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))),h=n-r-a,f=(c+h)/2;e.save(),e.beginPath(),e.moveTo(l,c),e.bezierCurveTo(l,f,t-r*.3,h,t,h),e.bezierCurveTo(t+r*.3,h,u,f,u,c),e.quadraticCurveTo(t,n-r*.78,l,c),e.closePath();const d=e.createLinearGradient(0,h,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 ro(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 e2(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 t2(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 $m(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 n2(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 h=0;h<l;h++){const f=o.prog-o.len*(h/l),d=o.prog-o.len*((h+1)/l),m=ro(t,n,r,f,o.theta),g=ro(t,n,r,d,o.theta),b=(1-h/l)*.42;e.strokeStyle=`rgba(200,228,250,${b})`,e.lineWidth=o.thick*(1-h/l*.7),e.lineCap="round",e.beginPath(),e.moveTo(m.x,m.y),e.lineTo(g.x,g.y),e.stroke()}const u=ro(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 r2(e,t,n,r){for(;yr.length<t.length;)yr.push([]);for(;Wn.length<t.length;)Wn.push(0);for(;ci.length<t.length;)ci.push(.3);for(;ui.length<t.length;)ui.push([]);for(;Yn.length<t.length;)Yn.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,(ci[s]??.3)+8e-4);ci[s]=a,Jy(e,i.x,i.y,i.r,a)}else if(n.particles==="rain"){if(e2(e,i.x,i.y,i.r),Wn[s]=Wn[s]-1,Wn[s]<=0&&yr[s].length<3){const a=Math.random()<.5?-1:1;yr[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}),Wn[s]=40+Math.random()*60}if(n2(e,i.x,i.y,i.r,yr[s]),Yn[s]=Yn[s]-1,Yn[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 h=o<0?-1:1;ui[s].push({x:a,y:l,vx:h*(.5+Math.random()*2)*(Math.random()<.5?-1:1),vy:-(1.5+Math.random()*2.5),life:18+Math.floor(Math.random()*14)})}Yn[s]=30+Math.floor(Math.random()*50)}$m(e,ui[s])}}}function i2(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 s2(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 a2(e,t,n,r,s){const i=e.createLinearGradient(0,n*.4,0,n),a=er(s.hor,[255,255,255],.3);i.addColorStop(0,Mr(a,0)),i.addColorStop(1,Mr(a,r)),e.fillStyle=i,e.fillRect(0,n*.4,t,n*.6)}let pr=0,Yc=0;function o2(e,t,n,r,s){if(s>Yc&&(pr=1,Yc=s+1400+Math.random()*2600),pr*=.86,pr<.02){pr=0;return}if(e.fillStyle=`rgba(255,255,255,${pr*.5})`,e.fillRect(0,0,t,n),pr>.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 l2(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=Wc(1,1);const h=Wy();let f=[],d=[],m=0,g=0,b=!0;const y=performance.now(),w=window.matchMedia("(prefers-reduced-motion: reduce)").matches;function E(){const N=a.getBoundingClientRect();if(u=Math.min(window.devicePixelRatio||1,2),o=Math.max(1,N.width),l=Math.max(1,N.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=Wc(o,l),r.particles==="rain"&&f.length===0){const C=r.weather==="storm",D=C?140:70;for(let P=0;P<D;P++)f.push({x:Math.random(),y:Math.random(),len:C?12+Math.random()*14:6+Math.random()*8,v:C?.9+Math.random()*.4:.5+Math.random()*.3})}if(r.particles==="snow"&&d.length===0)for(let C=0;C<120;C++)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 S(){const N=t.scrollHeight-t.clientHeight;m=N>0?ya(t.scrollTop/N,0,1):0}function v(N){if(!b)return;const C=m,D=w?0:(N-y)/1e3,P=Vy(C,r.sky);Yy(i,P,o,l),Gy(i,C,c,o,l,D),Xy(i,$y(C,o,l,.92,.08)),Ky(i,qy(C,o,l,.16,.88),r.sunTint),Zy(i,C,h,o,l,N,r.cloudCover,P,r.weather==="storm"),r.particles==="rain"&&i2(i,o,l,f,r.weather==="storm"),r.particles==="snow"&&s2(i,o,l,d,N),r.fogAlpha>0&&a2(i,o,l,r.fogAlpha,P),r.lightning&&o2(i,o,l,!0,N),w||(g=requestAnimationFrame(v))}const T=()=>S(),_=new ResizeObserver(()=>{E(),S()});_.observe(a),E(),S();let A;if(w){let N=!1;A=()=>{S(),N||(N=!0,requestAnimationFrame(()=>{N=!1,v(performance.now())}))},t.addEventListener("scroll",A,{passive:!0}),v(performance.now())}else A=T,t.addEventListener("scroll",A,{passive:!0}),g=requestAnimationFrame(v);return()=>{b=!1,cancelAnimationFrame(g),_.disconnect(),t.removeEventListener("scroll",A)}}function u2(e,t,n,r,s,i){const a=()=>{yr.length=0,ci.length=0,Wn.length=0,ui.length=0,Yn.length=0,bs.length=0,Jr.length=0;const w=e.getContext("2d");w&&w.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,h=0,f=1,d=0,m=!0;function g(){const w=t.getBoundingClientRect();f=Math.min(window.devicePixelRatio||1,2),c=Math.max(1,w.width),h=Math.max(1,w.height),e.width=Math.floor(c*f),e.height=Math.floor(h*f),e.style.width=c+"px",e.style.height=h+"px",u.setTransform(f,0,0,f,0,0)}function b(w){if(!m)return;u.clearRect(0,0,c,h);const E=r();if(r2(u,E,n),s){for(const S of s()){const v=3+Math.min(5,Math.floor(S.speed/3));for(let T=0;T<v;T++)bs.push({x:S.x,y:S.y,vx:(Math.random()-.5)*3.2,vy:-(1.5+Math.random()*2.5),life:16+Math.floor(Math.random()*12)})}bs.length>0&&$m(u,bs)}if(i){for(const S of i()){const v=1+Math.min(2,Math.round(S.amount*40));for(let T=0;T<v;T++){const _=55+Math.floor(Math.random()*40);Jr.push({x:S.x+(Math.random()-.5)*8,y:S.y+(Math.random()-.5)*6,vx:S.vx*.6+(Math.random()-.5)*.8,vy:S.vy*.6-Math.random()*.5,life:_,maxLife:_,r:1.2+Math.random()*2.2})}}for(;Jr.length>240;)Jr.shift();t2(u,Jr)}d=requestAnimationFrame(b)}const y=new ResizeObserver(g);return y.observe(t),g(),d=requestAnimationFrame(b),()=>{m=!1,cancelAnimationFrame(d),y.disconnect(),a()}}const c2=k.lazy(()=>_e(()=>import("./CourseSearchPanel-CEECNtWD.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.CourseSearchPanel})));function d2(e){const t=$e(),[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=!Jl(),h=k.useRef([]),f=k.useRef(I=>{h.current.push(...I),h.current.length>64&&h.current.splice(0,h.current.length-64)}).current,d=k.useRef([]),m=k.useRef(new Map),g=k.useRef(I=>{d.current.push(...I),d.current.length>96&&d.current.splice(0,d.current.length-96)}).current,b=e.sections.filter(I=>(I.world??"study")===s),y=e.sections.some(I=>I.world==="practice"),[w,E]=k.useState(null);k.useEffect(()=>{E(zy(e.courseId))},[e.courseId]);const S=w?Vm[w]??null:null;k.useEffect(()=>(wc({nav:a.current,visible:n==="map",weather:(S==null?void 0:S.weather)??"clear"}),()=>{wc({visible:!1,nav:null})}),[n,S,a]);const[v,T]=k.useState(!1);k.useEffect(()=>{if(!e.selectedNodeId)return;const I=o.current;if(!I)return;const R=I.querySelector(`[data-node-id="${CSS.escape(e.selectedNodeId)}"]`);if(!R)return;const B=I.getBoundingClientRect(),V=R.getBoundingClientRect();(V.top<B.top+60||V.bottom>B.bottom-60)&&R.scrollIntoView({behavior:"smooth",block:"center"})},[e.selectedNodeId]);const _=k.useRef(null);k.useEffect(()=>{T(!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[A,N]=k.useState(null),[C,D]=k.useState(!1),P=k.useRef({}),O=k.useRef(null);return k.useEffect(()=>{var V,z;const I=P.current,R={};let B=null;for(const Y of e.tree){const L=((V=e.progressMap[Y.id])==null?void 0:V.status)??"locked";R[Y.id]=L,I[Y.id]==="locked"&&L!=="locked"&&!B&&(B=Y.id)}if(B&&Object.keys(I).length>0){const Y=(z=a.current)==null?void 0:z.querySelector(`[data-testid="map-node-${B.slice(0,8)}"], [data-testid="exam-node-${B.slice(0,8)}"]`),L=Y==null?void 0:Y.getBoundingClientRect(),q=!!L&&L.width>0&&L.left>=0&&L.right<=window.innerWidth&&L.top>=0;Ar("unlock",q?{origin:{x:L.left+L.width/2,y:L.top+4}}:void 0)}P.current=R},[e.tree,e.progressMap]),p.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:[S&&p.jsxs(p.Fragment,{children:[p.jsx(f2,{scrollRef:o,navRef:a,preset:S}),p.jsx(m2,{scrollRef:o,navRef:a,preset:S,getImpacts:()=>h.current.splice(0),getFlakes:()=>d.current.splice(0),orbSnowRef:m})]}),p.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:[p.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:[p.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:[p.jsx(wm,{className:"w-3 h-3"})," ",t("map.tab.map")]}),p.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:[p.jsx(Vi,{className:"w-3 h-3"})," ",t("map.tab.import")]})]}),n==="map"&&p.jsxs("div",{className:"relative 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:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[e.courseId&&e.courses.length>0?p.jsxs("button",{type:"button","data-testid":"map-course-switch",onClick:()=>D(I=>!I),"data-tooltip":t("map.course.switch"),className:"flex-1 min-w-0 flex items-center gap-1 text-left rounded-md px-1 -mx-1 py-0.5 hover:bg-white/10 motion-safe:transition-colors",children:[p.jsx("h2",{className:"text-body font-extrabold text-white truncate flex-1","data-tooltip":e.courseTitle??"",children:e.courseTitle??t("map.course.none")}),p.jsx(pa,{className:`w-3.5 h-3.5 shrink-0 text-white/50 motion-safe:transition-transform ${C?"rotate-180":""}`})]}):p.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&&p.jsx(v2,{available:e.availableLanguages,current:e.currentLocale,onChange:e.onLocaleChange}),e.courseId&&p.jsx("button",{onClick:I=>{const R=I.currentTarget.getBoundingClientRect();N({id:e.courseId,title:e.courseTitle??"",rect:R})},"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:p.jsx(Nm,{className:"w-3 h-3"})})]}),C&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"fixed inset-0 z-40","data-noswipe":"",onClick:()=>D(!1)}),p.jsx("div",{className:"absolute left-3 right-3 top-full mt-1 z-50 rounded-lg border border-white/10 bg-[#141a26]/95 backdrop-blur-xl shadow-elevated overflow-hidden","data-testid":"map-course-menu",children:e.courses.map(I=>{const R=I.id===e.courseId;return p.jsxs("button",{type:"button","data-testid":`map-course-option-${I.id}`,onClick:()=>{e.onSelectCourse(I.id),D(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-left text-label transition-colors ${R?"text-brand bg-brand/10 font-bold":"text-white/80 hover:bg-white/10"}`,children:[p.jsx("span",{className:"flex-1 truncate",children:I.title}),R&&p.jsx(xn,{className:"w-3.5 h-3.5 shrink-0"})]},I.id)})})]}),p.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[p.jsx("div",{className:"flex-1 h-2.5 bg-black/40 rounded-full overflow-hidden ring-1 ring-white/10",children:p.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${l>=100?"bg-gold":"bg-brand"}`,style:{width:`${Math.max(3,l)}%`}})}),p.jsxs("span",{className:"text-label font-extrabold tabular-nums text-white drop-shadow-[0_1px_3px_rgba(0,0,0,0.6)]",children:[l,"%"]})]}),p.jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-1.5 text-caption",children:[p.jsxs("button",{onClick:()=>T(!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:[p.jsx(ey,{className:"w-3 h-3 text-white/50"}),p.jsx("span",{className:"font-bold text-white/60",children:t("map.search.label")})]}),p.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:[p.jsx(Jt,{className:`w-3 h-3 ${e.dueCount>0?"text-review":"text-white/50"}`}),p.jsx("span",{className:`font-bold ${e.dueCount>0?"text-review":"text-white/60"}`,children:t("map.review.label")}),e.dueCount>0&&p.jsx("span",{className:"font-extrabold text-review tabular-nums",children:e.dueCount})]})]}),y&&p.jsxs("div",{className:"flex gap-1 mt-1.5 p-0.5 rounded-lg bg-black/30",children:[p.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:[p.jsx(Jt,{className:"w-3 h-3"})," ",t("map.world.study")]}),p.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:[p.jsx(Mm,{className:"w-3 h-3"})," ",t("map.world.practice")]})]})]})]}),p.jsx("div",{className:"absolute inset-0 overflow-hidden z-10",children:p.jsxs("div",{className:"flex h-full transition-transform duration-300",style:{transform:n==="map"?"translateX(0)":"translateX(-50%)",width:"200%"},children:[p.jsx("div",{className:"w-1/2 h-full relative",children:p.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:I=>{O.current={x:I.clientX,y:I.clientY}},onClick:I=>{const R=O.current;O.current=null,!(!R||Math.hypot(I.clientX-R.x,I.clientY-R.y)>6)&&(I.target.closest("button, a, input, textarea, select")||Qo(I.clientX,I.clientY))},children:p.jsxs("div",{className:`map-sky-content ${S?`env-${S.season} env-${S.weather}`:""}`,children:[e.streaming&&p.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:[p.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?p.jsxs("div",{className:"text-center text-label text-white/60 mt-8 px-4 flex items-center justify-center gap-2",children:[p.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),t("map.generating")]}):p.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:[p.jsx("div",{className:"text-3xl mb-2 group-hover:scale-110 transition-transform",children:"🗺️"}),p.jsx("div",{className:"text-body font-bold text-white/90 mb-1",children:t("map.empty.cta.title")}),p.jsx("div",{className:"text-label text-white/60 leading-relaxed",children:t("map.empty.cta.desc")}),p.jsx("div",{className:"mt-2 text-caption text-brand font-bold",children:t("map.empty.cta.btn")})]}):b.length===0?p.jsx("div",{className:"text-center text-label text-white/60 mt-8 px-4",children:t(s==="practice"?"map.empty.practice":"map.generating")}):p.jsx("div",{className:"space-y-6 pt-2",children:b.map((I,R)=>p.jsx(p2,{section:I,sectionIndex:R,tree:e.tree,progressMap:e.progressMap,selectedNodeId:e.selectedNodeId,dueNodeIds:e.dueNodeIds,streamingNodeIds:e.streamingNodeIds,onJumpNode:e.onJumpNode,nextCueNodeId:e.nextCueNodeId,physics:c,physicsWeather:(S==null?void 0:S.weather)??"clear",scrollRef:o,navRef:a,onImpacts:f,onFlakes:g,orbSnowRef:m},I.id))})]})})}),p.jsx("div",{className:"w-1/2 h-full overflow-y-auto px-3 pt-20 pb-3 space-y-2.5",children:p.jsx(h2,{courses:e.courses,selectedCourseId:e.courseId,onSelectCourse:I=>{e.onSelectCourse(I),r("map")},onDeleteCourse:(I,R,B)=>N({id:I,title:R,rect:B}),onCoursesChanged:e.onCoursesChanged})})]})}),v&&e.courseId&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(c2,{sections:e.sections,tree:e.tree,progressMap:e.progressMap,selectedNodeId:e.selectedNodeId,onJump:I=>{i(I.world??"study"),T(!1),Zo(null,null,I.id),e.onJumpNode(I.id)},onClose:()=>T(!1)})}),A&&p.jsx(Fm,{anchorRect:A.rect,message:`${A.title} — ${t("import.delete.confirm")}`,danger:!0,confirmLabel:t("import.delete"),testid:"course-delete-confirm",onConfirm:()=>{e.onDeleteCourse(A.id),N(null)},onCancel:()=>N(null)})]})}function h2({courses:e,selectedCourseId:t,onSelectCourse:n,onDeleteCourse:r,onCoursesChanged:s}){const i=$e(),[a,o]=k.useState("url"),[l,u]=k.useState(!1),[c,h]=k.useState(""),[f,d]=k.useState(""),m=k.useRef(null),g=k.useRef(null),b=k.useRef(null),[y,w]=k.useState(""),[E,S]=k.useState(""),[v,T]=k.useState(!1),[_,A]=k.useState(null),[N,C]=k.useState(null),[D,P]=k.useState(null),[O,I]=k.useState(null),[R,B]=k.useState([]),[,V]=k.useState(0),z=k.useRef(null);k.useEffect(()=>{const Z=se.on("import:progress",be=>{B(ve=>{const Fe=/\d+\/\d+/.test(be),je=ve[ve.length-1];if(Fe&&je&&je.status==="working"){const Oe=[...ve];return Oe[Oe.length-1]={...je,msg:be},Oe}const Se=ve.map(Oe=>Oe.status==="working"?{...Oe,status:"done"}:Oe);return Se.push({msg:be,status:"working",ts:Date.now()}),Se})}),re=setInterval(()=>V(be=>be+1),1e3);return()=>{Z(),clearInterval(re)}},[]),k.useEffect(()=>se.on("import:done",re=>{T(!1),Bt(!1),re.cancelled||Hb(re.ok),P(re.ok?null:re.planId??null),re.ok?(C(`${i("import.success.folder")}: ${re.title??""}${re.reused?`(${i("import.success.reused")})`:""}`),I(re.courseId?{courseId:re.courseId,packable:re.packable??!1}:null),s()):re.cancelled?(B([]),A(null),C(i("import.cancelled"))):A(re.error??"导入失败")}),[s,i]),k.useEffect(()=>{const Z=z.current;Z&&(Z.scrollTop=Z.scrollHeight)},[R]);const Y=async()=>{if(!(!c.trim()||v)){A(null),C(null),B([]);try{await se.importUrl(c.trim()),T(!0),Bt(!0)}catch(Z){A(Z instanceof Error?Z.message:String(Z))}}},L=async()=>{if(!(!y.trim()||v)){A(null),C(null),B([]);try{await se.importText({name:E.trim()||void 0,text:y.trim()}),T(!0),Bt(!0)}catch(Z){A(Z instanceof Error?Z.message:String(Z))}}},q=async()=>{var re;if(v)return;if(A(null),C(null),B([]),!fn){(re=g.current)==null||re.click();return}await se.importEpub().catch(be=>(A(be instanceof Error?be.message:String(be)),null))&&(T(!0),Bt(!0))},K=async Z=>{if(!(!Z||v)){A(null),C(null),B([]);try{const re=new Uint8Array(await Z.arrayBuffer());let be="";for(let Fe=0;Fe<re.length;Fe+=32768)be+=String.fromCharCode(...re.subarray(Fe,Fe+32768));await se.importEpub({fileName:Z.name,contentBase64:btoa(be)})&&T(!0),Bt(!0)}catch(re){A(re instanceof Error?re.message:String(re))}}},M=async()=>{if(v)return;if(A(null),C(null),B([]),!fn){const re=f.trim();if(!re){A(i("import.folder.pathRequired"));return}try{await se.importLocalFolder(re)&&T(!0),Bt(!0)}catch(be){A(be instanceof Error?be.message:String(be))}return}await se.importLocalFolder()&&(T(!0),Bt(!0))},G=async()=>{var re;if(v)return;if(A(null),C(null),B([]),!fn){(re=m.current)==null||re.click();return}await se.importPack().catch(be=>(A(be instanceof Error?be.message:String(be)),null))&&(T(!0),Bt(!0))},ae=async Z=>{if(!(!Z||v)){A(null),C(null),B([]);try{const re=await Z.text();await se.importPack({fileName:Z.name,content:re})&&T(!0),Bt(!0)}catch(re){A(re instanceof Error?re.message:String(re))}}},ne=async()=>{var re;if(v)return;if(A(null),C(null),B([]),!fn){(re=b.current)==null||re.click();return}await se.importAudio().catch(be=>(A(be instanceof Error?be.message:String(be)),null))&&(T(!0),Bt(!0))},X=async Z=>{if(!(!Z||Z.length===0||v)){A(null),C(null),B([]);try{const re=[];for(const ve of Array.from(Z)){const Fe=new Uint8Array(await ve.arrayBuffer());let je="";for(let Se=0;Se<Fe.length;Se+=32768)je+=String.fromCharCode(...Fe.subarray(Se,Se+32768));re.push({fileName:ve.name,contentBase64:btoa(je)})}await se.importAudio(re)&&T(!0),Bt(!0)}catch(re){A(re instanceof Error?re.message:String(re))}}},te=async Z=>{if(!v){A(null),B([]);try{await se.importResume(Z),T(!0),Bt(!0)}catch(re){A(re instanceof Error?re.message:String(re))}}},ue=async Z=>{try{const re=await se.exportPack(Z);re!=null&&re.content&&re.fileName?(ge(re.fileName,re.content),C(i("import.pack.exported",{path:re.fileName}))):re!=null&&re.path&&C(i("import.pack.exported",{path:re.path}))}catch(re){A(re instanceof Error?re.message:String(re))}},ge=(Z,re)=>{const be=new Blob([re],{type:"application/json"}),ve=URL.createObjectURL(be),Fe=document.createElement("a");Fe.href=ve,Fe.download=Z,Fe.click(),setTimeout(()=>URL.revokeObjectURL(ve),5e3)};return p.jsxs(p.Fragment,{children:[e.length===0?p.jsxs("div",{className:"text-center py-10",children:[p.jsx("div",{className:"text-3xl mb-2 opacity-30",children:"📚"}),p.jsx("p",{className:"text-label text-white/45 leading-relaxed",children:i("import.empty")})]}):p.jsx("div",{className:"space-y-2","data-testid":"course-list",children:e.map(Z=>{const re=Z.id===t;return p.jsxs("div",{"data-testid":"course-row",className:`relative rounded-xl transition-all duration-150 group ${re?"bg-brand/12 ring-1 ring-brand/40":"bg-white/5 hover:bg-white/10 hover:-translate-y-0.5"}`,children:[p.jsx("button",{onClick:()=>n(Z.id),className:"w-full text-left p-3",children:p.jsxs("div",{className:"flex items-start justify-between gap-2",children:[p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:`text-body font-bold truncate ${re?"text-brand":"text-white/90"}`,children:Z.title}),p.jsx("div",{className:"text-caption text-white/40 truncate mt-0.5",children:Z.repoName})]}),re&&p.jsx("span",{className:"shrink-0 w-5 h-5 rounded-full bg-brand flex items-center justify-center",children:p.jsx(xn,{className:"w-3 h-3 text-white"})})]})}),p.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:[p.jsxs("button",{onClick:be=>{be.stopPropagation(),A(null),C(null),se.exportPack(Z.id).then(ve=>{ve!=null&&ve.content&&ve.fileName?(ge(ve.fileName,ve.content),C(i("import.pack.exported",{path:ve.fileName}))):ve!=null&&ve.path&&C(i("import.pack.exported",{path:ve.path}))}).catch(ve=>{A(ve instanceof Error?ve.message:String(ve))})},"data-testid":"course-row-export",className:"text-caption text-white/40 hover:text-brand flex items-center gap-0.5",children:[p.jsx(Dc,{className:"w-2.5 h-2.5"})," ",i("import.export")]}),p.jsxs("button",{onClick:be=>{be.stopPropagation();const ve=be.currentTarget.getBoundingClientRect();r(Z.id,Z.title,ve)},"data-testid":"course-row-delete",className:"text-caption text-white/40 hover:text-warning flex items-center gap-0.5",children:[p.jsx(Nm,{className:"w-2.5 h-2.5"})," ",i("import.delete")]})]})]},Z.id)})}),p.jsxs("div",{className:e.length>0?"mt-6":"",children:[p.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:[p.jsx(Cm,{className:`w-4 h-4 transition-transform ${l?"rotate-45":""}`})," ",i("import.cta")]}),l&&p.jsxs("div",{className:"mt-3 space-y-3",children:[v?p.jsxs("div",{className:"rounded-xl bg-black/30 border border-brand/30 p-4","data-testid":"import-progress",children:[p.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[p.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin shrink-0"}),p.jsx("span",{className:"text-body font-bold text-white/90",children:i("import.progress.title")}),p.jsx("button",{onClick:()=>{se.importCancel()},"data-testid":"import-cancel-btn",className:"ml-auto text-caption text-white/50 hover:text-warning transition-colors",children:i("import.progress.cancel")})]}),p.jsx("div",{className:"text-caption text-white/40 mb-2.5",children:i("import.progress.note")}),(a==="url"?c.trim():a==="markdown"&&E.trim())?p.jsx("div",{className:"text-caption text-white/40 font-mono truncate mb-2.5",children:a==="url"?c.trim():E.trim()}):null,p.jsx("div",{ref:z,className:"space-y-1.5 max-h-[40vh] overflow-y-auto pr-1",children:R.length===0?p.jsx("div",{className:"text-caption text-white/50 py-1",children:i("import.progress.starting")}):R.map((Z,re)=>p.jsxs("div",{className:"flex items-start gap-1.5 text-caption",children:[Z.status==="done"?p.jsx(xn,{className:"w-3 h-3 text-brand shrink-0 mt-px"}):p.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"}),p.jsxs("span",{className:Z.status==="done"?"text-white/40":"text-white/90",children:[Z.msg,Z.status==="working"&&p.jsxs("span",{className:"text-white/35 ml-1",children:["(",i("import.progress.elapsed",{s:Math.floor((Date.now()-Z.ts)/1e3)}),")"]})]})]},re))})]}):p.jsxs(p.Fragment,{children:[p.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:Ux},{k:"markdown",label:i("import.tab.md"),icon:Vi},{k:"folder",label:i("import.tab.folder"),icon:Px},{k:"epub",label:i("import.tab.epub"),icon:Jt},{k:"audio",label:i("import.tab.audio"),icon:Ms},{k:"pack",label:i("import.tab.pack"),icon:Dc}].map(({k:Z,label:re,icon:be})=>p.jsxs("button",{onClick:()=>o(Z),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===Z?"bg-brand/15 text-brand":"text-white/50 hover:text-white/80"}`,children:[p.jsx(be,{className:"w-3 h-3 shrink-0"}),p.jsx("span",{className:"whitespace-nowrap",style:{fontSize:"clamp(0.75rem, 4cqi, 0.875rem)"},children:re})]},Z))}),a==="url"?p.jsxs("section",{className:"space-y-2","data-testid":"import-url-section",children:[p.jsx("input",{type:"text",value:c,onChange:Z=>h(Z.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"}),p.jsx("p",{className:"text-caption text-white/45 leading-relaxed",children:i("import.url.desc")}),p.jsx("button",{onClick:Y,disabled:!c.trim()||v,"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"?p.jsxs("section",{className:"space-y-2","data-testid":"import-md-section",children:[p.jsx("input",{type:"text",value:E,onChange:Z=>S(Z.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"}),p.jsx("textarea",{value:y,onChange:Z=>w(Z.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"}),p.jsx("button",{onClick:L,disabled:!y.trim()||v,"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"?p.jsxs("section",{className:"space-y-2","data-testid":"import-folder-section",children:[p.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.folder.desc")}),!fn&&p.jsx("input",{type:"text",value:f,onChange:Z=>d(Z.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"}),p.jsx("button",{onClick:M,disabled:v||!fn&&!f.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"?p.jsxs("section",{className:"space-y-2","data-testid":"import-epub-section",children:[p.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.epub.desc")}),!fn&&p.jsx("input",{ref:g,type:"file",accept:".epub,application/epub+zip",className:"hidden","data-testid":"import-epub-file",onChange:Z=>{var re;K((re=Z.target.files)==null?void 0:re[0]),Z.currentTarget.value=""}}),p.jsx("button",{onClick:q,disabled:v,"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"?p.jsxs("section",{className:"space-y-2","data-testid":"import-audio-section",children:[p.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.audio.desc")}),!fn&&p.jsx("input",{ref:b,type:"file",multiple:!0,accept:".wav,.mp3,.m4a,.flac,.aac,.ogg,.opus,audio/*",className:"hidden","data-testid":"import-audio-file",onChange:Z=>{X(Z.target.files),Z.currentTarget.value=""}}),p.jsx("button",{onClick:ne,disabled:v,"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")})]}):p.jsxs("section",{className:"space-y-2","data-testid":"import-pack-section",children:[p.jsx("p",{className:"text-caption text-white/50 leading-relaxed",children:i("import.pack.desc")}),!fn&&p.jsx("input",{ref:m,type:"file",accept:".json,application/json",className:"hidden","data-testid":"import-pack-file",onChange:Z=>{var re;ae((re=Z.target.files)==null?void 0:re[0]),Z.currentTarget.value=""}}),p.jsx("button",{onClick:G,disabled:v,"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")})]})]}),_&&p.jsxs("div",{className:"border border-warning/40 text-warning-light text-label rounded-lg p-2 whitespace-pre-wrap","data-testid":"import-error",children:[_,D&&p.jsx("button",{onClick:()=>void te(D),disabled:v,"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")})]}),N&&p.jsxs("div",{className:"border border-brand/30 text-brand text-label rounded-lg p-2","data-testid":"import-success",children:[p.jsx(xn,{className:"inline-block w-3.5 h-3.5 mr-1 align-[-3px]"}),N,(O==null?void 0:O.packable)&&p.jsx("button",{onClick:()=>void ue(O.courseId),disabled:v,"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 f2({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:l2(s,i,a,n)},[e,t,n]),p.jsx("canvas",{ref:r,className:"map-sky-canvas","aria-hidden":"true"})}function m2({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,h=null;const f=()=>{c=null,h=null},d=new MutationObserver(f);d.observe(u,{childList:!0,subtree:!0}),window.addEventListener("resize",f);const g=u2(o,l,n,()=>{var w,E;c||(c=Array.from(u.querySelectorAll(".lesson-bubble")));const b=h??l.getBoundingClientRect();h=b;const y=[];for(const S of c){const v=S.getBoundingClientRect();if(v.bottom<b.top||v.top>b.bottom)continue;const T=(w=S.closest("[data-node-id]"))==null?void 0:w.getAttribute("data-node-id"),_=T?(E=i==null?void 0:i.current)==null?void 0:E.get(T):void 0;y.push({x:v.left-b.left+v.width/2,y:v.top-b.top+v.height/2,r:v.width/2,..._!==void 0?{snow:_}:{}})}return y},r,s);return()=>{g(),d.disconnect(),window.removeEventListener("resize",f)}},[e,t,n,r,s]),p.jsx("canvas",{ref:a,className:"map-orb-weather-canvas","aria-hidden":"true"})}function p2({section:e,sectionIndex:t,tree:n,progressMap:r,selectedNodeId:s,nextCueNodeId:i,dueNodeIds:a,streamingNodeIds:o,onJumpNode:l,physics:u,physicsWeather:c,scrollRef:h,navRef:f,onImpacts:d,onFlakes:m,orbSnowRef:g}){const b=n.filter(X=>X.parentId===e.id).sort((X,te)=>X.orderIdx-te.orderIdx),y=b.filter(X=>X.type==="lesson"),w=y.length>0&&y.every(X=>{var te;return(((te=r[X.id])==null?void 0:te.mastery)??0)>=hy}),E=k.useRef(null),[S,v]=k.useState(268);k.useEffect(()=>{if(!E.current)return;const X=()=>{var ge;const ue=((ge=E.current)==null?void 0:ge.clientWidth)??268;v(ue>0?ue:268)};X();const te=new ResizeObserver(X);return te.observe(E.current),()=>te.disconnect()},[]);const T=Ty(b.length,S,e.id),_=T.height,A=110,N=76,C=k.useRef(null),D=k.useRef(new Map),P=k.useRef(0),O=k.useRef(null),I=k.useRef(0),R=b.map(X=>X.id).join(","),B=b.map(X=>{var te;return(X.type==="exam"?!w:(((te=r[X.id])==null?void 0:te.status)??"locked")==="locked")?1:0}).join("");k.useEffect(()=>{var Be,Q;if(!u||b.length===0||S<=0)return;const X=E.current,te=h.current;if(!X||!te)return;let ue;const ge=b[b.length-1];if((ge==null?void 0:ge.type)==="exam"){const ee=(Q=(Be=X.closest("section"))==null?void 0:Be.nextElementSibling)==null?void 0:Q.querySelector(".map-signpost");ee&&(ue={x:ms(`${e.id}:next`,S),y:ee.getBoundingClientRect().top-X.getBoundingClientRect().top})}const Z=jy({nodes:T.nodes.map((ee,he)=>{const Te=b[he];return{id:Te.id,x:ee.x,y:ee.y,isExam:Te.type==="exam",locked:V(Te),spawn:(()=>{const Re=D.current.get(Te.id);return Re?Hy(Re,P.current,S):void 0})()}}),width:S,height:T.height+40,weather:c,anchorKnotX:ms(`${e.id}:knot`,S),nextKnot:ue});C.current=Z,Bb(e.id,Z,X);const re=X.querySelector("[data-next-knot]");re&&(Z.nextKnot?(re.setAttribute("cx",String(Z.nextKnot.x)),re.setAttribute("cy",String(Z.nextKnot.y))):re.setAttribute("opacity","0"));const be=X.querySelector("[data-exam-rope]");be&&!Z.nextKnot&&be.setAttribute("opacity","0");const ve=new Map;for(const ee of X.querySelectorAll("[data-node-id]"))ee.dataset.nodeId&&ve.set(ee.dataset.nodeId,ee);const Fe=Array.from(X.querySelectorAll("[data-rope]")),je=Array.from(X.querySelectorAll("[data-pulse]")),Se=Array.from(X.querySelectorAll("[data-field]"));let Oe=!0;const st=new IntersectionObserver(ee=>{for(const he of ee)Oe=he.isIntersecting},{root:te,rootMargin:"200px 0px 200px 0px"});st.observe(X);const pt=520,me=[];let rt=0,ie=performance.now();const Ie=ee=>{var dt;rt=requestAnimationFrame(Ie);const he=Math.min(50,ee-ie);if(ie=ee,!Oe)return;Z.step(he);for(const xe of Z.balls){const De=ve.get(xe.nodeId);De&&(De.style.transform=My(xe.body.position.x-xe.layoutX,xe.body.position.y-xe.layoutY,xe.squash,xe.squashAngle)),xe.squash=Ry(xe.squash,he),(dt=g.current)==null||dt.set(xe.nodeId,xe.snow)}const Te=xe=>{if(xe==="__anchor")return Z.anchor;if(xe==="__next")return Z.nextKnot??Z.anchor;const De=Z.ball(xe);if(De)return{x:De.body.position.x,y:De.body.position.y+Ht*gn};const Ve=b.findIndex(We=>We.id===xe),pe=Ve>=0?T.nodes[Ve]:void 0;return pe?{x:pe.x,y:pe.y+Ht*gn}:{x:0,y:0}};for(let xe=0;xe<Z.links.length&&xe<Fe.length;xe++){const De=Z.links[xe],Ve=[Te(De.from)];for(const pe of De.particles)Ve.push({x:pe.position.x,y:pe.position.y});Ve.push(Te(De.to)),Fe[xe].setAttribute("d",Iy(Ve))}for(let xe=0;xe<Z.balls.length&&xe<Se.length;xe++){const De=Z.balls[xe],Ve=Se[xe];De.field>.03?(Ve.setAttribute("cx",String(De.body.position.x)),Ve.setAttribute("cy",String(De.body.position.y)),Ve.setAttribute("r",String(Ht+4+De.field*5)),Ve.setAttribute("opacity",String((.3*De.field).toFixed(3)))):Ve.setAttribute("opacity","0")}const Re=Z.drainImpacts();for(const xe of Re)me.push({x:xe.x,y:xe.y,t0:ee,s:Math.min(1,xe.speed/14)});for(let xe=me.length-1;xe>=0;xe--)ee-me[xe].t0>pt&&me.splice(xe,1);for(let xe=0;xe<je.length;xe++){const De=me[xe],Ve=je[xe];if(!De){Ve.setAttribute("opacity","0");continue}const pe=(ee-De.t0)/pt;Ve.setAttribute("cx",String(De.x)),Ve.setAttribute("cy",String(De.y)),Ve.setAttribute("r",String(6+pe*(14+De.s*14))),Ve.setAttribute("opacity",String(.55*(1-pe))),Ve.setAttribute("stroke-width",String(2+De.s*1.5))}const Ze=Z.drainFlakes();if((Re.length>0||Ze.length>0)&&f.current){const xe=X.getBoundingClientRect(),De=f.current.getBoundingClientRect(),Ve=pe=>({x:pe.x+xe.left-De.left,y:pe.y+xe.top-De.top});Re.length>0&&d(Re.map(pe=>({...Ve(pe),speed:pe.speed}))),Ze.length>0&&m(Ze.map(pe=>({...Ve(pe),vx:pe.vx,vy:pe.vy,amount:pe.amount})))}};return rt=requestAnimationFrame(Ie),()=>{cancelAnimationFrame(rt),st.disconnect();for(const ee of Z.balls)D.current.set(ee.nodeId,{x:ee.body.position.x,y:ee.body.position.y,vx:ee.body.velocity.x,vy:ee.body.velocity.y});P.current=S,jb(e.id),Z.dispose(),C.current=null;for(const ee of ve.values())ee.style.transform=""}},[u,S,R,B,e.id,c]);const V=X=>{var te;return X?X.type==="exam"?!w:(((te=r[X.id])==null?void 0:te.status)??"locked")==="locked":!0},z=(X,te)=>{if(!(!C.current||X.button!==0||V(b.find(Z=>Z.id===te))||!E.current)){try{X.currentTarget.setPointerCapture(X.pointerId)}catch{}I.current=0,O.current={track:{startX:X.clientX,startY:X.clientY},id:X.pointerId,dragging:!1,nodeId:te}}},Y=X=>{const te=O.current,ue=C.current;if(!te||!ue||X.pointerId!==te.id)return;const ge=E.current;if(!ge||(!te.dragging&&Uc(te.track,X.clientX,X.clientY)==="drag"&&(te.dragging=!0,X.currentTarget.style.zIndex="40",ue.beginDrag(te.nodeId,X.clientX-ge.getBoundingClientRect().left,X.clientY-ge.getBoundingClientRect().top)),!te.dragging))return;const Z=ge.getBoundingClientRect();ue.moveDrag(X.clientX-Z.left,X.clientY-Z.top)},L=X=>{var ue;const te=O.current;if(!(!te||X.pointerId!==te.id)){if((ue=C.current)==null||ue.endDrag(),X.currentTarget.style.zIndex="",Uc(te.track,X.clientX,X.clientY)==="drag")I.current=Date.now()+300;else{const ge=b.find(Z=>Z.id===te.nodeId);ge&&Date.now()>=I.current&&!V(ge)&&(Zo(X.clientX,X.clientY,ge.id),l(ge.id))}O.current=null}},q=X=>{const te=b[X],ue=te?r[te.id]:void 0,ge=(ue==null?void 0:ue.status)==="mastered"||(ue==null?void 0:ue.status)==="in_progress"||(ue==null?void 0:ue.status)==="available";return{stroke:ge?"var(--brand)":"var(--ink-faint)",strokeWidth:ge?4:2.5,strokeOpacity:ge?.6:.5,strokeDasharray:ge?"none":"3 7"}},K=T.nodes[0]?{x:ms(`${e.id}:knot`,S),y:Qs}:{x:S/2,y:Qs},M=b[b.length-1],G=(M==null?void 0:M.type)==="exam",ae=T.nodes[T.nodes.length-1],ne=G&&ae?{x:ms(`${e.id}:next`,S),y:_+24}:void 0;return p.jsxs("section",{"data-testid":`map-section-${e.id.slice(0,8)}`,className:"py-3 px-2",children:[p.jsxs("div",{className:"map-signpost flex items-center gap-2 mb-3 px-2.5 py-1.5 rounded-lg shadow-sm",children:[p.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}),p.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})]}),p.jsxs("div",{ref:E,className:"relative",style:{minHeight:_},children:[p.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true",style:{height:_,overflow:"visible"},children:u?p.jsxs(p.Fragment,{children:[T.nodes[0]&&p.jsx("circle",{cx:K.x,cy:K.y,r:3.5,fill:"#ffc800",opacity:.9}),T.nodes[0]&&p.jsx("path",{"data-rope":0,d:`M ${K.x} ${K.y} L ${T.nodes[0].x} ${T.nodes[0].y+Ht*gn}`,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",style:q(0)}),T.segments.map((X,te)=>p.jsx("path",{"data-rope":te+1,d:`M ${X.from.x} ${X.from.y+Ht*gn} L ${X.to.x} ${X.to.y+Ht*gn}`,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",style:q(X.index)},X.index)),ne&&ae&&p.jsxs(p.Fragment,{children:[p.jsx("path",{"data-rope":T.segments.length+1,"data-exam-rope":!0,d:`M ${ne.x} ${ne.y} L ${ae.x} ${ae.y+Ht*gn}`,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",style:q(b.length-1)}),p.jsx("circle",{"data-next-knot":!0,cx:ne.x,cy:ne.y,r:3.5,fill:"#ffc800",opacity:.9})]}),Array.from({length:8},(X,te)=>p.jsx("circle",{"data-pulse":te,cx:0,cy:0,r:0,fill:"none",stroke:"white",opacity:0},te)),b.map((X,te)=>p.jsx("circle",{"data-field":te,cx:0,cy:0,r:0,fill:"none",stroke:"#1cb0f6",strokeWidth:2,opacity:0},`f-${X.id}`))]}):T.segments.map(X=>{const te=g2(b[X.index],r);return p.jsx("path",{d:wy(X),stroke:te?"var(--brand)":"var(--ink-faint)",strokeWidth:te?4:2.5,strokeOpacity:te?.6:.5,fill:"none",strokeLinecap:"round",strokeDasharray:te?"none":"3 7",style:te?{pathLength:1,animation:"path-draw 600ms var(--ease-out-expo)"}:void 0},X.index)})}),b.map((X,te)=>{const ue=T.nodes[te];if(!ue)return null;const ge=nl(X.id),Z=`${ge%40/10}s`,re=`${5+ge%30/10}s`;return p.jsx("div",{"data-node-id":X.id,"data-noswipe":"",className:u?`absolute hover:z-30 will-change-transform ${V(X)?"cursor-not-allowed":"cursor-grab active:cursor-grabbing"}`:"absolute balloon-bob hover:z-30",style:{left:ue.x-A/2,top:ue.y-N/2+10,width:A,...u?{touchAction:"pan-y"}:{"--bob-delay":Z,"--bob-duration":re}},onPointerDown:u?be=>z(be,X.id):void 0,onPointerMove:u?Y:void 0,onPointerUp:u?L:void 0,onPointerCancel:u?L:void 0,children:p.jsx(b2,{lesson:X,progress:r[X.id],isSelected:X.id===s,isNextCue:X.id===i,isDue:a.has(X.id),isStreaming:o.includes(X.id),chapterLessonsMastered:w,onClick:()=>{Date.now()<I.current||(Zo(null,null,X.id),l(X.id))}})},X.id)})]})]})}function g2(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 b2({lesson:e,progress:t,isSelected:n,isNextCue:r,isDue:s,isStreaming:i,chapterLessonsMastered:a,onClick:o}){const l=$e(),u=(t==null?void 0:t.status)??"locked",c=(t==null?void 0:t.crownLevel)??0,h=e.type==="exam",f=Math.min(3,c),d=h?!a:u==="locked",m=h&&d,g=!h&&(u==="in_progress"||u==="mastered"),b=u==="mastered"?100:u==="in_progress"?Math.round(((t==null?void 0:t.mastery)??0)*100):0;return p.jsxs("div",{className:"group relative flex flex-col items-center w-full",children:[p.jsxs("button",{onClick:()=>!d&&o(),disabled:d,"data-testid":`${h?"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 ${h?m?"lesson-bubble exam-bubble-locked":y2(c>0):x2(u)} ${d?"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":""} ${r?"next-cue":""}`,title:void 0,"data-tooltip":m?`🔒 ${e.title}${l("node.locked.chapterHint")}`:h?`🎯 ${e.title}`:d?`🔒 ${e.title}`:s?`📖 ${e.title}${l("node.due.hint")}`:e.title,children:[i&&p.jsx(Tm,{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":l("thread.streamingBadge"),"data-testid":`node-streaming-${e.id.slice(0,8)}`}),g&&p.jsxs("svg",{className:"absolute inset-0 w-full h-full -rotate-90 pointer-events-none",viewBox:"0 0 56 56","aria-hidden":"true",children:[p.jsx("circle",{cx:"28",cy:"28",r:"25",fill:"none",stroke:"rgb(255 255 255 / 0.2)",strokeWidth:"2.5"}),p.jsx("circle",{cx:"28",cy:"28",r:"25",fill:"none",stroke:u==="mastered"?"#ffc800":"white",strokeWidth:"2.5",strokeLinecap:"round",strokeDasharray:`${b/100*157} 157`,className:"transition-all duration-500"})]}),h?m?p.jsx("span",{"aria-label":"exam-locked",className:"relative z-10 opacity-60",children:"🔒"}):p.jsx(ay,{"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}):d?p.jsx("span",{"aria-label":"locked",className:"relative z-10 opacity-50",children:"🔒"}):u==="mastered"?p.jsx("span",{"aria-label":"mastered",className:"relative z-10 drop-shadow-lg crown-sparkle",children:"👑"}):u==="in_progress"?p.jsx(Jt,{"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}):p.jsx("span",{"aria-label":"available",className:"relative z-10 drop-shadow",children:"⭐"}),s&&!d&&!h&&p.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:"!"})]}),h&&p.jsx("div",{className:"flex gap-0.5 mt-1","data-testid":`map-stars-${e.id.slice(0,8)}`,children:[0,1,2].map(y=>p.jsx("span",{className:`text-caption ${y<f?"text-gold":"text-white/25"}`,children:"★"},y))}),n&&p.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 x2(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 y2(e){return e?"lesson-bubble exam-bubble-passed":"lesson-bubble exam-bubble"}function v2({available:e,current:t,onChange:n}){const r=$e(),[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 p.jsxs("div",{className:"relative shrink-0",children:[p.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:[p.jsx(Dx,{className:"w-3 h-3"}),o]}),s&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>i(!1)}),p.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:[p.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=>p.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 E2=500,zn=8;function k2(){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(b=>{o()||r(y=>y.mode==="cursor"?{...y,x:b.clientX,y:b.clientY}:y)},[o]),u=k.useCallback(b=>{var E;if(o())return;const y=(E=b.target)==null?void 0:E.closest("[data-tooltip]"),w=y==null?void 0:y.getAttribute("data-tooltip");if(w){t(w),r({mode:"cursor",x:b.clientX,y:b.clientY});return}t(null)},[o]),c=k.useCallback(b=>{var w,E;if(o())return;((E=(w=b.target)==null?void 0:w.closest)==null?void 0:E.call(w,"[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 b=null;const y=()=>{b&&(clearTimeout(b),b=null)},w=T=>{var C;if(!o()||T.touches.length!==1)return y();const _=(C=T.target)==null?void 0:C.closest("[data-tooltip]"),A=_==null?void 0:_.getAttribute("data-tooltip");if(!A||!_)return y();const N=_;y(),b=setTimeout(()=>{N.isConnected&&(t(A),r({mode:"rect",x:0,y:0,rect:N.getBoundingClientRect()}))},E2)},E=()=>{y(),t(T=>T&&null)},S=()=>y(),v=()=>{y(),t(null)};return document.addEventListener("touchstart",w,{passive:!0}),document.addEventListener("touchend",E,{passive:!0}),document.addEventListener("touchmove",S,{passive:!0}),document.addEventListener("touchcancel",v,{passive:!0}),()=>{y(),document.removeEventListener("touchstart",w),document.removeEventListener("touchend",E),document.removeEventListener("touchmove",S),document.removeEventListener("touchcancel",v)}},[o]),k.useLayoutEffect(()=>{a.current&&e&&i({w:a.current.offsetWidth,h:a.current.offsetHeight})},[e]),!e)return null;const h=window.innerWidth,f=window.innerHeight;let d,m,g;if(n.mode==="rect"&&n.rect){const b=n.rect;d=b.left+b.width/2-s.w/2,m=b.top-s.h-6,g="none",m<zn&&(m=b.bottom+6)}else d=n.x,m=n.y-6,g="translate(0, -100%)";return d=Math.min(Math.max(d,zn),Math.max(zn,h-s.w-zn)),m=Math.min(Math.max(m,zn),Math.max(zn,f-s.h-zn)),Lm.createPortal(p.jsx("div",{ref:a,style:{position:"fixed",left:d,top:m,transform:g,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 FP(){}function Gc(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 Wm(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const T2=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,w2=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,S2={};function Kc(e,t){return(S2.jsx?w2:T2).test(e)}const A2=/[ \t\n\f\r]/g;function C2(e){return typeof e=="object"?e.type==="text"?Xc(e.value):!1:Xc(e)}function Xc(e){return e.replace(A2,"")===""}class qi{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}qi.prototype.normal={};qi.prototype.property={};qi.prototype.space=void 0;function Ym(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new qi(n,r,t)}function Pi(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 _2=0;const Le=cr(),ft=cr(),rl=cr(),de=cr(),Je=cr(),tr=cr(),Ot=cr();function cr(){return 2**++_2}const il=Object.freeze(Object.defineProperty({__proto__:null,boolean:Le,booleanish:ft,commaOrSpaceSeparated:Ot,commaSeparated:tr,number:de,overloadedBoolean:rl,spaceSeparated:Je},Symbol.toStringTag,{value:"Module"})),io=Object.keys(il);class lu extends Pt{constructor(t,n,r,s){let i=-1;if(super(t,n),Qc(this,"space",s),typeof r=="number")for(;++i<io.length;){const a=io[i];Qc(this,io[i],(r&il[a])===il[a])}}}lu.prototype.defined=!0;function Qc(e,t,n){n&&(e[t]=n)}function Fr(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new lu(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Pi(r)]=r,n[Pi(i.attribute)]=r}return new qi(t,n,e.space)}const Gm=Fr({properties:{ariaActiveDescendant:null,ariaAtomic:ft,ariaAutoComplete:null,ariaBusy:ft,ariaChecked:ft,ariaColCount:de,ariaColIndex:de,ariaColSpan:de,ariaControls:Je,ariaCurrent:null,ariaDescribedBy:Je,ariaDetails:null,ariaDisabled:ft,ariaDropEffect:Je,ariaErrorMessage:null,ariaExpanded:ft,ariaFlowTo:Je,ariaGrabbed:ft,ariaHasPopup:null,ariaHidden:ft,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Je,ariaLevel:de,ariaLive:null,ariaModal:ft,ariaMultiLine:ft,ariaMultiSelectable:ft,ariaOrientation:null,ariaOwns:Je,ariaPlaceholder:null,ariaPosInSet:de,ariaPressed:ft,ariaReadOnly:ft,ariaRelevant:null,ariaRequired:ft,ariaRoleDescription:Je,ariaRowCount:de,ariaRowIndex:de,ariaRowSpan:de,ariaSelected:ft,ariaSetSize:de,ariaSort:null,ariaValueMax:de,ariaValueMin:de,ariaValueNow:de,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Km(e,t){return t in e?e[t]:t}function Xm(e,t){return Km(e,t.toLowerCase())}const N2=Fr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:tr,acceptCharset:Je,accessKey:Je,action:null,allow:null,allowFullScreen:Le,allowPaymentRequest:Le,allowUserMedia:Le,alpha:Le,alt:null,as:null,async:Le,autoCapitalize:null,autoComplete:Je,autoFocus:Le,autoPlay:Le,blocking:Je,capture:null,charSet:null,checked:Le,cite:null,className:Je,closedBy:null,colorSpace:null,cols:de,colSpan:de,command:null,commandFor:null,content:null,contentEditable:ft,controls:Le,controlsList:Je,coords:de|tr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Le,defer:Le,dir:null,dirName:null,disabled:Le,download:rl,draggable:ft,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Le,formTarget:null,headers:Je,height:de,hidden:rl,high:de,href:null,hrefLang:null,htmlFor:Je,httpEquiv:Je,id:null,imageSizes:null,imageSrcSet:null,inert:Le,inputMode:null,integrity:null,is:null,isMap:Le,itemId:null,itemProp:Je,itemRef:Je,itemScope:Le,itemType:Je,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Le,low:de,manifest:null,max:null,maxLength:de,media:null,method:null,min:null,minLength:de,multiple:Le,muted:Le,name:null,nonce:null,noModule:Le,noValidate:Le,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:Le,optimum:de,pattern:null,ping:Je,placeholder:null,playsInline:Le,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Le,referrerPolicy:null,rel:Je,required:Le,reversed:Le,rows:de,rowSpan:de,sandbox:Je,scope:null,scoped:Le,seamless:Le,selected:Le,shadowRootClonable:Le,shadowRootCustomElementRegistry:Le,shadowRootDelegatesFocus:Le,shadowRootMode:null,shadowRootSerializable:Le,shape:null,size:de,sizes:null,slot:null,span:de,spellCheck:ft,src:null,srcDoc:null,srcLang:null,srcSet:null,start:de,step:null,style:null,tabIndex:de,target:null,title:null,translate:null,type:null,typeMustMatch:Le,useMap:null,value:ft,width:de,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Je,axis:null,background:null,bgColor:null,border:de,borderColor:null,bottomMargin:de,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Le,declare:Le,event:null,face:null,frame:null,frameBorder:null,hSpace:de,leftMargin:de,link:null,longDesc:null,lowSrc:null,marginHeight:de,marginWidth:de,noResize:Le,noHref:Le,noShade:Le,noWrap:Le,object:null,profile:null,prompt:null,rev:null,rightMargin:de,rules:null,scheme:null,scrolling:ft,standby:null,summary:null,text:null,topMargin:de,valueType:null,version:null,vAlign:null,vLink:null,vSpace:de,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Le,disablePictureInPicture:Le,disableRemotePlayback:Le,exportParts:tr,part:Je,prefix:null,property:null,results:de,security:null,unselectable:null},space:"html",transform:Xm}),I2=Fr({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:Ot,accentHeight:de,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:de,amplitude:de,arabicForm:null,ascent:de,attributeName:null,attributeType:null,azimuth:de,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:de,by:null,calcMode:null,capHeight:de,className:Je,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:de,diffuseConstant:de,direction:null,display:null,dur:null,divisor:de,dominantBaseline:null,download:Le,dx:null,dy:null,edgeMode:null,editable:null,elevation:de,enableBackground:null,end:null,event:null,exponent:de,externalResourcesRequired:null,fill:null,fillOpacity:de,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:tr,g2:tr,glyphName:tr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:de,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:de,horizOriginX:de,horizOriginY:de,id:null,ideographic:de,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:de,k:de,k1:de,k2:de,k3:de,k4:de,kernelMatrix:Ot,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:de,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:de,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:de,overlineThickness:de,paintOrder:null,panose1:null,path:null,pathLength:de,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Je,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:de,pointsAtY:de,pointsAtZ:de,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ot,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ot,rev:Ot,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ot,requiredFeatures:Ot,requiredFonts:Ot,requiredFormats:Ot,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:de,specularExponent:de,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:de,strikethroughThickness:de,string:null,stroke:null,strokeDashArray:Ot,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:de,strokeOpacity:de,strokeWidth:null,style:null,surfaceScale:de,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ot,tabIndex:de,tableValues:null,target:null,targetX:de,targetY:de,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ot,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:de,underlineThickness:de,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:de,values:null,vAlphabetic:de,vMathematical:de,vectorEffect:null,vHanging:de,vIdeographic:de,version:null,vertAdvY:de,vertOriginX:de,vertOriginY:de,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:de,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Km}),Qm=Fr({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()}}),Zm=Fr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Xm}),Jm=Fr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),R2={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"},M2=/[A-Z]/g,Zc=/-[a-z]/g,P2=/^data[-\w.:]+$/i;function ka(e,t){const n=Pi(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"&&P2.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(Zc,D2);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!Zc.test(i)){let a=i.replace(M2,L2);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=lu}return new s(r,t)}function L2(e){return"-"+e.toLowerCase()}function D2(e){return e.charAt(1).toUpperCase()}const $i=Ym([Gm,N2,Qm,Zm,Jm],"html"),Rn=Ym([Gm,I2,Qm,Zm,Jm],"svg");function Jc(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function ep(e){return e.join(" ").trim()}var gr={},so,ed;function O2(){if(ed)return so;ed=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=`
509
509
  `,u="/",c="*",h="",f="comment",d="declaration";function m(b,y){if(typeof b!="string")throw new TypeError("First argument must be a string");if(!b)return[];y=y||{};var w=1,E=1;function S(I){var R=I.match(t);R&&(w+=R.length);var B=I.lastIndexOf(l);E=~B?I.length-B:E+I.length}function v(){var I={line:w,column:E};return function(R){return R.position=new T(I),N(),R}}function T(I){this.start=I,this.end={line:w,column:E},this.source=y.source}T.prototype.content=b;function _(I){var R=new Error(y.source+":"+w+":"+E+": "+I);if(R.reason=I,R.filename=y.source,R.line=w,R.column=E,R.source=b,!y.silent)throw R}function A(I){var R=I.exec(b);if(R){var B=R[0];return S(B),b=b.slice(B.length),R}}function N(){A(n)}function C(I){var R;for(I=I||[];R=D();)R!==!1&&I.push(R);return I}function D(){var I=v();if(!(u!=b.charAt(0)||c!=b.charAt(1))){for(var R=2;h!=b.charAt(R)&&(c!=b.charAt(R)||u!=b.charAt(R+1));)++R;if(R+=2,h===b.charAt(R-1))return _("End of comment missing");var B=b.slice(2,R-2);return E+=2,S(B),b=b.slice(R),E+=2,I({type:f,comment:B})}}function P(){var I=v(),R=A(r);if(R){if(D(),!A(s))return _("property missing ':'");var B=A(i),V=I({type:d,property:g(R[0].replace(e,h)),value:B?g(B[0].replace(e,h)):h});return A(a),V}}function O(){var I=[];C(I);for(var R;R=P();)R!==!1&&(I.push(R),C(I));return I}return N(),O()}function g(b){return b?b.replace(o,h):h}return so=m,so}var td;function F2(){if(td)return gr;td=1;var e=gr&&gr.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(gr,"__esModule",{value:!0}),gr.default=n;const t=e(O2());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 gr}var ei={},nd;function B2(){if(nd)return ei;nd=1,Object.defineProperty(ei,"__esModule",{value:!0}),ei.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 ei.camelCase=l,ei}var ti,rd;function j2(){if(rd)return ti;rd=1;var e=ti&&ti.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},t=e(F2()),n=B2();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,ti=r,ti}var H2=j2();const U2=Zl(H2),Ta=tp("end"),dn=tp("start");function tp(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 np(e){const t=dn(e),n=Ta(e);if(t&&n)return{start:t,end:n}}function pi(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?id(e.position):"start"in e||"end"in e?id(e):"line"in e||"column"in e?sl(e):""}function sl(e){return sd(e&&e.line)+":"+sd(e&&e.column)}function id(e){return sl(e&&e.start)+"-"+sl(e&&e.end)}function sd(e){return e&&typeof e=="number"?e:1}class Tt 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=pi(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}}Tt.prototype.file="";Tt.prototype.name="";Tt.prototype.reason="";Tt.prototype.message="";Tt.prototype.stack="";Tt.prototype.column=void 0;Tt.prototype.line=void 0;Tt.prototype.ancestors=void 0;Tt.prototype.cause=void 0;Tt.prototype.fatal=void 0;Tt.prototype.place=void 0;Tt.prototype.ruleId=void 0;Tt.prototype.source=void 0;const uu={}.hasOwnProperty,z2=new Map,V2=/[A-Z]/g,q2=new Set(["table","tbody","thead","tfoot","tr"]),$2=new Set(["td","th"]),rp="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function W2(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=ev(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=J2(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"?Rn:$i,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=ip(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function ip(e,t,n){if(t.type==="element")return Y2(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return G2(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return X2(e,t,n);if(t.type==="mdxjsEsm")return K2(e,t);if(t.type==="root")return Q2(e,t,n);if(t.type==="text")return Z2(e,t)}function Y2(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=Rn,e.schema=s),e.ancestors.push(t);const i=ap(e,t.tagName,!1),a=tv(e,t);let o=du(e,t);return q2.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!C2(l):!0})),sp(e,a,i,t),cu(a,o),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function G2(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)}Li(e,t.position)}function K2(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Li(e,t.position)}function X2(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=Rn,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:ap(e,t.name,!0),a=nv(e,t),o=du(e,t);return sp(e,a,i,t),cu(a,o),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function Q2(e,t,n){const r={};return cu(r,du(e,t)),e.create(t,e.Fragment,r,n)}function Z2(e,t){return t.value}function sp(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function cu(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function J2(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 ev(e,t){return n;function n(r,s,i,a){const o=Array.isArray(i.children),l=dn(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 tv(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&uu.call(t.properties,s)){const i=rv(e,s,t.properties[s]);if(i){const[a,o]=i;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&$2.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 nv(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 Li(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 Li(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function du(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:z2;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=ip(e,i,a);o!==void 0&&n.push(o)}return n}function rv(e,t,n){const r=ka(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Wm(n):ep(n)),r.property==="style"){let s=typeof n=="object"?n:iv(e,String(n));return e.stylePropertyNameCase==="css"&&(s=sv(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?R2[r.property]||r.property:r.attribute,n]}}function iv(e,t){try{return U2(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Tt("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=rp+"#cannot-parse-style-attribute",s}}function ap(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=Kc(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=Kc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return uu.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Li(e)}function Li(e,t){const n=new Tt("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=rp+"#cannot-handle-mdx-estrees-without-createevaluater",n}function sv(e){const t={};let n;for(n in e)uu.call(e,n)&&(t[av(n)]=e[n]);return t}function av(e){let t=e.replace(V2,ov);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function ov(e){return"-"+e.toLowerCase()}const ao={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"]},lv={};function hu(e,t){const n=lv,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return op(e,r,s)}function op(e,t,n){if(uv(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 ad(e.children,t,n)}return Array.isArray(e)?ad(e,t,n):""}function ad(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=op(e[s],t,n);return r.join("")}function uv(e){return!!(e&&typeof e=="object")}const od=document.createElement("i");function fu(e){const t="&"+e+";";od.innerHTML=t;const n=od.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Ft(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 Ut(e,t){return e.length>0?(Ft(e,e.length,0,t),e):t}const ld={}.hasOwnProperty;function lp(e){const t={};let n=-1;for(;++n<e.length;)cv(t,e[n]);return t}function cv(e,t){let n;for(n in t){const s=(ld.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){ld.call(s,a)||(s[a]=[]);const o=i[a];dv(s[a],Array.isArray(o)?o:o?[o]:[])}}}function dv(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Ft(e,0,0,r)}function up(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 Qt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const At=Mn(/[A-Za-z]/),kt=Mn(/[\dA-Za-z]/),hv=Mn(/[#-'*+\--9=?A-Z^-~]/);function Zs(e){return e!==null&&(e<32||e===127)}const al=Mn(/\d/),fv=Mn(/[\dA-Fa-f]/),mv=Mn(/[!-/:-@[-`{-~]/);function Ne(e){return e!==null&&e<-2}function nt(e){return e!==null&&(e<0||e===32)}function Ue(e){return e===-2||e===-1||e===32}const wa=Mn(new RegExp("\\p{P}|\\p{S}","u")),or=Mn(/\s/);function Mn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Br(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&kt(e.charCodeAt(n+1))&&kt(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 qe(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 pv={tokenize:gv};function gv(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"),qe(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 Ne(o)?(e.consume(o),e.exit("chunkText"),i):(e.consume(o),a)}}const bv={tokenize:xv},ud={tokenize:yv};function xv(e){const t=this,n=[];let r=0,s,i,a;return o;function o(E){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,l,u)(E)}return u(E)}function l(E){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&w();const S=t.events.length;let v=S,T;for(;v--;)if(t.events[v][0]==="exit"&&t.events[v][1].type==="chunkFlow"){T=t.events[v][1].end;break}y(r);let _=S;for(;_<t.events.length;)t.events[_][1].end={...T},_++;return Ft(t.events,v+1,0,t.events.slice(S)),t.events.length=_,u(E)}return o(E)}function u(E){if(r===n.length){if(!s)return f(E);if(s.currentConstruct&&s.currentConstruct.concrete)return m(E);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ud,c,h)(E)}function c(E){return s&&w(),y(r),f(E)}function h(E){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(E)}function f(E){return t.containerState={},e.attempt(ud,d,m)(E)}function d(E){return r++,n.push([t.currentConstruct,t.containerState]),f(E)}function m(E){if(E===null){s&&w(),y(0),e.consume(E);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),g(E)}function g(E){if(E===null){b(e.exit("chunkFlow"),!0),y(0),e.consume(E);return}return Ne(E)?(e.consume(E),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(E),g)}function b(E,S){const v=t.sliceStream(E);if(S&&v.push(null),E.previous=i,i&&(i.next=E),i=E,s.defineSkip(E.start),s.write(v),t.parser.lazy[E.start.line]){let T=s.events.length;for(;T--;)if(s.events[T][1].start.offset<a&&(!s.events[T][1].end||s.events[T][1].end.offset>a))return;const _=t.events.length;let A=_,N,C;for(;A--;)if(t.events[A][0]==="exit"&&t.events[A][1].type==="chunkFlow"){if(N){C=t.events[A][1].end;break}N=!0}for(y(r),T=_;T<t.events.length;)t.events[T][1].end={...C},T++;Ft(t.events,A+1,0,t.events.slice(_)),t.events.length=T}}function y(E){let S=n.length;for(;S-- >E;){const v=n[S];t.containerState=v[1],v[0].exit.call(t,e)}n.length=E}function w(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function yv(e,t,n){return qe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Pr(e){if(e===null||nt(e)||or(e))return 1;if(wa(e))return 2}function Sa(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 ol={name:"attention",resolveAll:vv,tokenize:Ev};function vv(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 h={...e[r][1].end},f={...e[n][1].start};cd(h,-l),cd(f,l),a={type:l>1?"strongSequence":"emphasisSequence",start:h,end:{...e[r][1].end}},o={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},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=Ut(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Ut(u,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),u=Ut(u,Sa(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Ut(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=Ut(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):c=0,Ft(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 Ev(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=Pr(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=Pr(l),h=!c||c===2&&s||n.includes(l),f=!s||s===2&&c||n.includes(r);return u._open=!!(i===42?h:h&&(s||!f)),u._close=!!(i===42?f:f&&(c||!h)),t(l)}}function cd(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const kv={name:"autolink",tokenize:Tv};function Tv(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||kt(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||kt(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||Zs(d)?n(d):(e.consume(d),l)}function u(d){return d===64?(e.consume(d),c):hv(d)?(e.consume(d),u):n(d)}function c(d){return kt(d)?h(d):n(d)}function h(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):f(d)}function f(d){if((d===45||kt(d))&&r++<63){const m=d===45?f:h;return e.consume(d),m}return n(d)}}const Wi={partial:!0,tokenize:wv};function wv(e,t,n){return r;function r(i){return Ue(i)?qe(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||Ne(i)?t(i):n(i)}}const cp={continuation:{tokenize:Av},exit:Cv,name:"blockQuote",tokenize:Sv};function Sv(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 Av(e,t,n){const r=this;return s;function s(a){return Ue(a)?qe(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(cp,t,n)(a)}}function Cv(e){e.exit("blockQuote")}const dp={name:"characterEscape",tokenize:_v};function _v(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 mv(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const hp={name:"characterReference",tokenize:Nv};function Nv(e,t,n){const r=this;let s=0,i,a;return o;function o(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),l}function l(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),i=31,a=kt,c(h))}function u(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=fv,c):(e.enter("characterReferenceValue"),i=7,a=al,c(h))}function c(h){if(h===59&&s){const f=e.exit("characterReferenceValue");return a===kt&&!fu(r.sliceSerialize(f))?n(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(h)&&s++<i?(e.consume(h),c):n(h)}}const dd={partial:!0,tokenize:Rv},hd={concrete:!0,name:"codeFenced",tokenize:Iv};function Iv(e,t,n){const r=this,s={partial:!0,tokenize:v};let i=0,a=0,o;return l;function l(T){return u(T)}function u(T){const _=r.events[r.events.length-1];return i=_&&_[1].type==="linePrefix"?_[2].sliceSerialize(_[1],!0).length:0,o=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(T)}function c(T){return T===o?(a++,e.consume(T),c):a<3?n(T):(e.exit("codeFencedFenceSequence"),Ue(T)?qe(e,h,"whitespace")(T):h(T))}function h(T){return T===null||Ne(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(dd,g,S)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(T))}function f(T){return T===null||Ne(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(T)):Ue(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),qe(e,d,"whitespace")(T)):T===96&&T===o?n(T):(e.consume(T),f)}function d(T){return T===null||Ne(T)?h(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(T))}function m(T){return T===null||Ne(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(T)):T===96&&T===o?n(T):(e.consume(T),m)}function g(T){return e.attempt(s,S,b)(T)}function b(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),y}function y(T){return i>0&&Ue(T)?qe(e,w,"linePrefix",i+1)(T):w(T)}function w(T){return T===null||Ne(T)?e.check(dd,g,S)(T):(e.enter("codeFlowValue"),E(T))}function E(T){return T===null||Ne(T)?(e.exit("codeFlowValue"),w(T)):(e.consume(T),E)}function S(T){return e.exit("codeFenced"),t(T)}function v(T,_,A){let N=0;return C;function C(R){return T.enter("lineEnding"),T.consume(R),T.exit("lineEnding"),D}function D(R){return T.enter("codeFencedFence"),Ue(R)?qe(T,P,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):P(R)}function P(R){return R===o?(T.enter("codeFencedFenceSequence"),O(R)):A(R)}function O(R){return R===o?(N++,T.consume(R),O):N>=a?(T.exit("codeFencedFenceSequence"),Ue(R)?qe(T,I,"whitespace")(R):I(R)):A(R)}function I(R){return R===null||Ne(R)?(T.exit("codeFencedFence"),_(R)):A(R)}}}function Rv(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 oo={name:"codeIndented",tokenize:Pv},Mv={partial:!0,tokenize:Lv};function Pv(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),qe(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):Ne(u)?e.attempt(Mv,a,l)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||Ne(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function l(u){return e.exit("codeIndented"),t(u)}}function Lv(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):Ne(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):qe(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):Ne(a)?s(a):n(a)}}const Dv={name:"codeText",previous:Fv,resolve:Ov,tokenize:Bv};function Ov(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 Fv(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Bv(e,t,n){let r=0,s,i;return a;function a(h){return e.enter("codeText"),e.enter("codeTextSequence"),o(h)}function o(h){return h===96?(e.consume(h),r++,o):(e.exit("codeTextSequence"),l(h))}function l(h){return h===null?n(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),l):h===96?(i=e.enter("codeTextSequence"),s=0,c(h)):Ne(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(h))}function u(h){return h===null||h===32||h===96||Ne(h)?(e.exit("codeTextData"),l(h)):(e.consume(h),u)}function c(h){return h===96?(e.consume(h),s++,c):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(i.type="codeTextData",u(h))}}class jv{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&&ni(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),ni(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ni(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);ni(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ni(this.left,n.reverse())}}}function ni(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 fp(e){const t={};let n=-1,r,s,i,a,o,l,u;const c=new jv(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,Hv(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 Ft(e,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function Hv(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,h,f=-1,d=n,m=0,g=0;const b=[g];for(;d;){for(;e.get(++s)[1]!==d;);i.push(s),d._tokenizer||(c=r.sliceStream(d),d.next||c.push(null),h&&a.defineSkip(d.start),d._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(c),d._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),h=d,d=d.next}for(d=n;++f<o.length;)o[f][0]==="exit"&&o[f-1][0]==="enter"&&o[f][1].type===o[f-1][1].type&&o[f][1].start.line!==o[f][1].end.line&&(g=f+1,b.push(g),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(a.events=[],d?(d._tokenizer=void 0,d.previous=void 0):b.pop(),f=b.length;f--;){const y=o.slice(b[f],b[f+1]),w=i.pop();l.push([w,w+y.length-1]),e.splice(w,2,y)}for(l.reverse(),f=-1;++f<l.length;)u[m+l[f][0]]=m+l[f][1],m+=l[f][1]-l[f][0]-1;return u}const Uv={resolve:Vv,tokenize:qv},zv={partial:!0,tokenize:$v};function Vv(e){return fp(e),e}function qv(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):Ne(o)?e.check(zv,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 $v(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),qe(e,i,"linePrefix")}function i(a){if(a===null||Ne(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 mp(e,t,n,r,s,i,a,o,l){const u=l||Number.POSITIVE_INFINITY;let c=0;return h;function h(y){return y===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(y),e.exit(i),f):y===null||y===32||y===41||Zs(y)?n(y):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),g(y))}function f(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),f(y)):y===null||y===60||Ne(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 g(y){return!c&&(y===null||y===41||nt(y))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(y)):c<u&&y===40?(e.consume(y),c++,g):y===41?(e.consume(y),c--,g):y===null||y===32||y===40||Zs(y)?n(y):(e.consume(y),y===92?b:g)}function b(y){return y===40||y===41||y===92?(e.consume(y),g):g(y)}}function pp(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):Ne(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),h(d))}function h(d){return d===null||d===91||d===93||Ne(d)||o++>999?(e.exit("chunkString"),c(d)):(e.consume(d),l||(l=!Ue(d)),d===92?f:h)}function f(d){return d===91||d===92||d===93?(e.consume(d),o++,h):h(d)}}function gp(e,t,n,r,s,i){let a;return o;function o(f){return f===34||f===39||f===40?(e.enter(r),e.enter(s),e.consume(f),e.exit(s),a=f===40?41:f,l):n(f)}function l(f){return f===a?(e.enter(s),e.consume(f),e.exit(s),e.exit(r),t):(e.enter(i),u(f))}function u(f){return f===a?(e.exit(i),l(a)):f===null?n(f):Ne(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),qe(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(f))}function c(f){return f===a||f===null||Ne(f)?(e.exit("chunkString"),u(f)):(e.consume(f),f===92?h:c)}function h(f){return f===a||f===92?(e.consume(f),c):c(f)}}function gi(e,t){let n;return r;function r(s){return Ne(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):Ue(s)?qe(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const Wv={name:"definition",tokenize:Gv},Yv={partial:!0,tokenize:Kv};function Gv(e,t,n){const r=this;let s;return i;function i(d){return e.enter("definition"),a(d)}function a(d){return pp.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)}function o(d){return s=Qt(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 nt(d)?gi(e,u)(d):u(d)}function u(d){return mp(e,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(d)}function c(d){return e.attempt(Yv,h,h)(d)}function h(d){return Ue(d)?qe(e,f,"whitespace")(d):f(d)}function f(d){return d===null||Ne(d)?(e.exit("definition"),r.parser.defined.push(s),t(d)):n(d)}}function Kv(e,t,n){return r;function r(o){return nt(o)?gi(e,s)(o):n(o)}function s(o){return gp(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function i(o){return Ue(o)?qe(e,a,"whitespace")(o):a(o)}function a(o){return o===null||Ne(o)?t(o):n(o)}}const Xv={name:"hardBreakEscape",tokenize:Qv};function Qv(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return Ne(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const Zv={name:"headingAtx",resolve:Jv,tokenize:eE};function Jv(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"},Ft(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function eE(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||nt(c)?(e.exit("atxHeadingSequence"),o(c)):n(c)}function o(c){return c===35?(e.enter("atxHeadingSequence"),l(c)):c===null||Ne(c)?(e.exit("atxHeading"),t(c)):Ue(c)?qe(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||nt(c)?(e.exit("atxHeadingText"),o(c)):(e.consume(c),u)}}const tE=["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"],fd=["pre","script","style","textarea"],nE={concrete:!0,name:"htmlFlow",resolveTo:sE,tokenize:aE},rE={partial:!0,tokenize:lE},iE={partial:!0,tokenize:oE};function sE(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 aE(e,t,n){const r=this;let s,i,a,o,l;return u;function u(M){return c(M)}function c(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),h}function h(M){return M===33?(e.consume(M),f):M===47?(e.consume(M),i=!0,g):M===63?(e.consume(M),s=3,r.interrupt?t:L):At(M)?(e.consume(M),a=String.fromCharCode(M),b):n(M)}function f(M){return M===45?(e.consume(M),s=2,d):M===91?(e.consume(M),s=5,o=0,m):At(M)?(e.consume(M),s=4,r.interrupt?t:L):n(M)}function d(M){return M===45?(e.consume(M),r.interrupt?t:L):n(M)}function m(M){const G="CDATA[";return M===G.charCodeAt(o++)?(e.consume(M),o===G.length?r.interrupt?t:P:m):n(M)}function g(M){return At(M)?(e.consume(M),a=String.fromCharCode(M),b):n(M)}function b(M){if(M===null||M===47||M===62||nt(M)){const G=M===47,ae=a.toLowerCase();return!G&&!i&&fd.includes(ae)?(s=1,r.interrupt?t(M):P(M)):tE.includes(a.toLowerCase())?(s=6,G?(e.consume(M),y):r.interrupt?t(M):P(M)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(M):i?w(M):E(M))}return M===45||kt(M)?(e.consume(M),a+=String.fromCharCode(M),b):n(M)}function y(M){return M===62?(e.consume(M),r.interrupt?t:P):n(M)}function w(M){return Ue(M)?(e.consume(M),w):C(M)}function E(M){return M===47?(e.consume(M),C):M===58||M===95||At(M)?(e.consume(M),S):Ue(M)?(e.consume(M),E):C(M)}function S(M){return M===45||M===46||M===58||M===95||kt(M)?(e.consume(M),S):v(M)}function v(M){return M===61?(e.consume(M),T):Ue(M)?(e.consume(M),v):E(M)}function T(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),l=M,_):Ue(M)?(e.consume(M),T):A(M)}function _(M){return M===l?(e.consume(M),l=null,N):M===null||Ne(M)?n(M):(e.consume(M),_)}function A(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||nt(M)?v(M):(e.consume(M),A)}function N(M){return M===47||M===62||Ue(M)?E(M):n(M)}function C(M){return M===62?(e.consume(M),D):n(M)}function D(M){return M===null||Ne(M)?P(M):Ue(M)?(e.consume(M),D):n(M)}function P(M){return M===45&&s===2?(e.consume(M),B):M===60&&s===1?(e.consume(M),V):M===62&&s===4?(e.consume(M),q):M===63&&s===3?(e.consume(M),L):M===93&&s===5?(e.consume(M),Y):Ne(M)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(rE,K,O)(M)):M===null||Ne(M)?(e.exit("htmlFlowData"),O(M)):(e.consume(M),P)}function O(M){return e.check(iE,I,K)(M)}function I(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),R}function R(M){return M===null||Ne(M)?O(M):(e.enter("htmlFlowData"),P(M))}function B(M){return M===45?(e.consume(M),L):P(M)}function V(M){return M===47?(e.consume(M),a="",z):P(M)}function z(M){if(M===62){const G=a.toLowerCase();return fd.includes(G)?(e.consume(M),q):P(M)}return At(M)&&a.length<8?(e.consume(M),a+=String.fromCharCode(M),z):P(M)}function Y(M){return M===93?(e.consume(M),L):P(M)}function L(M){return M===62?(e.consume(M),q):M===45&&s===2?(e.consume(M),L):P(M)}function q(M){return M===null||Ne(M)?(e.exit("htmlFlowData"),K(M)):(e.consume(M),q)}function K(M){return e.exit("htmlFlow"),t(M)}}function oE(e,t,n){const r=this;return s;function s(a){return Ne(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 lE(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Wi,t,n)}}const uE={name:"htmlText",tokenize:cE};function cE(e,t,n){const r=this;let s,i,a;return o;function o(L){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(L),l}function l(L){return L===33?(e.consume(L),u):L===47?(e.consume(L),v):L===63?(e.consume(L),E):At(L)?(e.consume(L),A):n(L)}function u(L){return L===45?(e.consume(L),c):L===91?(e.consume(L),i=0,m):At(L)?(e.consume(L),w):n(L)}function c(L){return L===45?(e.consume(L),d):n(L)}function h(L){return L===null?n(L):L===45?(e.consume(L),f):Ne(L)?(a=h,V(L)):(e.consume(L),h)}function f(L){return L===45?(e.consume(L),d):h(L)}function d(L){return L===62?B(L):L===45?f(L):h(L)}function m(L){const q="CDATA[";return L===q.charCodeAt(i++)?(e.consume(L),i===q.length?g:m):n(L)}function g(L){return L===null?n(L):L===93?(e.consume(L),b):Ne(L)?(a=g,V(L)):(e.consume(L),g)}function b(L){return L===93?(e.consume(L),y):g(L)}function y(L){return L===62?B(L):L===93?(e.consume(L),y):g(L)}function w(L){return L===null||L===62?B(L):Ne(L)?(a=w,V(L)):(e.consume(L),w)}function E(L){return L===null?n(L):L===63?(e.consume(L),S):Ne(L)?(a=E,V(L)):(e.consume(L),E)}function S(L){return L===62?B(L):E(L)}function v(L){return At(L)?(e.consume(L),T):n(L)}function T(L){return L===45||kt(L)?(e.consume(L),T):_(L)}function _(L){return Ne(L)?(a=_,V(L)):Ue(L)?(e.consume(L),_):B(L)}function A(L){return L===45||kt(L)?(e.consume(L),A):L===47||L===62||nt(L)?N(L):n(L)}function N(L){return L===47?(e.consume(L),B):L===58||L===95||At(L)?(e.consume(L),C):Ne(L)?(a=N,V(L)):Ue(L)?(e.consume(L),N):B(L)}function C(L){return L===45||L===46||L===58||L===95||kt(L)?(e.consume(L),C):D(L)}function D(L){return L===61?(e.consume(L),P):Ne(L)?(a=D,V(L)):Ue(L)?(e.consume(L),D):N(L)}function P(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),s=L,O):Ne(L)?(a=P,V(L)):Ue(L)?(e.consume(L),P):(e.consume(L),I)}function O(L){return L===s?(e.consume(L),s=void 0,R):L===null?n(L):Ne(L)?(a=O,V(L)):(e.consume(L),O)}function I(L){return L===null||L===34||L===39||L===60||L===61||L===96?n(L):L===47||L===62||nt(L)?N(L):(e.consume(L),I)}function R(L){return L===47||L===62||nt(L)?N(L):n(L)}function B(L){return L===62?(e.consume(L),e.exit("htmlTextData"),e.exit("htmlText"),t):n(L)}function V(L){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),z}function z(L){return Ue(L)?qe(e,Y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):Y(L)}function Y(L){return e.enter("htmlTextData"),a(L)}}const mu={name:"labelEnd",resolveAll:mE,resolveTo:pE,tokenize:gE},dE={tokenize:bE},hE={tokenize:xE},fE={tokenize:yE};function mE(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&&Ft(e,0,e.length,n),e}function pE(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=Ut(o,e.slice(i+1,i+r+3)),o=Ut(o,[["enter",c,t]]),o=Ut(o,Sa(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=Ut(o,[["exit",c,t],e[a-2],e[a-1],["exit",u,t]]),o=Ut(o,e.slice(a+1)),o=Ut(o,[["exit",l,t]]),Ft(e,i,e.length,o),e}function gE(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(f){return i?i._inactive?h(f):(a=r.parser.defined.includes(Qt(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),l):n(f)}function l(f){return f===40?e.attempt(dE,c,a?c:h)(f):f===91?e.attempt(hE,c,a?u:h)(f):a?c(f):h(f)}function u(f){return e.attempt(fE,c,h)(f)}function c(f){return t(f)}function h(f){return i._balanced=!0,n(f)}}function bE(e,t,n){return r;function r(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),s}function s(h){return nt(h)?gi(e,i)(h):i(h)}function i(h){return h===41?c(h):mp(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function a(h){return nt(h)?gi(e,l)(h):c(h)}function o(h){return n(h)}function l(h){return h===34||h===39||h===40?gp(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):c(h)}function u(h){return nt(h)?gi(e,c)(h):c(h)}function c(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):n(h)}}function xE(e,t,n){const r=this;return s;function s(o){return pp.call(r,e,i,a,"reference","referenceMarker","referenceString")(o)}function i(o){return r.parser.defined.includes(Qt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function yE(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 vE={name:"labelStartImage",resolveAll:mu.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 kE={name:"labelStartLink",resolveAll:mu.resolveAll,tokenize:TE};function TE(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 lo={name:"lineEnding",tokenize:wE};function wE(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),qe(e,t,"linePrefix")}}const Ls={name:"thematicBreak",tokenize:SE};function SE(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||Ne(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===s?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),Ue(u)?qe(e,o,"whitespace")(u):o(u))}}const Mt={continuation:{tokenize:NE},exit:RE,name:"list",tokenize:_E},AE={partial:!0,tokenize:ME},CE={partial:!0,tokenize:IE};function _E(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:al(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(Ls,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 al(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(Wi,r.interrupt?n:c,e.attempt(AE,f,h))}function c(d){return r.containerState.initialBlankLine=!0,i++,f(d)}function h(d){return Ue(d)?(e.enter("listItemPrefixWhitespace"),e.consume(d),e.exit("listItemPrefixWhitespace"),f):n(d)}function f(d){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(d)}}function NE(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Wi,s,i);function s(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,qe(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(CE,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,qe(e,e.attempt(Mt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function IE(e,t,n){const r=this;return qe(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 RE(e){e.exit(this.containerState.type)}function ME(e,t,n){const r=this;return qe(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 md={name:"setextUnderline",resolveTo:PE,tokenize:LE};function PE(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 LE(e,t,n){const r=this;let s;return i;function i(u){let c=r.events.length,h;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){h=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(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)?qe(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||Ne(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const DE={tokenize:OE};function OE(e){const t=this,n=e.attempt(Wi,r,e.attempt(this.parser.constructs.flowInitial,s,qe(e,e.attempt(this.parser.constructs.flow,s,e.attempt(Uv,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 FE={resolveAll:xp()},BE=bp("string"),jE=bp("text");function bp(e){return{resolveAll:xp(e==="text"?HE: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 h=s[c];let f=-1;if(h)for(;++f<h.length;){const d=h[f];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function xp(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 HE(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 UE={42:Mt,43:Mt,45:Mt,48:Mt,49:Mt,50:Mt,51:Mt,52:Mt,53:Mt,54:Mt,55:Mt,56:Mt,57:Mt,62:cp},zE={91:Wv},VE={[-2]:oo,[-1]:oo,32:oo},qE={35:Zv,42:Ls,45:[md,Ls],60:nE,61:md,95:Ls,96:hd,126:hd},$E={38:hp,92:dp},WE={[-5]:lo,[-4]:lo,[-3]:lo,33:vE,38:hp,42:ol,60:[kv,uE],91:kE,92:[Xv,dp],93:mu,95:ol,96:Dv},YE={null:[ol,FE]},GE={null:[42,95]},KE={null:[]},XE=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:GE,contentInitial:zE,disable:KE,document:UE,flow:qE,flowInitial:VE,insideSpan:YE,string:$E,text:WE},Symbol.toStringTag,{value:"Module"}));function QE(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:_(v),check:_(T),consume:w,enter:E,exit:S,interrupt:_(T,{interrupt:!0})},u={code:null,containerState:{},defineSkip:g,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:d,write:h};let c=t.tokenize.call(u,l);return t.resolveAll&&i.push(t),u;function h(D){return a=Ut(a,D),b(),a[a.length-1]!==null?[]:(A(t,0),u.events=Sa(i,u.events,u),u.events)}function f(D,P){return JE(d(D),P)}function d(D){return ZE(a,D)}function m(){const{_bufferIndex:D,_index:P,line:O,column:I,offset:R}=r;return{_bufferIndex:D,_index:P,line:O,column:I,offset:R}}function g(D){s[D.line]=D.column,C()}function b(){let D;for(;r._index<a.length;){const P=a[r._index];if(typeof P=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<P.length;)y(P.charCodeAt(r._bufferIndex));else y(P)}}function y(D){c=c(D)}function w(D){Ne(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,C()):D!==-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=D}function E(D,P){const O=P||{};return O.type=D,O.start=m(),u.events.push(["enter",O,u]),o.push(O),O}function S(D){const P=o.pop();return P.end=m(),u.events.push(["exit",P,u]),P}function v(D,P){A(D,P.from)}function T(D,P){P.restore()}function _(D,P){return O;function O(I,R,B){let V,z,Y,L;return Array.isArray(I)?K(I):"tokenize"in I?K([I]):q(I);function q(ne){return X;function X(te){const ue=te!==null&&ne[te],ge=te!==null&&ne.null,Z=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(ge)?ge:ge?[ge]:[]];return K(Z)(te)}}function K(ne){return V=ne,z=0,ne.length===0?B:M(ne[z])}function M(ne){return X;function X(te){return L=N(),Y=ne,ne.partial||(u.currentConstruct=ne),ne.name&&u.parser.constructs.disable.null.includes(ne.name)?ae():ne.tokenize.call(P?Object.assign(Object.create(u),P):u,l,G,ae)(te)}}function G(ne){return D(Y,L),R}function ae(ne){return L.restore(),++z<V.length?M(V[z]):B}}}function A(D,P){D.resolveAll&&!i.includes(D)&&i.push(D),D.resolve&&Ft(u.events,P,u.events.length-P,D.resolve(u.events.slice(P),u)),D.resolveTo&&(u.events=D.resolveTo(u.events,u))}function N(){const D=m(),P=u.previous,O=u.currentConstruct,I=u.events.length,R=Array.from(o);return{from:I,restore:B};function B(){r=D,u.previous=P,u.currentConstruct=O,u.events.length=I,o=R,C()}}function C(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function ZE(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 JE(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=`
510
510
  `;break}case-3:{a=`\r
511
511
  `;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 ek(e){const r={constructs:lp([XE,...(e||{}).extensions||[]]),content:s(pv),defined:[],document:s(bv),flow:s(DE),lazy:{},string:s(BE),text:s(jE)};return r;function s(i){return a;function a(o){return QE(r,i,o)}}}function tk(e){for(;!fp(e););return e}const pd=/[\0\t\n\r]/g;function nk(){let e=1,t="",n=!0,r;return s;function s(i,a,o){const l=[];let u,c,h,f,d;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),h=0,t="",n&&(i.charCodeAt(0)===65279&&h++,n=void 0);h<i.length;){if(pd.lastIndex=h,u=pd.exec(i),f=u&&u.index!==void 0?u.index:i.length,d=i.charCodeAt(f),!u){t=i.slice(h);break}if(d===10&&h===f&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),h<f&&(l.push(i.slice(h,f)),e+=f-h),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}h=f+1}return o&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const rk=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ik(e){return e.replace(rk,sk)}function sk(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return up(n.slice(i?2:1),i?16:10)}return fu(n)||e}const yp={}.hasOwnProperty;function ak(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),ok(n)(tk(ek(n).document().write(nk()(e,t,!0))))}function ok(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(st),autolinkProtocol:N,autolinkEmail:N,atxHeading:i(Fe),blockQuote:i(ge),characterEscape:N,characterReference:N,codeFenced:i(Z),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(Z,a),codeText:i(re,a),codeTextData:N,data:N,codeFlowValue:N,definition:i(be),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(ve),hardBreakEscape:i(je),hardBreakTrailing:i(je),htmlFlow:i(Se,a),htmlFlowData:N,htmlText:i(Se,a),htmlTextData:N,image:i(Oe),label:a,link:i(st),listItem:i(me),listItemValue:f,listOrdered:i(pt,h),listUnordered:i(pt),paragraph:i(rt),reference:M,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(Fe),strong:i(ie),thematicBreak:i(Be)},exit:{atxHeading:l(),atxHeadingSequence:v,autolink:l(),autolinkEmail:ue,autolinkProtocol:te,blockQuote:l(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:ne,characterReference:X,codeFenced:l(b),codeFencedFence:g,codeFencedFenceInfo:d,codeFencedFenceMeta:m,codeFlowValue:C,codeIndented:l(y),codeText:l(R),codeTextData:C,data:C,definition:l(),definitionDestinationString:S,definitionLabelString:w,definitionTitleString:E,emphasis:l(),hardBreakEscape:l(P),hardBreakTrailing:l(P),htmlFlow:l(O),htmlFlowData:C,htmlText:l(I),htmlTextData:C,image:l(V),label:Y,labelText:z,lineEnding:D,link:l(B),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:G,resourceDestinationString:L,resourceTitleString:q,resource:K,setextHeading:l(A),setextHeadingLineSequence:_,setextHeadingText:T,strong:l(),thematicBreak:l()}};vp(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(Q){let ee={type:"root",children:[]};const he={stack:[ee],tokenStack:[],config:t,enter:o,exit:u,buffer:a,resume:c,data:n},Te=[];let Re=-1;for(;++Re<Q.length;)if(Q[Re][1].type==="listOrdered"||Q[Re][1].type==="listUnordered")if(Q[Re][0]==="enter")Te.push(Re);else{const Ze=Te.pop();Re=s(Q,Ze,Re)}for(Re=-1;++Re<Q.length;){const Ze=t[Q[Re][0]];yp.call(Ze,Q[Re][1].type)&&Ze[Q[Re][1].type].call(Object.assign({sliceSerialize:Q[Re][2].sliceSerialize},he),Q[Re][1])}if(he.tokenStack.length>0){const Ze=he.tokenStack[he.tokenStack.length-1];(Ze[1]||gd).call(he,void 0,Ze[0])}for(ee.position={start:En(Q.length>0?Q[0][1].start:{line:1,column:1,offset:0}),end:En(Q.length>0?Q[Q.length-2][1].end:{line:1,column:1,offset:0})},Re=-1;++Re<t.transforms.length;)ee=t.transforms[Re](ee)||ee;return ee}function s(Q,ee,he){let Te=ee-1,Re=-1,Ze=!1,dt,xe,De,Ve;for(;++Te<=he;){const pe=Q[Te];switch(pe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{pe[0]==="enter"?Re++:Re--,Ve=void 0;break}case"lineEndingBlank":{pe[0]==="enter"&&(dt&&!Ve&&!Re&&!De&&(De=Te),Ve=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ve=void 0}if(!Re&&pe[0]==="enter"&&pe[1].type==="listItemPrefix"||Re===-1&&pe[0]==="exit"&&(pe[1].type==="listUnordered"||pe[1].type==="listOrdered")){if(dt){let We=Te;for(xe=void 0;We--;){const ht=Q[We];if(ht[1].type==="lineEnding"||ht[1].type==="lineEndingBlank"){if(ht[0]==="exit")continue;xe&&(Q[xe][1].type="lineEndingBlank",Ze=!0),ht[1].type="lineEnding",xe=We}else if(!(ht[1].type==="linePrefix"||ht[1].type==="blockQuotePrefix"||ht[1].type==="blockQuotePrefixWhitespace"||ht[1].type==="blockQuoteMarker"||ht[1].type==="listItemIndent"))break}De&&(!xe||De<xe)&&(dt._spread=!0),dt.end=Object.assign({},xe?Q[xe][1].start:pe[1].end),Q.splice(xe||Te,0,["exit",dt,pe[2]]),Te++,he++}if(pe[1].type==="listItemPrefix"){const We={type:"listItem",_spread:!1,start:Object.assign({},pe[1].start),end:void 0};dt=We,Q.splice(Te,0,["enter",We,pe[2]]),Te++,he++,De=void 0,Ve=!0}}}return Q[ee][1]._spread=Ze,he}function i(Q,ee){return he;function he(Te){o.call(this,Q(Te),Te),ee&&ee.call(this,Te)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(Q,ee,he){this.stack[this.stack.length-1].children.push(Q),this.stack.push(Q),this.tokenStack.push([ee,he||void 0]),Q.position={start:En(ee.start),end:void 0}}function l(Q){return ee;function ee(he){Q&&Q.call(this,he),u.call(this,he)}}function u(Q,ee){const he=this.stack.pop(),Te=this.tokenStack.pop();if(Te)Te[0].type!==Q.type&&(ee?ee.call(this,Q,Te[0]):(Te[1]||gd).call(this,Q,Te[0]));else throw new Error("Cannot close `"+Q.type+"` ("+pi({start:Q.start,end:Q.end})+"): it’s not open");he.position.end=En(Q.end)}function c(){return hu(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function f(Q){if(this.data.expectingFirstListItemValue){const ee=this.stack[this.stack.length-2];ee.start=Number.parseInt(this.sliceSerialize(Q),10),this.data.expectingFirstListItemValue=void 0}}function d(){const Q=this.resume(),ee=this.stack[this.stack.length-1];ee.lang=Q}function m(){const Q=this.resume(),ee=this.stack[this.stack.length-1];ee.meta=Q}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const Q=this.resume(),ee=this.stack[this.stack.length-1];ee.value=Q.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const Q=this.resume(),ee=this.stack[this.stack.length-1];ee.value=Q.replace(/(\r?\n|\r)$/g,"")}function w(Q){const ee=this.resume(),he=this.stack[this.stack.length-1];he.label=ee,he.identifier=Qt(this.sliceSerialize(Q)).toLowerCase()}function E(){const Q=this.resume(),ee=this.stack[this.stack.length-1];ee.title=Q}function S(){const Q=this.resume(),ee=this.stack[this.stack.length-1];ee.url=Q}function v(Q){const ee=this.stack[this.stack.length-1];if(!ee.depth){const he=this.sliceSerialize(Q).length;ee.depth=he}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function _(Q){const ee=this.stack[this.stack.length-1];ee.depth=this.sliceSerialize(Q).codePointAt(0)===61?1:2}function A(){this.data.setextHeadingSlurpLineEnding=void 0}function N(Q){const he=this.stack[this.stack.length-1].children;let Te=he[he.length-1];(!Te||Te.type!=="text")&&(Te=Ie(),Te.position={start:En(Q.start),end:void 0},he.push(Te)),this.stack.push(Te)}function C(Q){const ee=this.stack.pop();ee.value+=this.sliceSerialize(Q),ee.position.end=En(Q.end)}function D(Q){const ee=this.stack[this.stack.length-1];if(this.data.atHardBreak){const he=ee.children[ee.children.length-1];he.position.end=En(Q.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ee.type)&&(N.call(this,Q),C.call(this,Q))}function P(){this.data.atHardBreak=!0}function O(){const Q=this.resume(),ee=this.stack[this.stack.length-1];ee.value=Q}function I(){const Q=this.resume(),ee=this.stack[this.stack.length-1];ee.value=Q}function R(){const Q=this.resume(),ee=this.stack[this.stack.length-1];ee.value=Q}function B(){const Q=this.stack[this.stack.length-1];if(this.data.inReference){const ee=this.data.referenceType||"shortcut";Q.type+="Reference",Q.referenceType=ee,delete Q.url,delete Q.title}else delete Q.identifier,delete Q.label;this.data.referenceType=void 0}function V(){const Q=this.stack[this.stack.length-1];if(this.data.inReference){const ee=this.data.referenceType||"shortcut";Q.type+="Reference",Q.referenceType=ee,delete Q.url,delete Q.title}else delete Q.identifier,delete Q.label;this.data.referenceType=void 0}function z(Q){const ee=this.sliceSerialize(Q),he=this.stack[this.stack.length-2];he.label=ik(ee),he.identifier=Qt(ee).toLowerCase()}function Y(){const Q=this.stack[this.stack.length-1],ee=this.resume(),he=this.stack[this.stack.length-1];if(this.data.inReference=!0,he.type==="link"){const Te=Q.children;he.children=Te}else he.alt=ee}function L(){const Q=this.resume(),ee=this.stack[this.stack.length-1];ee.url=Q}function q(){const Q=this.resume(),ee=this.stack[this.stack.length-1];ee.title=Q}function K(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function G(Q){const ee=this.resume(),he=this.stack[this.stack.length-1];he.label=ee,he.identifier=Qt(this.sliceSerialize(Q)).toLowerCase(),this.data.referenceType="full"}function ae(Q){this.data.characterReferenceType=Q.type}function ne(Q){const ee=this.sliceSerialize(Q),he=this.data.characterReferenceType;let Te;he?(Te=up(ee,he==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Te=fu(ee);const Re=this.stack[this.stack.length-1];Re.value+=Te}function X(Q){const ee=this.stack.pop();ee.position.end=En(Q.end)}function te(Q){C.call(this,Q);const ee=this.stack[this.stack.length-1];ee.url=this.sliceSerialize(Q)}function ue(Q){C.call(this,Q);const ee=this.stack[this.stack.length-1];ee.url="mailto:"+this.sliceSerialize(Q)}function ge(){return{type:"blockquote",children:[]}}function Z(){return{type:"code",lang:null,meta:null,value:""}}function re(){return{type:"inlineCode",value:""}}function be(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ve(){return{type:"emphasis",children:[]}}function Fe(){return{type:"heading",depth:0,children:[]}}function je(){return{type:"break"}}function Se(){return{type:"html",value:""}}function Oe(){return{type:"image",title:null,url:"",alt:null}}function st(){return{type:"link",title:null,url:"",children:[]}}function pt(Q){return{type:"list",ordered:Q.type==="listOrdered",start:null,spread:Q._spread,children:[]}}function me(Q){return{type:"listItem",spread:Q._spread,checked:null,children:[]}}function rt(){return{type:"paragraph",children:[]}}function ie(){return{type:"strong",children:[]}}function Ie(){return{type:"text",value:""}}function Be(){return{type:"thematicBreak"}}}function En(e){return{line:e.line,column:e.column,offset:e.offset}}function vp(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?vp(e,r):lk(e,r)}}function lk(e,t){let n;for(n in t)if(yp.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 gd(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+pi({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+pi({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+pi({start:t.start,end:t.end})+") is still open")}function uk(e){const t=this;t.parser=n;function n(r){return ak(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function ck(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 dk(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
@@ -534,7 +534,7 @@ Based on my performance, decide what comes next: explain why I got questions wro
534
534
  `,...i.current()});return/^[\t ]/.test(u)&&(u=Di(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),l(),o(),u}Fp.peek=Rw;function Fp(e){return e.value||""}function Rw(){return"<"}Bp.peek=Mw;function Bp(e,t,n,r){const s=vu(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 Mw(){return"!"}jp.peek=Pw;function jp(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 h=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=c,i(),s==="full"||!u||u!==h?l+=o.move(h+"]"):s==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function Pw(){return"!"}Hp.peek=Lw;function Hp(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 Lw(){return"`"}function Up(e,t){const n=hu(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))}zp.peek=Dw;function zp(e,t,n,r){const s=vu(n),i=s==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,l;if(Up(e,n)){const c=n.stack;n.stack=[],o=n.enter("autolink");let h=a.move("<");return h+=a.move(n.containerPhrasing(e,{before:h,after:">",...a.current()})),h+=a.move(">"),o(),n.stack=c,h}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 Dw(e,t,n){return Up(e,n)?"<":"["}Vp.peek=Ow;function Vp(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 h=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=c,i(),s==="full"||!u||u!==h?l+=o.move(h+"]"):s==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function Ow(){return"["}function Eu(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 Fw(e){const t=Eu(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 Bw(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 qp(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 jw(e,t,n,r){const s=n.enter("list"),i=n.bulletCurrent;let a=e.ordered?Bw(n):Eu(n);const o=e.ordered?a==="."?")":".":Fw(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),qp(n)===a&&c){let h=-1;for(;++h<e.children.length;){const f=e.children[h];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.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 Hw(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 Uw(e,t,n,r){const s=Hw(n);let i=n.bulletCurrent||Eu(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(h,f,d){return f?(d?"":" ".repeat(a))+h:(d?i:i+" ".repeat(a-i.length))+h}}function zw(e,t,n,r){const s=n.enter("paragraph"),i=n.enter("phrasing"),a=n.containerPhrasing(e,r);return i(),s(),a}const Vw=Ca(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function qw(e,t,n,r){return(e.children.some(function(a){return Vw(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function $w(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}$p.peek=Ww;function $p(e,t,n,r){const s=$w(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=ea(r.before.charCodeAt(r.before.length-1),u,s);c.inside&&(l=Di(u)+l.slice(1));const h=l.charCodeAt(l.length-1),f=ea(r.after.charCodeAt(0),h,s);f.inside&&(l=l.slice(0,-1)+Di(h));const d=a.move(s+s);return i(),n.attentionEncodeSurroundingInfo={after:f.outside,before:c.outside},o+l+d}function Ww(e,t,n){return n.options.strong||"*"}function Yw(e,t,n,r){return n.safe(e.value,r)}function Gw(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 Kw(e,t,n){const r=(qp(n)+(n.options.ruleSpaces?" ":"")).repeat(Gw(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Wp={blockquote:xw,break:Od,code:ww,definition:Aw,emphasis:Op,hardBreak:Od,heading:Iw,html:Fp,image:Bp,imageReference:jp,inlineCode:Hp,link:zp,linkReference:Vp,list:jw,listItem:Uw,paragraph:zw,root:qw,strong:$p,text:Yw,thematicBreak:Kw};function Xw(){return{enter:{table:Qw,tableData:Fd,tableHeader:Fd,tableRow:Jw},exit:{codeText:eS,table:Zw,tableData:Eo,tableHeader:Eo,tableRow:Eo}}}function Qw(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 Zw(e){this.exit(e),this.data.inTable=void 0}function Jw(e){this.enter({type:"tableRow",children:[]},e)}function Eo(e){this.exit(e)}function Fd(e){this.enter({type:"tableCell",children:[]},e)}function eS(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,tS));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function tS(e,t){return t==="|"?t:e}function nS(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,s=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
535
535
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:a,tableCell:l,tableRow:o}};function a(d,m,g,b){return u(c(d,g,b),d.align)}function o(d,m,g,b){const y=h(d,g,b),w=u([y]);return w.slice(0,w.indexOf(`
536
536
  `))}function l(d,m,g,b){const y=g.enter("tableCell"),w=g.enter("phrasing"),E=g.containerPhrasing(d,{...b,before:i,after:i});return w(),y(),E}function u(d,m){return gw(d,{align:m,alignDelimiters:r,padding:n,stringLength:s})}function c(d,m,g){const b=d.children;let y=-1;const w=[],E=m.enter("table");for(;++y<b.length;)w[y]=h(b[y],m,g);return E(),w}function h(d,m,g){const b=d.children;let y=-1;const w=[],E=m.enter("tableRow");for(;++y<b.length;)w[y]=l(b[y],d,m,g);return E(),w}function f(d,m,g){let b=Wp.inlineCode(d,m,g);return g.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function rS(){return{exit:{taskListCheckValueChecked:Bd,taskListCheckValueUnchecked:Bd,paragraph:sS}}}function iS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:aS}}}function Bd(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function sS(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 aS(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=Wp.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 oS(){return[jT(),aw(),cw(),Xw(),rS()]}function lS(e){return{extensions:[HT(),ow(e),dw(),nS(e),iS()]}}const uS={tokenize:pS,partial:!0},Yp={tokenize:gS,partial:!0},Gp={tokenize:bS,partial:!0},Kp={tokenize:xS,partial:!0},cS={tokenize:yS,partial:!0},Xp={name:"wwwAutolink",tokenize:fS,previous:Zp},Qp={name:"protocolAutolink",tokenize:mS,previous:Jp},yn={name:"emailAutolink",tokenize:hS,previous:e0},hn={};function dS(){return{text:hn}}let Vn=48;for(;Vn<123;)hn[Vn]=yn,Vn++,Vn===58?Vn=65:Vn===91&&(Vn=97);hn[43]=yn;hn[45]=yn;hn[46]=yn;hn[95]=yn;hn[72]=[yn,Qp];hn[104]=[yn,Qp];hn[87]=[yn,Xp];hn[119]=[yn,Xp];function hS(e,t,n){const r=this;let s,i;return a;function a(h){return!hl(h)||!e0.call(r,r.previous)||ku(r.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(h))}function o(h){return hl(h)?(e.consume(h),o):h===64?(e.consume(h),l):n(h)}function l(h){return h===46?e.check(cS,c,u)(h):h===45||h===95||kt(h)?(i=!0,e.consume(h),l):c(h)}function u(h){return e.consume(h),s=!0,l}function c(h){return i&&s&&At(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function fS(e,t,n){const r=this;return s;function s(a){return a!==87&&a!==119||!Zp.call(r,r.previous)||ku(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(uS,e.attempt(Yp,e.attempt(Gp,i),n),n)(a))}function i(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function mS(e,t,n){const r=this;let s="",i=!1;return a;function a(h){return(h===72||h===104)&&Jp.call(r,r.previous)&&!ku(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(h),e.consume(h),o):n(h)}function o(h){if(At(h)&&s.length<5)return s+=String.fromCodePoint(h),e.consume(h),o;if(h===58){const f=s.toLowerCase();if(f==="http"||f==="https")return e.consume(h),l}return n(h)}function l(h){return h===47?(e.consume(h),i?u:(i=!0,l)):n(h)}function u(h){return h===null||Zs(h)||nt(h)||or(h)||wa(h)?n(h):e.attempt(Yp,e.attempt(Gp,c),n)(h)}function c(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function pS(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 gS(e,t,n){let r,s,i;return a;function a(u){return u===46||u===95?e.check(Kp,l,o)(u):u===null||nt(u)||or(u)||u!==45&&wa(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 bS(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(Kp,t,i)(a):a===null||nt(a)||or(a)?t(a):(e.consume(a),s)}function i(a){return a===41&&r++,e.consume(a),s}}function xS(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||nt(o)||or(o)?t(o):n(o)}function s(o){return o===null||o===40||o===91||nt(o)||or(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 yS(e,t,n){return r;function r(i){return e.consume(i),s}function s(i){return kt(i)?n(i):t(i)}}function Zp(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||nt(e)}function Jp(e){return!At(e)}function e0(e){return!(e===47||hl(e))}function hl(e){return e===43||e===45||e===46||e===95||kt(e)}function ku(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 vS={tokenize:_S,partial:!0};function ES(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:SS,continuation:{tokenize:AS},exit:CS}},text:{91:{name:"gfmFootnoteCall",tokenize:wS},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:kS,resolveTo:TS}}}}function kS(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=Qt(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 TS(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 wS(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i=0,a;return o;function o(h){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),l}function l(h){return h!==94?n(h):(e.enter("gfmFootnoteCallMarker"),e.consume(h),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(h){if(i>999||h===93&&!a||h===null||h===91||nt(h))return n(h);if(h===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return s.includes(Qt(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(h)}return nt(h)||(a=!0),i++,e.consume(h),h===92?c:u}function c(h){return h===91||h===92||h===93?(e.consume(h),i++,u):u(h)}}function SS(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||nt(m))return n(m);if(m===93){e.exit("chunkString");const g=e.exit("gfmFootnoteDefinitionLabelString");return i=Qt(r.sliceSerialize(g)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return nt(m)||(o=!0),a++,e.consume(m),m===92?h:c}function h(m){return m===91||m===92||m===93?(e.consume(m),a++,c):c(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),s.includes(i)||s.push(i),qe(e,d,"gfmFootnoteDefinitionWhitespace")):n(m)}function d(m){return t(m)}}function AS(e,t,n){return e.check(Wi,t,e.attempt(vS,t,n))}function CS(e){e.exit("gfmFootnoteDefinition")}function _S(e,t,n){const r=this;return qe(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 NS(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)},h={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[l][1].start)},f=[["enter",c,o],["enter",a[u][1],o],["exit",a[u][1],o],["enter",h,o]],d=o.parser.constructs.insideSpan.null;d&&Ft(f,f.length,0,Sa(d,a.slice(u+1,l),o)),Ft(f,f.length,0,[["exit",h,o],["enter",a[l][1],o],["exit",a[l][1],o],["exit",c,o]]),Ft(a,u-1,l-u+3,f),l=u+f.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 h=0;return f;function f(m){return u===126&&c[c.length-1][1].type!=="characterEscape"?l(m):(a.enter("strikethroughSequenceTemporary"),d(m))}function d(m){const g=Pr(u);if(m===126)return h>1?l(m):(a.consume(m),h++,d);if(h<2&&!n)return l(m);const b=a.exit("strikethroughSequenceTemporary"),y=Pr(m);return b._open=!y||y===2&&!!g,b._close=!g||g===2&&!!y,o(m)}}}class IS{constructor(){this.map=[]}add(t,n,r){RS(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 RS(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 MS(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 PS(){return{flow:{null:{name:"table",tokenize:LS,resolveAll:DS}}}}function LS(e,t,n){const r=this;let s=0,i=0,a;return o;function o(C){let D=r.events.length-1;for(;D>-1;){const I=r.events[D][1].type;if(I==="lineEnding"||I==="linePrefix")D--;else break}const P=D>-1?r.events[D][1].type:null,O=P==="tableHead"||P==="tableRow"?T:l;return O===T&&r.parser.lazy[r.now().line]?n(C):O(C)}function l(C){return e.enter("tableHead"),e.enter("tableRow"),u(C)}function u(C){return C===124||(a=!0,i+=1),c(C)}function c(C){return C===null?n(C):Ne(C)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),d):n(C):Ue(C)?qe(e,c,"whitespace")(C):(i+=1,a&&(a=!1,s+=1),C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),a=!0,c):(e.enter("data"),h(C)))}function h(C){return C===null||C===124||nt(C)?(e.exit("data"),c(C)):(e.consume(C),C===92?f:h)}function f(C){return C===92||C===124?(e.consume(C),h):h(C)}function d(C){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(C):(e.enter("tableDelimiterRow"),a=!1,Ue(C)?qe(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):m(C))}function m(C){return C===45||C===58?b(C):C===124?(a=!0,e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),g):v(C)}function g(C){return Ue(C)?qe(e,b,"whitespace")(C):b(C)}function b(C){return C===58?(i+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),y):C===45?(i+=1,y(C)):C===null||Ne(C)?S(C):v(C)}function y(C){return C===45?(e.enter("tableDelimiterFiller"),w(C)):v(C)}function w(C){return C===45?(e.consume(C),w):C===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(C))}function E(C){return Ue(C)?qe(e,S,"whitespace")(C):S(C)}function S(C){return C===124?m(C):C===null||Ne(C)?!a||s!==i?v(C):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(C)):v(C)}function v(C){return n(C)}function T(C){return e.enter("tableRow"),_(C)}function _(C){return C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),_):C===null||Ne(C)?(e.exit("tableRow"),t(C)):Ue(C)?qe(e,_,"whitespace")(C):(e.enter("data"),A(C))}function A(C){return C===null||C===124||nt(C)?(e.exit("data"),_(C)):(e.consume(C),C===92?N:A)}function N(C){return C===92||C===124?(e.consume(C),A):A(C)}}function DS(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,h;const f=new IS;for(;++n<e.length;){const d=e[n],m=d[1];d[0]==="enter"?m.type==="tableHead"?(o=!1,l!==0&&(jd(f,t,l,u,c),c=void 0,l=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,h=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)},f.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],h=Es(f,t,i,s,void 0,h),i=[0,0,0,0]),a[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(i[1]!==0&&(a[0]=a[1],h=Es(f,t,i,s,void 0,h)),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],h=Es(f,t,i,s,n,h)):a[1]!==0&&(h=Es(f,t,a,s,n,h)),s=0):s&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&jd(f,t,l,u,c),f.consume(t.events),n=-1;++n<t.events.length;){const d=t.events[n];d[0]==="enter"&&d[1].type==="table"&&(d[1]._align=MS(t.events,n))}return e}function Es(e,t,n,r,s,i){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(i.end=Object.assign({},vr(t.events,n[0])),e.add(n[0],0,[["exit",i,t]]));const l=vr(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=vr(t.events,n[2]),c=vr(t.events,n[3]),h={type:o,start:Object.assign({},u),end:Object.assign({},c)};if(e.add(n[2],0,[["enter",h,t]]),r!==2){const f=t.events[n[2]],d=t.events[n[3]];if(f[1].end=Object.assign({},d[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,g=n[3]-n[2]-1;e.add(m,g,[])}}e.add(n[3]+1,0,[["exit",h,t]])}return s!==void 0&&(i.end=Object.assign({},vr(t.events,s)),e.add(s,0,[["exit",i,t]]),i=void 0),i}function jd(e,t,n,r,s){const i=[],a=vr(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 vr(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const OS={name:"tasklistCheck",tokenize:BS};function FS(){return{text:{91:OS}}}function BS(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 nt(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 Ne(l)?t(l):Ue(l)?e.check({tokenize:jS},t,n)(l):n(l)}}function jS(e,t,n){return qe(e,r,"whitespace");function r(s){return s===null?n(s):t(s)}}function HS(e){return lp([dS(),ES(),NS(e),PS(),FS()])}const US={};function t0(e){const t=this,n=e||US,r=t.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),i=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(HS(n)),i.push(oS()),a.push(lS(n))}const Hd=/[#.]/g;function zS(e,t){const n=e||"",r={};let s=0,i,a;for(;s<n.length;){Hd.lastIndex=s;const o=Hd.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 n0(e,t,n){const r=n?WS(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=zS(i,t);const u=l.tagName.toLowerCase(),c=r?r.get(u):void 0;if(l.tagName=c||u,VS(a))o.unshift(a);else for(const[h,f]of Object.entries(a))qS(e,l.properties,h,f)}for(const u of o)fl(l.children,u);return l.type==="element"&&l.tagName==="template"&&(l.content={type:"root",children:l.children},l.children=[]),l}return s}function VS(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 qS(e,t,n,r){const s=ka(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=Jc(r):s.commaSeparated?i=Gc(r):s.commaOrSpaceSeparated?i=Jc(Gc(r).join(" ")):i=Ud(s,s.property,r):Array.isArray(r)?i=[...r]:i=s.property==="style"?$S(r):String(r);if(Array.isArray(i)){const a=[];for(const o of i)a.push(Ud(s,s.property,o));i=a}s.property==="className"&&Array.isArray(t.className)&&(i=t.className.concat(i)),t[s.property]=i}}function fl(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)fl(e,n);else if(typeof t=="object"&&"type"in t)t.type==="root"?fl(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function Ud(e,t,n){if(typeof n=="string"){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===""||Pi(n)===Pi(t)))return!0}return n}function $S(e){const t=[];for(const[n,r]of Object.entries(e))t.push([n,r].join(": "));return t.join("; ")}function WS(e){const t=new Map;for(const n of e)t.set(n.toLowerCase(),n);return t}const YS=["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"],GS=n0($i,"div"),KS=n0(Rn,"g",YS);function XS(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=zd(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=zd(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 zd(e,t){const n=e.indexOf("\r",t),r=e.indexOf(`
537
- `,t);return r===-1?n:n===-1||n+1===r?r:n<r?n:r}const Xn={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/"},r0={}.hasOwnProperty,QS=Object.prototype;function ZS(e,t){const n=t||{};return Tu({file:n.file||void 0,location:!1,schema:n.space==="svg"?Rn:$i,verbose:n.verbose||!1},e)}function Tu(e,t){let n;switch(t.nodeName){case"#comment":{const r=t;return n={type:"comment",value:r.data},Ds(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:i0(e,t.childNodes),data:{quirksMode:s}},e.file&&e.location){const i=String(e.file),a=XS(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"},Ds(e,r,n),n}case"#text":{const r=t;return n={type:"text",value:r.value},Ds(e,r,n),n}default:return n=JS(e,t),n}}function i0(e,t){let n=-1;const r=[];for(;++n<t.length;){const s=Tu(e,t[n]);r.push(s)}return r}function JS(e,t){const n=e.schema;e.schema=t.namespaceURI===Xn.svg?Rn:$i;let r=-1;const s={};for(;++r<t.attrs.length;){const o=t.attrs[r],l=(o.prefix?o.prefix+":":"")+o.name;r0.call(QS,l)||(s[l]=o.value)}const a=(e.schema.space==="svg"?KS:GS)(t.tagName,s,i0(e,t.childNodes));if(Ds(e,t,a),a.tagName==="template"){const o=t,l=o.sourceCodeLocation,u=l&&l.startTag&&kr(l.startTag),c=l&&l.endTag&&kr(l.endTag),h=Tu(e,o.content);u&&c&&e.file&&(h.position={start:u.end,end:c.start}),a.content=h}return e.schema=n,a}function Ds(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const r=eA(e,n,t.sourceCodeLocation);r&&(e.location=!0,n.position=r)}}function eA(e,t,n){const r=kr(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)r0.call(n.attrs,a)&&(i[ka(e.schema,a).property]=kr(n.attrs[a]));n.startTag;const o=kr(n.startTag),l=n.endTag?kr(n.endTag):void 0,u={opening:o};l&&(u.closing=l),u.properties=i,t.data={position:u}}}return r}function kr(e){const t=Vd({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=Vd({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function Vd(e){return e.line&&e.column?e:void 0}const tA={},nA={}.hasOwnProperty,s0=Dp("type",{handlers:{root:iA,element:uA,text:oA,comment:lA,doctype:aA}});function rA(e,t){const r=(t||tA).space;return s0(e,r==="svg"?Rn:$i)}function iA(e,t){const n={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return n.childNodes=wu(e.children,n,t),jr(e,n),n}function sA(e,t){const n={nodeName:"#document-fragment",childNodes:[]};return n.childNodes=wu(e.children,n,t),jr(e,n),n}function aA(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return jr(e,t),t}function oA(e){const t={nodeName:"#text",value:e.value,parentNode:null};return jr(e,t),t}function lA(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return jr(e,t),t}function uA(e,t){const n=t;let r=n;e.type==="element"&&e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(r=Rn);const s=[];let i;if(e.properties){for(i in e.properties)if(i!=="children"&&nA.call(e.properties,i)){const l=cA(r,i,e.properties[i]);l&&s.push(l)}}const a=r.space,o={nodeName:e.tagName,tagName:e.tagName,attrs:s,namespaceURI:Xn[a],childNodes:[],parentNode:null};return o.childNodes=wu(e.children,o,r),jr(e,o),e.tagName==="template"&&e.content&&(o.content=sA(e.content,r)),o}function cA(e,t,n){const r=ka(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?Wm(n):ep(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=Xn[r.space]}return s}function wu(e,t,n){let r=-1;const s=[];if(e)for(;++r<e.length;){const i=s0(e[r],n);i.parentNode=t,s.push(i)}return s}function jr(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 dA=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],hA=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 F;(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"})(F||(F={}));const Rt={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function a0(e){return e>=55296&&e<=57343}function fA(e){return e>=56320&&e<=57343}function mA(e,t){return(e-55296)*1024+9216+t}function o0(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function l0(e){return e>=64976&&e<=65007||hA.has(e)}var J;(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"})(J||(J={}));const pA=65536;class gA{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=pA,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(fA(n))return this.pos++,this._addGap(),mA(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,F.EOF;return this._err(J.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,F.EOF;const r=this.html.charCodeAt(n);return r===F.CARRIAGE_RETURN?F.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,F.EOF;let t=this.html.charCodeAt(this.pos);return t===F.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,F.LINE_FEED):t===F.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,a0(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===F.LINE_FEED||t===F.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){o0(t)?this._err(J.controlCharacterInInputStream):l0(t)&&this._err(J.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 u0(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 bA=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))),xA=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 yA(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=xA.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 vA=32;var An;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(An||(An={}));function ml(e){return e>=xt.ZERO&&e<=xt.NINE}function EA(e){return e>=xt.UPPER_A&&e<=xt.UPPER_F||e>=xt.LOWER_A&&e<=xt.LOWER_F}function kA(e){return e>=xt.UPPER_A&&e<=xt.UPPER_Z||e>=xt.LOWER_A&&e<=xt.LOWER_Z||ml(e)}function TA(e){return e===xt.EQUALS||kA(e)}var bt;(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"})(bt||(bt={}));var bn;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(bn||(bn={}));class wA{constructor(t,n,r){this.decodeTree=t,this.emitCodePoint=n,this.errors=r,this.state=bt.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=bn.Strict}startEntity(t){this.decodeMode=t,this.state=bt.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,n){switch(this.state){case bt.EntityStart:return t.charCodeAt(n)===xt.NUM?(this.state=bt.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=bt.NamedEntity,this.stateNamedEntity(t,n));case bt.NumericStart:return this.stateNumericStart(t,n);case bt.NumericDecimal:return this.stateNumericDecimal(t,n);case bt.NumericHex:return this.stateNumericHex(t,n);case bt.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|vA)===xt.LOWER_X?(this.state=bt.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=bt.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(ml(s)||EA(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(ml(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===bn.Strict)return 0;return this.emitCodePoint(yA(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&An.VALUE_LENGTH)>>14;for(;n<t.length;n++,this.excess++){const a=t.charCodeAt(n);if(this.treeIndex=SA(r,s,this.treeIndex+Math.max(1,i),a),this.treeIndex<0)return this.result===0||this.decodeMode===bn.Attribute&&(i===0||TA(a))?0:this.emitNotTerminatedNamedEntity();if(s=r[this.treeIndex],i=(s&An.VALUE_LENGTH)>>14,i!==0){if(a===xt.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==bn.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]&An.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]&~An.VALUE_LENGTH:s[t+1],r),n===3&&this.emitCodePoint(s[t+2],r),r}end(){var t;switch(this.state){case bt.NamedEntity:return this.result!==0&&(this.decodeMode!==bn.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case bt.NumericDecimal:return this.emitNumericEntity(0,2);case bt.NumericHex:return this.emitNumericEntity(0,3);case bt.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case bt.EntityStart:return 0}}}function SA(e,t,n,r){const s=(t&An.BRANCH_LENGTH)>>7,i=t&An.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 le;(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/"})(le||(le={}));var nr;(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"})(nr||(nr={}));var zt;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(zt||(zt={}));var W;(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"})(W||(W={}));var x;(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"})(x||(x={}));const AA=new Map([[W.A,x.A],[W.ADDRESS,x.ADDRESS],[W.ANNOTATION_XML,x.ANNOTATION_XML],[W.APPLET,x.APPLET],[W.AREA,x.AREA],[W.ARTICLE,x.ARTICLE],[W.ASIDE,x.ASIDE],[W.B,x.B],[W.BASE,x.BASE],[W.BASEFONT,x.BASEFONT],[W.BGSOUND,x.BGSOUND],[W.BIG,x.BIG],[W.BLOCKQUOTE,x.BLOCKQUOTE],[W.BODY,x.BODY],[W.BR,x.BR],[W.BUTTON,x.BUTTON],[W.CAPTION,x.CAPTION],[W.CENTER,x.CENTER],[W.CODE,x.CODE],[W.COL,x.COL],[W.COLGROUP,x.COLGROUP],[W.DD,x.DD],[W.DESC,x.DESC],[W.DETAILS,x.DETAILS],[W.DIALOG,x.DIALOG],[W.DIR,x.DIR],[W.DIV,x.DIV],[W.DL,x.DL],[W.DT,x.DT],[W.EM,x.EM],[W.EMBED,x.EMBED],[W.FIELDSET,x.FIELDSET],[W.FIGCAPTION,x.FIGCAPTION],[W.FIGURE,x.FIGURE],[W.FONT,x.FONT],[W.FOOTER,x.FOOTER],[W.FOREIGN_OBJECT,x.FOREIGN_OBJECT],[W.FORM,x.FORM],[W.FRAME,x.FRAME],[W.FRAMESET,x.FRAMESET],[W.H1,x.H1],[W.H2,x.H2],[W.H3,x.H3],[W.H4,x.H4],[W.H5,x.H5],[W.H6,x.H6],[W.HEAD,x.HEAD],[W.HEADER,x.HEADER],[W.HGROUP,x.HGROUP],[W.HR,x.HR],[W.HTML,x.HTML],[W.I,x.I],[W.IMG,x.IMG],[W.IMAGE,x.IMAGE],[W.INPUT,x.INPUT],[W.IFRAME,x.IFRAME],[W.KEYGEN,x.KEYGEN],[W.LABEL,x.LABEL],[W.LI,x.LI],[W.LINK,x.LINK],[W.LISTING,x.LISTING],[W.MAIN,x.MAIN],[W.MALIGNMARK,x.MALIGNMARK],[W.MARQUEE,x.MARQUEE],[W.MATH,x.MATH],[W.MENU,x.MENU],[W.META,x.META],[W.MGLYPH,x.MGLYPH],[W.MI,x.MI],[W.MO,x.MO],[W.MN,x.MN],[W.MS,x.MS],[W.MTEXT,x.MTEXT],[W.NAV,x.NAV],[W.NOBR,x.NOBR],[W.NOFRAMES,x.NOFRAMES],[W.NOEMBED,x.NOEMBED],[W.NOSCRIPT,x.NOSCRIPT],[W.OBJECT,x.OBJECT],[W.OL,x.OL],[W.OPTGROUP,x.OPTGROUP],[W.OPTION,x.OPTION],[W.P,x.P],[W.PARAM,x.PARAM],[W.PLAINTEXT,x.PLAINTEXT],[W.PRE,x.PRE],[W.RB,x.RB],[W.RP,x.RP],[W.RT,x.RT],[W.RTC,x.RTC],[W.RUBY,x.RUBY],[W.S,x.S],[W.SCRIPT,x.SCRIPT],[W.SEARCH,x.SEARCH],[W.SECTION,x.SECTION],[W.SELECT,x.SELECT],[W.SOURCE,x.SOURCE],[W.SMALL,x.SMALL],[W.SPAN,x.SPAN],[W.STRIKE,x.STRIKE],[W.STRONG,x.STRONG],[W.STYLE,x.STYLE],[W.SUB,x.SUB],[W.SUMMARY,x.SUMMARY],[W.SUP,x.SUP],[W.TABLE,x.TABLE],[W.TBODY,x.TBODY],[W.TEMPLATE,x.TEMPLATE],[W.TEXTAREA,x.TEXTAREA],[W.TFOOT,x.TFOOT],[W.TD,x.TD],[W.TH,x.TH],[W.THEAD,x.THEAD],[W.TITLE,x.TITLE],[W.TR,x.TR],[W.TRACK,x.TRACK],[W.TT,x.TT],[W.U,x.U],[W.UL,x.UL],[W.SVG,x.SVG],[W.VAR,x.VAR],[W.WBR,x.WBR],[W.XMP,x.XMP]]);function Hr(e){var t;return(t=AA.get(e))!==null&&t!==void 0?t:x.UNKNOWN}const ce=x,CA={[le.HTML]:new Set([ce.ADDRESS,ce.APPLET,ce.AREA,ce.ARTICLE,ce.ASIDE,ce.BASE,ce.BASEFONT,ce.BGSOUND,ce.BLOCKQUOTE,ce.BODY,ce.BR,ce.BUTTON,ce.CAPTION,ce.CENTER,ce.COL,ce.COLGROUP,ce.DD,ce.DETAILS,ce.DIR,ce.DIV,ce.DL,ce.DT,ce.EMBED,ce.FIELDSET,ce.FIGCAPTION,ce.FIGURE,ce.FOOTER,ce.FORM,ce.FRAME,ce.FRAMESET,ce.H1,ce.H2,ce.H3,ce.H4,ce.H5,ce.H6,ce.HEAD,ce.HEADER,ce.HGROUP,ce.HR,ce.HTML,ce.IFRAME,ce.IMG,ce.INPUT,ce.LI,ce.LINK,ce.LISTING,ce.MAIN,ce.MARQUEE,ce.MENU,ce.META,ce.NAV,ce.NOEMBED,ce.NOFRAMES,ce.NOSCRIPT,ce.OBJECT,ce.OL,ce.P,ce.PARAM,ce.PLAINTEXT,ce.PRE,ce.SCRIPT,ce.SECTION,ce.SELECT,ce.SOURCE,ce.STYLE,ce.SUMMARY,ce.TABLE,ce.TBODY,ce.TD,ce.TEMPLATE,ce.TEXTAREA,ce.TFOOT,ce.TH,ce.THEAD,ce.TITLE,ce.TR,ce.TRACK,ce.UL,ce.WBR,ce.XMP]),[le.MATHML]:new Set([ce.MI,ce.MO,ce.MN,ce.MS,ce.MTEXT,ce.ANNOTATION_XML]),[le.SVG]:new Set([ce.TITLE,ce.FOREIGN_OBJECT,ce.DESC]),[le.XLINK]:new Set,[le.XML]:new Set,[le.XMLNS]:new Set},pl=new Set([ce.H1,ce.H2,ce.H3,ce.H4,ce.H5,ce.H6]);W.STYLE,W.SCRIPT,W.XMP,W.IFRAME,W.NOEMBED,W.NOFRAMES,W.PLAINTEXT;var j;(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"})(j||(j={}));const ct={DATA:j.DATA,RCDATA:j.RCDATA,RAWTEXT:j.RAWTEXT,SCRIPT_DATA:j.SCRIPT_DATA,PLAINTEXT:j.PLAINTEXT,CDATA_SECTION:j.CDATA_SECTION};function _A(e){return e>=F.DIGIT_0&&e<=F.DIGIT_9}function di(e){return e>=F.LATIN_CAPITAL_A&&e<=F.LATIN_CAPITAL_Z}function NA(e){return e>=F.LATIN_SMALL_A&&e<=F.LATIN_SMALL_Z}function kn(e){return NA(e)||di(e)}function qd(e){return kn(e)||_A(e)}function ks(e){return e+32}function c0(e){return e===F.SPACE||e===F.LINE_FEED||e===F.TABULATION||e===F.FORM_FEED}function $d(e){return c0(e)||e===F.SOLIDUS||e===F.GREATER_THAN_SIGN}function IA(e){return e===F.NULL?J.nullCharacterReference:e>1114111?J.characterReferenceOutsideUnicodeRange:a0(e)?J.surrogateCharacterReference:l0(e)?J.noncharacterCharacterReference:o0(e)||e===F.CARRIAGE_RETURN?J.controlCharacterReference:null}class RA{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=j.DATA,this.returnState=j.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new gA(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new wA(bA,(r,s)=>{this.preprocessor.pos=this.entityStartPos+s-1,this._flushCodePointConsumedAsCharacterReference(r)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(J.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:r=>{this._err(J.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+r)},validateNumericCharacterReference:r=>{const s=IA(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:x.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:He.END_TAG,tagName:"",tagID:x.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(u0(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(J.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=Hr(t.tagName),t.type===He.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(J.endTagWithAttributes),t.selfClosing&&this._err(J.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=c0(t)?He.WHITESPACE_CHARACTER:t===F.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=j.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?bn.Attribute:bn.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===j.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===j.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===j.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case j.DATA:{this._stateData(t);break}case j.RCDATA:{this._stateRcdata(t);break}case j.RAWTEXT:{this._stateRawtext(t);break}case j.SCRIPT_DATA:{this._stateScriptData(t);break}case j.PLAINTEXT:{this._statePlaintext(t);break}case j.TAG_OPEN:{this._stateTagOpen(t);break}case j.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case j.TAG_NAME:{this._stateTagName(t);break}case j.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case j.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case j.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case j.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case j.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case j.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case j.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case j.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case j.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case j.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case j.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case j.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case j.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case j.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case j.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case j.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case j.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case j.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case j.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case j.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case j.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case j.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case j.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case j.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case j.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case j.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case j.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case j.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case j.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case j.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case j.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case j.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case j.BOGUS_COMMENT:{this._stateBogusComment(t);break}case j.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case j.COMMENT_START:{this._stateCommentStart(t);break}case j.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case j.COMMENT:{this._stateComment(t);break}case j.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case j.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case j.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case j.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case j.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case j.COMMENT_END:{this._stateCommentEnd(t);break}case j.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case j.DOCTYPE:{this._stateDoctype(t);break}case j.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case j.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case j.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case j.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case j.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case j.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case j.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case j.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case j.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case j.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case j.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case j.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case j.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case j.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case j.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case j.CDATA_SECTION:{this._stateCdataSection(t);break}case j.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case j.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case j.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case j.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case F.LESS_THAN_SIGN:{this.state=j.TAG_OPEN;break}case F.AMPERSAND:{this._startCharacterReference();break}case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitCodePoint(t);break}case F.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case F.AMPERSAND:{this._startCharacterReference();break}case F.LESS_THAN_SIGN:{this.state=j.RCDATA_LESS_THAN_SIGN;break}case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitChars(ot);break}case F.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case F.LESS_THAN_SIGN:{this.state=j.RAWTEXT_LESS_THAN_SIGN;break}case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitChars(ot);break}case F.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_LESS_THAN_SIGN;break}case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitChars(ot);break}case F.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitChars(ot);break}case F.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(kn(t))this._createStartTagToken(),this.state=j.TAG_NAME,this._stateTagName(t);else switch(t){case F.EXCLAMATION_MARK:{this.state=j.MARKUP_DECLARATION_OPEN;break}case F.SOLIDUS:{this.state=j.END_TAG_OPEN;break}case F.QUESTION_MARK:{this._err(J.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=j.BOGUS_COMMENT,this._stateBogusComment(t);break}case F.EOF:{this._err(J.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(J.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=j.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(kn(t))this._createEndTagToken(),this.state=j.TAG_NAME,this._stateTagName(t);else switch(t){case F.GREATER_THAN_SIGN:{this._err(J.missingEndTagName),this.state=j.DATA;break}case F.EOF:{this._err(J.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(J.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=j.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this.state=j.BEFORE_ATTRIBUTE_NAME;break}case F.SOLIDUS:{this.state=j.SELF_CLOSING_START_TAG;break}case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentTagToken();break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.tagName+=ot;break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:n.tagName+=String.fromCodePoint(di(t)?ks(t):t)}}_stateRcdataLessThanSign(t){t===F.SOLIDUS?this.state=j.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=j.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){kn(t)?(this.state=j.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=j.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 F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=j.BEFORE_ATTRIBUTE_NAME,!1;case F.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=j.SELF_CLOSING_START_TAG,!1;case F.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=j.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=j.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===F.SOLIDUS?this.state=j.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=j.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){kn(t)?(this.state=j.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=j.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=j.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case F.SOLIDUS:{this.state=j.SCRIPT_DATA_END_TAG_OPEN;break}case F.EXCLAMATION_MARK:{this.state=j.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=j.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){kn(t)?(this.state=j.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=j.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=j.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===F.HYPHEN_MINUS?(this.state=j.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=j.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===F.HYPHEN_MINUS?(this.state=j.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=j.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case F.HYPHEN_MINUS:{this.state=j.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitChars(ot);break}case F.EOF:{this._err(J.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case F.HYPHEN_MINUS:{this.state=j.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.state=j.SCRIPT_DATA_ESCAPED,this._emitChars(ot);break}case F.EOF:{this._err(J.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=j.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case F.HYPHEN_MINUS:{this._emitChars("-");break}case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case F.GREATER_THAN_SIGN:{this.state=j.SCRIPT_DATA,this._emitChars(">");break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.state=j.SCRIPT_DATA_ESCAPED,this._emitChars(ot);break}case F.EOF:{this._err(J.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=j.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===F.SOLIDUS?this.state=j.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:kn(t)?(this._emitChars("<"),this.state=j.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=j.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){kn(t)?(this.state=j.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=j.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=j.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(Rt.SCRIPT,!1)&&$d(this.preprocessor.peek(Rt.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<Rt.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=j.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case F.HYPHEN_MINUS:{this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitChars(ot);break}case F.EOF:{this._err(J.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case F.HYPHEN_MINUS:{this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(ot);break}case F.EOF:{this._err(J.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case F.HYPHEN_MINUS:{this._emitChars("-");break}case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case F.GREATER_THAN_SIGN:{this.state=j.SCRIPT_DATA,this._emitChars(">");break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(ot);break}case F.EOF:{this._err(J.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===F.SOLIDUS?(this.state=j.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(Rt.SCRIPT,!1)&&$d(this.preprocessor.peek(Rt.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<Rt.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=j.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.SOLIDUS:case F.GREATER_THAN_SIGN:case F.EOF:{this.state=j.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case F.EQUALS_SIGN:{this._err(J.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=j.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=j.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:case F.SOLIDUS:case F.GREATER_THAN_SIGN:case F.EOF:{this._leaveAttrName(),this.state=j.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case F.EQUALS_SIGN:{this._leaveAttrName(),this.state=j.BEFORE_ATTRIBUTE_VALUE;break}case F.QUOTATION_MARK:case F.APOSTROPHE:case F.LESS_THAN_SIGN:{this._err(J.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.currentAttr.name+=ot;break}default:this.currentAttr.name+=String.fromCodePoint(di(t)?ks(t):t)}}_stateAfterAttributeName(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.SOLIDUS:{this.state=j.SELF_CLOSING_START_TAG;break}case F.EQUALS_SIGN:{this.state=j.BEFORE_ATTRIBUTE_VALUE;break}case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentTagToken();break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=j.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.QUOTATION_MARK:{this.state=j.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case F.APOSTROPHE:{this.state=j.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case F.GREATER_THAN_SIGN:{this._err(J.missingAttributeValue),this.state=j.DATA,this.emitCurrentTagToken();break}default:this.state=j.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case F.QUOTATION_MARK:{this.state=j.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case F.AMPERSAND:{this._startCharacterReference();break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.currentAttr.value+=ot;break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case F.APOSTROPHE:{this.state=j.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case F.AMPERSAND:{this._startCharacterReference();break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.currentAttr.value+=ot;break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this._leaveAttrValue(),this.state=j.BEFORE_ATTRIBUTE_NAME;break}case F.AMPERSAND:{this._startCharacterReference();break}case F.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=j.DATA,this.emitCurrentTagToken();break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.currentAttr.value+=ot;break}case F.QUOTATION_MARK:case F.APOSTROPHE:case F.LESS_THAN_SIGN:case F.EQUALS_SIGN:case F.GRAVE_ACCENT:{this._err(J.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this._leaveAttrValue(),this.state=j.BEFORE_ATTRIBUTE_NAME;break}case F.SOLIDUS:{this._leaveAttrValue(),this.state=j.SELF_CLOSING_START_TAG;break}case F.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=j.DATA,this.emitCurrentTagToken();break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:this._err(J.missingWhitespaceBetweenAttributes),this.state=j.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case F.GREATER_THAN_SIGN:{const n=this.currentToken;n.selfClosing=!0,this.state=j.DATA,this.emitCurrentTagToken();break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:this._err(J.unexpectedSolidusInTag),this.state=j.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const n=this.currentToken;switch(t){case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentComment(n);break}case F.EOF:{this.emitCurrentComment(n),this._emitEOFToken();break}case F.NULL:{this._err(J.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=j.COMMENT_START):this._consumeSequenceIfMatch(Rt.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(Rt.DOCTYPE.length+1),this.state=j.DOCTYPE):this._consumeSequenceIfMatch(Rt.CDATA_START,!0)?this.inForeignNode?this.state=j.CDATA_SECTION:(this._err(J.cdataInHtmlContent),this._createCommentToken(Rt.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=j.BOGUS_COMMENT):this._ensureHibernation()||(this._err(J.incorrectlyOpenedComment),this._createCommentToken(2),this.state=j.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case F.HYPHEN_MINUS:{this.state=j.COMMENT_START_DASH;break}case F.GREATER_THAN_SIGN:{this._err(J.abruptClosingOfEmptyComment),this.state=j.DATA;const n=this.currentToken;this.emitCurrentComment(n);break}default:this.state=j.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const n=this.currentToken;switch(t){case F.HYPHEN_MINUS:{this.state=j.COMMENT_END;break}case F.GREATER_THAN_SIGN:{this._err(J.abruptClosingOfEmptyComment),this.state=j.DATA,this.emitCurrentComment(n);break}case F.EOF:{this._err(J.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=j.COMMENT,this._stateComment(t)}}_stateComment(t){const n=this.currentToken;switch(t){case F.HYPHEN_MINUS:{this.state=j.COMMENT_END_DASH;break}case F.LESS_THAN_SIGN:{n.data+="<",this.state=j.COMMENT_LESS_THAN_SIGN;break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.data+=ot;break}case F.EOF:{this._err(J.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const n=this.currentToken;switch(t){case F.EXCLAMATION_MARK:{n.data+="!",this.state=j.COMMENT_LESS_THAN_SIGN_BANG;break}case F.LESS_THAN_SIGN:{n.data+="<";break}default:this.state=j.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===F.HYPHEN_MINUS?this.state=j.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=j.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===F.HYPHEN_MINUS?this.state=j.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=j.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==F.GREATER_THAN_SIGN&&t!==F.EOF&&this._err(J.nestedComment),this.state=j.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const n=this.currentToken;switch(t){case F.HYPHEN_MINUS:{this.state=j.COMMENT_END;break}case F.EOF:{this._err(J.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=j.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const n=this.currentToken;switch(t){case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentComment(n);break}case F.EXCLAMATION_MARK:{this.state=j.COMMENT_END_BANG;break}case F.HYPHEN_MINUS:{n.data+="-";break}case F.EOF:{this._err(J.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--",this.state=j.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const n=this.currentToken;switch(t){case F.HYPHEN_MINUS:{n.data+="--!",this.state=j.COMMENT_END_DASH;break}case F.GREATER_THAN_SIGN:{this._err(J.incorrectlyClosedComment),this.state=j.DATA,this.emitCurrentComment(n);break}case F.EOF:{this._err(J.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--!",this.state=j.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this.state=j.BEFORE_DOCTYPE_NAME;break}case F.GREATER_THAN_SIGN:{this.state=j.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case F.EOF:{this._err(J.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingWhitespaceBeforeDoctypeName),this.state=j.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(di(t))this._createDoctypeToken(String.fromCharCode(ks(t))),this.state=j.DOCTYPE_NAME;else switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.NULL:{this._err(J.unexpectedNullCharacter),this._createDoctypeToken(ot),this.state=j.DOCTYPE_NAME;break}case F.GREATER_THAN_SIGN:{this._err(J.missingDoctypeName),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.EOF:{this._err(J.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=j.DOCTYPE_NAME}}_stateDoctypeName(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this.state=j.AFTER_DOCTYPE_NAME;break}case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.name+=ot;break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.name+=String.fromCodePoint(di(t)?ks(t):t)}}_stateAfterDoctypeName(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(Rt.PUBLIC,!1)?this.state=j.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(Rt.SYSTEM,!1)?this.state=j.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(J.invalidCharacterSequenceAfterDoctypeName),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this.state=j.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case F.QUOTATION_MARK:{this._err(J.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=j.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case F.APOSTROPHE:{this._err(J.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=j.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case F.GREATER_THAN_SIGN:{this._err(J.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.QUOTATION_MARK:{n.publicId="",this.state=j.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case F.APOSTROPHE:{n.publicId="",this.state=j.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case F.GREATER_THAN_SIGN:{this._err(J.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case F.QUOTATION_MARK:{this.state=j.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.publicId+=ot;break}case F.GREATER_THAN_SIGN:{this._err(J.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.EOF:{this._err(J.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 F.APOSTROPHE:{this.state=j.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.publicId+=ot;break}case F.GREATER_THAN_SIGN:{this._err(J.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.EOF:{this._err(J.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 F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this.state=j.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.QUOTATION_MARK:{this._err(J.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case F.APOSTROPHE:{this._err(J.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.QUOTATION_MARK:{n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case F.APOSTROPHE:{n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this.state=j.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case F.QUOTATION_MARK:{this._err(J.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case F.APOSTROPHE:{this._err(J.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case F.GREATER_THAN_SIGN:{this._err(J.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.QUOTATION_MARK:{n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case F.APOSTROPHE:{n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case F.GREATER_THAN_SIGN:{this._err(J.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case F.QUOTATION_MARK:{this.state=j.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.systemId+=ot;break}case F.GREATER_THAN_SIGN:{this._err(J.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.EOF:{this._err(J.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 F.APOSTROPHE:{this.state=j.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.systemId+=ot;break}case F.GREATER_THAN_SIGN:{this._err(J.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.EOF:{this._err(J.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 F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const n=this.currentToken;switch(t){case F.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.NULL:{this._err(J.unexpectedNullCharacter);break}case F.EOF:{this.emitCurrentDoctype(n),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case F.RIGHT_SQUARE_BRACKET:{this.state=j.CDATA_SECTION_BRACKET;break}case F.EOF:{this._err(J.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===F.RIGHT_SQUARE_BRACKET?this.state=j.CDATA_SECTION_END:(this._emitChars("]"),this.state=j.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case F.GREATER_THAN_SIGN:{this.state=j.DATA;break}case F.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=j.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(F.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&qd(this.preprocessor.peek(1))?j.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){qd(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===F.SEMICOLON&&this._err(J.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const d0=new Set([x.DD,x.DT,x.LI,x.OPTGROUP,x.OPTION,x.P,x.RB,x.RP,x.RT,x.RTC]),Wd=new Set([...d0,x.CAPTION,x.COLGROUP,x.TBODY,x.TD,x.TFOOT,x.TH,x.THEAD,x.TR]),ta=new Set([x.APPLET,x.CAPTION,x.HTML,x.MARQUEE,x.OBJECT,x.TABLE,x.TD,x.TEMPLATE,x.TH]),MA=new Set([...ta,x.OL,x.UL]),PA=new Set([...ta,x.BUTTON]),Yd=new Set([x.ANNOTATION_XML,x.MI,x.MN,x.MO,x.MS,x.MTEXT]),Gd=new Set([x.DESC,x.FOREIGN_OBJECT,x.TITLE]),LA=new Set([x.TR,x.TEMPLATE,x.HTML]),DA=new Set([x.TBODY,x.TFOOT,x.THEAD,x.TEMPLATE,x.HTML]),OA=new Set([x.TABLE,x.TEMPLATE,x.HTML]),FA=new Set([x.TD,x.TH]);class BA{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=x.UNKNOWN,this.current=t}_indexOf(t){return this.items.lastIndexOf(t,this.stackTop)}_isInTemplate(){return this.currentTagId===x.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===le.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])!==le.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(pl,le.HTML)}popUntilTableCellPopped(){this.popUntilPopped(FA,le.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(OA,le.HTML)}clearBackToTableBodyContext(){this.clearBackTo(DA,le.HTML)}clearBackToTableRowContext(){this.clearBackTo(LA,le.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]===x.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]===x.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 le.HTML:{if(s===t)return!0;if(n.has(s))return!1;break}case le.SVG:{if(Gd.has(s))return!1;break}case le.MATHML:{if(Yd.has(s))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,ta)}hasInListItemScope(t){return this.hasInDynamicScope(t,MA)}hasInButtonScope(t){return this.hasInDynamicScope(t,PA)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case le.HTML:{if(pl.has(n))return!0;if(ta.has(n))return!1;break}case le.SVG:{if(Gd.has(n))return!1;break}case le.MATHML:{if(Yd.has(n))return!1;break}}}return!0}hasInTableScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===le.HTML)switch(this.tagIDs[n]){case t:return!0;case x.TABLE:case x.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===le.HTML)switch(this.tagIDs[t]){case x.TBODY:case x.THEAD:case x.TFOOT:return!0;case x.TABLE:case x.HTML:return!1}return!0}hasInSelectScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===le.HTML)switch(this.tagIDs[n]){case t:return!0;case x.OPTION:case x.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&d0.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&Wd.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&Wd.has(this.currentTagId);)this.pop()}}const ko=3;var an;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(an||(an={}));const Kd={type:an.Marker};class jA{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===an.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<ko)return;const n=this.treeAdapter.getAttrList(t),r=this._getNoahArkConditionCandidates(t,n);if(r.length<ko)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>=ko&&this.entries.splice(o.idx,1))}}insertMarker(){this.entries.unshift(Kd)}pushElement(t,n){this._ensureNoahArkCondition(t),this.entries.unshift({type:an.Element,element:t,token:n})}insertElementAfterBookmark(t,n){const r=this.entries.indexOf(this.bookmark);this.entries.splice(r,0,{type:an.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(Kd);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const n=this.entries.find(r=>r.type===an.Marker||this.treeAdapter.getTagName(r.element)===t);return n&&n.type===an.Element?n:null}getElementEntry(t){return this.entries.find(n=>n.type===an.Element&&n.element===t)}}const Tn={createDocument(){return{nodeName:"#document",mode:zt.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};Tn.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(Tn.isTextNode(n)){n.value+=t;return}}Tn.appendChild(e,Tn.createTextNode(t))},insertTextBefore(e,t,n){const r=e.childNodes[e.childNodes.indexOf(n)-1];r&&Tn.isTextNode(r)?r.value+=t:Tn.insertBefore(e,Tn.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}}},h0="html",HA="about:legacy-compat",UA="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",f0=["+//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//"],zA=[...f0,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],VA=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),m0=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],qA=[...m0,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function Xd(e,t){return t.some(n=>e.startsWith(n))}function $A(e){return e.name===h0&&e.publicId===null&&(e.systemId===null||e.systemId===HA)}function WA(e){if(e.name!==h0)return zt.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===UA)return zt.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),VA.has(n))return zt.QUIRKS;let r=t===null?zA:f0;if(Xd(n,r))return zt.QUIRKS;if(r=t===null?m0:qA,Xd(n,r))return zt.LIMITED_QUIRKS}return zt.NO_QUIRKS}const Qd={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},YA="definitionurl",GA="definitionURL",KA=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])),XA=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:le.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:le.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:le.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:le.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:le.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:le.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:le.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:le.XML}],["xml:space",{prefix:"xml",name:"space",namespace:le.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:le.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:le.XMLNS}]]),QA=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])),ZA=new Set([x.B,x.BIG,x.BLOCKQUOTE,x.BODY,x.BR,x.CENTER,x.CODE,x.DD,x.DIV,x.DL,x.DT,x.EM,x.EMBED,x.H1,x.H2,x.H3,x.H4,x.H5,x.H6,x.HEAD,x.HR,x.I,x.IMG,x.LI,x.LISTING,x.MENU,x.META,x.NOBR,x.OL,x.P,x.PRE,x.RUBY,x.S,x.SMALL,x.SPAN,x.STRONG,x.STRIKE,x.SUB,x.SUP,x.TABLE,x.TT,x.U,x.UL,x.VAR]);function JA(e){const t=e.tagID;return t===x.FONT&&e.attrs.some(({name:r})=>r===nr.COLOR||r===nr.SIZE||r===nr.FACE)||ZA.has(t)}function p0(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===YA){e.attrs[t].name=GA;break}}function g0(e){for(let t=0;t<e.attrs.length;t++){const n=KA.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function Su(e){for(let t=0;t<e.attrs.length;t++){const n=XA.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 eC(e){const t=QA.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=Hr(e.tagName))}function tC(e,t){return t===le.MATHML&&(e===x.MI||e===x.MO||e===x.MN||e===x.MS||e===x.MTEXT)}function nC(e,t,n){if(t===le.MATHML&&e===x.ANNOTATION_XML){for(let r=0;r<n.length;r++)if(n[r].name===nr.ENCODING){const s=n[r].value.toLowerCase();return s===Qd.TEXT_HTML||s===Qd.APPLICATION_XML}}return t===le.SVG&&(e===x.FOREIGN_OBJECT||e===x.DESC||e===x.TITLE)}function rC(e,t,n,r){return(!r||r===le.HTML)&&nC(e,t,n)||(!r||r===le.MATHML)&&tC(e,t)}const iC="hidden",sC=8,aC=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 oC={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},b0=new Set([x.TABLE,x.TBODY,x.TFOOT,x.THEAD,x.TR]),Zd={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:Tn,onParseError:null};class Jd{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={...Zd,...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 RA(this.options,this),this.activeFormattingElements=new jA(this.treeAdapter),this.fragmentContextID=r?Hr(this.treeAdapter.getTagName(r)):x.UNKNOWN,this._setContextModes(r??this.document,this.fragmentContextID),this.openElements=new BA(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={...Zd,...n};t??(t=r.treeAdapter.createElement(W.TEMPLATE,le.HTML,[]));const s=r.treeAdapter.createElement("documentmock",le.HTML,[]),i=new this(r,s,t);return i.fragmentContextID===x.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:oC,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)===le.HTML;this.currentNotInHTML=!r,this.tokenizer.inForeignNode=!r&&t!==void 0&&n!==void 0&&!this._isIntegrationPoint(n,t)}_switchToTextParsing(t,n){this._insertElement(t,le.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=ct.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)===W.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==le.HTML))switch(this.fragmentContextID){case x.TITLE:case x.TEXTAREA:{this.tokenizer.state=ct.RCDATA;break}case x.STYLE:case x.XMP:case x.IFRAME:case x.NOEMBED:case x.NOFRAMES:case x.NOSCRIPT:{this.tokenizer.state=ct.RAWTEXT;break}case x.SCRIPT:{this.tokenizer.state=ct.SCRIPT_DATA;break}case x.PLAINTEXT:{this.tokenizer.state=ct.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,le.HTML,[]);this._attachElementToTree(r,null),this.openElements.push(r,n)}_insertTemplate(t){const n=this.treeAdapter.createElement(t.tagName,le.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(W.HTML,le.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(t,null),this.treeAdapter.appendChild(this.openElements.current,t),this.openElements.push(t,x.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===x.SVG&&this.treeAdapter.getTagName(n)===W.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===le.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===x.MGLYPH||t.tagID===x.MALIGNMARK)&&r!==void 0&&!this._isIntegrationPoint(r,n,le.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 rC(t,s,i,r)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const n=this.activeFormattingElements.entries.findIndex(s=>s.type===an.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(x.P),this.openElements.popUntilTagNamePopped(x.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case x.TR:{this.insertionMode=U.IN_ROW;return}case x.TBODY:case x.THEAD:case x.TFOOT:{this.insertionMode=U.IN_TABLE_BODY;return}case x.CAPTION:{this.insertionMode=U.IN_CAPTION;return}case x.COLGROUP:{this.insertionMode=U.IN_COLUMN_GROUP;return}case x.TABLE:{this.insertionMode=U.IN_TABLE;return}case x.BODY:{this.insertionMode=U.IN_BODY;return}case x.FRAMESET:{this.insertionMode=U.IN_FRAMESET;return}case x.SELECT:{this._resetInsertionModeForSelect(t);return}case x.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case x.HTML:{this.insertionMode=this.headElement?U.AFTER_HEAD:U.BEFORE_HEAD;return}case x.TD:case x.TH:{if(t>0){this.insertionMode=U.IN_CELL;return}break}case x.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===x.TEMPLATE)break;if(r===x.TABLE){this.insertionMode=U.IN_SELECT_IN_TABLE;return}}this.insertionMode=U.IN_SELECT}_isElementCausesFosterParenting(t){return b0.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 x.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(n)===le.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case x.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 CA[r].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){F3(this,t);return}switch(this.insertionMode){case U.INITIAL:{ii(this,t);break}case U.BEFORE_HTML:{xi(this,t);break}case U.BEFORE_HEAD:{yi(this,t);break}case U.IN_HEAD:{vi(this,t);break}case U.IN_HEAD_NO_SCRIPT:{Ei(this,t);break}case U.AFTER_HEAD:{ki(this,t);break}case U.IN_BODY:case U.IN_CAPTION:case U.IN_CELL:case U.IN_TEMPLATE:{y0(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:{To(this,t);break}case U.IN_TABLE_TEXT:{S0(this,t);break}case U.IN_COLUMN_GROUP:{na(this,t);break}case U.AFTER_BODY:{ra(this,t);break}case U.AFTER_AFTER_BODY:{Os(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){O3(this,t);return}switch(this.insertionMode){case U.INITIAL:{ii(this,t);break}case U.BEFORE_HTML:{xi(this,t);break}case U.BEFORE_HEAD:{yi(this,t);break}case U.IN_HEAD:{vi(this,t);break}case U.IN_HEAD_NO_SCRIPT:{Ei(this,t);break}case U.AFTER_HEAD:{ki(this,t);break}case U.TEXT:{this._insertCharacters(t);break}case U.IN_TABLE:case U.IN_TABLE_BODY:case U.IN_ROW:{To(this,t);break}case U.IN_COLUMN_GROUP:{na(this,t);break}case U.AFTER_BODY:{ra(this,t);break}case U.AFTER_AFTER_BODY:{Os(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){gl(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:{gl(this,t);break}case U.IN_TABLE_TEXT:{si(this,t);break}case U.AFTER_BODY:{mC(this,t);break}case U.AFTER_AFTER_BODY:case U.AFTER_AFTER_FRAMESET:{pC(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case U.INITIAL:{gC(this,t);break}case U.BEFORE_HEAD:case U.IN_HEAD:case U.IN_HEAD_NO_SCRIPT:case U.AFTER_HEAD:{this._err(t,J.misplacedDoctype);break}case U.IN_TABLE_TEXT:{si(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,J.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?B3(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case U.INITIAL:{ii(this,t);break}case U.BEFORE_HTML:{bC(this,t);break}case U.BEFORE_HEAD:{yC(this,t);break}case U.IN_HEAD:{en(this,t);break}case U.IN_HEAD_NO_SCRIPT:{kC(this,t);break}case U.AFTER_HEAD:{wC(this,t);break}case U.IN_BODY:{wt(this,t);break}case U.IN_TABLE:{Lr(this,t);break}case U.IN_TABLE_TEXT:{si(this,t);break}case U.IN_CAPTION:{v3(this,t);break}case U.IN_COLUMN_GROUP:{_u(this,t);break}case U.IN_TABLE_BODY:{Ma(this,t);break}case U.IN_ROW:{Pa(this,t);break}case U.IN_CELL:{T3(this,t);break}case U.IN_SELECT:{_0(this,t);break}case U.IN_SELECT_IN_TABLE:{S3(this,t);break}case U.IN_TEMPLATE:{C3(this,t);break}case U.AFTER_BODY:{N3(this,t);break}case U.IN_FRAMESET:{I3(this,t);break}case U.AFTER_FRAMESET:{M3(this,t);break}case U.AFTER_AFTER_BODY:{L3(this,t);break}case U.AFTER_AFTER_FRAMESET:{D3(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?j3(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case U.INITIAL:{ii(this,t);break}case U.BEFORE_HTML:{xC(this,t);break}case U.BEFORE_HEAD:{vC(this,t);break}case U.IN_HEAD:{EC(this,t);break}case U.IN_HEAD_NO_SCRIPT:{TC(this,t);break}case U.AFTER_HEAD:{SC(this,t);break}case U.IN_BODY:{Ra(this,t);break}case U.TEXT:{c3(this,t);break}case U.IN_TABLE:{Oi(this,t);break}case U.IN_TABLE_TEXT:{si(this,t);break}case U.IN_CAPTION:{E3(this,t);break}case U.IN_COLUMN_GROUP:{k3(this,t);break}case U.IN_TABLE_BODY:{bl(this,t);break}case U.IN_ROW:{C0(this,t);break}case U.IN_CELL:{w3(this,t);break}case U.IN_SELECT:{N0(this,t);break}case U.IN_SELECT_IN_TABLE:{A3(this,t);break}case U.IN_TEMPLATE:{_3(this,t);break}case U.AFTER_BODY:{R0(this,t);break}case U.IN_FRAMESET:{R3(this,t);break}case U.AFTER_FRAMESET:{P3(this,t);break}case U.AFTER_AFTER_BODY:{Os(this,t);break}}}onEof(t){switch(this.insertionMode){case U.INITIAL:{ii(this,t);break}case U.BEFORE_HTML:{xi(this,t);break}case U.BEFORE_HEAD:{yi(this,t);break}case U.IN_HEAD:{vi(this,t);break}case U.IN_HEAD_NO_SCRIPT:{Ei(this,t);break}case U.AFTER_HEAD:{ki(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:{T0(this,t);break}case U.TEXT:{d3(this,t);break}case U.IN_TABLE_TEXT:{si(this,t);break}case U.IN_TEMPLATE:{I0(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:{Cu(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===F.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:{x0(this,t);break}case U.IN_TABLE:case U.IN_TABLE_BODY:case U.IN_ROW:{To(this,t);break}case U.IN_TABLE_TEXT:{w0(this,t);break}}}}function lC(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):k0(e,t),n}function uC(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 cC(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>=aC;!o||l?(l&&e.activeFormattingElements.removeEntry(o),e.openElements.remove(a)):(a=dC(e,o),r===t&&(e.activeFormattingElements.bookmark=o),e.treeAdapter.detachNode(r),e.treeAdapter.appendChild(a,r),r=a)}return r}function dC(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 hC(e,t,n){const r=e.treeAdapter.getTagName(t),s=Hr(r);if(e._isElementCausesFosterParenting(s))e._fosterParentElement(n);else{const i=e.treeAdapter.getNamespaceURI(t);s===x.TEMPLATE&&i===le.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function fC(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 Au(e,t){for(let n=0;n<sC;n++){const r=lC(e,t);if(!r)break;const s=uC(e,r);if(!s)break;e.activeFormattingElements.bookmark=r;const i=cC(e,s,r.element),a=e.openElements.getCommonAncestor(r.element);e.treeAdapter.detachNode(i),a&&hC(e,a,i),fC(e,s,r)}}function gl(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function mC(e,t){e._appendCommentNode(t,e.openElements.items[0])}function pC(e,t){e._appendCommentNode(t,e.document)}function Cu(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 gC(e,t){e._setDocumentType(t);const n=t.forceQuirks?zt.QUIRKS:WA(t);$A(t)||e._err(t,J.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=U.BEFORE_HTML}function ii(e,t){e._err(t,J.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,zt.QUIRKS),e.insertionMode=U.BEFORE_HTML,e._processToken(t)}function bC(e,t){t.tagID===x.HTML?(e._insertElement(t,le.HTML),e.insertionMode=U.BEFORE_HEAD):xi(e,t)}function xC(e,t){const n=t.tagID;(n===x.HTML||n===x.HEAD||n===x.BODY||n===x.BR)&&xi(e,t)}function xi(e,t){e._insertFakeRootElement(),e.insertionMode=U.BEFORE_HEAD,e._processToken(t)}function yC(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.HEAD:{e._insertElement(t,le.HTML),e.headElement=e.openElements.current,e.insertionMode=U.IN_HEAD;break}default:yi(e,t)}}function vC(e,t){const n=t.tagID;n===x.HEAD||n===x.BODY||n===x.HTML||n===x.BR?yi(e,t):e._err(t,J.endTagWithoutMatchingOpenElement)}function yi(e,t){e._insertFakeElement(W.HEAD,x.HEAD),e.headElement=e.openElements.current,e.insertionMode=U.IN_HEAD,e._processToken(t)}function en(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.BASE:case x.BASEFONT:case x.BGSOUND:case x.LINK:case x.META:{e._appendElement(t,le.HTML),t.ackSelfClosing=!0;break}case x.TITLE:{e._switchToTextParsing(t,ct.RCDATA);break}case x.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,ct.RAWTEXT):(e._insertElement(t,le.HTML),e.insertionMode=U.IN_HEAD_NO_SCRIPT);break}case x.NOFRAMES:case x.STYLE:{e._switchToTextParsing(t,ct.RAWTEXT);break}case x.SCRIPT:{e._switchToTextParsing(t,ct.SCRIPT_DATA);break}case x.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=U.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(U.IN_TEMPLATE);break}case x.HEAD:{e._err(t,J.misplacedStartTagForHeadElement);break}default:vi(e,t)}}function EC(e,t){switch(t.tagID){case x.HEAD:{e.openElements.pop(),e.insertionMode=U.AFTER_HEAD;break}case x.BODY:case x.BR:case x.HTML:{vi(e,t);break}case x.TEMPLATE:{dr(e,t);break}default:e._err(t,J.endTagWithoutMatchingOpenElement)}}function dr(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==x.TEMPLATE&&e._err(t,J.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(x.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,J.endTagWithoutMatchingOpenElement)}function vi(e,t){e.openElements.pop(),e.insertionMode=U.AFTER_HEAD,e._processToken(t)}function kC(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.BASEFONT:case x.BGSOUND:case x.HEAD:case x.LINK:case x.META:case x.NOFRAMES:case x.STYLE:{en(e,t);break}case x.NOSCRIPT:{e._err(t,J.nestedNoscriptInHead);break}default:Ei(e,t)}}function TC(e,t){switch(t.tagID){case x.NOSCRIPT:{e.openElements.pop(),e.insertionMode=U.IN_HEAD;break}case x.BR:{Ei(e,t);break}default:e._err(t,J.endTagWithoutMatchingOpenElement)}}function Ei(e,t){const n=t.type===He.EOF?J.openElementsLeftAfterEof:J.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=U.IN_HEAD,e._processToken(t)}function wC(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.BODY:{e._insertElement(t,le.HTML),e.framesetOk=!1,e.insertionMode=U.IN_BODY;break}case x.FRAMESET:{e._insertElement(t,le.HTML),e.insertionMode=U.IN_FRAMESET;break}case x.BASE:case x.BASEFONT:case x.BGSOUND:case x.LINK:case x.META:case x.NOFRAMES:case x.SCRIPT:case x.STYLE:case x.TEMPLATE:case x.TITLE:{e._err(t,J.abandonedHeadElementChild),e.openElements.push(e.headElement,x.HEAD),en(e,t),e.openElements.remove(e.headElement);break}case x.HEAD:{e._err(t,J.misplacedStartTagForHeadElement);break}default:ki(e,t)}}function SC(e,t){switch(t.tagID){case x.BODY:case x.HTML:case x.BR:{ki(e,t);break}case x.TEMPLATE:{dr(e,t);break}default:e._err(t,J.endTagWithoutMatchingOpenElement)}}function ki(e,t){e._insertFakeElement(W.BODY,x.BODY),e.insertionMode=U.IN_BODY,Ia(e,t)}function Ia(e,t){switch(t.type){case He.CHARACTER:{y0(e,t);break}case He.WHITESPACE_CHARACTER:{x0(e,t);break}case He.COMMENT:{gl(e,t);break}case He.START_TAG:{wt(e,t);break}case He.END_TAG:{Ra(e,t);break}case He.EOF:{T0(e,t);break}}}function x0(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function y0(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function AC(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function CC(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function _C(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,le.HTML),e.insertionMode=U.IN_FRAMESET)}function NC(e,t){e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._insertElement(t,le.HTML)}function IC(e,t){e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&pl.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,le.HTML)}function RC(e,t){e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._insertElement(t,le.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function MC(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._insertElement(t,le.HTML),n||(e.formElement=e.openElements.current))}function PC(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===x.LI&&s===x.LI||(n===x.DD||n===x.DT)&&(s===x.DD||s===x.DT)){e.openElements.generateImpliedEndTagsWithExclusion(s),e.openElements.popUntilTagNamePopped(s);break}if(s!==x.ADDRESS&&s!==x.DIV&&s!==x.P&&e._isSpecialElement(e.openElements.items[r],s))break}e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._insertElement(t,le.HTML)}function LC(e,t){e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._insertElement(t,le.HTML),e.tokenizer.state=ct.PLAINTEXT}function DC(e,t){e.openElements.hasInScope(x.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(x.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,le.HTML),e.framesetOk=!1}function OC(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(W.A);n&&(Au(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,le.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function FC(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,le.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function BC(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(x.NOBR)&&(Au(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,le.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function jC(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,le.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function HC(e,t){e.treeAdapter.getDocumentMode(e.document)!==zt.QUIRKS&&e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._insertElement(t,le.HTML),e.framesetOk=!1,e.insertionMode=U.IN_TABLE}function v0(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,le.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function E0(e){const t=u0(e,nr.TYPE);return t!=null&&t.toLowerCase()===iC}function UC(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,le.HTML),E0(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function zC(e,t){e._appendElement(t,le.HTML),t.ackSelfClosing=!0}function VC(e,t){e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._appendElement(t,le.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function qC(e,t){t.tagName=W.IMG,t.tagID=x.IMG,v0(e,t)}function $C(e,t){e._insertElement(t,le.HTML),e.skipNextNewLine=!0,e.tokenizer.state=ct.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=U.TEXT}function WC(e,t){e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,ct.RAWTEXT)}function YC(e,t){e.framesetOk=!1,e._switchToTextParsing(t,ct.RAWTEXT)}function eh(e,t){e._switchToTextParsing(t,ct.RAWTEXT)}function GC(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,le.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 KC(e,t){e.openElements.currentTagId===x.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,le.HTML)}function XC(e,t){e.openElements.hasInScope(x.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,le.HTML)}function QC(e,t){e.openElements.hasInScope(x.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(x.RTC),e._insertElement(t,le.HTML)}function ZC(e,t){e._reconstructActiveFormattingElements(),p0(t),Su(t),t.selfClosing?e._appendElement(t,le.MATHML):e._insertElement(t,le.MATHML),t.ackSelfClosing=!0}function JC(e,t){e._reconstructActiveFormattingElements(),g0(t),Su(t),t.selfClosing?e._appendElement(t,le.SVG):e._insertElement(t,le.SVG),t.ackSelfClosing=!0}function th(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,le.HTML)}function wt(e,t){switch(t.tagID){case x.I:case x.S:case x.B:case x.U:case x.EM:case x.TT:case x.BIG:case x.CODE:case x.FONT:case x.SMALL:case x.STRIKE:case x.STRONG:{FC(e,t);break}case x.A:{OC(e,t);break}case x.H1:case x.H2:case x.H3:case x.H4:case x.H5:case x.H6:{IC(e,t);break}case x.P:case x.DL:case x.OL:case x.UL:case x.DIV:case x.DIR:case x.NAV:case x.MAIN:case x.MENU:case x.ASIDE:case x.CENTER:case x.FIGURE:case x.FOOTER:case x.HEADER:case x.HGROUP:case x.DIALOG:case x.DETAILS:case x.ADDRESS:case x.ARTICLE:case x.SEARCH:case x.SECTION:case x.SUMMARY:case x.FIELDSET:case x.BLOCKQUOTE:case x.FIGCAPTION:{NC(e,t);break}case x.LI:case x.DD:case x.DT:{PC(e,t);break}case x.BR:case x.IMG:case x.WBR:case x.AREA:case x.EMBED:case x.KEYGEN:{v0(e,t);break}case x.HR:{VC(e,t);break}case x.RB:case x.RTC:{XC(e,t);break}case x.RT:case x.RP:{QC(e,t);break}case x.PRE:case x.LISTING:{RC(e,t);break}case x.XMP:{WC(e,t);break}case x.SVG:{JC(e,t);break}case x.HTML:{AC(e,t);break}case x.BASE:case x.LINK:case x.META:case x.STYLE:case x.TITLE:case x.SCRIPT:case x.BGSOUND:case x.BASEFONT:case x.TEMPLATE:{en(e,t);break}case x.BODY:{CC(e,t);break}case x.FORM:{MC(e,t);break}case x.NOBR:{BC(e,t);break}case x.MATH:{ZC(e,t);break}case x.TABLE:{HC(e,t);break}case x.INPUT:{UC(e,t);break}case x.PARAM:case x.TRACK:case x.SOURCE:{zC(e,t);break}case x.IMAGE:{qC(e,t);break}case x.BUTTON:{DC(e,t);break}case x.APPLET:case x.OBJECT:case x.MARQUEE:{jC(e,t);break}case x.IFRAME:{YC(e,t);break}case x.SELECT:{GC(e,t);break}case x.OPTION:case x.OPTGROUP:{KC(e,t);break}case x.NOEMBED:case x.NOFRAMES:{eh(e,t);break}case x.FRAMESET:{_C(e,t);break}case x.TEXTAREA:{$C(e,t);break}case x.NOSCRIPT:{e.options.scriptingEnabled?eh(e,t):th(e,t);break}case x.PLAINTEXT:{LC(e,t);break}case x.COL:case x.TH:case x.TD:case x.TR:case x.HEAD:case x.FRAME:case x.TBODY:case x.TFOOT:case x.THEAD:case x.CAPTION:case x.COLGROUP:break;default:th(e,t)}}function e3(e,t){if(e.openElements.hasInScope(x.BODY)&&(e.insertionMode=U.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function t3(e,t){e.openElements.hasInScope(x.BODY)&&(e.insertionMode=U.AFTER_BODY,R0(e,t))}function n3(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function r3(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(x.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(x.FORM):n&&e.openElements.remove(n))}function i3(e){e.openElements.hasInButtonScope(x.P)||e._insertFakeElement(W.P,x.P),e._closePElement()}function s3(e){e.openElements.hasInListItemScope(x.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(x.LI),e.openElements.popUntilTagNamePopped(x.LI))}function a3(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function o3(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function l3(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function u3(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(W.BR,x.BR),e.openElements.pop(),e.framesetOk=!1}function k0(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!==x.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 Ra(e,t){switch(t.tagID){case x.A:case x.B:case x.I:case x.S:case x.U:case x.EM:case x.TT:case x.BIG:case x.CODE:case x.FONT:case x.NOBR:case x.SMALL:case x.STRIKE:case x.STRONG:{Au(e,t);break}case x.P:{i3(e);break}case x.DL:case x.UL:case x.OL:case x.DIR:case x.DIV:case x.NAV:case x.PRE:case x.MAIN:case x.MENU:case x.ASIDE:case x.BUTTON:case x.CENTER:case x.FIGURE:case x.FOOTER:case x.HEADER:case x.HGROUP:case x.DIALOG:case x.ADDRESS:case x.ARTICLE:case x.DETAILS:case x.SEARCH:case x.SECTION:case x.SUMMARY:case x.LISTING:case x.FIELDSET:case x.BLOCKQUOTE:case x.FIGCAPTION:{n3(e,t);break}case x.LI:{s3(e);break}case x.DD:case x.DT:{a3(e,t);break}case x.H1:case x.H2:case x.H3:case x.H4:case x.H5:case x.H6:{o3(e);break}case x.BR:{u3(e);break}case x.BODY:{e3(e,t);break}case x.HTML:{t3(e,t);break}case x.FORM:{r3(e);break}case x.APPLET:case x.OBJECT:case x.MARQUEE:{l3(e,t);break}case x.TEMPLATE:{dr(e,t);break}default:k0(e,t)}}function T0(e,t){e.tmplInsertionModeStack.length>0?I0(e,t):Cu(e,t)}function c3(e,t){var n;t.tagID===x.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function d3(e,t){e._err(t,J.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function To(e,t){if(e.openElements.currentTagId!==void 0&&b0.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:{S0(e,t);break}case He.WHITESPACE_CHARACTER:{w0(e,t);break}}else Gi(e,t)}function h3(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,le.HTML),e.insertionMode=U.IN_CAPTION}function f3(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,le.HTML),e.insertionMode=U.IN_COLUMN_GROUP}function m3(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(W.COLGROUP,x.COLGROUP),e.insertionMode=U.IN_COLUMN_GROUP,_u(e,t)}function p3(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,le.HTML),e.insertionMode=U.IN_TABLE_BODY}function g3(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(W.TBODY,x.TBODY),e.insertionMode=U.IN_TABLE_BODY,Ma(e,t)}function b3(e,t){e.openElements.hasInTableScope(x.TABLE)&&(e.openElements.popUntilTagNamePopped(x.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function x3(e,t){E0(t)?e._appendElement(t,le.HTML):Gi(e,t),t.ackSelfClosing=!0}function y3(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,le.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function Lr(e,t){switch(t.tagID){case x.TD:case x.TH:case x.TR:{g3(e,t);break}case x.STYLE:case x.SCRIPT:case x.TEMPLATE:{en(e,t);break}case x.COL:{m3(e,t);break}case x.FORM:{y3(e,t);break}case x.TABLE:{b3(e,t);break}case x.TBODY:case x.TFOOT:case x.THEAD:{p3(e,t);break}case x.INPUT:{x3(e,t);break}case x.CAPTION:{h3(e,t);break}case x.COLGROUP:{f3(e,t);break}default:Gi(e,t)}}function Oi(e,t){switch(t.tagID){case x.TABLE:{e.openElements.hasInTableScope(x.TABLE)&&(e.openElements.popUntilTagNamePopped(x.TABLE),e._resetInsertionMode());break}case x.TEMPLATE:{dr(e,t);break}case x.BODY:case x.CAPTION:case x.COL:case x.COLGROUP:case x.HTML:case x.TBODY:case x.TD:case x.TFOOT:case x.TH:case x.THEAD:case x.TR:break;default:Gi(e,t)}}function Gi(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,Ia(e,t),e.fosterParentingEnabled=n}function w0(e,t){e.pendingCharacterTokens.push(t)}function S0(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function si(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)Gi(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const A0=new Set([x.CAPTION,x.COL,x.COLGROUP,x.TBODY,x.TD,x.TFOOT,x.TH,x.THEAD,x.TR]);function v3(e,t){const n=t.tagID;A0.has(n)?e.openElements.hasInTableScope(x.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(x.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=U.IN_TABLE,Lr(e,t)):wt(e,t)}function E3(e,t){const n=t.tagID;switch(n){case x.CAPTION:case x.TABLE:{e.openElements.hasInTableScope(x.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(x.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=U.IN_TABLE,n===x.TABLE&&Oi(e,t));break}case x.BODY:case x.COL:case x.COLGROUP:case x.HTML:case x.TBODY:case x.TD:case x.TFOOT:case x.TH:case x.THEAD:case x.TR:break;default:Ra(e,t)}}function _u(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.COL:{e._appendElement(t,le.HTML),t.ackSelfClosing=!0;break}case x.TEMPLATE:{en(e,t);break}default:na(e,t)}}function k3(e,t){switch(t.tagID){case x.COLGROUP:{e.openElements.currentTagId===x.COLGROUP&&(e.openElements.pop(),e.insertionMode=U.IN_TABLE);break}case x.TEMPLATE:{dr(e,t);break}case x.COL:break;default:na(e,t)}}function na(e,t){e.openElements.currentTagId===x.COLGROUP&&(e.openElements.pop(),e.insertionMode=U.IN_TABLE,e._processToken(t))}function Ma(e,t){switch(t.tagID){case x.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,le.HTML),e.insertionMode=U.IN_ROW;break}case x.TH:case x.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(W.TR,x.TR),e.insertionMode=U.IN_ROW,Pa(e,t);break}case x.CAPTION:case x.COL:case x.COLGROUP:case x.TBODY:case x.TFOOT:case x.THEAD:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE,Lr(e,t));break}default:Lr(e,t)}}function bl(e,t){const n=t.tagID;switch(t.tagID){case x.TBODY:case x.TFOOT:case x.THEAD:{e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE);break}case x.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE,Oi(e,t));break}case x.BODY:case x.CAPTION:case x.COL:case x.COLGROUP:case x.HTML:case x.TD:case x.TH:case x.TR:break;default:Oi(e,t)}}function Pa(e,t){switch(t.tagID){case x.TH:case x.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,le.HTML),e.insertionMode=U.IN_CELL,e.activeFormattingElements.insertMarker();break}case x.CAPTION:case x.COL:case x.COLGROUP:case x.TBODY:case x.TFOOT:case x.THEAD:case x.TR:{e.openElements.hasInTableScope(x.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY,Ma(e,t));break}default:Lr(e,t)}}function C0(e,t){switch(t.tagID){case x.TR:{e.openElements.hasInTableScope(x.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY);break}case x.TABLE:{e.openElements.hasInTableScope(x.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY,bl(e,t));break}case x.TBODY:case x.TFOOT:case x.THEAD:{(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(x.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY,bl(e,t));break}case x.BODY:case x.CAPTION:case x.COL:case x.COLGROUP:case x.HTML:case x.TD:case x.TH:break;default:Oi(e,t)}}function T3(e,t){const n=t.tagID;A0.has(n)?(e.openElements.hasInTableScope(x.TD)||e.openElements.hasInTableScope(x.TH))&&(e._closeTableCell(),Pa(e,t)):wt(e,t)}function w3(e,t){const n=t.tagID;switch(n){case x.TD:case x.TH:{e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=U.IN_ROW);break}case x.TABLE:case x.TBODY:case x.TFOOT:case x.THEAD:case x.TR:{e.openElements.hasInTableScope(n)&&(e._closeTableCell(),C0(e,t));break}case x.BODY:case x.CAPTION:case x.COL:case x.COLGROUP:case x.HTML:break;default:Ra(e,t)}}function _0(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.OPTION:{e.openElements.currentTagId===x.OPTION&&e.openElements.pop(),e._insertElement(t,le.HTML);break}case x.OPTGROUP:{e.openElements.currentTagId===x.OPTION&&e.openElements.pop(),e.openElements.currentTagId===x.OPTGROUP&&e.openElements.pop(),e._insertElement(t,le.HTML);break}case x.HR:{e.openElements.currentTagId===x.OPTION&&e.openElements.pop(),e.openElements.currentTagId===x.OPTGROUP&&e.openElements.pop(),e._appendElement(t,le.HTML),t.ackSelfClosing=!0;break}case x.INPUT:case x.KEYGEN:case x.TEXTAREA:case x.SELECT:{e.openElements.hasInSelectScope(x.SELECT)&&(e.openElements.popUntilTagNamePopped(x.SELECT),e._resetInsertionMode(),t.tagID!==x.SELECT&&e._processStartTag(t));break}case x.SCRIPT:case x.TEMPLATE:{en(e,t);break}}}function N0(e,t){switch(t.tagID){case x.OPTGROUP:{e.openElements.stackTop>0&&e.openElements.currentTagId===x.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===x.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===x.OPTGROUP&&e.openElements.pop();break}case x.OPTION:{e.openElements.currentTagId===x.OPTION&&e.openElements.pop();break}case x.SELECT:{e.openElements.hasInSelectScope(x.SELECT)&&(e.openElements.popUntilTagNamePopped(x.SELECT),e._resetInsertionMode());break}case x.TEMPLATE:{dr(e,t);break}}}function S3(e,t){const n=t.tagID;n===x.CAPTION||n===x.TABLE||n===x.TBODY||n===x.TFOOT||n===x.THEAD||n===x.TR||n===x.TD||n===x.TH?(e.openElements.popUntilTagNamePopped(x.SELECT),e._resetInsertionMode(),e._processStartTag(t)):_0(e,t)}function A3(e,t){const n=t.tagID;n===x.CAPTION||n===x.TABLE||n===x.TBODY||n===x.TFOOT||n===x.THEAD||n===x.TR||n===x.TD||n===x.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(x.SELECT),e._resetInsertionMode(),e.onEndTag(t)):N0(e,t)}function C3(e,t){switch(t.tagID){case x.BASE:case x.BASEFONT:case x.BGSOUND:case x.LINK:case x.META:case x.NOFRAMES:case x.SCRIPT:case x.STYLE:case x.TEMPLATE:case x.TITLE:{en(e,t);break}case x.CAPTION:case x.COLGROUP:case x.TBODY:case x.TFOOT:case x.THEAD:{e.tmplInsertionModeStack[0]=U.IN_TABLE,e.insertionMode=U.IN_TABLE,Lr(e,t);break}case x.COL:{e.tmplInsertionModeStack[0]=U.IN_COLUMN_GROUP,e.insertionMode=U.IN_COLUMN_GROUP,_u(e,t);break}case x.TR:{e.tmplInsertionModeStack[0]=U.IN_TABLE_BODY,e.insertionMode=U.IN_TABLE_BODY,Ma(e,t);break}case x.TD:case x.TH:{e.tmplInsertionModeStack[0]=U.IN_ROW,e.insertionMode=U.IN_ROW,Pa(e,t);break}default:e.tmplInsertionModeStack[0]=U.IN_BODY,e.insertionMode=U.IN_BODY,wt(e,t)}}function _3(e,t){t.tagID===x.TEMPLATE&&dr(e,t)}function I0(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(x.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):Cu(e,t)}function N3(e,t){t.tagID===x.HTML?wt(e,t):ra(e,t)}function R0(e,t){var n;if(t.tagID===x.HTML){if(e.fragmentContext||(e.insertionMode=U.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===x.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 ra(e,t)}function ra(e,t){e.insertionMode=U.IN_BODY,Ia(e,t)}function I3(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.FRAMESET:{e._insertElement(t,le.HTML);break}case x.FRAME:{e._appendElement(t,le.HTML),t.ackSelfClosing=!0;break}case x.NOFRAMES:{en(e,t);break}}}function R3(e,t){t.tagID===x.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==x.FRAMESET&&(e.insertionMode=U.AFTER_FRAMESET))}function M3(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.NOFRAMES:{en(e,t);break}}}function P3(e,t){t.tagID===x.HTML&&(e.insertionMode=U.AFTER_AFTER_FRAMESET)}function L3(e,t){t.tagID===x.HTML?wt(e,t):Os(e,t)}function Os(e,t){e.insertionMode=U.IN_BODY,Ia(e,t)}function D3(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.NOFRAMES:{en(e,t);break}}}function O3(e,t){t.chars=ot,e._insertCharacters(t)}function F3(e,t){e._insertCharacters(t),e.framesetOk=!1}function M0(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==le.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function B3(e,t){if(JA(t))M0(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),r=e.treeAdapter.getNamespaceURI(n);r===le.MATHML?p0(t):r===le.SVG&&(eC(t),g0(t)),Su(t),t.selfClosing?e._appendElement(t,r):e._insertElement(t,r),t.ackSelfClosing=!0}}function j3(e,t){if(t.tagID===x.P||t.tagID===x.BR){M0(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)===le.HTML){e._endTagOutsideForeignContent(t);break}const s=e.treeAdapter.getTagName(r);if(s.toLowerCase()===t.tagName){t.tagName=s,e.openElements.shortenToLength(n);break}}}W.AREA,W.BASE,W.BASEFONT,W.BGSOUND,W.BR,W.COL,W.EMBED,W.FRAME,W.HR,W.IMG,W.INPUT,W.KEYGEN,W.LINK,W.META,W.PARAM,W.SOURCE,W.TRACK,W.WBR;const H3=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,U3=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),nh={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function P0(e,t){const n=Q3(e),r=Dp("type",{handlers:{root:z3,element:V3,text:q3,comment:D0,doctype:$3,raw:Y3},unknown:G3}),s={parser:n?new Jd(nh):Jd.getFragmentParser(void 0,nh),handle(o){r(o,s)},stitches:!1,options:t||{}};r(e,s),Ur(s,dn());const i=n?s.parser.document:s.parser.getFragment(),a=ZS(i,{file:s.options.file});return s.stitches&&Na(a,"comment",function(o,l,u){const c=o;if(c.value.stitch&&u&&l!==void 0){const h=u.children;return h[l]=c.value.stitch,l}}),a.type==="root"&&a.children.length===1&&a.children[0].type===e.type?a.children[0]:a}function L0(e,t){let n=-1;if(e)for(;++n<e.length;)t.handle(e[n])}function z3(e,t){L0(e.children,t)}function V3(e,t){K3(e,t),L0(e.children,t),X3(e,t)}function q3(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const n={type:He.CHARACTER,chars:e.value,location:Ki(e)};Ur(t,dn(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function $3(e,t){const n={type:He.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:Ki(e)};Ur(t,dn(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function W3(e,t){t.stitches=!0;const n=Z3(e);if("children"in e&&"children"in n){const r=P0({type:"root",children:e.children},t.options);n.children=r.children}D0({type:"comment",value:{stitch:n}},t)}function D0(e,t){const n=e.value,r={type:He.COMMENT,data:n,location:Ki(e)};Ur(t,dn(e)),t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken)}function Y3(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,O0(t,dn(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(H3,"&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 G3(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))W3(n,t);else{let r="";throw U3.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 Ur(e,t){O0(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=ct.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 O0(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 K3(e,t){const n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===ct.PLAINTEXT)return;Ur(t,dn(e));const r=t.parser.openElements.current;let s="namespaceURI"in r?r.namespaceURI:Xn.html;s===Xn.html&&n==="svg"&&(s=Xn.svg);const i=rA({...e,children:[]},{space:s===Xn.svg?"svg":"html"}),a={type:He.START_TAG,tagName:n,tagID:Hr(n),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in i?i.attrs:[],location:Ki(e)};t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=n}function X3(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&dA.includes(n)||t.parser.tokenizer.state===ct.PLAINTEXT)return;Ur(t,Ta(e));const r={type:He.END_TAG,tagName:n,tagID:Hr(n),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:Ki(e)};t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken),n===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===ct.RCDATA||t.parser.tokenizer.state===ct.RAWTEXT||t.parser.tokenizer.state===ct.SCRIPT_DATA)&&(t.parser.tokenizer.state=ct.DATA)}function Q3(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function Ki(e){const t=dn(e)||{line:void 0,column:void 0,offset:void 0},n=Ta(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 Z3(e){return"children"in e?lr({...e,children:[]}):lr(e)}function F0(e){return function(t,n){return P0(t,{...e,file:n})}}const qn=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],Ti={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...qn,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...qn],h2:[["className","sr-only"]],img:[...qn,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...qn,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...qn],table:[...qn],ul:[...qn,["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"]},Sn={}.hasOwnProperty;function J3(e,t){let n={type:"root",children:[]};const r={schema:t?{...Ti,...t}:Ti,stack:[]},s=B0(r,e);return s&&(Array.isArray(s)?s.length===1?n=s[0]:n.children=s:n=s),n}function B0(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return e_(e,n);case"doctype":return t_(e,n);case"element":return n_(e,n);case"root":return r_(e,n);case"text":return i_(e,n)}}}function e_(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 Xi(i,t),i}}function t_(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return Xi(n,t),n}}function n_(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const r=j0(e,t.children),s=s_(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&&Sn.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 Xi(a,t),a}function r_(e,t){const r={type:"root",children:j0(e,t.children)};return Xi(r,t),r}function i_(e,t){const r={type:"text",value:typeof t.value=="string"?t.value:""};return Xi(r,t),r}function j0(e,t){const n=[];if(Array.isArray(t)){const r=t;let s=-1;for(;++s<r.length;){const i=B0(e,r[s]);i&&(Array.isArray(i)?n.push(...i):n.push(i))}}return n}function s_(e,t){const n=e.stack[e.stack.length-1],r=e.schema.attributes,s=e.schema.required,i=r&&Sn.call(r,n)?r[n]:void 0,a=r&&Sn.call(r,"*")?r["*"]:void 0,o=t&&typeof t=="object"?t:{},l={};let u;for(u in o)if(Sn.call(o,u)){const c=o[u];let h=rh(e,ih(i,u),u,c);h==null&&(h=rh(e,ih(a,u),u,c)),h!=null&&(l[u]=h)}if(s&&Sn.call(s,n)){const c=s[n];for(u in c)Sn.call(c,u)&&!Sn.call(l,u)&&(l[u]=c[u])}return l}function rh(e,t,n,r){return t?Array.isArray(r)?a_(e,t,n,r):H0(e,t,n,r):void 0}function a_(e,t,n,r){let s=-1;const i=[];for(;++s<r.length;){const a=H0(e,t,n,r[s]);(typeof a=="number"||typeof a=="string")&&i.push(a)}return i}function H0(e,t,n,r){if(!(typeof r!="boolean"&&typeof r!="number"&&typeof r!="string")&&o_(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 o_(e,t,n){const r=e.schema.protocols&&Sn.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 Xi(e,t){const n=np(t);t.data&&(e.data=lr(t.data)),n&&(e.position=n)}function ih(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 U0(e){return function(t){return J3(t,e)}}var dm;const z0={...Ti,protocols:{...Ti.protocols,src:[...((dm=Ti.protocols)==null?void 0:dm.src)??["http","https","mailto"],"data"]}},l_={remarkPlugins:[t0],rehypePlugins:[F0,[U0,z0]]};let hi=null,sh=null;function u_(){return hi?Promise.resolve(hi):(sh??(sh=Promise.all([_e(()=>import("./index-QdMubkyO.js"),__vite__mapDeps([3,1,2]),import.meta.url),_e(()=>import("./index-C1KQONPL.js"),__vite__mapDeps([4,1,2]),import.meta.url)]).then(([{default:e},{default:t}])=>(hi={remarkPlugins:[t0,e],rehypePlugins:[F0,[U0,z0],t]},hi))),sh)}function c_(e){return e.includes("$")||e.includes("\\(")||e.includes("\\[")}function V0(e){const[t,n]=k.useState(hi),r=c_(e??"");return k.useEffect(()=>{if(!r||t)return;let s=!0;return u_().then(i=>{s&&n(i)}),()=>{s=!1}},[r,t]),t??l_}function d_({retry:e}){const t=$e();return p.jsxs("div",{className:"text-body text-warning p-4 flex items-start gap-2",children:[p.jsx(su,{className:"w-4 h-4 shrink-0 mt-0.5"}),p.jsxs("span",{children:[t("error.renderFailed")," ",p.jsx("button",{className:"underline ml-1",onClick:e,children:t("error.retry")})]})]})}class h_ extends k.Component{constructor(){super(...arguments);qa(this,"state",{error:null});qa(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):p.jsx(d_,{error:this.state.error,retry:this.retry}):this.props.children}}const rr=new Set(["。","!","?","!","?",";",";","…"]),f_=new Set([",",",","、",":",":"," "," "]),m_=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}\u{2B00}-\u{2BFF}]/u;function ia(e){return e!=null&&m_.test(String.fromCodePoint(e))}const p_=/(?:[\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,Cr=new Set(["”",'"',"」","』","》",")","】","])".slice(0,1)]);function g_(e){let t=e;return t=t.replace(/\r\n?/g,`
537
+ `,t);return r===-1?n:n===-1||n+1===r?r:n<r?n:r}const Xn={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/"},r0={}.hasOwnProperty,QS=Object.prototype;function ZS(e,t){const n=t||{};return Tu({file:n.file||void 0,location:!1,schema:n.space==="svg"?Rn:$i,verbose:n.verbose||!1},e)}function Tu(e,t){let n;switch(t.nodeName){case"#comment":{const r=t;return n={type:"comment",value:r.data},Ds(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:i0(e,t.childNodes),data:{quirksMode:s}},e.file&&e.location){const i=String(e.file),a=XS(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"},Ds(e,r,n),n}case"#text":{const r=t;return n={type:"text",value:r.value},Ds(e,r,n),n}default:return n=JS(e,t),n}}function i0(e,t){let n=-1;const r=[];for(;++n<t.length;){const s=Tu(e,t[n]);r.push(s)}return r}function JS(e,t){const n=e.schema;e.schema=t.namespaceURI===Xn.svg?Rn:$i;let r=-1;const s={};for(;++r<t.attrs.length;){const o=t.attrs[r],l=(o.prefix?o.prefix+":":"")+o.name;r0.call(QS,l)||(s[l]=o.value)}const a=(e.schema.space==="svg"?KS:GS)(t.tagName,s,i0(e,t.childNodes));if(Ds(e,t,a),a.tagName==="template"){const o=t,l=o.sourceCodeLocation,u=l&&l.startTag&&kr(l.startTag),c=l&&l.endTag&&kr(l.endTag),h=Tu(e,o.content);u&&c&&e.file&&(h.position={start:u.end,end:c.start}),a.content=h}return e.schema=n,a}function Ds(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const r=eA(e,n,t.sourceCodeLocation);r&&(e.location=!0,n.position=r)}}function eA(e,t,n){const r=kr(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)r0.call(n.attrs,a)&&(i[ka(e.schema,a).property]=kr(n.attrs[a]));n.startTag;const o=kr(n.startTag),l=n.endTag?kr(n.endTag):void 0,u={opening:o};l&&(u.closing=l),u.properties=i,t.data={position:u}}}return r}function kr(e){const t=Vd({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=Vd({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function Vd(e){return e.line&&e.column?e:void 0}const tA={},nA={}.hasOwnProperty,s0=Dp("type",{handlers:{root:iA,element:uA,text:oA,comment:lA,doctype:aA}});function rA(e,t){const r=(t||tA).space;return s0(e,r==="svg"?Rn:$i)}function iA(e,t){const n={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return n.childNodes=wu(e.children,n,t),jr(e,n),n}function sA(e,t){const n={nodeName:"#document-fragment",childNodes:[]};return n.childNodes=wu(e.children,n,t),jr(e,n),n}function aA(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return jr(e,t),t}function oA(e){const t={nodeName:"#text",value:e.value,parentNode:null};return jr(e,t),t}function lA(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return jr(e,t),t}function uA(e,t){const n=t;let r=n;e.type==="element"&&e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(r=Rn);const s=[];let i;if(e.properties){for(i in e.properties)if(i!=="children"&&nA.call(e.properties,i)){const l=cA(r,i,e.properties[i]);l&&s.push(l)}}const a=r.space,o={nodeName:e.tagName,tagName:e.tagName,attrs:s,namespaceURI:Xn[a],childNodes:[],parentNode:null};return o.childNodes=wu(e.children,o,r),jr(e,o),e.tagName==="template"&&e.content&&(o.content=sA(e.content,r)),o}function cA(e,t,n){const r=ka(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?Wm(n):ep(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=Xn[r.space]}return s}function wu(e,t,n){let r=-1;const s=[];if(e)for(;++r<e.length;){const i=s0(e[r],n);i.parentNode=t,s.push(i)}return s}function jr(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 dA=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],hA=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 F;(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"})(F||(F={}));const Rt={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function a0(e){return e>=55296&&e<=57343}function fA(e){return e>=56320&&e<=57343}function mA(e,t){return(e-55296)*1024+9216+t}function o0(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function l0(e){return e>=64976&&e<=65007||hA.has(e)}var J;(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"})(J||(J={}));const pA=65536;class gA{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=pA,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(fA(n))return this.pos++,this._addGap(),mA(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,F.EOF;return this._err(J.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,F.EOF;const r=this.html.charCodeAt(n);return r===F.CARRIAGE_RETURN?F.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,F.EOF;let t=this.html.charCodeAt(this.pos);return t===F.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,F.LINE_FEED):t===F.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,a0(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===F.LINE_FEED||t===F.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){o0(t)?this._err(J.controlCharacterInInputStream):l0(t)&&this._err(J.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 u0(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 bA=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))),xA=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 yA(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=xA.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 vA=32;var An;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(An||(An={}));function ml(e){return e>=xt.ZERO&&e<=xt.NINE}function EA(e){return e>=xt.UPPER_A&&e<=xt.UPPER_F||e>=xt.LOWER_A&&e<=xt.LOWER_F}function kA(e){return e>=xt.UPPER_A&&e<=xt.UPPER_Z||e>=xt.LOWER_A&&e<=xt.LOWER_Z||ml(e)}function TA(e){return e===xt.EQUALS||kA(e)}var bt;(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"})(bt||(bt={}));var bn;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(bn||(bn={}));class wA{constructor(t,n,r){this.decodeTree=t,this.emitCodePoint=n,this.errors=r,this.state=bt.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=bn.Strict}startEntity(t){this.decodeMode=t,this.state=bt.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,n){switch(this.state){case bt.EntityStart:return t.charCodeAt(n)===xt.NUM?(this.state=bt.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=bt.NamedEntity,this.stateNamedEntity(t,n));case bt.NumericStart:return this.stateNumericStart(t,n);case bt.NumericDecimal:return this.stateNumericDecimal(t,n);case bt.NumericHex:return this.stateNumericHex(t,n);case bt.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|vA)===xt.LOWER_X?(this.state=bt.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=bt.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(ml(s)||EA(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(ml(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===bn.Strict)return 0;return this.emitCodePoint(yA(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&An.VALUE_LENGTH)>>14;for(;n<t.length;n++,this.excess++){const a=t.charCodeAt(n);if(this.treeIndex=SA(r,s,this.treeIndex+Math.max(1,i),a),this.treeIndex<0)return this.result===0||this.decodeMode===bn.Attribute&&(i===0||TA(a))?0:this.emitNotTerminatedNamedEntity();if(s=r[this.treeIndex],i=(s&An.VALUE_LENGTH)>>14,i!==0){if(a===xt.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==bn.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]&An.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]&~An.VALUE_LENGTH:s[t+1],r),n===3&&this.emitCodePoint(s[t+2],r),r}end(){var t;switch(this.state){case bt.NamedEntity:return this.result!==0&&(this.decodeMode!==bn.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case bt.NumericDecimal:return this.emitNumericEntity(0,2);case bt.NumericHex:return this.emitNumericEntity(0,3);case bt.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case bt.EntityStart:return 0}}}function SA(e,t,n,r){const s=(t&An.BRANCH_LENGTH)>>7,i=t&An.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 le;(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/"})(le||(le={}));var nr;(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"})(nr||(nr={}));var zt;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(zt||(zt={}));var W;(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"})(W||(W={}));var x;(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"})(x||(x={}));const AA=new Map([[W.A,x.A],[W.ADDRESS,x.ADDRESS],[W.ANNOTATION_XML,x.ANNOTATION_XML],[W.APPLET,x.APPLET],[W.AREA,x.AREA],[W.ARTICLE,x.ARTICLE],[W.ASIDE,x.ASIDE],[W.B,x.B],[W.BASE,x.BASE],[W.BASEFONT,x.BASEFONT],[W.BGSOUND,x.BGSOUND],[W.BIG,x.BIG],[W.BLOCKQUOTE,x.BLOCKQUOTE],[W.BODY,x.BODY],[W.BR,x.BR],[W.BUTTON,x.BUTTON],[W.CAPTION,x.CAPTION],[W.CENTER,x.CENTER],[W.CODE,x.CODE],[W.COL,x.COL],[W.COLGROUP,x.COLGROUP],[W.DD,x.DD],[W.DESC,x.DESC],[W.DETAILS,x.DETAILS],[W.DIALOG,x.DIALOG],[W.DIR,x.DIR],[W.DIV,x.DIV],[W.DL,x.DL],[W.DT,x.DT],[W.EM,x.EM],[W.EMBED,x.EMBED],[W.FIELDSET,x.FIELDSET],[W.FIGCAPTION,x.FIGCAPTION],[W.FIGURE,x.FIGURE],[W.FONT,x.FONT],[W.FOOTER,x.FOOTER],[W.FOREIGN_OBJECT,x.FOREIGN_OBJECT],[W.FORM,x.FORM],[W.FRAME,x.FRAME],[W.FRAMESET,x.FRAMESET],[W.H1,x.H1],[W.H2,x.H2],[W.H3,x.H3],[W.H4,x.H4],[W.H5,x.H5],[W.H6,x.H6],[W.HEAD,x.HEAD],[W.HEADER,x.HEADER],[W.HGROUP,x.HGROUP],[W.HR,x.HR],[W.HTML,x.HTML],[W.I,x.I],[W.IMG,x.IMG],[W.IMAGE,x.IMAGE],[W.INPUT,x.INPUT],[W.IFRAME,x.IFRAME],[W.KEYGEN,x.KEYGEN],[W.LABEL,x.LABEL],[W.LI,x.LI],[W.LINK,x.LINK],[W.LISTING,x.LISTING],[W.MAIN,x.MAIN],[W.MALIGNMARK,x.MALIGNMARK],[W.MARQUEE,x.MARQUEE],[W.MATH,x.MATH],[W.MENU,x.MENU],[W.META,x.META],[W.MGLYPH,x.MGLYPH],[W.MI,x.MI],[W.MO,x.MO],[W.MN,x.MN],[W.MS,x.MS],[W.MTEXT,x.MTEXT],[W.NAV,x.NAV],[W.NOBR,x.NOBR],[W.NOFRAMES,x.NOFRAMES],[W.NOEMBED,x.NOEMBED],[W.NOSCRIPT,x.NOSCRIPT],[W.OBJECT,x.OBJECT],[W.OL,x.OL],[W.OPTGROUP,x.OPTGROUP],[W.OPTION,x.OPTION],[W.P,x.P],[W.PARAM,x.PARAM],[W.PLAINTEXT,x.PLAINTEXT],[W.PRE,x.PRE],[W.RB,x.RB],[W.RP,x.RP],[W.RT,x.RT],[W.RTC,x.RTC],[W.RUBY,x.RUBY],[W.S,x.S],[W.SCRIPT,x.SCRIPT],[W.SEARCH,x.SEARCH],[W.SECTION,x.SECTION],[W.SELECT,x.SELECT],[W.SOURCE,x.SOURCE],[W.SMALL,x.SMALL],[W.SPAN,x.SPAN],[W.STRIKE,x.STRIKE],[W.STRONG,x.STRONG],[W.STYLE,x.STYLE],[W.SUB,x.SUB],[W.SUMMARY,x.SUMMARY],[W.SUP,x.SUP],[W.TABLE,x.TABLE],[W.TBODY,x.TBODY],[W.TEMPLATE,x.TEMPLATE],[W.TEXTAREA,x.TEXTAREA],[W.TFOOT,x.TFOOT],[W.TD,x.TD],[W.TH,x.TH],[W.THEAD,x.THEAD],[W.TITLE,x.TITLE],[W.TR,x.TR],[W.TRACK,x.TRACK],[W.TT,x.TT],[W.U,x.U],[W.UL,x.UL],[W.SVG,x.SVG],[W.VAR,x.VAR],[W.WBR,x.WBR],[W.XMP,x.XMP]]);function Hr(e){var t;return(t=AA.get(e))!==null&&t!==void 0?t:x.UNKNOWN}const ce=x,CA={[le.HTML]:new Set([ce.ADDRESS,ce.APPLET,ce.AREA,ce.ARTICLE,ce.ASIDE,ce.BASE,ce.BASEFONT,ce.BGSOUND,ce.BLOCKQUOTE,ce.BODY,ce.BR,ce.BUTTON,ce.CAPTION,ce.CENTER,ce.COL,ce.COLGROUP,ce.DD,ce.DETAILS,ce.DIR,ce.DIV,ce.DL,ce.DT,ce.EMBED,ce.FIELDSET,ce.FIGCAPTION,ce.FIGURE,ce.FOOTER,ce.FORM,ce.FRAME,ce.FRAMESET,ce.H1,ce.H2,ce.H3,ce.H4,ce.H5,ce.H6,ce.HEAD,ce.HEADER,ce.HGROUP,ce.HR,ce.HTML,ce.IFRAME,ce.IMG,ce.INPUT,ce.LI,ce.LINK,ce.LISTING,ce.MAIN,ce.MARQUEE,ce.MENU,ce.META,ce.NAV,ce.NOEMBED,ce.NOFRAMES,ce.NOSCRIPT,ce.OBJECT,ce.OL,ce.P,ce.PARAM,ce.PLAINTEXT,ce.PRE,ce.SCRIPT,ce.SECTION,ce.SELECT,ce.SOURCE,ce.STYLE,ce.SUMMARY,ce.TABLE,ce.TBODY,ce.TD,ce.TEMPLATE,ce.TEXTAREA,ce.TFOOT,ce.TH,ce.THEAD,ce.TITLE,ce.TR,ce.TRACK,ce.UL,ce.WBR,ce.XMP]),[le.MATHML]:new Set([ce.MI,ce.MO,ce.MN,ce.MS,ce.MTEXT,ce.ANNOTATION_XML]),[le.SVG]:new Set([ce.TITLE,ce.FOREIGN_OBJECT,ce.DESC]),[le.XLINK]:new Set,[le.XML]:new Set,[le.XMLNS]:new Set},pl=new Set([ce.H1,ce.H2,ce.H3,ce.H4,ce.H5,ce.H6]);W.STYLE,W.SCRIPT,W.XMP,W.IFRAME,W.NOEMBED,W.NOFRAMES,W.PLAINTEXT;var j;(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"})(j||(j={}));const ct={DATA:j.DATA,RCDATA:j.RCDATA,RAWTEXT:j.RAWTEXT,SCRIPT_DATA:j.SCRIPT_DATA,PLAINTEXT:j.PLAINTEXT,CDATA_SECTION:j.CDATA_SECTION};function _A(e){return e>=F.DIGIT_0&&e<=F.DIGIT_9}function di(e){return e>=F.LATIN_CAPITAL_A&&e<=F.LATIN_CAPITAL_Z}function NA(e){return e>=F.LATIN_SMALL_A&&e<=F.LATIN_SMALL_Z}function kn(e){return NA(e)||di(e)}function qd(e){return kn(e)||_A(e)}function ks(e){return e+32}function c0(e){return e===F.SPACE||e===F.LINE_FEED||e===F.TABULATION||e===F.FORM_FEED}function $d(e){return c0(e)||e===F.SOLIDUS||e===F.GREATER_THAN_SIGN}function IA(e){return e===F.NULL?J.nullCharacterReference:e>1114111?J.characterReferenceOutsideUnicodeRange:a0(e)?J.surrogateCharacterReference:l0(e)?J.noncharacterCharacterReference:o0(e)||e===F.CARRIAGE_RETURN?J.controlCharacterReference:null}class RA{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=j.DATA,this.returnState=j.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new gA(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new wA(bA,(r,s)=>{this.preprocessor.pos=this.entityStartPos+s-1,this._flushCodePointConsumedAsCharacterReference(r)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(J.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:r=>{this._err(J.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+r)},validateNumericCharacterReference:r=>{const s=IA(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:x.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:He.END_TAG,tagName:"",tagID:x.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(u0(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(J.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=Hr(t.tagName),t.type===He.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(J.endTagWithAttributes),t.selfClosing&&this._err(J.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=c0(t)?He.WHITESPACE_CHARACTER:t===F.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=j.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?bn.Attribute:bn.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===j.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===j.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===j.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case j.DATA:{this._stateData(t);break}case j.RCDATA:{this._stateRcdata(t);break}case j.RAWTEXT:{this._stateRawtext(t);break}case j.SCRIPT_DATA:{this._stateScriptData(t);break}case j.PLAINTEXT:{this._statePlaintext(t);break}case j.TAG_OPEN:{this._stateTagOpen(t);break}case j.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case j.TAG_NAME:{this._stateTagName(t);break}case j.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case j.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case j.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case j.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case j.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case j.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case j.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case j.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case j.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case j.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case j.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case j.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case j.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case j.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case j.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case j.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case j.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case j.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case j.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case j.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case j.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case j.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case j.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case j.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case j.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case j.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case j.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case j.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case j.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case j.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case j.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case j.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case j.BOGUS_COMMENT:{this._stateBogusComment(t);break}case j.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case j.COMMENT_START:{this._stateCommentStart(t);break}case j.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case j.COMMENT:{this._stateComment(t);break}case j.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case j.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case j.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case j.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case j.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case j.COMMENT_END:{this._stateCommentEnd(t);break}case j.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case j.DOCTYPE:{this._stateDoctype(t);break}case j.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case j.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case j.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case j.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case j.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case j.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case j.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case j.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case j.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case j.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case j.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case j.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case j.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case j.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case j.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case j.CDATA_SECTION:{this._stateCdataSection(t);break}case j.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case j.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case j.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case j.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case F.LESS_THAN_SIGN:{this.state=j.TAG_OPEN;break}case F.AMPERSAND:{this._startCharacterReference();break}case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitCodePoint(t);break}case F.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case F.AMPERSAND:{this._startCharacterReference();break}case F.LESS_THAN_SIGN:{this.state=j.RCDATA_LESS_THAN_SIGN;break}case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitChars(ot);break}case F.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case F.LESS_THAN_SIGN:{this.state=j.RAWTEXT_LESS_THAN_SIGN;break}case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitChars(ot);break}case F.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_LESS_THAN_SIGN;break}case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitChars(ot);break}case F.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitChars(ot);break}case F.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(kn(t))this._createStartTagToken(),this.state=j.TAG_NAME,this._stateTagName(t);else switch(t){case F.EXCLAMATION_MARK:{this.state=j.MARKUP_DECLARATION_OPEN;break}case F.SOLIDUS:{this.state=j.END_TAG_OPEN;break}case F.QUESTION_MARK:{this._err(J.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=j.BOGUS_COMMENT,this._stateBogusComment(t);break}case F.EOF:{this._err(J.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(J.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=j.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(kn(t))this._createEndTagToken(),this.state=j.TAG_NAME,this._stateTagName(t);else switch(t){case F.GREATER_THAN_SIGN:{this._err(J.missingEndTagName),this.state=j.DATA;break}case F.EOF:{this._err(J.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(J.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=j.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this.state=j.BEFORE_ATTRIBUTE_NAME;break}case F.SOLIDUS:{this.state=j.SELF_CLOSING_START_TAG;break}case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentTagToken();break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.tagName+=ot;break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:n.tagName+=String.fromCodePoint(di(t)?ks(t):t)}}_stateRcdataLessThanSign(t){t===F.SOLIDUS?this.state=j.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=j.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){kn(t)?(this.state=j.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=j.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 F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=j.BEFORE_ATTRIBUTE_NAME,!1;case F.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=j.SELF_CLOSING_START_TAG,!1;case F.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=j.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=j.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===F.SOLIDUS?this.state=j.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=j.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){kn(t)?(this.state=j.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=j.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=j.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case F.SOLIDUS:{this.state=j.SCRIPT_DATA_END_TAG_OPEN;break}case F.EXCLAMATION_MARK:{this.state=j.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=j.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){kn(t)?(this.state=j.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=j.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=j.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===F.HYPHEN_MINUS?(this.state=j.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=j.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===F.HYPHEN_MINUS?(this.state=j.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=j.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case F.HYPHEN_MINUS:{this.state=j.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitChars(ot);break}case F.EOF:{this._err(J.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case F.HYPHEN_MINUS:{this.state=j.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.state=j.SCRIPT_DATA_ESCAPED,this._emitChars(ot);break}case F.EOF:{this._err(J.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=j.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case F.HYPHEN_MINUS:{this._emitChars("-");break}case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case F.GREATER_THAN_SIGN:{this.state=j.SCRIPT_DATA,this._emitChars(">");break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.state=j.SCRIPT_DATA_ESCAPED,this._emitChars(ot);break}case F.EOF:{this._err(J.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=j.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===F.SOLIDUS?this.state=j.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:kn(t)?(this._emitChars("<"),this.state=j.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=j.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){kn(t)?(this.state=j.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=j.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=j.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(Rt.SCRIPT,!1)&&$d(this.preprocessor.peek(Rt.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<Rt.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=j.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case F.HYPHEN_MINUS:{this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case F.NULL:{this._err(J.unexpectedNullCharacter),this._emitChars(ot);break}case F.EOF:{this._err(J.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case F.HYPHEN_MINUS:{this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(ot);break}case F.EOF:{this._err(J.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case F.HYPHEN_MINUS:{this._emitChars("-");break}case F.LESS_THAN_SIGN:{this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case F.GREATER_THAN_SIGN:{this.state=j.SCRIPT_DATA,this._emitChars(">");break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(ot);break}case F.EOF:{this._err(J.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===F.SOLIDUS?(this.state=j.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(Rt.SCRIPT,!1)&&$d(this.preprocessor.peek(Rt.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<Rt.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=j.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=j.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.SOLIDUS:case F.GREATER_THAN_SIGN:case F.EOF:{this.state=j.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case F.EQUALS_SIGN:{this._err(J.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=j.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=j.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:case F.SOLIDUS:case F.GREATER_THAN_SIGN:case F.EOF:{this._leaveAttrName(),this.state=j.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case F.EQUALS_SIGN:{this._leaveAttrName(),this.state=j.BEFORE_ATTRIBUTE_VALUE;break}case F.QUOTATION_MARK:case F.APOSTROPHE:case F.LESS_THAN_SIGN:{this._err(J.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.currentAttr.name+=ot;break}default:this.currentAttr.name+=String.fromCodePoint(di(t)?ks(t):t)}}_stateAfterAttributeName(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.SOLIDUS:{this.state=j.SELF_CLOSING_START_TAG;break}case F.EQUALS_SIGN:{this.state=j.BEFORE_ATTRIBUTE_VALUE;break}case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentTagToken();break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=j.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.QUOTATION_MARK:{this.state=j.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case F.APOSTROPHE:{this.state=j.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case F.GREATER_THAN_SIGN:{this._err(J.missingAttributeValue),this.state=j.DATA,this.emitCurrentTagToken();break}default:this.state=j.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case F.QUOTATION_MARK:{this.state=j.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case F.AMPERSAND:{this._startCharacterReference();break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.currentAttr.value+=ot;break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case F.APOSTROPHE:{this.state=j.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case F.AMPERSAND:{this._startCharacterReference();break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.currentAttr.value+=ot;break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this._leaveAttrValue(),this.state=j.BEFORE_ATTRIBUTE_NAME;break}case F.AMPERSAND:{this._startCharacterReference();break}case F.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=j.DATA,this.emitCurrentTagToken();break}case F.NULL:{this._err(J.unexpectedNullCharacter),this.currentAttr.value+=ot;break}case F.QUOTATION_MARK:case F.APOSTROPHE:case F.LESS_THAN_SIGN:case F.EQUALS_SIGN:case F.GRAVE_ACCENT:{this._err(J.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this._leaveAttrValue(),this.state=j.BEFORE_ATTRIBUTE_NAME;break}case F.SOLIDUS:{this._leaveAttrValue(),this.state=j.SELF_CLOSING_START_TAG;break}case F.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=j.DATA,this.emitCurrentTagToken();break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:this._err(J.missingWhitespaceBetweenAttributes),this.state=j.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case F.GREATER_THAN_SIGN:{const n=this.currentToken;n.selfClosing=!0,this.state=j.DATA,this.emitCurrentTagToken();break}case F.EOF:{this._err(J.eofInTag),this._emitEOFToken();break}default:this._err(J.unexpectedSolidusInTag),this.state=j.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const n=this.currentToken;switch(t){case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentComment(n);break}case F.EOF:{this.emitCurrentComment(n),this._emitEOFToken();break}case F.NULL:{this._err(J.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=j.COMMENT_START):this._consumeSequenceIfMatch(Rt.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(Rt.DOCTYPE.length+1),this.state=j.DOCTYPE):this._consumeSequenceIfMatch(Rt.CDATA_START,!0)?this.inForeignNode?this.state=j.CDATA_SECTION:(this._err(J.cdataInHtmlContent),this._createCommentToken(Rt.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=j.BOGUS_COMMENT):this._ensureHibernation()||(this._err(J.incorrectlyOpenedComment),this._createCommentToken(2),this.state=j.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case F.HYPHEN_MINUS:{this.state=j.COMMENT_START_DASH;break}case F.GREATER_THAN_SIGN:{this._err(J.abruptClosingOfEmptyComment),this.state=j.DATA;const n=this.currentToken;this.emitCurrentComment(n);break}default:this.state=j.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const n=this.currentToken;switch(t){case F.HYPHEN_MINUS:{this.state=j.COMMENT_END;break}case F.GREATER_THAN_SIGN:{this._err(J.abruptClosingOfEmptyComment),this.state=j.DATA,this.emitCurrentComment(n);break}case F.EOF:{this._err(J.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=j.COMMENT,this._stateComment(t)}}_stateComment(t){const n=this.currentToken;switch(t){case F.HYPHEN_MINUS:{this.state=j.COMMENT_END_DASH;break}case F.LESS_THAN_SIGN:{n.data+="<",this.state=j.COMMENT_LESS_THAN_SIGN;break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.data+=ot;break}case F.EOF:{this._err(J.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const n=this.currentToken;switch(t){case F.EXCLAMATION_MARK:{n.data+="!",this.state=j.COMMENT_LESS_THAN_SIGN_BANG;break}case F.LESS_THAN_SIGN:{n.data+="<";break}default:this.state=j.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===F.HYPHEN_MINUS?this.state=j.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=j.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===F.HYPHEN_MINUS?this.state=j.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=j.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==F.GREATER_THAN_SIGN&&t!==F.EOF&&this._err(J.nestedComment),this.state=j.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const n=this.currentToken;switch(t){case F.HYPHEN_MINUS:{this.state=j.COMMENT_END;break}case F.EOF:{this._err(J.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=j.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const n=this.currentToken;switch(t){case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentComment(n);break}case F.EXCLAMATION_MARK:{this.state=j.COMMENT_END_BANG;break}case F.HYPHEN_MINUS:{n.data+="-";break}case F.EOF:{this._err(J.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--",this.state=j.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const n=this.currentToken;switch(t){case F.HYPHEN_MINUS:{n.data+="--!",this.state=j.COMMENT_END_DASH;break}case F.GREATER_THAN_SIGN:{this._err(J.incorrectlyClosedComment),this.state=j.DATA,this.emitCurrentComment(n);break}case F.EOF:{this._err(J.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--!",this.state=j.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this.state=j.BEFORE_DOCTYPE_NAME;break}case F.GREATER_THAN_SIGN:{this.state=j.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case F.EOF:{this._err(J.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingWhitespaceBeforeDoctypeName),this.state=j.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(di(t))this._createDoctypeToken(String.fromCharCode(ks(t))),this.state=j.DOCTYPE_NAME;else switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.NULL:{this._err(J.unexpectedNullCharacter),this._createDoctypeToken(ot),this.state=j.DOCTYPE_NAME;break}case F.GREATER_THAN_SIGN:{this._err(J.missingDoctypeName),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.EOF:{this._err(J.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=j.DOCTYPE_NAME}}_stateDoctypeName(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this.state=j.AFTER_DOCTYPE_NAME;break}case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.name+=ot;break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.name+=String.fromCodePoint(di(t)?ks(t):t)}}_stateAfterDoctypeName(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(Rt.PUBLIC,!1)?this.state=j.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(Rt.SYSTEM,!1)?this.state=j.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(J.invalidCharacterSequenceAfterDoctypeName),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this.state=j.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case F.QUOTATION_MARK:{this._err(J.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=j.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case F.APOSTROPHE:{this._err(J.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=j.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case F.GREATER_THAN_SIGN:{this._err(J.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.QUOTATION_MARK:{n.publicId="",this.state=j.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case F.APOSTROPHE:{n.publicId="",this.state=j.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case F.GREATER_THAN_SIGN:{this._err(J.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case F.QUOTATION_MARK:{this.state=j.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.publicId+=ot;break}case F.GREATER_THAN_SIGN:{this._err(J.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.EOF:{this._err(J.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 F.APOSTROPHE:{this.state=j.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.publicId+=ot;break}case F.GREATER_THAN_SIGN:{this._err(J.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.EOF:{this._err(J.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 F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this.state=j.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case F.GREATER_THAN_SIGN:{this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.QUOTATION_MARK:{this._err(J.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case F.APOSTROPHE:{this._err(J.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.QUOTATION_MARK:{n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case F.APOSTROPHE:{n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:{this.state=j.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case F.QUOTATION_MARK:{this._err(J.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case F.APOSTROPHE:{this._err(J.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case F.GREATER_THAN_SIGN:{this._err(J.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.QUOTATION_MARK:{n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case F.APOSTROPHE:{n.systemId="",this.state=j.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case F.GREATER_THAN_SIGN:{this._err(J.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=j.DATA,this.emitCurrentDoctype(n);break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case F.QUOTATION_MARK:{this.state=j.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.systemId+=ot;break}case F.GREATER_THAN_SIGN:{this._err(J.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.EOF:{this._err(J.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 F.APOSTROPHE:{this.state=j.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case F.NULL:{this._err(J.unexpectedNullCharacter),n.systemId+=ot;break}case F.GREATER_THAN_SIGN:{this._err(J.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.EOF:{this._err(J.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 F.SPACE:case F.LINE_FEED:case F.TABULATION:case F.FORM_FEED:break;case F.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.EOF:{this._err(J.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(J.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=j.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const n=this.currentToken;switch(t){case F.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=j.DATA;break}case F.NULL:{this._err(J.unexpectedNullCharacter);break}case F.EOF:{this.emitCurrentDoctype(n),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case F.RIGHT_SQUARE_BRACKET:{this.state=j.CDATA_SECTION_BRACKET;break}case F.EOF:{this._err(J.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===F.RIGHT_SQUARE_BRACKET?this.state=j.CDATA_SECTION_END:(this._emitChars("]"),this.state=j.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case F.GREATER_THAN_SIGN:{this.state=j.DATA;break}case F.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=j.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(F.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&qd(this.preprocessor.peek(1))?j.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){qd(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===F.SEMICOLON&&this._err(J.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const d0=new Set([x.DD,x.DT,x.LI,x.OPTGROUP,x.OPTION,x.P,x.RB,x.RP,x.RT,x.RTC]),Wd=new Set([...d0,x.CAPTION,x.COLGROUP,x.TBODY,x.TD,x.TFOOT,x.TH,x.THEAD,x.TR]),ta=new Set([x.APPLET,x.CAPTION,x.HTML,x.MARQUEE,x.OBJECT,x.TABLE,x.TD,x.TEMPLATE,x.TH]),MA=new Set([...ta,x.OL,x.UL]),PA=new Set([...ta,x.BUTTON]),Yd=new Set([x.ANNOTATION_XML,x.MI,x.MN,x.MO,x.MS,x.MTEXT]),Gd=new Set([x.DESC,x.FOREIGN_OBJECT,x.TITLE]),LA=new Set([x.TR,x.TEMPLATE,x.HTML]),DA=new Set([x.TBODY,x.TFOOT,x.THEAD,x.TEMPLATE,x.HTML]),OA=new Set([x.TABLE,x.TEMPLATE,x.HTML]),FA=new Set([x.TD,x.TH]);class BA{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=x.UNKNOWN,this.current=t}_indexOf(t){return this.items.lastIndexOf(t,this.stackTop)}_isInTemplate(){return this.currentTagId===x.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===le.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])!==le.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(pl,le.HTML)}popUntilTableCellPopped(){this.popUntilPopped(FA,le.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(OA,le.HTML)}clearBackToTableBodyContext(){this.clearBackTo(DA,le.HTML)}clearBackToTableRowContext(){this.clearBackTo(LA,le.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]===x.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]===x.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 le.HTML:{if(s===t)return!0;if(n.has(s))return!1;break}case le.SVG:{if(Gd.has(s))return!1;break}case le.MATHML:{if(Yd.has(s))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,ta)}hasInListItemScope(t){return this.hasInDynamicScope(t,MA)}hasInButtonScope(t){return this.hasInDynamicScope(t,PA)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case le.HTML:{if(pl.has(n))return!0;if(ta.has(n))return!1;break}case le.SVG:{if(Gd.has(n))return!1;break}case le.MATHML:{if(Yd.has(n))return!1;break}}}return!0}hasInTableScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===le.HTML)switch(this.tagIDs[n]){case t:return!0;case x.TABLE:case x.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===le.HTML)switch(this.tagIDs[t]){case x.TBODY:case x.THEAD:case x.TFOOT:return!0;case x.TABLE:case x.HTML:return!1}return!0}hasInSelectScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===le.HTML)switch(this.tagIDs[n]){case t:return!0;case x.OPTION:case x.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&d0.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&Wd.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&Wd.has(this.currentTagId);)this.pop()}}const ko=3;var an;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(an||(an={}));const Kd={type:an.Marker};class jA{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===an.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<ko)return;const n=this.treeAdapter.getAttrList(t),r=this._getNoahArkConditionCandidates(t,n);if(r.length<ko)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>=ko&&this.entries.splice(o.idx,1))}}insertMarker(){this.entries.unshift(Kd)}pushElement(t,n){this._ensureNoahArkCondition(t),this.entries.unshift({type:an.Element,element:t,token:n})}insertElementAfterBookmark(t,n){const r=this.entries.indexOf(this.bookmark);this.entries.splice(r,0,{type:an.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(Kd);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const n=this.entries.find(r=>r.type===an.Marker||this.treeAdapter.getTagName(r.element)===t);return n&&n.type===an.Element?n:null}getElementEntry(t){return this.entries.find(n=>n.type===an.Element&&n.element===t)}}const Tn={createDocument(){return{nodeName:"#document",mode:zt.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};Tn.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(Tn.isTextNode(n)){n.value+=t;return}}Tn.appendChild(e,Tn.createTextNode(t))},insertTextBefore(e,t,n){const r=e.childNodes[e.childNodes.indexOf(n)-1];r&&Tn.isTextNode(r)?r.value+=t:Tn.insertBefore(e,Tn.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}}},h0="html",HA="about:legacy-compat",UA="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",f0=["+//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//"],zA=[...f0,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],VA=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),m0=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],qA=[...m0,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function Xd(e,t){return t.some(n=>e.startsWith(n))}function $A(e){return e.name===h0&&e.publicId===null&&(e.systemId===null||e.systemId===HA)}function WA(e){if(e.name!==h0)return zt.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===UA)return zt.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),VA.has(n))return zt.QUIRKS;let r=t===null?zA:f0;if(Xd(n,r))return zt.QUIRKS;if(r=t===null?m0:qA,Xd(n,r))return zt.LIMITED_QUIRKS}return zt.NO_QUIRKS}const Qd={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},YA="definitionurl",GA="definitionURL",KA=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])),XA=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:le.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:le.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:le.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:le.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:le.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:le.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:le.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:le.XML}],["xml:space",{prefix:"xml",name:"space",namespace:le.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:le.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:le.XMLNS}]]),QA=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])),ZA=new Set([x.B,x.BIG,x.BLOCKQUOTE,x.BODY,x.BR,x.CENTER,x.CODE,x.DD,x.DIV,x.DL,x.DT,x.EM,x.EMBED,x.H1,x.H2,x.H3,x.H4,x.H5,x.H6,x.HEAD,x.HR,x.I,x.IMG,x.LI,x.LISTING,x.MENU,x.META,x.NOBR,x.OL,x.P,x.PRE,x.RUBY,x.S,x.SMALL,x.SPAN,x.STRONG,x.STRIKE,x.SUB,x.SUP,x.TABLE,x.TT,x.U,x.UL,x.VAR]);function JA(e){const t=e.tagID;return t===x.FONT&&e.attrs.some(({name:r})=>r===nr.COLOR||r===nr.SIZE||r===nr.FACE)||ZA.has(t)}function p0(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===YA){e.attrs[t].name=GA;break}}function g0(e){for(let t=0;t<e.attrs.length;t++){const n=KA.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function Su(e){for(let t=0;t<e.attrs.length;t++){const n=XA.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 eC(e){const t=QA.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=Hr(e.tagName))}function tC(e,t){return t===le.MATHML&&(e===x.MI||e===x.MO||e===x.MN||e===x.MS||e===x.MTEXT)}function nC(e,t,n){if(t===le.MATHML&&e===x.ANNOTATION_XML){for(let r=0;r<n.length;r++)if(n[r].name===nr.ENCODING){const s=n[r].value.toLowerCase();return s===Qd.TEXT_HTML||s===Qd.APPLICATION_XML}}return t===le.SVG&&(e===x.FOREIGN_OBJECT||e===x.DESC||e===x.TITLE)}function rC(e,t,n,r){return(!r||r===le.HTML)&&nC(e,t,n)||(!r||r===le.MATHML)&&tC(e,t)}const iC="hidden",sC=8,aC=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 oC={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},b0=new Set([x.TABLE,x.TBODY,x.TFOOT,x.THEAD,x.TR]),Zd={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:Tn,onParseError:null};class Jd{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={...Zd,...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 RA(this.options,this),this.activeFormattingElements=new jA(this.treeAdapter),this.fragmentContextID=r?Hr(this.treeAdapter.getTagName(r)):x.UNKNOWN,this._setContextModes(r??this.document,this.fragmentContextID),this.openElements=new BA(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={...Zd,...n};t??(t=r.treeAdapter.createElement(W.TEMPLATE,le.HTML,[]));const s=r.treeAdapter.createElement("documentmock",le.HTML,[]),i=new this(r,s,t);return i.fragmentContextID===x.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:oC,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)===le.HTML;this.currentNotInHTML=!r,this.tokenizer.inForeignNode=!r&&t!==void 0&&n!==void 0&&!this._isIntegrationPoint(n,t)}_switchToTextParsing(t,n){this._insertElement(t,le.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=ct.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)===W.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==le.HTML))switch(this.fragmentContextID){case x.TITLE:case x.TEXTAREA:{this.tokenizer.state=ct.RCDATA;break}case x.STYLE:case x.XMP:case x.IFRAME:case x.NOEMBED:case x.NOFRAMES:case x.NOSCRIPT:{this.tokenizer.state=ct.RAWTEXT;break}case x.SCRIPT:{this.tokenizer.state=ct.SCRIPT_DATA;break}case x.PLAINTEXT:{this.tokenizer.state=ct.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,le.HTML,[]);this._attachElementToTree(r,null),this.openElements.push(r,n)}_insertTemplate(t){const n=this.treeAdapter.createElement(t.tagName,le.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(W.HTML,le.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(t,null),this.treeAdapter.appendChild(this.openElements.current,t),this.openElements.push(t,x.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===x.SVG&&this.treeAdapter.getTagName(n)===W.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===le.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===x.MGLYPH||t.tagID===x.MALIGNMARK)&&r!==void 0&&!this._isIntegrationPoint(r,n,le.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 rC(t,s,i,r)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const n=this.activeFormattingElements.entries.findIndex(s=>s.type===an.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(x.P),this.openElements.popUntilTagNamePopped(x.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case x.TR:{this.insertionMode=U.IN_ROW;return}case x.TBODY:case x.THEAD:case x.TFOOT:{this.insertionMode=U.IN_TABLE_BODY;return}case x.CAPTION:{this.insertionMode=U.IN_CAPTION;return}case x.COLGROUP:{this.insertionMode=U.IN_COLUMN_GROUP;return}case x.TABLE:{this.insertionMode=U.IN_TABLE;return}case x.BODY:{this.insertionMode=U.IN_BODY;return}case x.FRAMESET:{this.insertionMode=U.IN_FRAMESET;return}case x.SELECT:{this._resetInsertionModeForSelect(t);return}case x.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case x.HTML:{this.insertionMode=this.headElement?U.AFTER_HEAD:U.BEFORE_HEAD;return}case x.TD:case x.TH:{if(t>0){this.insertionMode=U.IN_CELL;return}break}case x.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===x.TEMPLATE)break;if(r===x.TABLE){this.insertionMode=U.IN_SELECT_IN_TABLE;return}}this.insertionMode=U.IN_SELECT}_isElementCausesFosterParenting(t){return b0.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 x.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(n)===le.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case x.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 CA[r].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){F3(this,t);return}switch(this.insertionMode){case U.INITIAL:{ii(this,t);break}case U.BEFORE_HTML:{xi(this,t);break}case U.BEFORE_HEAD:{yi(this,t);break}case U.IN_HEAD:{vi(this,t);break}case U.IN_HEAD_NO_SCRIPT:{Ei(this,t);break}case U.AFTER_HEAD:{ki(this,t);break}case U.IN_BODY:case U.IN_CAPTION:case U.IN_CELL:case U.IN_TEMPLATE:{y0(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:{To(this,t);break}case U.IN_TABLE_TEXT:{S0(this,t);break}case U.IN_COLUMN_GROUP:{na(this,t);break}case U.AFTER_BODY:{ra(this,t);break}case U.AFTER_AFTER_BODY:{Os(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){O3(this,t);return}switch(this.insertionMode){case U.INITIAL:{ii(this,t);break}case U.BEFORE_HTML:{xi(this,t);break}case U.BEFORE_HEAD:{yi(this,t);break}case U.IN_HEAD:{vi(this,t);break}case U.IN_HEAD_NO_SCRIPT:{Ei(this,t);break}case U.AFTER_HEAD:{ki(this,t);break}case U.TEXT:{this._insertCharacters(t);break}case U.IN_TABLE:case U.IN_TABLE_BODY:case U.IN_ROW:{To(this,t);break}case U.IN_COLUMN_GROUP:{na(this,t);break}case U.AFTER_BODY:{ra(this,t);break}case U.AFTER_AFTER_BODY:{Os(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){gl(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:{gl(this,t);break}case U.IN_TABLE_TEXT:{si(this,t);break}case U.AFTER_BODY:{mC(this,t);break}case U.AFTER_AFTER_BODY:case U.AFTER_AFTER_FRAMESET:{pC(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case U.INITIAL:{gC(this,t);break}case U.BEFORE_HEAD:case U.IN_HEAD:case U.IN_HEAD_NO_SCRIPT:case U.AFTER_HEAD:{this._err(t,J.misplacedDoctype);break}case U.IN_TABLE_TEXT:{si(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,J.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?B3(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case U.INITIAL:{ii(this,t);break}case U.BEFORE_HTML:{bC(this,t);break}case U.BEFORE_HEAD:{yC(this,t);break}case U.IN_HEAD:{en(this,t);break}case U.IN_HEAD_NO_SCRIPT:{kC(this,t);break}case U.AFTER_HEAD:{wC(this,t);break}case U.IN_BODY:{wt(this,t);break}case U.IN_TABLE:{Lr(this,t);break}case U.IN_TABLE_TEXT:{si(this,t);break}case U.IN_CAPTION:{v3(this,t);break}case U.IN_COLUMN_GROUP:{_u(this,t);break}case U.IN_TABLE_BODY:{Ma(this,t);break}case U.IN_ROW:{Pa(this,t);break}case U.IN_CELL:{T3(this,t);break}case U.IN_SELECT:{_0(this,t);break}case U.IN_SELECT_IN_TABLE:{S3(this,t);break}case U.IN_TEMPLATE:{C3(this,t);break}case U.AFTER_BODY:{N3(this,t);break}case U.IN_FRAMESET:{I3(this,t);break}case U.AFTER_FRAMESET:{M3(this,t);break}case U.AFTER_AFTER_BODY:{L3(this,t);break}case U.AFTER_AFTER_FRAMESET:{D3(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?j3(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case U.INITIAL:{ii(this,t);break}case U.BEFORE_HTML:{xC(this,t);break}case U.BEFORE_HEAD:{vC(this,t);break}case U.IN_HEAD:{EC(this,t);break}case U.IN_HEAD_NO_SCRIPT:{TC(this,t);break}case U.AFTER_HEAD:{SC(this,t);break}case U.IN_BODY:{Ra(this,t);break}case U.TEXT:{c3(this,t);break}case U.IN_TABLE:{Oi(this,t);break}case U.IN_TABLE_TEXT:{si(this,t);break}case U.IN_CAPTION:{E3(this,t);break}case U.IN_COLUMN_GROUP:{k3(this,t);break}case U.IN_TABLE_BODY:{bl(this,t);break}case U.IN_ROW:{C0(this,t);break}case U.IN_CELL:{w3(this,t);break}case U.IN_SELECT:{N0(this,t);break}case U.IN_SELECT_IN_TABLE:{A3(this,t);break}case U.IN_TEMPLATE:{_3(this,t);break}case U.AFTER_BODY:{R0(this,t);break}case U.IN_FRAMESET:{R3(this,t);break}case U.AFTER_FRAMESET:{P3(this,t);break}case U.AFTER_AFTER_BODY:{Os(this,t);break}}}onEof(t){switch(this.insertionMode){case U.INITIAL:{ii(this,t);break}case U.BEFORE_HTML:{xi(this,t);break}case U.BEFORE_HEAD:{yi(this,t);break}case U.IN_HEAD:{vi(this,t);break}case U.IN_HEAD_NO_SCRIPT:{Ei(this,t);break}case U.AFTER_HEAD:{ki(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:{T0(this,t);break}case U.TEXT:{d3(this,t);break}case U.IN_TABLE_TEXT:{si(this,t);break}case U.IN_TEMPLATE:{I0(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:{Cu(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===F.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:{x0(this,t);break}case U.IN_TABLE:case U.IN_TABLE_BODY:case U.IN_ROW:{To(this,t);break}case U.IN_TABLE_TEXT:{w0(this,t);break}}}}function lC(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):k0(e,t),n}function uC(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 cC(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>=aC;!o||l?(l&&e.activeFormattingElements.removeEntry(o),e.openElements.remove(a)):(a=dC(e,o),r===t&&(e.activeFormattingElements.bookmark=o),e.treeAdapter.detachNode(r),e.treeAdapter.appendChild(a,r),r=a)}return r}function dC(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 hC(e,t,n){const r=e.treeAdapter.getTagName(t),s=Hr(r);if(e._isElementCausesFosterParenting(s))e._fosterParentElement(n);else{const i=e.treeAdapter.getNamespaceURI(t);s===x.TEMPLATE&&i===le.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function fC(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 Au(e,t){for(let n=0;n<sC;n++){const r=lC(e,t);if(!r)break;const s=uC(e,r);if(!s)break;e.activeFormattingElements.bookmark=r;const i=cC(e,s,r.element),a=e.openElements.getCommonAncestor(r.element);e.treeAdapter.detachNode(i),a&&hC(e,a,i),fC(e,s,r)}}function gl(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function mC(e,t){e._appendCommentNode(t,e.openElements.items[0])}function pC(e,t){e._appendCommentNode(t,e.document)}function Cu(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 gC(e,t){e._setDocumentType(t);const n=t.forceQuirks?zt.QUIRKS:WA(t);$A(t)||e._err(t,J.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=U.BEFORE_HTML}function ii(e,t){e._err(t,J.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,zt.QUIRKS),e.insertionMode=U.BEFORE_HTML,e._processToken(t)}function bC(e,t){t.tagID===x.HTML?(e._insertElement(t,le.HTML),e.insertionMode=U.BEFORE_HEAD):xi(e,t)}function xC(e,t){const n=t.tagID;(n===x.HTML||n===x.HEAD||n===x.BODY||n===x.BR)&&xi(e,t)}function xi(e,t){e._insertFakeRootElement(),e.insertionMode=U.BEFORE_HEAD,e._processToken(t)}function yC(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.HEAD:{e._insertElement(t,le.HTML),e.headElement=e.openElements.current,e.insertionMode=U.IN_HEAD;break}default:yi(e,t)}}function vC(e,t){const n=t.tagID;n===x.HEAD||n===x.BODY||n===x.HTML||n===x.BR?yi(e,t):e._err(t,J.endTagWithoutMatchingOpenElement)}function yi(e,t){e._insertFakeElement(W.HEAD,x.HEAD),e.headElement=e.openElements.current,e.insertionMode=U.IN_HEAD,e._processToken(t)}function en(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.BASE:case x.BASEFONT:case x.BGSOUND:case x.LINK:case x.META:{e._appendElement(t,le.HTML),t.ackSelfClosing=!0;break}case x.TITLE:{e._switchToTextParsing(t,ct.RCDATA);break}case x.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,ct.RAWTEXT):(e._insertElement(t,le.HTML),e.insertionMode=U.IN_HEAD_NO_SCRIPT);break}case x.NOFRAMES:case x.STYLE:{e._switchToTextParsing(t,ct.RAWTEXT);break}case x.SCRIPT:{e._switchToTextParsing(t,ct.SCRIPT_DATA);break}case x.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=U.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(U.IN_TEMPLATE);break}case x.HEAD:{e._err(t,J.misplacedStartTagForHeadElement);break}default:vi(e,t)}}function EC(e,t){switch(t.tagID){case x.HEAD:{e.openElements.pop(),e.insertionMode=U.AFTER_HEAD;break}case x.BODY:case x.BR:case x.HTML:{vi(e,t);break}case x.TEMPLATE:{dr(e,t);break}default:e._err(t,J.endTagWithoutMatchingOpenElement)}}function dr(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==x.TEMPLATE&&e._err(t,J.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(x.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,J.endTagWithoutMatchingOpenElement)}function vi(e,t){e.openElements.pop(),e.insertionMode=U.AFTER_HEAD,e._processToken(t)}function kC(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.BASEFONT:case x.BGSOUND:case x.HEAD:case x.LINK:case x.META:case x.NOFRAMES:case x.STYLE:{en(e,t);break}case x.NOSCRIPT:{e._err(t,J.nestedNoscriptInHead);break}default:Ei(e,t)}}function TC(e,t){switch(t.tagID){case x.NOSCRIPT:{e.openElements.pop(),e.insertionMode=U.IN_HEAD;break}case x.BR:{Ei(e,t);break}default:e._err(t,J.endTagWithoutMatchingOpenElement)}}function Ei(e,t){const n=t.type===He.EOF?J.openElementsLeftAfterEof:J.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=U.IN_HEAD,e._processToken(t)}function wC(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.BODY:{e._insertElement(t,le.HTML),e.framesetOk=!1,e.insertionMode=U.IN_BODY;break}case x.FRAMESET:{e._insertElement(t,le.HTML),e.insertionMode=U.IN_FRAMESET;break}case x.BASE:case x.BASEFONT:case x.BGSOUND:case x.LINK:case x.META:case x.NOFRAMES:case x.SCRIPT:case x.STYLE:case x.TEMPLATE:case x.TITLE:{e._err(t,J.abandonedHeadElementChild),e.openElements.push(e.headElement,x.HEAD),en(e,t),e.openElements.remove(e.headElement);break}case x.HEAD:{e._err(t,J.misplacedStartTagForHeadElement);break}default:ki(e,t)}}function SC(e,t){switch(t.tagID){case x.BODY:case x.HTML:case x.BR:{ki(e,t);break}case x.TEMPLATE:{dr(e,t);break}default:e._err(t,J.endTagWithoutMatchingOpenElement)}}function ki(e,t){e._insertFakeElement(W.BODY,x.BODY),e.insertionMode=U.IN_BODY,Ia(e,t)}function Ia(e,t){switch(t.type){case He.CHARACTER:{y0(e,t);break}case He.WHITESPACE_CHARACTER:{x0(e,t);break}case He.COMMENT:{gl(e,t);break}case He.START_TAG:{wt(e,t);break}case He.END_TAG:{Ra(e,t);break}case He.EOF:{T0(e,t);break}}}function x0(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function y0(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function AC(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function CC(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function _C(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,le.HTML),e.insertionMode=U.IN_FRAMESET)}function NC(e,t){e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._insertElement(t,le.HTML)}function IC(e,t){e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&pl.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,le.HTML)}function RC(e,t){e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._insertElement(t,le.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function MC(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._insertElement(t,le.HTML),n||(e.formElement=e.openElements.current))}function PC(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===x.LI&&s===x.LI||(n===x.DD||n===x.DT)&&(s===x.DD||s===x.DT)){e.openElements.generateImpliedEndTagsWithExclusion(s),e.openElements.popUntilTagNamePopped(s);break}if(s!==x.ADDRESS&&s!==x.DIV&&s!==x.P&&e._isSpecialElement(e.openElements.items[r],s))break}e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._insertElement(t,le.HTML)}function LC(e,t){e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._insertElement(t,le.HTML),e.tokenizer.state=ct.PLAINTEXT}function DC(e,t){e.openElements.hasInScope(x.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(x.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,le.HTML),e.framesetOk=!1}function OC(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(W.A);n&&(Au(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,le.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function FC(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,le.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function BC(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(x.NOBR)&&(Au(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,le.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function jC(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,le.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function HC(e,t){e.treeAdapter.getDocumentMode(e.document)!==zt.QUIRKS&&e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._insertElement(t,le.HTML),e.framesetOk=!1,e.insertionMode=U.IN_TABLE}function v0(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,le.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function E0(e){const t=u0(e,nr.TYPE);return t!=null&&t.toLowerCase()===iC}function UC(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,le.HTML),E0(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function zC(e,t){e._appendElement(t,le.HTML),t.ackSelfClosing=!0}function VC(e,t){e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._appendElement(t,le.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function qC(e,t){t.tagName=W.IMG,t.tagID=x.IMG,v0(e,t)}function $C(e,t){e._insertElement(t,le.HTML),e.skipNextNewLine=!0,e.tokenizer.state=ct.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=U.TEXT}function WC(e,t){e.openElements.hasInButtonScope(x.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,ct.RAWTEXT)}function YC(e,t){e.framesetOk=!1,e._switchToTextParsing(t,ct.RAWTEXT)}function eh(e,t){e._switchToTextParsing(t,ct.RAWTEXT)}function GC(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,le.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 KC(e,t){e.openElements.currentTagId===x.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,le.HTML)}function XC(e,t){e.openElements.hasInScope(x.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,le.HTML)}function QC(e,t){e.openElements.hasInScope(x.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(x.RTC),e._insertElement(t,le.HTML)}function ZC(e,t){e._reconstructActiveFormattingElements(),p0(t),Su(t),t.selfClosing?e._appendElement(t,le.MATHML):e._insertElement(t,le.MATHML),t.ackSelfClosing=!0}function JC(e,t){e._reconstructActiveFormattingElements(),g0(t),Su(t),t.selfClosing?e._appendElement(t,le.SVG):e._insertElement(t,le.SVG),t.ackSelfClosing=!0}function th(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,le.HTML)}function wt(e,t){switch(t.tagID){case x.I:case x.S:case x.B:case x.U:case x.EM:case x.TT:case x.BIG:case x.CODE:case x.FONT:case x.SMALL:case x.STRIKE:case x.STRONG:{FC(e,t);break}case x.A:{OC(e,t);break}case x.H1:case x.H2:case x.H3:case x.H4:case x.H5:case x.H6:{IC(e,t);break}case x.P:case x.DL:case x.OL:case x.UL:case x.DIV:case x.DIR:case x.NAV:case x.MAIN:case x.MENU:case x.ASIDE:case x.CENTER:case x.FIGURE:case x.FOOTER:case x.HEADER:case x.HGROUP:case x.DIALOG:case x.DETAILS:case x.ADDRESS:case x.ARTICLE:case x.SEARCH:case x.SECTION:case x.SUMMARY:case x.FIELDSET:case x.BLOCKQUOTE:case x.FIGCAPTION:{NC(e,t);break}case x.LI:case x.DD:case x.DT:{PC(e,t);break}case x.BR:case x.IMG:case x.WBR:case x.AREA:case x.EMBED:case x.KEYGEN:{v0(e,t);break}case x.HR:{VC(e,t);break}case x.RB:case x.RTC:{XC(e,t);break}case x.RT:case x.RP:{QC(e,t);break}case x.PRE:case x.LISTING:{RC(e,t);break}case x.XMP:{WC(e,t);break}case x.SVG:{JC(e,t);break}case x.HTML:{AC(e,t);break}case x.BASE:case x.LINK:case x.META:case x.STYLE:case x.TITLE:case x.SCRIPT:case x.BGSOUND:case x.BASEFONT:case x.TEMPLATE:{en(e,t);break}case x.BODY:{CC(e,t);break}case x.FORM:{MC(e,t);break}case x.NOBR:{BC(e,t);break}case x.MATH:{ZC(e,t);break}case x.TABLE:{HC(e,t);break}case x.INPUT:{UC(e,t);break}case x.PARAM:case x.TRACK:case x.SOURCE:{zC(e,t);break}case x.IMAGE:{qC(e,t);break}case x.BUTTON:{DC(e,t);break}case x.APPLET:case x.OBJECT:case x.MARQUEE:{jC(e,t);break}case x.IFRAME:{YC(e,t);break}case x.SELECT:{GC(e,t);break}case x.OPTION:case x.OPTGROUP:{KC(e,t);break}case x.NOEMBED:case x.NOFRAMES:{eh(e,t);break}case x.FRAMESET:{_C(e,t);break}case x.TEXTAREA:{$C(e,t);break}case x.NOSCRIPT:{e.options.scriptingEnabled?eh(e,t):th(e,t);break}case x.PLAINTEXT:{LC(e,t);break}case x.COL:case x.TH:case x.TD:case x.TR:case x.HEAD:case x.FRAME:case x.TBODY:case x.TFOOT:case x.THEAD:case x.CAPTION:case x.COLGROUP:break;default:th(e,t)}}function e3(e,t){if(e.openElements.hasInScope(x.BODY)&&(e.insertionMode=U.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function t3(e,t){e.openElements.hasInScope(x.BODY)&&(e.insertionMode=U.AFTER_BODY,R0(e,t))}function n3(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function r3(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(x.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(x.FORM):n&&e.openElements.remove(n))}function i3(e){e.openElements.hasInButtonScope(x.P)||e._insertFakeElement(W.P,x.P),e._closePElement()}function s3(e){e.openElements.hasInListItemScope(x.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(x.LI),e.openElements.popUntilTagNamePopped(x.LI))}function a3(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function o3(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function l3(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function u3(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(W.BR,x.BR),e.openElements.pop(),e.framesetOk=!1}function k0(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!==x.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 Ra(e,t){switch(t.tagID){case x.A:case x.B:case x.I:case x.S:case x.U:case x.EM:case x.TT:case x.BIG:case x.CODE:case x.FONT:case x.NOBR:case x.SMALL:case x.STRIKE:case x.STRONG:{Au(e,t);break}case x.P:{i3(e);break}case x.DL:case x.UL:case x.OL:case x.DIR:case x.DIV:case x.NAV:case x.PRE:case x.MAIN:case x.MENU:case x.ASIDE:case x.BUTTON:case x.CENTER:case x.FIGURE:case x.FOOTER:case x.HEADER:case x.HGROUP:case x.DIALOG:case x.ADDRESS:case x.ARTICLE:case x.DETAILS:case x.SEARCH:case x.SECTION:case x.SUMMARY:case x.LISTING:case x.FIELDSET:case x.BLOCKQUOTE:case x.FIGCAPTION:{n3(e,t);break}case x.LI:{s3(e);break}case x.DD:case x.DT:{a3(e,t);break}case x.H1:case x.H2:case x.H3:case x.H4:case x.H5:case x.H6:{o3(e);break}case x.BR:{u3(e);break}case x.BODY:{e3(e,t);break}case x.HTML:{t3(e,t);break}case x.FORM:{r3(e);break}case x.APPLET:case x.OBJECT:case x.MARQUEE:{l3(e,t);break}case x.TEMPLATE:{dr(e,t);break}default:k0(e,t)}}function T0(e,t){e.tmplInsertionModeStack.length>0?I0(e,t):Cu(e,t)}function c3(e,t){var n;t.tagID===x.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function d3(e,t){e._err(t,J.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function To(e,t){if(e.openElements.currentTagId!==void 0&&b0.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:{S0(e,t);break}case He.WHITESPACE_CHARACTER:{w0(e,t);break}}else Gi(e,t)}function h3(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,le.HTML),e.insertionMode=U.IN_CAPTION}function f3(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,le.HTML),e.insertionMode=U.IN_COLUMN_GROUP}function m3(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(W.COLGROUP,x.COLGROUP),e.insertionMode=U.IN_COLUMN_GROUP,_u(e,t)}function p3(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,le.HTML),e.insertionMode=U.IN_TABLE_BODY}function g3(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(W.TBODY,x.TBODY),e.insertionMode=U.IN_TABLE_BODY,Ma(e,t)}function b3(e,t){e.openElements.hasInTableScope(x.TABLE)&&(e.openElements.popUntilTagNamePopped(x.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function x3(e,t){E0(t)?e._appendElement(t,le.HTML):Gi(e,t),t.ackSelfClosing=!0}function y3(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,le.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function Lr(e,t){switch(t.tagID){case x.TD:case x.TH:case x.TR:{g3(e,t);break}case x.STYLE:case x.SCRIPT:case x.TEMPLATE:{en(e,t);break}case x.COL:{m3(e,t);break}case x.FORM:{y3(e,t);break}case x.TABLE:{b3(e,t);break}case x.TBODY:case x.TFOOT:case x.THEAD:{p3(e,t);break}case x.INPUT:{x3(e,t);break}case x.CAPTION:{h3(e,t);break}case x.COLGROUP:{f3(e,t);break}default:Gi(e,t)}}function Oi(e,t){switch(t.tagID){case x.TABLE:{e.openElements.hasInTableScope(x.TABLE)&&(e.openElements.popUntilTagNamePopped(x.TABLE),e._resetInsertionMode());break}case x.TEMPLATE:{dr(e,t);break}case x.BODY:case x.CAPTION:case x.COL:case x.COLGROUP:case x.HTML:case x.TBODY:case x.TD:case x.TFOOT:case x.TH:case x.THEAD:case x.TR:break;default:Gi(e,t)}}function Gi(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,Ia(e,t),e.fosterParentingEnabled=n}function w0(e,t){e.pendingCharacterTokens.push(t)}function S0(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function si(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)Gi(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const A0=new Set([x.CAPTION,x.COL,x.COLGROUP,x.TBODY,x.TD,x.TFOOT,x.TH,x.THEAD,x.TR]);function v3(e,t){const n=t.tagID;A0.has(n)?e.openElements.hasInTableScope(x.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(x.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=U.IN_TABLE,Lr(e,t)):wt(e,t)}function E3(e,t){const n=t.tagID;switch(n){case x.CAPTION:case x.TABLE:{e.openElements.hasInTableScope(x.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(x.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=U.IN_TABLE,n===x.TABLE&&Oi(e,t));break}case x.BODY:case x.COL:case x.COLGROUP:case x.HTML:case x.TBODY:case x.TD:case x.TFOOT:case x.TH:case x.THEAD:case x.TR:break;default:Ra(e,t)}}function _u(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.COL:{e._appendElement(t,le.HTML),t.ackSelfClosing=!0;break}case x.TEMPLATE:{en(e,t);break}default:na(e,t)}}function k3(e,t){switch(t.tagID){case x.COLGROUP:{e.openElements.currentTagId===x.COLGROUP&&(e.openElements.pop(),e.insertionMode=U.IN_TABLE);break}case x.TEMPLATE:{dr(e,t);break}case x.COL:break;default:na(e,t)}}function na(e,t){e.openElements.currentTagId===x.COLGROUP&&(e.openElements.pop(),e.insertionMode=U.IN_TABLE,e._processToken(t))}function Ma(e,t){switch(t.tagID){case x.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,le.HTML),e.insertionMode=U.IN_ROW;break}case x.TH:case x.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(W.TR,x.TR),e.insertionMode=U.IN_ROW,Pa(e,t);break}case x.CAPTION:case x.COL:case x.COLGROUP:case x.TBODY:case x.TFOOT:case x.THEAD:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE,Lr(e,t));break}default:Lr(e,t)}}function bl(e,t){const n=t.tagID;switch(t.tagID){case x.TBODY:case x.TFOOT:case x.THEAD:{e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE);break}case x.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE,Oi(e,t));break}case x.BODY:case x.CAPTION:case x.COL:case x.COLGROUP:case x.HTML:case x.TD:case x.TH:case x.TR:break;default:Oi(e,t)}}function Pa(e,t){switch(t.tagID){case x.TH:case x.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,le.HTML),e.insertionMode=U.IN_CELL,e.activeFormattingElements.insertMarker();break}case x.CAPTION:case x.COL:case x.COLGROUP:case x.TBODY:case x.TFOOT:case x.THEAD:case x.TR:{e.openElements.hasInTableScope(x.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY,Ma(e,t));break}default:Lr(e,t)}}function C0(e,t){switch(t.tagID){case x.TR:{e.openElements.hasInTableScope(x.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY);break}case x.TABLE:{e.openElements.hasInTableScope(x.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY,bl(e,t));break}case x.TBODY:case x.TFOOT:case x.THEAD:{(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(x.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=U.IN_TABLE_BODY,bl(e,t));break}case x.BODY:case x.CAPTION:case x.COL:case x.COLGROUP:case x.HTML:case x.TD:case x.TH:break;default:Oi(e,t)}}function T3(e,t){const n=t.tagID;A0.has(n)?(e.openElements.hasInTableScope(x.TD)||e.openElements.hasInTableScope(x.TH))&&(e._closeTableCell(),Pa(e,t)):wt(e,t)}function w3(e,t){const n=t.tagID;switch(n){case x.TD:case x.TH:{e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=U.IN_ROW);break}case x.TABLE:case x.TBODY:case x.TFOOT:case x.THEAD:case x.TR:{e.openElements.hasInTableScope(n)&&(e._closeTableCell(),C0(e,t));break}case x.BODY:case x.CAPTION:case x.COL:case x.COLGROUP:case x.HTML:break;default:Ra(e,t)}}function _0(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.OPTION:{e.openElements.currentTagId===x.OPTION&&e.openElements.pop(),e._insertElement(t,le.HTML);break}case x.OPTGROUP:{e.openElements.currentTagId===x.OPTION&&e.openElements.pop(),e.openElements.currentTagId===x.OPTGROUP&&e.openElements.pop(),e._insertElement(t,le.HTML);break}case x.HR:{e.openElements.currentTagId===x.OPTION&&e.openElements.pop(),e.openElements.currentTagId===x.OPTGROUP&&e.openElements.pop(),e._appendElement(t,le.HTML),t.ackSelfClosing=!0;break}case x.INPUT:case x.KEYGEN:case x.TEXTAREA:case x.SELECT:{e.openElements.hasInSelectScope(x.SELECT)&&(e.openElements.popUntilTagNamePopped(x.SELECT),e._resetInsertionMode(),t.tagID!==x.SELECT&&e._processStartTag(t));break}case x.SCRIPT:case x.TEMPLATE:{en(e,t);break}}}function N0(e,t){switch(t.tagID){case x.OPTGROUP:{e.openElements.stackTop>0&&e.openElements.currentTagId===x.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===x.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===x.OPTGROUP&&e.openElements.pop();break}case x.OPTION:{e.openElements.currentTagId===x.OPTION&&e.openElements.pop();break}case x.SELECT:{e.openElements.hasInSelectScope(x.SELECT)&&(e.openElements.popUntilTagNamePopped(x.SELECT),e._resetInsertionMode());break}case x.TEMPLATE:{dr(e,t);break}}}function S3(e,t){const n=t.tagID;n===x.CAPTION||n===x.TABLE||n===x.TBODY||n===x.TFOOT||n===x.THEAD||n===x.TR||n===x.TD||n===x.TH?(e.openElements.popUntilTagNamePopped(x.SELECT),e._resetInsertionMode(),e._processStartTag(t)):_0(e,t)}function A3(e,t){const n=t.tagID;n===x.CAPTION||n===x.TABLE||n===x.TBODY||n===x.TFOOT||n===x.THEAD||n===x.TR||n===x.TD||n===x.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(x.SELECT),e._resetInsertionMode(),e.onEndTag(t)):N0(e,t)}function C3(e,t){switch(t.tagID){case x.BASE:case x.BASEFONT:case x.BGSOUND:case x.LINK:case x.META:case x.NOFRAMES:case x.SCRIPT:case x.STYLE:case x.TEMPLATE:case x.TITLE:{en(e,t);break}case x.CAPTION:case x.COLGROUP:case x.TBODY:case x.TFOOT:case x.THEAD:{e.tmplInsertionModeStack[0]=U.IN_TABLE,e.insertionMode=U.IN_TABLE,Lr(e,t);break}case x.COL:{e.tmplInsertionModeStack[0]=U.IN_COLUMN_GROUP,e.insertionMode=U.IN_COLUMN_GROUP,_u(e,t);break}case x.TR:{e.tmplInsertionModeStack[0]=U.IN_TABLE_BODY,e.insertionMode=U.IN_TABLE_BODY,Ma(e,t);break}case x.TD:case x.TH:{e.tmplInsertionModeStack[0]=U.IN_ROW,e.insertionMode=U.IN_ROW,Pa(e,t);break}default:e.tmplInsertionModeStack[0]=U.IN_BODY,e.insertionMode=U.IN_BODY,wt(e,t)}}function _3(e,t){t.tagID===x.TEMPLATE&&dr(e,t)}function I0(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(x.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):Cu(e,t)}function N3(e,t){t.tagID===x.HTML?wt(e,t):ra(e,t)}function R0(e,t){var n;if(t.tagID===x.HTML){if(e.fragmentContext||(e.insertionMode=U.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===x.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 ra(e,t)}function ra(e,t){e.insertionMode=U.IN_BODY,Ia(e,t)}function I3(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.FRAMESET:{e._insertElement(t,le.HTML);break}case x.FRAME:{e._appendElement(t,le.HTML),t.ackSelfClosing=!0;break}case x.NOFRAMES:{en(e,t);break}}}function R3(e,t){t.tagID===x.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==x.FRAMESET&&(e.insertionMode=U.AFTER_FRAMESET))}function M3(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.NOFRAMES:{en(e,t);break}}}function P3(e,t){t.tagID===x.HTML&&(e.insertionMode=U.AFTER_AFTER_FRAMESET)}function L3(e,t){t.tagID===x.HTML?wt(e,t):Os(e,t)}function Os(e,t){e.insertionMode=U.IN_BODY,Ia(e,t)}function D3(e,t){switch(t.tagID){case x.HTML:{wt(e,t);break}case x.NOFRAMES:{en(e,t);break}}}function O3(e,t){t.chars=ot,e._insertCharacters(t)}function F3(e,t){e._insertCharacters(t),e.framesetOk=!1}function M0(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==le.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function B3(e,t){if(JA(t))M0(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),r=e.treeAdapter.getNamespaceURI(n);r===le.MATHML?p0(t):r===le.SVG&&(eC(t),g0(t)),Su(t),t.selfClosing?e._appendElement(t,r):e._insertElement(t,r),t.ackSelfClosing=!0}}function j3(e,t){if(t.tagID===x.P||t.tagID===x.BR){M0(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)===le.HTML){e._endTagOutsideForeignContent(t);break}const s=e.treeAdapter.getTagName(r);if(s.toLowerCase()===t.tagName){t.tagName=s,e.openElements.shortenToLength(n);break}}}W.AREA,W.BASE,W.BASEFONT,W.BGSOUND,W.BR,W.COL,W.EMBED,W.FRAME,W.HR,W.IMG,W.INPUT,W.KEYGEN,W.LINK,W.META,W.PARAM,W.SOURCE,W.TRACK,W.WBR;const H3=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,U3=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),nh={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function P0(e,t){const n=Q3(e),r=Dp("type",{handlers:{root:z3,element:V3,text:q3,comment:D0,doctype:$3,raw:Y3},unknown:G3}),s={parser:n?new Jd(nh):Jd.getFragmentParser(void 0,nh),handle(o){r(o,s)},stitches:!1,options:t||{}};r(e,s),Ur(s,dn());const i=n?s.parser.document:s.parser.getFragment(),a=ZS(i,{file:s.options.file});return s.stitches&&Na(a,"comment",function(o,l,u){const c=o;if(c.value.stitch&&u&&l!==void 0){const h=u.children;return h[l]=c.value.stitch,l}}),a.type==="root"&&a.children.length===1&&a.children[0].type===e.type?a.children[0]:a}function L0(e,t){let n=-1;if(e)for(;++n<e.length;)t.handle(e[n])}function z3(e,t){L0(e.children,t)}function V3(e,t){K3(e,t),L0(e.children,t),X3(e,t)}function q3(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const n={type:He.CHARACTER,chars:e.value,location:Ki(e)};Ur(t,dn(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function $3(e,t){const n={type:He.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:Ki(e)};Ur(t,dn(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function W3(e,t){t.stitches=!0;const n=Z3(e);if("children"in e&&"children"in n){const r=P0({type:"root",children:e.children},t.options);n.children=r.children}D0({type:"comment",value:{stitch:n}},t)}function D0(e,t){const n=e.value,r={type:He.COMMENT,data:n,location:Ki(e)};Ur(t,dn(e)),t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken)}function Y3(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,O0(t,dn(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(H3,"&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 G3(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))W3(n,t);else{let r="";throw U3.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 Ur(e,t){O0(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=ct.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 O0(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 K3(e,t){const n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===ct.PLAINTEXT)return;Ur(t,dn(e));const r=t.parser.openElements.current;let s="namespaceURI"in r?r.namespaceURI:Xn.html;s===Xn.html&&n==="svg"&&(s=Xn.svg);const i=rA({...e,children:[]},{space:s===Xn.svg?"svg":"html"}),a={type:He.START_TAG,tagName:n,tagID:Hr(n),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in i?i.attrs:[],location:Ki(e)};t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=n}function X3(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&dA.includes(n)||t.parser.tokenizer.state===ct.PLAINTEXT)return;Ur(t,Ta(e));const r={type:He.END_TAG,tagName:n,tagID:Hr(n),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:Ki(e)};t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken),n===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===ct.RCDATA||t.parser.tokenizer.state===ct.RAWTEXT||t.parser.tokenizer.state===ct.SCRIPT_DATA)&&(t.parser.tokenizer.state=ct.DATA)}function Q3(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function Ki(e){const t=dn(e)||{line:void 0,column:void 0,offset:void 0},n=Ta(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 Z3(e){return"children"in e?lr({...e,children:[]}):lr(e)}function F0(e){return function(t,n){return P0(t,{...e,file:n})}}const qn=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],Ti={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...qn,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...qn],h2:[["className","sr-only"]],img:[...qn,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...qn,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...qn],table:[...qn],ul:[...qn,["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"]},Sn={}.hasOwnProperty;function J3(e,t){let n={type:"root",children:[]};const r={schema:t?{...Ti,...t}:Ti,stack:[]},s=B0(r,e);return s&&(Array.isArray(s)?s.length===1?n=s[0]:n.children=s:n=s),n}function B0(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return e_(e,n);case"doctype":return t_(e,n);case"element":return n_(e,n);case"root":return r_(e,n);case"text":return i_(e,n)}}}function e_(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 Xi(i,t),i}}function t_(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return Xi(n,t),n}}function n_(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const r=j0(e,t.children),s=s_(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&&Sn.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 Xi(a,t),a}function r_(e,t){const r={type:"root",children:j0(e,t.children)};return Xi(r,t),r}function i_(e,t){const r={type:"text",value:typeof t.value=="string"?t.value:""};return Xi(r,t),r}function j0(e,t){const n=[];if(Array.isArray(t)){const r=t;let s=-1;for(;++s<r.length;){const i=B0(e,r[s]);i&&(Array.isArray(i)?n.push(...i):n.push(i))}}return n}function s_(e,t){const n=e.stack[e.stack.length-1],r=e.schema.attributes,s=e.schema.required,i=r&&Sn.call(r,n)?r[n]:void 0,a=r&&Sn.call(r,"*")?r["*"]:void 0,o=t&&typeof t=="object"?t:{},l={};let u;for(u in o)if(Sn.call(o,u)){const c=o[u];let h=rh(e,ih(i,u),u,c);h==null&&(h=rh(e,ih(a,u),u,c)),h!=null&&(l[u]=h)}if(s&&Sn.call(s,n)){const c=s[n];for(u in c)Sn.call(c,u)&&!Sn.call(l,u)&&(l[u]=c[u])}return l}function rh(e,t,n,r){return t?Array.isArray(r)?a_(e,t,n,r):H0(e,t,n,r):void 0}function a_(e,t,n,r){let s=-1;const i=[];for(;++s<r.length;){const a=H0(e,t,n,r[s]);(typeof a=="number"||typeof a=="string")&&i.push(a)}return i}function H0(e,t,n,r){if(!(typeof r!="boolean"&&typeof r!="number"&&typeof r!="string")&&o_(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 o_(e,t,n){const r=e.schema.protocols&&Sn.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 Xi(e,t){const n=np(t);t.data&&(e.data=lr(t.data)),n&&(e.position=n)}function ih(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 U0(e){return function(t){return J3(t,e)}}var dm;const z0={...Ti,protocols:{...Ti.protocols,src:[...((dm=Ti.protocols)==null?void 0:dm.src)??["http","https","mailto"],"data"]}},l_={remarkPlugins:[t0],rehypePlugins:[F0,[U0,z0]]};let hi=null,sh=null;function u_(){return hi?Promise.resolve(hi):(sh??(sh=Promise.all([_e(()=>import("./index-DsNNOEb3.js"),__vite__mapDeps([3,1,2]),import.meta.url),_e(()=>import("./index-CXmOpaVd.js"),__vite__mapDeps([4,1,2]),import.meta.url)]).then(([{default:e},{default:t}])=>(hi={remarkPlugins:[t0,e],rehypePlugins:[F0,[U0,z0],t]},hi))),sh)}function c_(e){return e.includes("$")||e.includes("\\(")||e.includes("\\[")}function V0(e){const[t,n]=k.useState(hi),r=c_(e??"");return k.useEffect(()=>{if(!r||t)return;let s=!0;return u_().then(i=>{s&&n(i)}),()=>{s=!1}},[r,t]),t??l_}function d_({retry:e}){const t=$e();return p.jsxs("div",{className:"text-body text-warning p-4 flex items-start gap-2",children:[p.jsx(su,{className:"w-4 h-4 shrink-0 mt-0.5"}),p.jsxs("span",{children:[t("error.renderFailed")," ",p.jsx("button",{className:"underline ml-1",onClick:e,children:t("error.retry")})]})]})}class h_ extends k.Component{constructor(){super(...arguments);qa(this,"state",{error:null});qa(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):p.jsx(d_,{error:this.state.error,retry:this.retry}):this.props.children}}const rr=new Set(["。","!","?","!","?",";",";","…"]),f_=new Set([",",",","、",":",":"," "," "]),m_=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}\u{2B00}-\u{2BFF}]/u;function ia(e){return e!=null&&m_.test(String.fromCodePoint(e))}const p_=/(?:[\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,Cr=new Set(["”",'"',"」","』","》",")","】","])".slice(0,1)]);function g_(e){let t=e;return t=t.replace(/\r\n?/g,`
538
538
  `),t=t.replace(/(?:^|\n)[ \t]*(?:```|~~~)[^\n]*\n[\s\S]*?(?:\n[ \t]*(?:```|~~~)[^\n]*|\n?$)/g,`
539
539
  `),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,`
540
540
 
@@ -543,8 +543,8 @@ Based on my performance, decide what comes next: explain why I got questions wro
543
543
  `?!0:p_.test(t)}function y_(e,t,n,r=400){const s=e.length,i=o=>{if(o<0||o>=s)return-1;const l=e[o];if(l===`
544
544
  `)return o+1;if(rr.has(l)){let c=o+1;for(;c<s&&(rr.has(e[c])||Cr.has(e[c]));)c++;return c}if(l==="."){const c=o>0?e[o-1]:"",h=o+1<s?e[o+1]:"";if((h===""||/\s/.test(h))&&!/\d/.test(c)){let f=o+1;for(;f<s&&(Cr.has(e[f])||rr.has(e[f]));)f++;return f}return-1}const u=e.codePointAt(o);if(ia(u)){let c=o+(u>65535?2:1);for(;c<s;){const h=e.codePointAt(c),f=h>65535?2:1;if(h===65039||h===8205||h>=127995&&h<=127999||ia(h)){c+=f;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($0(e.slice(0,Math.min(n,s)))){let o=Math.min(n,s);for(;o<s&&Cr.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 ur(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")||l.closest("[data-md-diagram]")||!(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 W0(e,t){const n=ah(e.startContainer,e.startOffset,t,"start"),r=ah(e.endContainer,e.endOffset,t,"end");return n==null||r==null||r<=n?null:{start:n,end:r}}function ah(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=Y0(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=G0(o[u],n);if(c!=null)return c}const l=n.nodes[0];return l?l.start:null}}return null}function Y0(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=Y0(n,t);if(r!=null)return r}return null}function G0(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=G0(r,t);s!=null&&(n=s)}return n}return null}function Fi(e,t,n){var o,l,u,c;if(n<=t)return null;let r=null,s=0,i=null,a=0;for(const h of e.nodes)if(!r&&t>=h.start&&t<h.end&&(r=h.node,s=t-h.start),!i&&n>h.start&&n<=h.end&&(i=h.node,a=n-h.start),r&&i)break;if(!r&&e.nodes.length>0){const h=e.nodes[e.nodes.length-1];r=h.node,s=((o=h.node.textContent)==null?void 0:o.length)??0}if(!i&&e.nodes.length>0){const h=e.nodes[e.nodes.length-1];i=h.node,a=((l=h.node.textContent)==null?void 0:l.length)??0}if(!r||!i)return null;try{const h=document.createRange();return h.setStart(r,Math.min(s,((u=r.textContent)==null?void 0:u.length)??0)),h.setEnd(i,Math.min(a,((c=i.textContent)==null?void 0:c.length)??0)),h}catch{return null}}function K0(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=ur(e),s=[];for(const i of t){const a=Nu(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=Fi(r,i.start,i.end);if(!a)continue;const o=E_(a,i.noteId);o&&n.set(i.noteId,o)}return n}const oh="cp-user-note",lh="cp-user-note-flash";function wi(){return typeof Highlight<"u"&&!!CSS.highlights}const ln=new Map,xl=new WeakMap;function X0(){var t,n;const e=CSS;for(const[r,s]of ln)s.startContainer.isConnected||ln.delete(r);try{ln.size===0?(t=e.highlights)==null||t.delete(oh):(n=e.highlights)==null||n.set(oh,new Highlight(...ln.values()))}catch{}}function Q0(e,t){const n=new Map,r=xl.get(e);if(r)for(const i of r)ln.delete(i);const s=ur(e);for(const i of t){const a=Nu(s.text,i.text,i.surrounding);if(a<0)continue;const o=Fi(s,a,a+i.text.length);o&&(n.set(i.noteId,o),ln.set(i.noteId,o))}return xl.set(e,new Set(n.keys())),X0(),n}function Z0(e){const t=ln.get(e)??null;return t&&!t.startContainer.isConnected?(ln.delete(e),X0(),null):t}function uh(e){return ln.has(e)?!0:!!document.querySelector(`mark[data-note-id="${CSS.escape(e)}"]`)}let Ts=null;function J0(e){var n,r,s;(r=(n=e.startContainer.parentElement)==null?void 0:n.scrollIntoView)==null||r.call(n,{behavior:"smooth",block:"center"});const t=CSS;try{(s=t.highlights)==null||s.set(lh,new Highlight(e)),Ts&&clearTimeout(Ts),Ts=setTimeout(()=>{var i;(i=t.highlights)==null||i.delete(lh),Ts=null},1500)}catch{}}function v_(e){const t=xl.get(e);if(!t||t.size===0)return null;let n=null;for(const r of t){const s=ln.get(r);if(!(!s||!s.startContainer.isConnected)){if(!n){n=s;continue}try{s.compareBoundaryPoints(Range.START_TO_START,n)>0&&(n=s)}catch{}}}return n}function Nu(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 E_(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,eg(e,r)}function eg(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 tg="cp-reading-mark",ng="cp-reading";function ir(e){var n;const t=CSS;try{(n=t.highlights)==null||n.delete(ng)}catch{}Iu=null,Ru=null,e.querySelectorAll(`.${tg}`).forEach(r=>{const s=r.parentNode;if(s){for(;r.firstChild;)s.insertBefore(r.firstChild,r);s.removeChild(r)}}),e.normalize()}const k_=/[0-9A-Za-z\u00C0-\u024F\u0370-\u03FF\u0400-\u04FF\u4E00-\u9FFF\u3040-\u30FF\uAC00-\uD7AF]/,T_=`「『(([【<《"'“‘`,w_=`。』」))]】>》"'”’!!??…,,、;;::`;function rg(e){const t=e.codePointAt(0);let n=e;return t>=65281&&t<=65374&&(n=String.fromCharCode(t-65248)),k_.test(n)?n.toLowerCase():null}function S_(e){let t="";const n=[];for(let r=0;r<e.length;r++){const s=rg(e[r]);s!==null&&(t+=s,n.push(r))}return{canon:t,map:n}}function A_(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 ch(e,t,n){const{canon:r,map:s}=S_(e),i=t.trim().split(/\s+/).map(m=>[...m].map(rg).filter(Boolean).join("")).filter(m=>m.length>0);if(i.length===0||r.length===0){const m=t.trim();if(!m)return null;const g=e.indexOf(m,Math.max(0,n));return g>=0?{start:g,end:g+m.length}:null}const a=A_(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 g of i){const b=r.indexOf(g,m);if(b<0)return null;l<0&&(l=b),u=b+g.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 h=s[l],f=s[u]+1;const d=n>0?n:0;for(let m=0;m<3&&h-1>=d&&T_.includes(e[h-1]);m++)h--;for(let m=0;m<4&&f<e.length&&w_.includes(e[f]);m++)f++;return{start:h,end:f}}const yl=new WeakMap;function ig(e){yl.delete(e)}function sg(e,t,n){ir(e);const r=t.trim();if(!r)return null;const s=ur(e,n==null?void 0:n.within,{includeMarks:!0}),i=yl.get(e)??0;let a=ch(s.text,r,i);if(!a&&i>0&&(a=ch(s.text,r,0)),!a)return null;yl.set(e,a.end);const o=Fi(s,a.start,a.end);if(!o)return null;const l=y_(s.text,a.start,a.end);Ru=Fi(s,l.start,l.end);const u=CSS;if(typeof Highlight<"u"&&u.highlights)try{return u.highlights.set(ng,new Highlight(o)),Iu=o,o}catch{}const c=document.createElement("span");return c.className=tg,eg(o,c)?o:null}let Iu=null;function C_(){return Iu}let Ru=null;function __(){return Ru}function ag(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 sn=null,_r=null,Fs=null;function dh(e){if(!e){sn=null,_r=null,Fs=null;return}if(e instanceof Range)sn=e,_r=e.toString(),Fs=e.startContainer.parentElement;else{const t=document.createRange();t.selectNodeContents(e),sn=t,_r=e.textContent,Fs=e}}function N_(){const e=Fs;if(sn&&!sn.startContainer.isConnected&&e&&_r)try{const n=ur(e),r=Nu(n.text,_r);if(r>=0){const s=Fi(n,r,r+_r.length);s&&(sn=s)}}catch{}if(!sn||!sn.startContainer.isConnected)return null;const t=sn.startContainer.parentElement??null;return{range:sn,host:(t==null?void 0:t.closest('[data-testid="notebook-panel"], [data-testid="chat-stream"]'))??null,block:(t==null?void 0:t.closest("p, li, h1, h2, h3, h4, h5, h6, blockquote, pre, td, th"))??null}}function og(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 lg(e){const t=[];let n=!1;for(const r of e.split(`
545
545
  `)){if(/^[ \t]*(?:```|~~~)/.test(r)){t.push(r),n=!n;continue}t.push(n?r:r.replace(/\\\[|\\\]|\\\(|\\\)/g,s=>s==="\\["||s==="\\]"?"$$":"$"))}return t.join(`
546
- `)}function ug(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 hh="lookatstudy-tts-settings-changed";function fh(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 mh(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=fh(e.filter(i=>i.default));return r.length>0&&I_(r[0].lang)?r[0]:fh(e)[0]??null}function I_(e){return e.toLowerCase().startsWith("zh")}function BP(e){return`${e.name} · ${e.lang}`}const R_=[["\\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","点点点"]],M_={alpha:"阿尔法",beta:"贝塔",gamma:"伽马",delta:"德尔塔",epsilon:"艾普西隆",zeta:"泽塔",eta:"伊塔",theta:"西塔",iota:"约塔",kappa:"卡帕",lambda:"拉姆达",mu:"缪",nu:"纽",xi:"克西",pi:"派",rho:"柔",sigma:"西格马",tau:"陶",phi:"斐",chi:"凯",psi:"普西",omega:"欧米伽"};function P_(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 ai(e,t){const n=P_(e,t);return n||{body:e[t]??"",end:t+1}}function L_(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=ai(r,s+5),a=ai(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=ai(r,s+6),a=ai(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=ai(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 R_)t=t.split(n).join(` ${r} `);return t=t.replace(/\\([A-Za-z]+)\b/g,(n,r)=>` ${M_[r]??r} `),t=t.replace(/[{}]/g," "),t.replace(/\s+/g," ").trim()}function D_(e){return e.replace(/\$\$([^$]+)\$\$|\$([^$]+)\$/g,(t,n,r)=>{const s=L_(n??r??"");return s?` ${s} `:""})}const ph=new WeakMap;let cg=null;function wo(e){cg=e}function O_(){return cg}const dg=1024;function hg(e){let t=ph.get(e);return t||(t=e.createAnalyser(),t.fftSize=dg,t.smoothingTimeConstant=.55,ph.set(e,t)),t}function F_(e,t){try{const n=hg(e);t.connect(n),n.connect(e.destination)}catch{try{t.connect(e.destination)}catch{}}}const Nr=1024,gh=512,B_=3500,j_=7500,H_=.3,U_=.16,z_=1400,V_=2800,ws=70,fg=new Float64Array(Nr);for(let e=0;e<Nr;e++)fg[e]=.5*(1-Math.cos(2*Math.PI*e/(Nr-1)));function q_(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 h=0;h<o;h++){const f=e[l+h],d=t[l+h],m=e[l+h+o],g=t[l+h+o],b=m*u-g*c,y=m*c+g*u;e[l+h]=f+b,t[l+h]=d+y,e[l+h+o]=f-b,t[l+h+o]=d-y;const w=u*i-c*a;c=u*a+c*i,u=w}}}}function $_(e,t){const n=e.length;let r=0;const s=new Float64Array(n),i=new Float64Array(n);for(let g=0;g<n;g++){const b=e[g];r+=Math.abs(b),s[g]=b*fg[g]}q_(s,i);const a=n>>1,o=t/n,l=new Float64Array(a);let u=0,c=0,h=0,f=0,d=0,m=0;for(let g=0;g<a;g++){const b=g*o;if(b>=t/2-o)break;const y=Math.hypot(s[g],i[g])/a;l[g]=y,u+=y,b>=B_&&b<j_&&(c+=y),b>=Sc.lo&&b<Sc.hi?(h+=y,f+=y*b):b>=Ac.lo&&b<Ac.hi&&(d+=y,m+=y*b)}return{level:n>0?Math.min(1,r/n/.22):0,f1:h>0?f/h:400,f2:d>0?m/d:800,hfRatio:u>0?c/u:0}}function W_(e,t){return e.level<=Ub?"closed":e.hfRatio>=H_?"SS":e.hfRatio>=U_&&e.level<.45?"FV":t==="closed"&&e.f2>=z_&&e.f2<=V_?"L":zb(e.f1,e.f2,e.level)}function Y_(e,t){const n=[],r=(c,h,f,d)=>{if(h<=0)return;const m=n[n.length-1];if(m&&m.viseme===f&&Math.abs(m.t+m.dur-c)<1e-9){m.dur+=h,m.level=Math.max(m.level,d);return}n.push({t:c,dur:h,viseme:f,level:d})};if(e.length<Nr)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=gh/t;for(let c=0;c+Nr<=e.length;c+=gh){const h=e.subarray(c,c+Nr),f=$_(h,t),d=W_(f,s);r(c/t,i,d,f.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<=ws/1e3)l.viseme="closed";else{const c=Math.min(l.dur*.5,ws/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,ws/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 h=n[c];if(h.viseme!=="closed"&&h.dur<ws/1e3){const f=n[c-1];f.dur+=h.dur,n.splice(c,1)}}return{cues:n,duration:a}}function G_(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 K_(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 mg(){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),[h,f]=k.useState(!1),d=k.useRef(null),m=k.useRef(new Map),g=k.useRef(new Map),b=k.useRef(0),y=k.useRef(!1),w=k.useRef([]),E=k.useRef(0),S=k.useRef(0),v=k.useRef(!1),T=k.useRef(null),_=k.useRef(0),A=k.useRef(null),N=k.useRef(null),C=k.useRef(null);C.current||(C.current=()=>{const z=N.current,Y=typeof window<"u"?window.speechSynthesis:void 0;if(!z||z.stopped||!Y)return;if(z.i>=z.sentences.length){N.current=null,T.current=null,t(null),r(null),i(null);return}const L=z.i,q=D_(z.sentences[L]),K=new SpeechSynthesisUtterance(q);z.voice&&(K.voice=z.voice,K.lang=z.voice.lang),K.rate=z.rate,K.onstart=()=>{!N.current||N.current.stopped||i({index:L,total:z.sentences.length,text:q})};const M=()=>{var G;!N.current||N.current.stopped||(N.current.i+=1,(G=C.current)==null||G.call(C))};K.onend=M,K.onerror=M,Y.speak(K)});const D=k.useCallback((z,Y)=>{var M;if(typeof window>"u"||!("speechSynthesis"in window)){c("engine-unavailable");return}const L=b_(Y);if(L.length===0){c("empty-text");return}l.current=L.slice(),o(L.slice()),_.current=L.length,r({index:0,total:L.length,text:L[0]??""});const q=A.current,K=mh(window.speechSynthesis.getVoices(),(q==null?void 0:q.systemVoice)??null);N.current={messageId:z,sentences:L,i:0,stopped:!1,voice:K,rate:bh(q==null?void 0:q.speed)},window.speechSynthesis.cancel(),(M=C.current)==null||M.call(C)},[]),P=()=>{if(!d.current){const z=window.AudioContext??window.webkitAudioContext;d.current=new z}return d.current.resume(),d.current},O=k.useCallback(()=>{v.current&&S.current>=E.current&&!y.current&&(T.current=null,t(null),r(null),i(null))},[]),I=k.useCallback(()=>{const z=d.current;if(!z||y.current)return;const Y=m.current.get(b.current);if(!Y){O();return}const L=b.current;m.current.delete(L),y.current=!0,i({index:L,total:_.current,text:l.current[L]??""}),b.current+=1;const q=z.createBufferSource();q.buffer=Y,F_(z,q),wo({ctx:z,timeline:g.current.get(L)??null,startedAtCtxTime:z.currentTime,analyser:hg(z)}),q.onended=()=>{S.current+=1,y.current=!1,wo(null),I()},w.current.push(q),q.start()},[O]),R=k.useCallback(()=>{for(const z of w.current)try{z.onended=null,z.stop()}catch{}w.current=[],m.current.clear(),g.current.clear(),wo(null),y.current=!1,E.current=0,S.current=0,v.current=!1,T.current=null,b.current=0,_.current=0,l.current=[],o([]),t(null),r(null),i(null),N.current&&(N.current.stopped=!0,N.current=null),typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()},[]),B=k.useCallback(()=>{R(),window.api.ttsStop().catch(()=>{})},[R]),V=k.useCallback((z,Y)=>{var L;if(T.current===z){B();return}if(R(),window.dispatchEvent(new CustomEvent("lookatstudy-speech-start",{detail:z})),c(null),T.current=z,E.current=0,S.current=0,v.current=!1,b.current=0,_.current=0,t(z),r({index:0,total:0,text:""}),((L=A.current)==null?void 0:L.engine)==="system"){D(z,Y);return}P(),window.api.ttsSpeak(Y,z).then(q=>{if(q.ok){q.firstUse&&f(!0);return}R(),q.reason!=="empty-text"&&c(q.reason)}).catch(()=>R())},[D,B,R]);return k.useEffect(()=>{const z=window.api.on("speech:ttsAudio",q=>{if(q.messageId!==T.current)return;const K=P();E.current+=1,_.current=q.sentenceTotal,r({index:q.sentenceIndex,total:q.sentenceTotal,text:q.sentence??""}),q.sentence!=null&&(l.current[q.sentenceIndex]=q.sentence,o(l.current.slice())),K.decodeAudioData(q.wavBytes).then(M=>{var G;if(q.messageId===T.current){m.current.set(q.sentenceIndex,M);try{const ae=(G=q.visemeCues)!=null&&G.length?G_(q.visemeCues):Y_(X_(M),M.sampleRate);ae&&g.current.set(q.sentenceIndex,ae)}catch{}I()}},()=>{q.messageId===T.current&&(E.current-=1,I())})}),Y=window.api.on("speech:ttsDone",q=>{q.messageId===T.current&&(v.current=!0,O())}),L=window.api.on("speech:ttsError",()=>R());return()=>{z(),Y(),L()}},[O,I,R]),k.useEffect(()=>R,[R]),k.useEffect(()=>{const z=Y=>{const L=Y.detail;T.current&&L!==T.current&&R()};return window.addEventListener("lookatstudy-speech-start",z),()=>window.removeEventListener("lookatstudy-speech-start",z)},[R]),k.useEffect(()=>{let z=!0;const Y=()=>{Promise.all([window.api.getSetting("tts_engine"),window.api.getSetting("tts_system_voice"),window.api.getSetting("tts_speed")]).then(([L,q,K])=>{z&&(A.current={engine:(L??"").trim(),systemVoice:q??null,speed:bh(K)})}).catch(()=>{})};return Y(),window.addEventListener(hh,Y),()=>{z=!1,window.removeEventListener(hh,Y)}},[]),k.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const z=()=>{var L;const Y=N.current;!Y||Y.voice||(Y.voice=mh(window.speechSynthesis.getVoices(),((L=A.current)==null?void 0:L.systemVoice)??null))};return window.speechSynthesis.addEventListener("voiceschanged",z),()=>window.speechSynthesis.removeEventListener("voiceschanged",z)},[]),k.useEffect(()=>{Vb(e!==null)},[e]),{speakingMessageId:e,speakingSentence:n,playingSentence:s,streamTexts:a,failReason:u,clearFailReason:()=>c(null),onlineNotice:h,clearOnlineNotice:()=>f(!1),speak:V,stop:B}}function X_(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 bh(e){const t=typeof e=="number"?e:Number.parseFloat(e??"");return Number.isFinite(t)?Math.min(2,Math.max(.5,t)):1}const pg=k.createContext(null);let Q_=0;const Z_={default:4e3,success:4e3,info:4e3,warning:5e3,error:6e3},J_={default:null,success:p.jsx(nu,{className:"w-4 h-4 text-brand shrink-0"}),error:p.jsx(_x,{className:"w-4 h-4 text-warning shrink-0"}),warning:p.jsx(su,{className:"w-4 h-4 text-review shrink-0"}),info:p.jsx(jx,{className:"w-4 h-4 text-accent shrink-0"})};function eN({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=++Q_,u=(o==null?void 0:o.severity)??"default",c=(o==null?void 0:o.duration)??Z_[u],h={id:l,message:a,action:o==null?void 0:o.action,duration:c,severity:u,exiting:!1};n(f=>[...f,h]),window.setTimeout(()=>s(l),c)},[s]);return p.jsxs(pg.Provider,{value:{show:i},children:[e,p.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=>p.jsx(tN,{item:a,onAction:()=>{a.action.onClick(),s(a.id)},onDismiss:()=>s(a.id),onExitDone:()=>r(a.id)},a.id))})]})}function tN({item:e,onAction:t,onDismiss:n,onExitDone:r}){const s=$e(),i=J_[e.severity];return p.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,p.jsx("span",{className:"flex-1",children:e.message}),e.action&&p.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}),p.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:p.jsx(_n,{className:"w-3.5 h-3.5"})})]})}function Mu(){const e=k.useContext(pg);return e||{show:()=>{}}}const gg={typescript:()=>_e(()=>import("./typescript-BPQ3VLAy.js"),[],import.meta.url),tsx:()=>_e(()=>import("./tsx-COt5Ahok.js"),[],import.meta.url),javascript:()=>_e(()=>import("./javascript-wDzz0qaB.js"),[],import.meta.url),jsx:()=>_e(()=>import("./jsx-g9-lgVsj.js"),[],import.meta.url),python:()=>_e(()=>import("./python-B6aJPvgy.js"),[],import.meta.url),go:()=>_e(()=>import("./go-C27-OAKa.js"),[],import.meta.url),rust:()=>_e(()=>import("./rust-B1yitclQ.js"),[],import.meta.url),java:()=>_e(()=>import("./java-CylS5w8V.js"),[],import.meta.url),c:()=>_e(()=>import("./c-BIGW1oBm.js"),[],import.meta.url),cpp:()=>_e(()=>import("./cpp-DddhVWhK.js"),__vite__mapDeps([5,6]),import.meta.url),csharp:()=>_e(()=>import("./csharp-DSvCPggb.js"),[],import.meta.url),ruby:()=>_e(()=>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:()=>_e(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([21,8,9,10,11,12,13,22]),import.meta.url),swift:()=>_e(()=>import("./swift-C2oV4EkX.js"),[],import.meta.url),kotlin:()=>_e(()=>import("./kotlin-BdnUsdx6.js"),[],import.meta.url),lua:()=>_e(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([19,6]),import.meta.url),r:()=>_e(()=>import("./r-Cf5RLm7j.js"),[],import.meta.url),shellscript:()=>_e(()=>import("./shellscript-Yzrsuije.js"),[],import.meta.url),sql:()=>_e(()=>import("./sql-CRqJ_cUM.js"),[],import.meta.url),html:()=>_e(()=>import("./html-pp8916En.js"),__vite__mapDeps([8,9,10]),import.meta.url),css:()=>_e(()=>import("./css-CLj8gQPS.js"),[],import.meta.url),scss:()=>_e(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([23,10]),import.meta.url),xml:()=>_e(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([11,12]),import.meta.url),json:()=>_e(()=>import("./json-Cp-IABpG.js"),[],import.meta.url),yaml:()=>_e(()=>import("./yaml-Buea-lGh.js"),[],import.meta.url),toml:()=>_e(()=>import("./toml-vGWfd6FD.js"),[],import.meta.url),ini:()=>_e(()=>import("./ini-BEwlwnbL.js"),[],import.meta.url),markdown:()=>_e(()=>import("./markdown-Cvjx9yec.js"),[],import.meta.url),dockerfile:()=>_e(()=>import("./dockerfile-BcOcwvcX.js"),[],import.meta.url),makefile:()=>_e(()=>import("./makefile-CHLpvVh8.js"),[],import.meta.url),diff:()=>_e(()=>import("./diff-D97Zzqfu.js"),[],import.meta.url),graphql:()=>_e(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([14,9,15,16,17]),import.meta.url),latex:()=>_e(()=>import("./latex-B2nUCzCX.js"),__vite__mapDeps([24,25]),import.meta.url),vue:()=>_e(()=>import("./vue-CHlpWS_5.js"),__vite__mapDeps([26,10,9,15,22,8]),import.meta.url)},xh={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 nN(e){const t=e.trim().toLowerCase();return t?t in xh?xh[t]||null:t in gg?t:null:null}let oi=null;const yh=new Set;function Pu(){return oi||(oi=(async()=>{const[e,t,n,r]=await Promise.all([_e(()=>import("./core-C69ArKBS.js"),__vite__mapDeps([27,1,2]),import.meta.url),_e(()=>import("./engine-javascript-DBd1bXLz.js"),[],import.meta.url),_e(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url),_e(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url)]);return e.createHighlighterCore({themes:[n.default,r.default],langs:[],engine:t.createJavaScriptRegexEngine({forgiving:!0})})})(),oi.catch(()=>{oi=null})),oi}async function bg(e){const t=nN(e);if(!t)return null;if(yh.has(t))return t;const n=gg[t];if(!n)return null;const r=await Pu(),s=await n();return await r.loadLanguage(s),yh.add(t),t}async function rN(e,t){try{const n=await bg(t);return n?(await Pu()).codeToHtml(e,{lang:n,themes:{light:"github-light",dark:"github-dark"},defaultColor:"dark"}):null}catch{return null}}const iN=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");async function jP(e,t){try{const n=await bg(t);return n?(await Pu()).codeToTokens(e,{lang:n,theme:"github-dark"}).tokens.map(i=>i.map(a=>`<span style="color:${a.color}">${iN(a.content)}</span>`).join("")):null}catch{return null}}function sN(e,t){return e==="mermaid"&&t.trim().length>0}function aN(e){const t=e.trimStart().slice(0,40).toLowerCase();return t.startsWith("sequencediagram")?"sequence":t.startsWith("statediagram")?"state":"flowchart"}const oN=k.lazy(()=>_e(()=>import("./MermaidArtifact-BVmEpDZk.js").then(e=>e.a),__vite__mapDeps([28,1,2,29]),import.meta.url).then(e=>({default:e.MermaidArtifact})));function lN(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 xg({children:e,...t}){const n=$e(),[r,s]=k.useState(!1),[i,a]=k.useState(null),{lang:o,text:l}=lN(e),u=sN(o,l);k.useEffect(()=>{let h=!0;if(!(!l||u))return rN(l.replace(/\n$/,""),o).then(f=>{h&&f&&a(f)}),()=>{h=!1}},[l,u]);const c=()=>{var h;(h=navigator.clipboard)==null||h.writeText(l).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})};return u?p.jsx("div",{className:"my-3","data-md-diagram":"",children:p.jsx(k.Suspense,{fallback:p.jsx("div",{className:"surface-card min-h-[120px]"}),children:p.jsx(oN,{data:{artifactType:"diagram",title:n("artifact.mermaid.inlineTitle"),diagramType:aN(l),mermaid:l}})})}):p.jsxs("div",{className:"relative group my-3","data-testid":"md-codeblock",children:[p.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:[p.jsx("span",{className:"text-caption font-mono text-ink-faint uppercase tracking-wider",children:o||"code"}),p.jsx("button",{onClick:c,"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?p.jsxs(p.Fragment,{children:[p.jsx(xn,{className:"w-3 h-3 inline"}),n("chat.copied")]}):p.jsxs(p.Fragment,{children:[p.jsx(Rx,{className:"w-3 h-3 inline"}),n("chat.copy")]})})]}),i?p.jsx("div",{className:"md-shiki","data-testid":"md-shiki",dangerouslySetInnerHTML:{__html:i}}):p.jsx("pre",{...t,className:"!mt-0 !rounded-t-none !border-t-0",children:e})]})}const yg=k.lazy(()=>_e(()=>import("./index-CmgjThXN.js"),__vite__mapDeps([30,1,2,28,29,31]),import.meta.url).then(e=>({default:e.ArtifactRenderer}))),uN=k.lazy(()=>_e(()=>import("./CanvasStage-D4hAqHX5.js").then(e=>e.a),__vite__mapDeps([29,1,2]),import.meta.url).then(e=>({default:e.CanvasStage}))),cN={concept_map:_m,quiz:km,compare_table:sy,diagram:Lx,code_walkthrough:Ix},dN=new Set(["concept_map","quiz","compare_table","diagram","code_walkthrough"]);function hN(e,t){return dN.has(t)?e(`artifact.type.${t}`):e("artifact.type.unknown")}function fN({selectedNode:e,items:t,loading:n,forceTab:r,canvasArtifact:s,onUserTabChange:i,onRemove:a,onTogglePin:o,onRecordQuizResult:l,onSaveContentNote:u,onUpdateNoteComment:c,onJumpToSource:h,onQuoteToChat:f,locale:d}){var v;const m=$e(),[g,b]=k.useState("content"),y=r??g,w=T=>{b(T),i==null||i()},E=e?t.filter(T=>T.nodeId===e.id):[],S=k.useRef(null);return k.useEffect(()=>{var T;(T=S.current)==null||T.scrollTo({top:0})},[e==null?void 0:e.id]),p.jsxs("div",{className:"relative h-full flex flex-col bg-surface-2","data-testid":"notebook-panel",children:[p.jsx("div",{className:"px-3 pt-3 pb-1 shrink-0","data-testid":"notebook-tabs",children:p.jsxs("div",{className:"flex p-1 rounded-lg gap-1 bg-ink/[0.08]",role:"tablist","aria-label":"Notebook",children:[p.jsx(_o,{label:m("notebook.tab.explain"),icon:Jt,active:y==="content",onClick:()=>w("content"),testid:"tab-content"}),p.jsx(_o,{label:m("notebook.tab.notes"),icon:Vx,active:y==="notes",onClick:()=>w("notes"),testid:"tab-notes",badge:E.length>0?String(E.length):void 0}),p.jsx(_o,{label:m("notebook.tab.board"),icon:Wa,active:y==="board",onClick:()=>w("board"),testid:"tab-board"})]})}),p.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 animate-tab-slide",ref:S,role:"tabpanel",children:y==="board"?p.jsx("div",{className:"h-full flex flex-col","data-testid":"board-tab-content",children:s?p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"px-4 pt-3 pb-2 shrink-0 flex items-center gap-2 min-w-0",children:[p.jsx(Wa,{className:"w-4 h-4 text-ink-muted shrink-0"}),p.jsx("span",{className:"text-label font-bold text-ink truncate",children:((v=s.output)==null?void 0:v.title)??s.toolName})]}),p.jsx("div",{className:"flex-1 min-h-0 px-2 pb-2",children:p.jsx("div",{className:"h-full rounded-xl overflow-hidden bg-surface-0/60 border border-[var(--border-faint)]",children:p.jsx(k.Suspense,{fallback:null,children:p.jsx(uN,{testid:"board-canvas-stage",children:p.jsx(yg,{data:s.output,variant:"canvas"})})})})})]}):p.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6",children:[p.jsx(Wa,{className:"w-10 h-10 mb-3 text-ink-muted opacity-30"}),p.jsx("div",{className:"text-body text-ink-muted max-w-sm leading-relaxed",children:m("notebook.board.empty")})]})}):p.jsx(p.Fragment,{children:p.jsx("div",{className:"mx-auto w-full max-w-[960px] min-h-full flex flex-col",children:y==="content"?p.jsx(mN,{selectedNode:e,contentNotes:E.filter(T=>T.artifactType==="user_note"&&T.sourceAnchor),onQuoteToChat:f,onSaveContentNote:u,locale:d}):p.jsx(pN,{items:E,loading:n,selectedNode:e,onRemove:a,onTogglePin:o,onRecordQuizResult:l,onUpdateNoteComment:c,onJumpToSource:h})})})},y)]})}function mN({selectedNode:e,contentNotes:t,onQuoteToChat:n,onSaveContentNote:r,locale:s}){const i=$e(),a=Mu(),o=mg();k.useEffect(()=>{if(o.failReason){const O=o.failReason==="engine-unavailable"?"chat.speech.engine_unavailable":o.failReason==="azure-key-missing"?"chat.speech.azure_key_missing":o.failReason==="azure-region-missing"?"chat.speech.azure_region_missing":o.failReason==="edge-failed"?"chat.speech.edge_failed":"chat.speech.model_missing";a.show(i(O),{severity:"warning"}),o.clearFailReason()}else o.onlineNotice&&(a.show(i("chat.speech.edge_disclosed"),{severity:"info"}),o.clearOnlineNotice())},[o.failReason,o.onlineNotice,a,i,o]);const l=k.useRef(o.stop);l.current=o.stop;const u=e?`content-${e.id}`:null;k.useEffect(()=>()=>{l.current()},[u]);const[c,h]=k.useState(null),f=V0(c??""),[d,m]=k.useState(!1),[g,b]=k.useState(!1),[y,w]=k.useState([]),[E,S]=k.useState(null),v=k.useRef(null),T=k.useRef(null),_=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches;k.useEffect(()=>{if(!e){h(null),b(!1);return}let O=!1;return m(!0),b(!1),se.getNodeContent(e.id,s??void 0).then(I=>{O||h(I)}).catch(()=>{O||(h(null),b(!0))}).finally(()=>{O||m(!1)}),()=>{O=!0}},[e==null?void 0:e.id,s]),k.useEffect(()=>{if(!e){w([]);return}let O=!1;return se.listAssetsByNode(e.id).then(I=>{O||w(I)}).catch(()=>{O||w([])}),()=>{O=!0}},[e==null?void 0:e.id]),k.useEffect(()=>{if(!c||!v.current)return;const O=[];for(const R of t)try{const B=JSON.parse(R.sourceAnchor);if(B.type==="content"){const V=JSON.parse(R.data).text??"";V&&O.push({noteId:R.id,text:V,surrounding:B.surroundingText})}}catch{}const I=setTimeout(()=>{T.current&&(wi()?Q0(T.current,O):K0(T.current,O))},80);return()=>clearTimeout(I)},[c,t]),k.useEffect(()=>{const O=I=>{var V;const R=I.detail;if(!R)return;if(wi()){const z=Z0(R);z&&J0(z);return}const B=(V=T.current)==null?void 0:V.querySelector(`mark[data-note-id="${R}"]`);B&&og(B)};return window.addEventListener("lookatstudy-jump-to-note",O),()=>window.removeEventListener("lookatstudy-jump-to-note",O)},[]);const A=o.speakingMessageId===u&&o.playingSentence!=null?o.playingSentence.index:null;k.useEffect(()=>{const O=T.current;if(!O)return;if(A==null){ir(O);return}const I=q0(o.streamTexts,A);if(!I)return;A===0&&ig(O);const R=setTimeout(()=>{const B=sg(O,I);B&&ag(B,O.closest(".overflow-y-auto"))},30);return()=>clearTimeout(R)},[A,o.streamTexts,u]),k.useEffect(()=>{A==null&&T.current&&ir(T.current)},[A]);const N=k.useRef(!1);N.current=A!=null,k.useEffect(()=>()=>{N.current&&ir(document.body)},[]);const C=k.useCallback(()=>{var ne;if(!n&&!r)return;const O=window.getSelection(),I=(O==null?void 0:O.toString().trim())??"";if(I.length<2||I.length>500){S(null);return}const R=O==null?void 0:O.getRangeAt(0);if(!R||!((ne=v.current)!=null&&ne.contains(R.commonAncestorContainer))){S(null);return}const B=R.getBoundingClientRect(),V=v.current.getBoundingClientRect(),z=T.current;let Y=null;if(z&&z.contains(R.commonAncestorContainer)){const X=ur(z);Y=W0(R,X)}const L=z?ur(z).text:I,q=Y?Y.start:L.indexOf(I),K=q>=0?L.slice(Math.max(0,q-30),q+I.length+30):I,M=R.getClientRects(),G=M.length?M[M.length-1]:B,ae=ug({left:B.left-V.left,top:B.top-V.top,right:B.right-V.left,bottom:B.bottom-V.top,width:B.width,height:B.height},V.width,n?_?190:150:_?140:100,{left:G.left-V.left,top:G.top-V.top,right:G.right-V.left,bottom:G.bottom-V.top,width:G.width,height:G.height},_);S({x:ae.left,y:ae.top,transform:ae.transform,text:I,surrounding:K,offsets:Y??void 0})},[n,r,_]);k.useEffect(()=>{const O=_?600:250;let I=null,R=null,B=!1;const V=()=>{var q;return(((q=window.getSelection())==null?void 0:q.toString().trim().length)??0)>=2},z=()=>{V()?(R&&(clearTimeout(R),R=null),S(q=>q&&null),I&&clearTimeout(I),I=setTimeout(()=>{I=null,!B&&V()&&C()},O)):R||(R=setTimeout(()=>S(q=>q&&null),250))},Y=q=>{var M;const K=q.target;(M=K==null?void 0:K.closest)!=null&&M.call(K,"[data-selection-popover]")||(B=!0)},L=()=>{B=!1,I&&(clearTimeout(I),I=null),!R&&V()&&C()};return document.addEventListener("selectionchange",z),window.addEventListener("pointerdown",Y,!0),window.addEventListener("pointerup",L,!0),window.addEventListener("pointercancel",L,!0),()=>{document.removeEventListener("selectionchange",z),window.removeEventListener("pointerdown",Y,!0),window.removeEventListener("pointerup",L,!0),window.removeEventListener("pointercancel",L,!0),I&&clearTimeout(I),R&&clearTimeout(R)}},[C]);const D=k.useCallback(()=>{var I;if(!E||!n)return;const O=E.text.length>200?E.text.slice(0,200)+"…":E.text;n(i("notebook.quote.template",{text:O})),S(null),(I=window.getSelection())==null||I.removeAllRanges()},[E,n,i]),P=k.useCallback(()=>{var I,R,B;if(!E||!r||!e)return;const O=E.text.length>200?E.text.slice(0,200)+"…":E.text;r(O,{type:"content",surroundingText:E.surrounding,startOffset:(I=E.offsets)==null?void 0:I.start,endOffset:(R=E.offsets)==null?void 0:R.end}),qb(),setTimeout(()=>{if(!T.current)return;if(wi()){const Y=v_(T.current);Y&&dh(Y);return}const V=T.current.querySelectorAll("mark.lookatstudy-underline"),z=V&&V.length>0?V[V.length-1]:null;z&&dh(z)},200),S(null),(B=window.getSelection())==null||B.removeAllRanges()},[E,r,e]);return e?p.jsxs("div",{className:"p-5 relative","data-testid":"node-content",ref:v,children:[!d&&!g&&c&&p.jsx("div",{className:"sticky top-0 z-20 flex justify-end gap-2 -mt-2 pointer-events-none",children:p.jsx("button",{onClick:()=>o.speak(u??"content",c),"data-tooltip":o.speakingMessageId===u?i("chat.speech.stop"):i("chat.speech.read_aloud_node"),"aria-label":o.speakingMessageId===u?i("chat.speech.stop"):i("chat.speech.read_aloud_node"),"data-testid":o.speakingMessageId===u?"node-content-speak-active":"node-content-speak",className:`pointer-events-auto shrink-0 rounded-full p-2 bg-surface-2 shadow-elevated transition-colors ${o.speakingMessageId===u?"text-brand animate-pulse":"text-ink-muted hover:text-ink-strong"}`,children:o.speakingMessageId===u?p.jsx(iu,{className:"w-4 h-4"}):p.jsx(Rm,{className:"w-4 h-4"})})}),p.jsx("div",{className:"text-caption font-bold text-brand uppercase tracking-wider mb-1",children:e.type==="section"?i("notebook.node_type.section"):e.type==="concept"?i("notebook.node_type.concept"):i("notebook.node_type.lesson")}),p.jsx("div",{className:"flex items-start justify-between gap-3 mb-4",children:p.jsx("h2",{className:"text-title font-extrabold text-ink-strong tracking-tight","data-testid":"node-content-title",children:e.title})}),d?p.jsxs("div",{className:"text-body text-ink-muted flex items-center gap-2",children:[p.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),i("notebook.content.loading")]}):g?p.jsxs("div",{className:"text-body text-warning",children:[i("notebook.content.load_failed"),p.jsx("button",{className:"underline ml-1",onClick:()=>{b(!1),m(!0),se.getNodeContent(e.id,s??void 0).then(h).catch(()=>b(!0)).finally(()=>m(!1))},children:i("notebook.content.retry")})]}):c?p.jsx(h_,{fallback:(O,I)=>p.jsxs("div",{className:"prose prose-sm max-w-[80ch] leading-relaxed [&_pre]:max-w-full [&_pre]:overflow-x-auto",children:[p.jsx("div",{className:"text-body text-warning mb-2",children:i("notebook.content.render_failed")}),p.jsxs("pre",{className:"text-caption text-ink-muted whitespace-pre-wrap break-words bg-surface-1 p-3 rounded",children:[c.slice(0,500),c.length>500?`
547
- `+i("notebook.content.truncated"):""]}),p.jsx("div",{className:"flex gap-2 mt-2",children:p.jsx("button",{className:"text-caption underline text-accent",onClick:I,children:i("notebook.content.retry_render")})})]}),children:p.jsx("div",{ref:T,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:p.jsx(Ip,{remarkPlugins:f.remarkPlugins,rehypePlugins:f.rehypePlugins,components:{pre({children:O,...I}){return p.jsx(xg,{...I,children:O})},a({children:O,...I}){return p.jsx("a",{...I,target:"_blank",rel:"noopener noreferrer",children:O})},img({src:O,alt:I,...R}){return p.jsx(gN,{src:O,alt:I,assets:y,...R})},table({children:O}){return p.jsx("div",{className:"overflow-x-auto my-4",children:p.jsx("table",{children:O})})}},children:lg(c)})})},`${e.id}-${s??"orig"}`):p.jsx("div",{className:"text-body text-ink-muted",children:i("notebook.content.empty")}),y.length>0&&p.jsxs("div",{className:"mt-6 pt-4 border-t border-[var(--border-faint)]",children:[p.jsxs("div",{className:"text-label font-bold text-ink-muted mb-2 flex items-center gap-1",children:[p.jsx(Fx,{className:"w-3.5 h-3.5"}),p.jsx("span",{children:i("notebook.images.heading",{n:y.length})})]}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:y.map(O=>p.jsx(bN,{asset:O},O.id))})]}),E&&p.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&&p.jsxs("button",{onClick:D,"data-testid":"quote-to-chat-btn","aria-label":i("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:[p.jsx(Sm,{className:"w-3 h-3"}),i("notebook.quote.ask")]}),p.jsxs("button",{onClick:P,"data-testid":"save-note-btn","aria-label":i("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:i("notebook.quote.save_note.title"),children:[p.jsx(Ri,{className:"w-3.5 h-3.5"}),i("notebook.quote.add_note")]})]}),e.sourcePath&&p.jsx("div",{className:"mt-6 pt-3 border-t border-[var(--border-faint)] text-label text-ink-muted",children:i("notebook.source.label",{path:e.sourcePath})}),p.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:[p.jsx(Em,{className:"w-3.5 h-3.5 shrink-0 mt-0.5 text-accent"}),p.jsx("span",{children:i("notebook.quote.hint")})]})]}):p.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6",children:[p.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),p.jsx("div",{className:"text-body text-ink-muted max-w-xs",children:i("notebook.empty.select_node")})]})}function pN({items:e,loading:t,selectedNode:n,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o}){const l=$e();if(!n)return p.jsx(vh,{message:l("notebook.empty.notes.title"),icon:"📓"});if(t)return p.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2 text-body text-ink-muted",children:[p.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(g=>["concept_map","compare_table","diagram","code_walkthrough"].includes(g.artifactType)),c=e.filter(g=>g.artifactType==="user_note"),h=e.filter(g=>g.artifactType==="quiz"),f=e.length,d=h.filter(g=>g.lastResult==="correct").length,m=h.filter(g=>g.lastResult==="wrong").length;return f===0?p.jsx(vh,{message:l("notebook.empty.no_notes_message"),icon:"🧩"}):p.jsxs("div",{className:"p-4 space-y-3","data-testid":"notes-list",children:[p.jsx(So,{title:l("notebook.zone.understand"),icon:p.jsx(_m,{className:"w-4 h-4"}),subtitle:l("notebook.zone.understand.subtitle"),count:u.length,testid:"zone-understand",defaultOpen:!1,children:u.length===0?p.jsx(Ao,{hint:l("notebook.zone.understand.empty_hint")}):u.map(g=>p.jsx(Co,{item:g,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o},g.id))}),p.jsx(So,{title:l("notebook.zone.note"),icon:p.jsx(Ri,{className:"w-4 h-4"}),subtitle:l("notebook.zone.note.subtitle"),count:c.length,testid:"zone-note",defaultOpen:!1,children:c.length===0?p.jsx(Ao,{hint:l("notebook.zone.note.empty_hint")}):c.map(g=>p.jsx(Co,{item:g,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o},g.id))}),p.jsx(So,{title:l("notebook.zone.practice"),icon:p.jsx(km,{className:"w-4 h-4"}),subtitle:h.length>0?l("notebook.zone.practice.subtitle_stats",{total:h.length,correct:d,wrong:m}):l("notebook.zone.practice.subtitle_empty"),count:h.length,testid:"zone-practice",defaultOpen:!1,children:h.length===0?p.jsx(Ao,{hint:l("notebook.zone.practice.empty_hint")}):h.map(g=>p.jsx(Co,{item:g,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o},g.id))})]})}function So({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]),p.jsxs("section",{className:"rounded-xl bg-surface-1 overflow-hidden","data-testid":s,children:[p.jsxs("button",{onClick:()=>l(h=>!h),"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:[p.jsx(pa,{className:`w-4 h-4 text-ink-muted transition-transform duration-200 ease-out-back ${o?"":"-rotate-90"}`}),p.jsx("span",{className:"text-body text-ink-strong flex items-center",children:t}),p.jsx("span",{className:"text-body font-bold text-ink",children:e}),p.jsx("span",{className:"text-caption font-bold px-1.5 py-0.5 rounded-full bg-brand/15 text-brand",children:r}),p.jsx("span",{className:"text-label text-ink-muted ml-auto truncate",children:n})]}),p.jsx("div",{className:"grid transition-all duration-200 ease-out-expo",style:{gridTemplateRows:o?"1fr":"0fr"},children:p.jsx("div",{className:"overflow-hidden",children:p.jsx("div",{className:"p-3 space-y-3",children:a})})})]})}function Ao({hint:e}){return p.jsx("div",{className:"text-center py-3 text-body text-ink-muted",children:e})}function Co({item:e,onRemove:t,onTogglePin:n,onRecordQuizResult:r,onUpdateNoteComment:s,onJumpToSource:i}){const a=$e(),[o,l]=k.useState(!1),[u,c]=k.useState(e.notes??""),h=k.useCallback((E,S,v)=>{e.nodeId&&se.recordQuizAnswer(e.nodeId,v).catch(()=>{}),r(e.id,v)},[e.nodeId,e.id,r]),f=e.artifactType==="user_note";let d="",m=null;if(f){try{d=JSON.parse(e.data).text??""}catch{d=e.title??""}try{e.sourceAnchor&&(m=JSON.parse(e.sourceAnchor))}catch{m=null}}let g=null;if(!f)try{g=JSON.parse(e.data)}catch{g=null}const b=new Date(e.createdAt),y=`${b.getMonth()+1}/${b.getDate()} ${b.getHours().toString().padStart(2,"0")}:${b.getMinutes().toString().padStart(2,"0")}`;if(f){const E=e.notes&&e.notes.trim().length>0?e.notes:null,S=()=>{c(E??""),l(!0)},v=()=>{c(E??""),l(!1)},T=()=>{s==null||s(e.id,u),l(!1)};return p.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:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(Xx,{className:"w-4 h-4 text-accent shrink-0 mt-0.5"}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"text-body text-ink leading-relaxed whitespace-pre-wrap",children:d}),s&&o?p.jsxs("div",{className:"mt-2 space-y-1.5","data-testid":`note-comment-edit-${e.id.slice(0,8)}`,children:[p.jsx("textarea",{value:u,onChange:_=>c(_.target.value),rows:2,placeholder:a(E?"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)}`}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("button",{onClick:T,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:[p.jsx(xn,{className:"w-3 h-3"})," ",a("notebook.action.save")]}),p.jsxs("button",{onClick:v,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:[p.jsx(_n,{className:"w-3 h-3"})," ",a("notebook.action.cancel")]})]})]}):E?p.jsxs("div",{className:"mt-2 px-2.5 py-1.5 rounded-lg bg-ink/5",children:[p.jsx("div",{className:"text-label text-ink-muted italic leading-relaxed whitespace-pre-wrap",children:E}),s&&p.jsxs("button",{onClick:S,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:[p.jsx(Ri,{className:"w-2.5 h-2.5"})," ",a("notebook.note.edit_comment")]})]}):s?p.jsxs("button",{onClick:S,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:[p.jsx(Ri,{className:"w-2.5 h-2.5"})," ",a("notebook.note.add_comment")]}):null,m&&i&&p.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"?p.jsxs(p.Fragment,{children:[p.jsx(Jt,{className:"w-3 h-3"}),a("notebook.source.jump_content")]}):p.jsxs(p.Fragment,{children:[p.jsx(Sm,{className:"w-3 h-3"}),a("notebook.source.jump_chat")]})}),p.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[p.jsx("span",{className:"text-caption text-ink-muted",children:y}),p.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:p.jsx(el,{className:"w-3 h-3"})})]})]})]})})}const w=cN[e.artifactType]??Kx;return p.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:[p.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[p.jsx("span",{className:"text-body inline-flex items-center text-ink-strong",children:p.jsx(w,{className:"w-4 h-4"})}),p.jsx("span",{className:"text-label font-bold text-ink-muted flex-1 truncate",children:e.title??hN(a,e.artifactType)}),e.artifactType==="quiz"&&e.lastResult&&p.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?p.jsxs("span",{className:"text-caption text-brand font-bold flex items-center gap-0.5",children:[p.jsx(Oc,{className:"w-2.5 h-2.5"}),a("notebook.note.pinned")]}):null,p.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:p.jsx(Oc,{className:"w-3 h-3"})}),p.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:p.jsx(el,{className:"w-3 h-3"})})]}),p.jsx("div",{className:"text-label",children:g?p.jsx(k.Suspense,{fallback:null,children:p.jsx(yg,{data:g,onQuizAnswered:h})}):p.jsx("div",{className:"text-ink-muted",children:a("notebook.artifact.broken")})}),p.jsx("div",{className:"text-caption text-ink-muted mt-2",children:y})]})}function vh({message:e,icon:t}){return p.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6","data-testid":"empty-notebook",children:[p.jsx("div",{className:"text-4xl mb-3 opacity-30",children:t}),p.jsx("div",{className:"text-body text-ink-muted max-w-xs leading-relaxed",children:e})]})}function _o({label:e,icon:t,active:n,onClick:r,testid:s,badge:i}){return p.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:[p.jsx(t,{className:"w-3 h-3"}),p.jsx("span",{children:e}),i&&p.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 gN({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 h;return(h=c.sourcePath)==null?void 0:h.endsWith(u)})??n.find(c=>c.filename===u)??null},[a,n]);if(k.useEffect(()=>{if(!o){i(null);return}let u=!1;return se.getAssetDataUrl(o.id).then(c=>{u||i(c)}),()=>{u=!0}},[o]),!a)return null;const l=s??a;return p.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 bN({asset:e}){const t=$e(),[n,r]=k.useState(null),[s,i]=k.useState(!1);return k.useEffect(()=>{let a=!1;return se.getAssetDataUrl(e.id).then(o=>{a||r(o)}),()=>{a=!0}},[e.id]),p.jsxs(p.Fragment,{children:[p.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?p.jsx("img",{src:n,alt:e.altText??e.filename,"data-asset-id":e.id,className:"w-full h-24 object-cover",loading:"lazy"}):p.jsx("div",{className:"w-full h-24 flex items-center justify-center text-ink-faint text-caption",children:t("notebook.asset.loading")})}),s&&n&&p.jsxs("div",{className:"fixed inset-0 z-50 bg-black/80 flex items-center justify-center p-8 cursor-pointer",onClick:()=>i(!1),children:[p.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"}),p.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:p.jsx(_n,{className:"w-6 h-6"})})]})]})}const xN=["INTJ","INTP","ENTJ","ENTP","INFJ","INFP","ENFJ","ENFP","ISTJ","ISFJ","ESTJ","ESFJ","ISTP","ISFP","ESTP","ESFP"],vg=["external","introjected","identified","integrated","intrinsic"],yN={start:null,interaction:null,feedback:null,pacing:null};function No(){return{name:null,mbti:null,style:{...yN},motiveStage:null,interests:null,freeNote:null,updatedAt:new Date(0).toISOString()}}function Eg(e){return{start:e.includes("N")?"framework":"analogy",interaction:e.includes("E")?"dialogue":"lecture",feedback:e.includes("T")?"direct":"encouraging",pacing:e.includes("P")?"exploratory":"sequential"}}function Eh(e){var t;return!!(e.name||e.mbti||e.motiveStage||e.freeNote||(((t=e.interests)==null?void 0:t.length)??0)>0||e.style.start||e.style.interaction||e.style.feedback||e.style.pacing)}const vN=8;function EN(e){if(!Array.isArray(e))return null;const t=[];for(const n of e){if(typeof n!="string")continue;const r=n.trim();if(r&&!t.includes(r)&&t.push(r),t.length>=vN)break}return t.length?t:null}function vl(e){return EN((e??"").split(/[,,、;;]+/))}const kN={start:{analogy:{zh:"先具体实例建直觉",en:"concrete examples first"},framework:{zh:"先框架后细节",en:"framework first, details later"}},interaction:{dialogue:{zh:"边讲边问",en:"dialogue-heavy teaching"},lecture:{zh:"讲完一节再答疑",en:"lecture first, Q&A after"}},feedback:{direct:{zh:"直接纠错",en:"direct corrections"},encouraging:{zh:"先肯定再指正",en:"encouraging corrections"}},pacing:{sequential:{zh:"按顺序推进",en:"sequential progression"},exploratory:{zh:"允许跳着学",en:"exploratory jumping"}}};function HP(e,t,n){const r=kN[e][t];return r?n==="en"?r.en:r.zh:""}const TN={external:{nameZh:"为了考试/面试",nameEn:"For an exam",taglineZh:"这场考试/面试在前头等着,得过去。",taglineEn:"The exam or interview is waiting — gotta get past it.",botZh:"行,考点优先,咱们稳稳过。",botEn:"Alright — exam points first, steady pace, we'll pass."},introjected:{nameZh:"为了填满休息时间",nameEn:"To fill free time",taglineZh:"闲着也是闲着,学点总没坏处。",taglineEn:"Got spare time anyway — might as well learn something.",botZh:"轻松学,不赶进度,学到哪算哪。",botEn:"Easy pace, no rush — we go as far as we go."},identified:{nameZh:"未来能用得上",nameEn:"It'll pay off",taglineZh:"这本事存着,总有一天用得上。",taglineEn:"Stash the skill — one day it pays off.",botZh:"好,都往用得上讲。",botEn:"Got it — everything aimed at real use."},integrated:{nameZh:"终身学习",nameEn:"Lifelong learning",taglineZh:"学习这事儿,我打算干一辈子。",taglineEn:"Learning is a lifelong thing for me.",botZh:"同路人,往深了讲。",botEn:"Fellow traveler — let's go deep."},intrinsic:{nameZh:"享受学习过程",nameEn:"For the fun of it",taglineZh:"懂的那个瞬间,本身就挺爽。",taglineEn:"That click when it finally makes sense — love it.",botZh:"那就挑有意思的讲!",botEn:"Then let's pick the fun stuff!"}};function Ir(e,t){const n=TN[e];return t==="en"?{name:n.nameEn,tagline:n.taglineEn,bot:n.botEn}:{name:n.nameZh,tagline:n.taglineZh,bot:n.botZh}}const wN={INTJ:{nameZh:"建筑师",nameEn:"Architect",taglineZh:"要蓝图不要碎片:先给全貌和设计意图,细节他自己会填。",taglineEn:"Wants the blueprint, not fragments: give the big picture and design intent first; he'll fill in details himself.",botZh:"收到,我先给你画地图,路你自己走。",botEn:"Got it — I'll draw the map, you pick the path."},INTP:{nameZh:"逻辑学家",nameEn:"Logician",taglineZh:"定义先行:把概念边界和推理链讲清楚,他自己能走完。",taglineEn:"Definitions first: lay out concept boundaries and the reasoning chain; he can walk the rest.",botZh:"好,我们先把术语掰干净。",botEn:"Alright, let's nail down the terms first."},ENTJ:{nameZh:"指挥官",nameEn:"Commander",taglineZh:"目标导向:直说这知识能干什么、怎么最快上手。",taglineEn:"Goal-driven: say what this knowledge is for and the fastest way to competence.",botZh:"明白,直奔主线。",botEn:"Understood — straight to the main line."},ENTP:{nameZh:"辩论家",nameEn:"Debater",taglineZh:"辩论驱动:抛论点让他攻击,他记住的是自己反驳过的东西;小心他只聊不做题。",taglineEn:"Debate-driven: throw out claims for him to attack — he remembers what he argued against; watch that he doesn't just chat and skip quizzes.",botZh:"来,先过两招。",botEn:"Come on then — let's spar a round."},INFJ:{nameZh:"提倡者",nameEn:"Advocate",taglineZh:"意义驱动:先讲这知识为什么重要、和什么相连。",taglineEn:"Meaning-driven: start with why this matters and what it connects to.",botZh:"好的,从「为什么」讲起。",botEn:"Sure — let's start with the 'why'."},INFP:{nameZh:"调停者",nameEn:"Mediator",taglineZh:"兴趣驱动:用他关心的例子引路,少逼问多启发。",taglineEn:"Interest-driven: lead with examples he cares about; inspire more, interrogate less.",botZh:"嗯,我们挑你最有感觉的部分开始。",botEn:"Hmm — let's start with whatever resonates most."},ENFJ:{nameZh:"主人公",nameEn:"Protagonist",taglineZh:"共鸣驱动:多确认感受,节奏放软,用故事讲。",taglineEn:"Resonance-driven: check in on how it's landing, soften the pace, teach through stories.",botZh:"好呀,我们慢慢来。",botEn:"Of course — let's take it easy."},ENFP:{nameZh:"竞选者",nameEn:"Campaigner",taglineZh:"新鲜感驱动:多变花样、多跳观点,小心他三分钟热度。",taglineEn:"Novelty-driven: vary the angles and keep it fresh; watch for fading enthusiasm.",botZh:"走,今天学点新鲜的!",botEn:"Let's go — something fresh today!"},ISTJ:{nameZh:"物流师",nameEn:"Logistician",taglineZh:"顺序驱动:按地图一格一格来,讲清楚规则和依据。",taglineEn:"Order-driven: follow the map step by step; make rules and rationale explicit.",botZh:"好,按部就班。",botEn:"Good — step by step."},ISFJ:{nameZh:"守卫者",nameEn:"Defender",taglineZh:"稳妥驱动:小步确认,多鼓励,别一次灌太多。",taglineEn:"Steady-driven: small steps with frequent check-ins; encourage; don't dump too much at once.",botZh:"放心,我们一步步来。",botEn:"Don't worry — one step at a time."},ESTJ:{nameZh:"总经理",nameEn:"Executive",taglineZh:"务实驱动:直接给可执行的步骤和检验标准。",taglineEn:"Pragmatic-driven: hand over actionable steps and clear acceptance criteria.",botZh:"行,列个清单开工。",botEn:"Fine — checklist and go."},ESFJ:{nameZh:"执政官",nameEn:"Consul",taglineZh:"陪伴驱动:多互动多反馈,让他感到进度被看见。",taglineEn:"Companion-driven: interact and give feedback often so progress feels seen.",botZh:"一起学,我盯着你的进度。",botEn:"We'll learn together — I'm watching your progress."},ISTP:{nameZh:"鉴赏家",nameEn:"Virtuoso",taglineZh:"动手驱动:少讲理论多上手,例子要真实可拆。",taglineEn:"Hands-on-driven: less theory, more doing; examples must be real and dissectable.",botZh:"直接上手试试?",botEn:"Wanna just dive in?"},ISFP:{nameZh:"探险家",nameEn:"Adventurer",taglineZh:"体验驱动:从具体感受入手,审美和直觉都吃得开。",taglineEn:"Experience-driven: start from concrete impressions; aesthetics and intuition both work.",botZh:"我们从好玩的讲起。",botEn:"Let's start with the fun part."},ESTP:{nameZh:"企业家",nameEn:"Entrepreneur",taglineZh:"实战驱动:先跑起来再补理论,边做边纠。",taglineEn:"Action-driven: run it first, patch theory later; correct while doing.",botZh:"先干了再说。",botEn:"Do it now, talk later."},ESFP:{nameZh:"表演者",nameEn:"Entertainer",taglineZh:"舞台驱动:讲得有声有色,及时给掌声。",taglineEn:"Stage-driven: teach with color and energy; applaud generously and promptly.",botZh:"上课啦,今天包好看!",botEn:"Class is on — promise it'll be a good show!"}};function Io(e,t){const n=wN[e];return t==="en"?{code:e,name:n.nameEn,tagline:n.taglineEn,bot:n.botEn}:{code:e,name:n.nameZh,tagline:n.taglineZh,bot:n.botZh}}function UP({t:e,locale:t,profile:n,onSave:r,onCancel:s,testIdPrefix:i="boot"}){const a=m=>`${i}-edit-${m}`,[o,l]=k.useState({...n,style:{...n.style}}),u=t==="en",c=m=>l(g=>({...g,...m})),[h,f]=k.useState(()=>{var m;return((m=n.interests)==null?void 0:m.join(u?", ":"、"))??""}),d=u?", ":"、";return p.jsxs("section",{className:"flex flex-col gap-4","data-testid":`${i}-editcard`,children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-title font-bold text-ink mb-1",children:e("boot.profile_quiz.title")}),p.jsx("div",{className:"text-label text-ink-muted",children:e("boot.profile_quiz.desc")})]}),p.jsxs("label",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-label text-ink-faint",children:e("boot.card.name.label")}),p.jsx("input",{className:"bg-surface-0 rounded-lg px-3 py-2 text-body text-ink outline-none focus:ring-2 focus:ring-accent",placeholder:e("boot.card.name.placeholder"),value:o.name??"",onChange:m=>c({name:m.target.value||null}),"data-testid":a("name")})]}),p.jsx(kg,{t:e,locale:t,value:o.mbti,onPick:m=>{Rr(),c({mbti:m,style:Eg(m)})}}),p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-label text-ink",children:e("boot.card.motive.label")}),p.jsx("div",{className:"grid grid-cols-1 gap-1.5",role:"radiogroup","aria-label":e("boot.card.motive.label"),children:vg.map(m=>p.jsx("button",{role:"radio","aria-checked":o.motiveStage===m,className:o.motiveStage===m?"btn-3d-brand text-left px-3 py-2.5":"btn-3d-neutral text-left px-3 py-2.5",onClick:()=>c({motiveStage:m}),"data-testid":a(`motive-${m}`),children:Ir(m,t).name},m))}),o.motiveStage&&p.jsxs("div",{className:"reveal-enter rounded-xl bg-surface-0 p-3 flex flex-col gap-1","data-testid":a("motive-flip"),children:[p.jsx("div",{className:"text-label text-ink-muted",children:Ir(o.motiveStage,t).tagline}),p.jsx("div",{className:"text-label text-accent",children:Ir(o.motiveStage,t).bot})]})]}),p.jsxs("label",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-label text-ink-faint",children:e("boot.card.interests.label")}),p.jsx("input",{className:"bg-surface-0 rounded-lg px-3 py-2 text-body text-ink outline-none focus:ring-2 focus:ring-accent",placeholder:e("boot.card.interests.placeholder"),value:h,onChange:m=>{f(m.target.value),c({interests:vl(m.target.value)})},onBlur:()=>{var m;return f(((m=o.interests)==null?void 0:m.join(d))??"")},"data-testid":a("interests")})]}),p.jsxs("label",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-label text-ink-faint",children:e("boot.card.free.label")}),p.jsx("textarea",{className:"bg-surface-0 rounded-lg px-3 py-2 text-body text-ink outline-none focus:ring-2 focus:ring-accent resize-none",rows:2,placeholder:e("boot.card.free.placeholder"),value:o.freeNote??"",onChange:m=>c({freeNote:m.target.value||null}),"data-testid":a("free")})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsxs("button",{className:"btn-3d-brand inline-flex items-center gap-1.5 px-4 py-2",onClick:()=>r({...o,interests:vl(h),updatedAt:new Date().toISOString()}),"data-testid":a("save"),children:[p.jsx(tu,{size:16}),e("boot.profile.save")]}),s&&p.jsxs("button",{className:"btn-3d-neutral inline-flex items-center gap-1.5 px-4 py-2",onClick:s,children:[p.jsx(_n,{size:16}),e("boot.profile.cancel")]})]})]})}function kg({t:e,locale:t,value:n,onPick:r}){return p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx("span",{className:"text-label text-ink",children:e("boot.card.mbti.label")}),p.jsx("div",{className:"grid grid-cols-4 gap-1.5",role:"radiogroup","aria-label":e("boot.card.mbti.label"),"data-testid":"boot-mbti-grid",children:xN.map(s=>p.jsx("button",{role:"radio","aria-checked":n===s,className:n===s?"btn-3d-brand text-label px-1 py-2.5":"btn-3d-neutral text-label px-1 py-2.5",onClick:()=>r(s),"data-testid":`boot-mbti-${s}`,children:s},s))}),n&&p.jsxs("div",{className:"reveal-enter rounded-xl bg-surface-0 p-3 flex flex-col gap-1","data-testid":"boot-mbti-flip",children:[p.jsxs("div",{className:"text-label font-bold text-ink",children:[n," · ",Io(n,t).name]}),p.jsx("div",{className:"text-label text-ink-muted",children:Io(n,t).tagline}),p.jsx("div",{className:"text-label text-accent",children:Io(n,t).bot})]})]})}function SN(e){const t=e.wizardStep;return t<=1&&e.hasKey&&t===1?{scene:"profile_quiz",mood:"cheer",lines:[{key:"boot.profile_quiz.title"},{key:"boot.profile_quiz.desc"}],actions:[{kind:"wizard_next",labelKey:"boot.action.wizard_next"}],welcomeBack:!1}:t<=0?{scene:"welcome_intro",mood:"wave",lines:[{key:"boot.welcome.title"},{key:"boot.welcome.desc",vars:{name:e.name??""}},{key:"boot.welcome.forms"}],actions:[{kind:"wizard_next",labelKey:"boot.action.hello"}],welcomeBack:!1}:t===1?{scene:"key_setup",mood:"thinking",lines:[{key:"boot.key.title"},{key:"boot.key.desc"}],actions:[{kind:"settings_llm",labelKey:"boot.action.go_settings"},{kind:"wizard_next",labelKey:"boot.action.later"}],welcomeBack:!1}:t===2?{scene:"profile_quiz",mood:"cheer",lines:[{key:"boot.profile_quiz.title"},{key:"boot.profile_quiz.desc"}],actions:[{kind:"wizard_next",labelKey:e.profileFilled?"boot.action.done_quiz":"boot.action.wizard_next"}],welcomeBack:!1}:{scene:"course_pick",mood:"star",lines:[{key:"boot.pick.title"},{key:"boot.pick.desc"}],actions:[{kind:"start_import",labelKey:"boot.action.start_import"},{kind:"companion_settings",labelKey:"boot.action.companion"}],welcomeBack:!1}}function AN(e){const t=[];if(e.lastSession&&e.hasCourses)return e.dueCount>0&&t.push({kind:"review",labelKey:"boot.action.review_n"}),e.profileFilled||t.push({kind:"edit_profile",labelKey:"boot.action.edit_profile"}),{scene:"resume_last",mood:"wave",lines:[{key:"boot.resume.title",vars:{course:e.lastSession.courseTitle,node:e.lastSession.nodeTitle??""}},{key:"boot.resume.desc"},...e.dueCount>0?[{key:"boot.resume.due",vars:{n:e.dueCount}}]:[]],actions:[{kind:"resume",labelKey:"boot.action.resume"},...t.slice(0,2)],welcomeBack:!1};if(e.dueCount>0){const n=[];return e.profileFilled||n.push({kind:"edit_profile",labelKey:"boot.action.edit_profile"}),{scene:"review_due",mood:"cheer",lines:[{key:"boot.review.title",vars:{n:e.dueCount}},{key:"boot.review.desc"}],actions:[{kind:"review",labelKey:"boot.action.review"},...n.slice(0,2)],welcomeBack:!1}}return e.streak&&!e.streak.todayDone&&e.streak.atRisk?{scene:"streak_danger",mood:"star",lines:[{key:"boot.streak.title",vars:{hours:Math.max(1,Math.round(e.streak.hoursLeft))}},{key:"boot.streak.desc"}],actions:[{kind:"review",labelKey:"boot.action.keep_flame"},{kind:"pick_course",labelKey:"boot.action.pick_course"}],welcomeBack:!1}:e.suspendedExamNodeTitle?{scene:"exam_suspended",mood:"thinking",lines:[{key:"boot.exam.title",vars:{node:e.suspendedExamNodeTitle}},{key:"boot.exam.desc"}],actions:[{kind:"goto_node",labelKey:"boot.action.continue_exam",target:"exam"},{kind:"review",labelKey:"boot.action.review"}],welcomeBack:!1}:e.nearMasteryNodeTitle?{scene:"near_mastery",mood:"star",lines:[{key:"boot.mastery.title",vars:{node:e.nearMasteryNodeTitle}},{key:"boot.mastery.desc"}],actions:[{kind:"goto_node",labelKey:"boot.action.finish_it",target:"near_mastery"},{kind:"review",labelKey:"boot.action.review"}],welcomeBack:!1}:e.topFrictionNodeTitle?{scene:"friction_revisit",mood:"thinking",lines:[{key:"boot.friction.title",vars:{node:e.topFrictionNodeTitle}},{key:"boot.friction.desc"}],actions:[{kind:"goto_node",labelKey:"boot.action.retry",target:"friction"},{kind:"review",labelKey:"boot.action.review"}],welcomeBack:!1}:{scene:"ready_room",mood:"idle",lines:[{key:"boot.ready.title",vars:{name:e.name??""}},{key:e.profileFilled?"boot.ready.profile_done":"boot.ready.profile_empty"},...e.hasCourses?[{key:"boot.ready.has_courses"}]:[{key:"boot.ready.desc"}],...!e.hasKey&&!e.keyPromptDismissed?[{key:"boot.ready.key_hint"}]:[]],actions:[...e.hasCourses?[{kind:"pick_course",labelKey:"boot.action.pick_course"}]:[{kind:"pick_course",labelKey:"boot.action.import_course"}],{kind:"edit_profile",labelKey:e.profileFilled?"boot.action.view_profile":"boot.action.meet_me"}],welcomeBack:!1}}function CN(e){const t=e.bootDone?AN(e):SN(e);return e.bootDone?{...t,welcomeBack:e.returningAfterDays}:{...t,welcomeBack:!1}}const kh=4,Th=[{id:"cable-vs-wifi",better:"a",zh:{q:"同样一段数据,走网线还是走 WiFi,哪个延迟更低?",a:"网线",b:"WiFi",revealA:"对!网线是全双工专用通道,不受空气里的排队和干扰——打游戏的都懂。",revealB:"差一点!WiFi 是共享无线信道,要排队抢空气;网线是专用通道,延迟更稳更低。"},en:{q:"For the same chunk of data, which has lower latency — Ethernet cable or WiFi?",a:"Ethernet cable",b:"WiFi",revealA:"Correct! Ethernet is a dedicated full-duplex lane — no queuing in the air. Gamers know.",revealB:"Close! WiFi shares the wireless medium and queues for airtime; Ethernet is a dedicated lane with lower, steadier latency."}},{id:"http-vs-https",better:"a",zh:{q:"浏览器地址栏的 https 里的 s,保护的是哪一段?",a:"你电脑到网站之间的传输",b:"网站服务器本身不被黑",revealA:"对!s = 传输加密,防的是路上的偷看和篡改;服务器被黑是另一回事。",revealB:"不是哦——s 只加密'路上'的传输,服务器自己被攻破它管不着。"},en:{q:"In https, what does the 's' actually protect?",a:"The transport between your computer and the site",b:"The server from being hacked",revealA:"Right! s = encrypted transport — it stops eavesdropping and tampering in transit. Server breaches are a different problem.",revealB:"Not quite — the 's' only encrypts the road; if the server itself is compromised, it can't help."}},{id:"ram-vs-disk",better:"b",zh:{q:"断电后数据还在的是?",a:"内存(RAM)",b:"硬盘",revealB:"对!硬盘是持久存储;内存断电即忘——所以'保存'保存的是写进硬盘。",revealA:"恰恰相反——内存断电就忘,硬盘才记得住。'保存'就是从内存写进硬盘。"},en:{q:"Which one keeps its data after a power cut?",a:"RAM",b:"The disk",revealB:"Correct! Disks persist; RAM forgets on power loss — that's why 'save' means writing to disk.",revealA:"Other way around — RAM forgets on power loss; disks remember. 'Saving' means writing from RAM to disk."}},{id:"compile-vs-run",better:"b",zh:{q:"你写的代码,CPU 直接执行的是?",a:"你敲的源代码",b:"翻译后的机器指令",revealB:"对!CPU 只吃自己的指令集;你写的代码先被翻译(编译/解释)成机器指令。",revealA:"不不——CPU 看不懂你敲的语言,它只执行翻译后的机器指令。"},en:{q:"What does the CPU actually execute directly?",a:"The source code you type",b:"Translated machine instructions",revealB:"Correct! The CPU only speaks its own instruction set; your code is translated (compiled/interpreted) first.",revealA:"Nope — the CPU can't read your language; it runs translated machine instructions only."}},{id:"shortcut-ctrl-z",better:"a",zh:{q:"Ctrl+Z 撤销的是?",a:"上一次操作",b:"上一次保存",revealA:"对!撤销栈记的是操作历史,一步一步可以回退——是个'时间倒流'按钮。",revealB:"不是保存——撤销回退的是操作历史,跟保存点无关。"},en:{q:"What does Ctrl+Z undo?",a:"Your last action",b:"Your last save",revealA:"Right! The undo stack records action history — it's a mini time machine.",revealB:"Not saves — undo steps back through actions, not save points."}},{id:"cache-purpose",better:"a",zh:{q:"为什么删了缓存,下次打开 app 反而更慢?",a:"缓存是提前备好的常用数据",b:"删缓存把网络也删慢了",revealA:"对!缓存就是'放得近的备用件',删了它,app 只好重新去老远的地方拉一遍。",revealB:"网络没变慢——是缓存没了,常用数据得重新下载/计算一遍。"},en:{q:"Why is an app slower right after you clear its cache?",a:"Cache holds pre-fetched frequently-used data",b:"Clearing cache slows down your network",revealA:"Right! Cache is 'spare parts kept nearby'; clear it and the app must fetch everything from far away again.",revealB:"Your network didn't change — the cache is gone, so common data must be re-downloaded and recomputed."}}];function _N(e,t){const n=Th[NN(e,Th.length)];return t==="en"?{id:n.id,q:n.en.q,a:n.en.a,b:n.en.b,revealA:n.en.revealA,revealB:n.en.revealB,better:n.better}:{id:n.id,q:n.zh.q,a:n.zh.a,b:n.zh.b,revealA:n.zh.revealA,revealB:n.zh.revealB,better:n.better}}function NN(e,t){let n=2166136261;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619);return Math.abs(n)%t}const IN={wizard_next:p.jsx(tu,{size:16}),settings_llm:p.jsx(ym,{size:16}),pick_course:p.jsx(Jt,{size:16}),start_import:p.jsx(Bx,{size:16}),companion_settings:p.jsx(wx,{size:16}),resume:p.jsx(Am,{size:16}),review:p.jsx(gm,{size:16}),goto_node:p.jsx(vm,{size:16}),edit_profile:p.jsx(Gx,{size:16})},RN={welcome_intro:p.jsx(Ys,{size:22,className:"text-accent"}),key_setup:p.jsx(ym,{size:22,className:"text-warning"}),profile_quiz:p.jsx(xm,{size:22,className:"text-accent"}),course_pick:p.jsx(Jt,{size:22,className:"text-brand"}),resume_last:p.jsx(Am,{size:22,className:"text-brand"}),review_due:p.jsx(gm,{size:22,className:"text-accent"}),streak_danger:p.jsx(ga,{size:22,className:"text-review"}),friction_revisit:p.jsx(vm,{size:22,className:"text-accent"}),near_mastery:p.jsx(Im,{size:22,className:"text-gold"}),exam_suspended:p.jsx(Vi,{size:22,className:"text-warning"}),ready_room:p.jsx(Ys,{size:22,className:"text-accent"})};function MN(e){var w,E;const t=$e(),r=ba()==="en"?"en":"zh-CN",[s,i]=k.useState(null),[a,o]=k.useState(0),[l,u]=k.useState(null),c=k.useRef(!1);k.useEffect(()=>(mi(!0),()=>mi(!1)),[]),k.useEffect(()=>{let S=!0;return se.bootGetState().then(v=>{S&&(i(v),u(T=>T??No()))}).catch(()=>{S&&u(v=>v??No())}),se.profileGet().then(v=>{!S||!v||Eh(v)&&u(T=>T&&Eh(T)?T:v)}).catch(()=>{}),()=>{S=!1}},[]);const h=k.useMemo(()=>s?CN({...s,bootDone:s.bootDone&&a===0,wizardStep:a}):null,[s,a]),f=l??No(),d=k.useCallback(S=>{u(S),se.profileSet(S).then(()=>{var v;return(v=e.onProfileChanged)==null?void 0:v.call(e)}).catch(()=>{})},[e]);k.useEffect(()=>{!s||(h==null?void 0:h.scene)!=="ready_room"||s.hasKey||s.keyPromptDismissed||c.current||(c.current=!0,se.getSetting("key_prompt_count").then(S=>{const v=Number(S??"0")||0;return se.setSetting("key_prompt_count",String(v+1))}).catch(()=>{}))},[s,h]);const m=k.useCallback(()=>{se.setSetting("boot_done","1").catch(()=>{}),i(S=>S&&{...S,bootDone:!0})},[]),g=k.useCallback((S,v)=>{if(s){if(S==="wizard_next")o(T=>Math.min(kh-1,T+1));else if(S==="settings_llm")e.onOpenModelManager();else if(S==="start_import"||S==="pick_course")mi(!1),e.onPickCourse();else if(S==="companion_settings")e.onOpenSettings("companion");else if(S==="edit_profile")e.onOpenProfile();else if(S==="resume"&&s.targets.resume)m(),e.onResume(s.targets.resume.courseId,s.targets.resume.nodeId);else if(S==="review")e.onOpenReview(s.targets.reviewCourseId);else if(S==="goto_node"&&v){m();const T=v==="friction"?s.targets.frictionNodeId:v==="near_mastery"?s.targets.nearMasteryNodeId:s.targets.examNodeId;T&&e.onGotoNode(T,v)}}},[s,h,m,e]);if(!s||!h)return p.jsx("div",{className:"flex-1 flex items-center justify-center","data-testid":"boot-guide-loading",children:p.jsx("div",{className:"text-label text-ink-faint",children:t("boot.welcome.title")})});const b=(s.name??"").trim(),y=(S,v)=>t(S,{name:b?r==="en"?`${b}, `:`${b},`:"",...v});return p.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-8","data-testid":"boot-guide","data-scene":h.scene,"data-boot-done":s.bootDone?"1":"0",children:p.jsxs("div",{className:"mx-auto max-w-md flex flex-col gap-4","data-companion-anchor":"boot-guide",children:[h.welcomeBack&&p.jsx("div",{className:"text-center text-body text-accent font-bold","data-testid":"boot-welcome-back",children:y("boot.welcome_back")}),p.jsxs("section",{className:"surface-card rounded-2xl p-6 shadow-card flex flex-col gap-4","data-testid":`boot-card-${h.scene}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[RN[h.scene],p.jsx("div",{className:"text-title font-bold text-ink",children:y(((w=h.lines[0])==null?void 0:w.key)??"boot.ready.title",(E=h.lines[0])==null?void 0:E.vars)})]}),h.lines.slice(1).map(S=>p.jsx("p",{className:"text-body text-ink-muted leading-relaxed",children:y(S.key,S.vars)},S.key)),!(h.scene==="profile_quiz"&&a===2)&&p.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:h.actions.map(S=>p.jsxs("button",{className:S===h.actions[0]?"btn-3d-brand inline-flex items-center gap-1.5 px-4 py-2":"btn-3d-neutral inline-flex items-center gap-1.5 px-4 py-2",onClick:()=>g(S.kind,S.target),"data-testid":`boot-action-${S.kind}`,children:[IN[S.kind],t(S.labelKey,S.kind==="review"&&s.dueCount>0?{n:s.dueCount}:void 0)]},S.kind+(S.target??"")))}),!s.bootDone&&!(h.scene==="profile_quiz"&&a===2)&&p.jsx("div",{className:"flex gap-1.5","data-testid":"boot-wizard-dots",children:Array.from({length:kh}).map((S,v)=>p.jsx("span",{className:`h-1.5 rounded-full transition-all ${v===a?"w-6 bg-brand":"w-2 bg-neutral-300 dark:bg-neutral-700"}`},v))})]}),!s.bootDone&&a===2?p.jsxs(p.Fragment,{children:[p.jsx(PN,{t,locale:r,profile:f,onPatch:S=>d({...f,...S,style:{...f.style,...S.style},updatedAt:new Date().toISOString()}),onFinish:()=>{m(),o(3)}}),p.jsx("button",{className:"self-start text-label text-ink-faint hover:text-ink transition-colors px-1 py-1.5",onClick:()=>g("wizard_next"),"data-testid":"boot-wizard-skip-quiz",children:t("boot.action.skip_quiz")})]}):null]})})}function PN({t:e,locale:t,profile:n,onPatch:r,onFinish:s}){const[i,a]=k.useState(0),o=k.useMemo(()=>_N(new Date().toISOString().slice(0,10),t),[t]),[l,u]=k.useState(null),[c,h]=k.useState(()=>{var m;return((m=n.interests)==null?void 0:m.join(t==="en"?", ":"、"))??""}),f=t==="en"?", ":"、",d=p.jsx("div",{className:"flex gap-1.5","data-testid":"boot-wizard-subdots",children:[0,1,2].map(m=>p.jsx("span",{className:`h-1.5 rounded-full transition-all ${m===i?"w-6 bg-brand":"w-2 bg-neutral-300 dark:bg-neutral-700"}`},m))});return i===0?p.jsxs("section",{className:"surface-card rounded-2xl p-6 shadow-card flex flex-col gap-4","data-testid":"boot-wizard-card1",children:[d,p.jsxs("label",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-label text-ink-faint",children:e("boot.card.name.label")}),p.jsx("input",{className:"bg-surface-0 rounded-lg px-3 py-2 text-body text-ink outline-none focus:ring-2 focus:ring-accent",placeholder:e("boot.card.name.placeholder"),value:n.name??"",onChange:m=>r({name:m.target.value||null}),"data-testid":"boot-wizard-name"})]}),p.jsx(kg,{t:e,locale:t,value:n.mbti,onPick:m=>{Rr(),r({mbti:m,style:Eg(m)})}}),p.jsx("button",{className:"btn-3d-brand self-start px-4 py-2",onClick:()=>a(1),"data-testid":"boot-wizard-next1",children:n.mbti?e("boot.card.mbti.next"):e("boot.card.mbti.skip")})]}):i===1?p.jsxs("section",{className:"surface-card rounded-2xl p-6 shadow-card flex flex-col gap-4","data-testid":"boot-wizard-card2",children:[d,p.jsx("div",{className:"text-title font-bold text-ink",children:n.name?e("boot.card.motive.named",{name:n.name}):e("boot.card.motive.label")}),p.jsx("div",{className:"grid grid-cols-1 gap-1.5",role:"radiogroup","aria-label":e("boot.card.motive.label"),"data-testid":"boot-motive-grid",children:vg.map(m=>p.jsx("button",{role:"radio","aria-checked":n.motiveStage===m,className:n.motiveStage===m?"btn-3d-brand text-left px-3 py-2.5":"btn-3d-neutral text-left px-3 py-2.5",onClick:()=>{Rr(),r({motiveStage:m})},"data-testid":`boot-wizard-motive-${m}`,children:Ir(m,t).name},m))}),n.motiveStage&&p.jsxs("div",{className:"reveal-enter rounded-xl bg-surface-0 p-3 flex flex-col gap-1","data-testid":"boot-motive-flip",children:[p.jsx("div",{className:"text-label text-ink-muted",children:Ir(n.motiveStage,t).tagline}),p.jsx("div",{className:"text-label text-accent",children:Ir(n.motiveStage,t).bot})]}),p.jsxs("label",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-label text-ink-faint",children:e("boot.card.interests.label")}),p.jsx("input",{className:"bg-surface-0 rounded-lg px-3 py-2 text-body text-ink outline-none focus:ring-2 focus:ring-accent",placeholder:e("boot.card.interests.placeholder"),value:c,onChange:m=>{h(m.target.value),r({interests:vl(m.target.value)})},onBlur:()=>{var m;return h(((m=n.interests)==null?void 0:m.join(f))??"")},"data-testid":"boot-wizard-interests"})]}),p.jsx("button",{className:"btn-3d-brand self-start px-4 py-2",onClick:()=>a(2),"data-testid":"boot-wizard-next2",children:e("boot.card.motive.next")})]}):p.jsxs("section",{className:"surface-card rounded-2xl p-6 shadow-card flex flex-col gap-4","data-testid":"boot-wizard-card3",children:[d,p.jsx("div",{className:"text-title font-bold text-ink",children:e("boot.card.quiz.label")}),p.jsx("div",{className:"text-body text-ink",children:o.q}),l===null?p.jsxs("div",{className:"flex gap-2",role:"radiogroup","aria-label":o.q,children:[p.jsx("button",{role:"radio","aria-checked":!1,className:"btn-3d-neutral flex-1 px-3 py-2.5",onClick:()=>{u("a"),o.better==="a"&&Ar("correct")},"data-testid":"boot-wizard-quiz-a",children:o.a}),p.jsx("button",{role:"radio","aria-checked":!1,className:"btn-3d-neutral flex-1 px-3 py-2.5",onClick:()=>{u("b"),o.better==="b"&&Ar("correct")},"data-testid":"boot-wizard-quiz-b",children:o.b})]}):p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"reveal-enter rounded-xl bg-surface-0 p-3 text-label text-ink leading-relaxed","data-testid":"boot-wizard-quiz-reveal",children:l==="a"?o.revealA:o.revealB}),p.jsxs("button",{className:"btn-3d-brand self-start inline-flex items-center gap-1.5 px-4 py-2",onClick:s,"data-testid":"boot-wizard-finish",children:[p.jsx(tu,{size:16}),e("boot.card.quiz.next")]})]})]})}const wh=[{id:"spacing",zh:"隔一天再复习,比当场连看三遍记得牢——间隔重复是记忆的免费午餐。",en:"Revisiting after a day beats three passes in a row — spacing is memory's free lunch."},{id:"recall",zh:"合上书回想一遍,比再读一遍有效得多。难受的感觉正是记忆在加固。",en:"Close the book and recall — far more effective than rereading. The strain IS the strengthening."},{id:"teach",zh:"学完就假装教一个外行:讲不清的地方,就是你没真懂的地方。",en:"After learning, teach it to a layman: where you can't explain clearly is where you don't understand."},{id:"interleave",zh:"交替练不同的题型,比同一题型连刷十道更接近真实考试的样子。",en:"Mixing problem types beats grinding ten of the same — it looks more like real tests."},{id:"sleep",zh:"睡眠是记忆的保存按钮——熬夜学的,大脑来不及归档。",en:"Sleep is memory's save button — the brain can't file what you crammed at 3am."},{id:"small",zh:"每天 20 分钟胜过每周末 3 小时:习惯的对手是中断,不是时长。",en:"Twenty minutes daily beats three hours on Sunday: habits die from breaks, not from shortness."},{id:"why",zh:"先问「这东西解决什么问题」再学怎么做——带着问题的脑子记得牢。",en:"Ask 'what problem does this solve' before 'how' — a question-loaded brain retains better."},{id:"mistakes",zh:"错题本不是抄题本:只记「我当时为什么会那么想」。",en:"A mistake log isn't for copying problems — record only 'why did I think that'."},{id:"analogy",zh:"新概念配一个你熟悉领域的类比,像给记忆一个挂钩。",en:"Pair every new concept with an analogy from familiar ground — give memory a hook."},{id:"env",zh:"固定的学习角落会形成条件反射:一坐下,大脑就知道该开工了。",en:"A fixed study spot builds a reflex: sit down, and the brain knows it's time."}];function LN(e,t){let n=2166136261;for(let s=0;s<e.length;s++)n^=e.charCodeAt(s),n=Math.imul(n,16777619);const r=wh[Math.abs(n)%wh.length];return{id:r.id,text:t==="en"?r.en:r.zh}}function DN(){const e=$e(),n=ba()==="en"?"en":"zh-CN",[r,s]=k.useState(null);k.useEffect(()=>{let l=!0;return se.bootGetState().then(u=>{l&&s(u)}).catch(()=>{}),()=>{l=!1}},[]);const i=LN(new Date().toISOString().slice(0,10),n),a=(r==null?void 0:r.recap)??null,o=!!a&&(a.totalXp>0||a.masteredCount>0||a.streakDays>0);return p.jsx("div",{className:"h-full overflow-y-auto px-5 py-8","data-testid":"notebook-panel",children:p.jsx("div",{className:"h-full","data-testid":"boot-recap","data-mode":o?"recap":"tips",children:p.jsx("div",{className:"mx-auto max-w-sm flex flex-col gap-4",children:o&&a?p.jsxs("section",{className:"surface-card rounded-2xl p-5 shadow-card flex flex-col gap-4","data-testid":"boot-recap-card",children:[p.jsx("div",{className:"text-label font-bold text-ink",children:e("boot.recap.title")}),p.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[p.jsxs("div",{className:"rounded-xl bg-surface-0 p-3 flex flex-col gap-1","data-testid":"boot-recap-xp",children:[p.jsx(Gs,{size:18,className:"text-brand self-center"}),p.jsx("div",{className:"text-title font-bold text-ink",children:a.totalXp}),p.jsx("div",{className:"text-caption text-ink-muted",children:e("boot.recap.total_xp")})]}),p.jsxs("div",{className:"rounded-xl bg-surface-0 p-3 flex flex-col gap-1","data-testid":"boot-recap-mastered",children:[p.jsx(ru,{size:18,className:"text-gold self-center"}),p.jsx("div",{className:"text-title font-bold text-ink",children:a.masteredCount}),p.jsx("div",{className:"text-caption text-ink-muted",children:e("boot.recap.mastered")})]}),p.jsxs("div",{className:"rounded-xl bg-surface-0 p-3 flex flex-col gap-1","data-testid":"boot-recap-streak",children:[p.jsx(ga,{size:18,className:"text-review self-center"}),p.jsx("div",{className:"text-title font-bold text-ink",children:a.streakDays}),p.jsx("div",{className:"text-caption text-ink-muted",children:e("boot.recap.streak_days")})]})]}),(r==null?void 0:r.lastSession)&&p.jsxs("div",{className:"flex items-start gap-2 text-label text-ink-muted","data-testid":"boot-recap-recent",children:[p.jsx(Jt,{size:15,className:"shrink-0 mt-0.5 text-accent"}),p.jsxs("span",{children:[e("boot.recap.recent"),n==="en"?`: "${r.lastSession.courseTitle}"`:`:「${r.lastSession.courseTitle}」`,r.lastSession.nodeTitle?` · ${r.lastSession.nodeTitle}`:""]})]})]}):p.jsxs("section",{className:"surface-card rounded-2xl p-5 shadow-card flex flex-col gap-3","data-testid":"boot-tips-card",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Em,{size:18,className:"text-accent"}),p.jsx("div",{className:"text-label font-bold text-ink",children:e("boot.recap.tips_title")})]}),p.jsx("p",{className:"text-body text-ink-muted leading-relaxed","data-testid":"boot-tip-text",children:i.text})]})})})})}const Sh=[{bg:"#E8F0FE",fg:"#1a56DB"},{bg:"#E6F4EA",fg:"#137333"},{bg:"#FDF0E6",fg:"#B25000"},{bg:"#F3E8FD",fg:"#6B21A8"},{bg:"#FDE8E8",fg:"#B91C1C"},{bg:"#E0F2F1",fg:"#00695C"},{bg:"#FEF9E7",fg:"#92760B"},{bg:"#ECEFF1",fg:"#455A64"}];function ON(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return Math.abs(t)}function FN(e){const t=(e??"").trim();if(!t)return null;const n=[...t][0]??"",r=/[a-z]/i.test(n)?n.toUpperCase():n,s=Sh[ON(t.toLowerCase())%Sh.length];return{bg:s.bg,fg:s.fg,initial:r}}function BN(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 se.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 g=await se.canvasSave({...m,courseId:e});return n(b=>b.some(y=>y.id===g.id)?b:[g,...b]),g}catch{return null}},[e]),o=k.useCallback(async m=>{if(!e)return null;try{const g=await se.canvasSaveUserNote({...m,courseId:e});return n(b=>[g,...b]),g}catch{return null}},[e]),l=k.useCallback(async(m,g)=>{try{const b=await se.canvasRecordQuizResult(m,g);return b&&n(y=>y.map(w=>w.id===m?b:w)),b}catch{return null}},[]),u=k.useCallback(async(m,g)=>{try{const b=await se.canvasUpdateUserNoteComment(m,g);return b&&n(y=>y.map(w=>w.id===m?b:w)),b}catch{return null}},[]),c=k.useCallback(async m=>{try{await se.canvasDelete(m),n(g=>g.filter(b=>b.id!==m))}catch{}},[]),h=k.useCallback(async m=>{try{const g=await se.canvasTogglePin(m);g&&n(b=>b.map(w=>w.id===m?g:w).sort((w,E)=>E.pinned!==w.pinned?E.pinned-w.pinned:E.createdAt.localeCompare(w.createdAt)))}catch{}},[]),f=k.useCallback(m=>m===null?t:t.filter(g=>g.nodeId===m),[t]),d=k.useCallback((m,g)=>{const b=m===null?t:t.filter(y=>y.nodeId===m);return g==="note"?b.filter(y=>y.artifactType==="user_note"):g==="practice"?b.filter(y=>y.artifactType==="quiz"):b.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:h,byNode:f,byZone:d}}const Ah={small:16,medium:17,large:18},Ch="lookatstudy-font-size",jN="medium";function HN(){const[e,t]=k.useState(()=>{if(typeof localStorage<"u"){const r=localStorage.getItem(Ch);if(r&&r in Ah)return r}return jN});k.useEffect(()=>{document.documentElement.style.fontSize=`${Ah[e]}px`,localStorage.setItem(Ch,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}}function UN(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 zN(e){return e.map((t,n)=>t.type!=="tool-call"||t.state!=="output-error"?!0:!e.some((r,s)=>s>n&&r.type==="tool-call"&&r.toolName===t.toolName&&(r.state==="input-available"||r.state==="output-available")))}const Tg="end_review_session",wg="[[review-kickoff]]";function VN(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n.role==="assistant"&&qN(n.parts))return"ended";if(n.role==="user"&&$N(n.parts).includes(wg))return"open"}return"open"}function qN(e){for(const t of e)if(t.type==="tool-call"&&t.toolName===Tg&&t.state==="output-available")return!0;return!1}function $N(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}const Ro=new Map;function WN({ref_:e,onOpen:t}){const n=$e(),[r,s]=k.useState(e.previewUrl??(e.file?Ro.get(e.file)??null:null));return k.useEffect(()=>{if(r||!e.file)return;let i=!1;return(async()=>{const a=Ro.get(e.file);if(a){i||s(a);return}const o=await se.getAttachmentDataUrl(e.file);o&&!i&&(Ro.set(e.file,o),s(o))})(),()=>{i=!0}},[e.file,r]),r?p.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:p.jsx("img",{src:r,alt:e.name,className:"w-full h-full object-cover"})}):p.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 YN({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]),p.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:[p.jsx("img",{src:e,alt:t,className:"max-w-full max-h-full object-contain rounded-lg shadow-elevated"}),p.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:p.jsx(_n,{className:"w-4 h-4"})})]})}function GN({parts:e}){const t=$e(),[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 p.jsxs("div",{className:"flex flex-col gap-1.5 mb-1","data-testid":"message-attachments",children:[i.length>0&&p.jsx("div",{className:"flex gap-1.5 flex-wrap",children:i.map((o,l)=>p.jsx(WN,{ref_:o,onOpen:u=>r({src:u,name:o.name})},o.file??o.previewUrl??`${o.name}:${l}`))}),a.length>0&&p.jsx("div",{className:"flex gap-1.5 flex-wrap",children:a.map((o,l)=>p.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:[p.jsx(Vi,{className:"w-3 h-3 shrink-0"}),p.jsx("span",{className:"truncate max-w-[12rem]",children:o.name})]},`${o.name}:${l}`))}),n&&p.jsx(YN,{src:n.src,name:n.name,onClose:()=>r(null)})]})}const KN=k.lazy(()=>_e(()=>import("./index-CmgjThXN.js"),__vite__mapDeps([30,1,2,28,29,31]),import.meta.url).then(e=>({default:e.ArtifactRenderer})));function XN({messages:e,streaming:t,onApplyProposal:n,onRejectProposal:r,onUndoProposal:s,summary:i,onStartLearning:a,agentReady:o=!0,onOpenModelManager:l,hasNode:u=!0,selectedNodeId:c,threadId:h,onSaveChatNote:f,chatNotes:d,onPickQuizAction:m,onQuizCompleted:g,cardMode:b=!1,reviewNextNodeId:y,onStartReviewSession:w}){const E=$e(),S=Mu(),v=mg();k.useEffect(()=>{if(v.failReason){const q=v.failReason==="engine-unavailable"?"chat.speech.engine_unavailable":v.failReason==="azure-key-missing"?"chat.speech.azure_key_missing":v.failReason==="azure-region-missing"?"chat.speech.azure_region_missing":v.failReason==="edge-failed"?"chat.speech.edge_failed":v.failReason==="custom-provider-missing"?"chat.speech.custom_provider_missing":"chat.speech.model_missing";S.show(E(q),{severity:"warning"}),v.clearFailReason()}},[v.failReason,S,E,v]),k.useEffect(()=>{v.onlineNotice&&(S.show(E("chat.speech.edge_disclosed"),{severity:"info"}),v.clearOnlineNotice())},[v.onlineNotice,S,E,v]);const T=k.useCallback((q,K,M)=>{c&&se.recordQuizAnswer(c,M,q.kc).catch(()=>{})},[c]),[_,A]=k.useState(null);k.useEffect(()=>{if(!c){A(null);return}let q=!1;const K=()=>se.getProgress(c).then(G=>{q||A((G==null?void 0:G.mastery)??null)}).catch(()=>{});K();const M=se.on("state:changed",G=>{G==="mastery"&&K()});return()=>{q=!0,M()}},[c]);const N=k.useRef(null),C=k.useRef(!0),[D,P]=k.useState(!1);k.useEffect(()=>{const q=K=>{const M=K.detail;if(!(M!=null&&M.msgId))return;const G=document.querySelector(`[data-msg-id="${M.msgId}"]`);G&&(G.scrollIntoView({behavior:"smooth",block:"center"}),G.classList.add("ring-2","ring-accent","rounded-lg"),setTimeout(()=>G.classList.remove("ring-2","ring-accent","rounded-lg"),2500))};return window.addEventListener("lookatstudy-highlight-message",q),()=>window.removeEventListener("lookatstudy-highlight-message",q)},[]),k.useEffect(()=>{if(t||!N.current||!d||d.length===0)return;const q=setTimeout(()=>{if(!N.current)return;const K=new Map;for(const M of d)try{const G=JSON.parse(M.sourceAnchor);if(G.type==="chat"&&G.msgId){const ae=JSON.parse(M.data).text??"";if(ae){const ne=K.get(G.msgId)??[];ne.push({noteId:M.id,text:ae}),K.set(G.msgId,ne)}}}catch{}for(const[M,G]of K){const ae=N.current.querySelector(`[data-msg-id="${M}"]`);ae&&(wi()?Q0(ae,G):K0(ae,G))}},150);return()=>clearTimeout(q)},[e,d,t]),k.useEffect(()=>{const q=K=>{var ae;const M=K.detail;if(!M)return;if(wi()){const ne=Z0(M);ne&&J0(ne);return}const G=(ae=N.current)==null?void 0:ae.querySelector(`mark[data-note-id="${M}"]`);G&&og(G)};return window.addEventListener("lookatstudy-jump-to-chat-note",q),()=>window.removeEventListener("lookatstudy-jump-to-chat-note",q)},[]);const[O,I]=k.useState(null),R=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,B=k.useCallback(()=>{if(!f||!h)return;const q=window.getSelection(),K=(q==null?void 0:q.toString().trim())??"";if(K.length<2||K.length>500){I(null);return}const M=q==null?void 0:q.getRangeAt(0);if(!M){I(null);return}const G=N.current;if(!(G!=null&&G.contains(M.commonAncestorContainer))){I(null);return}let ae=M.commonAncestorContainer,ne=null;for(;ae&&ae!==G;){if(ae instanceof HTMLElement&&ae.dataset.msgId){ne=ae;break}ae=ae.parentNode}if(!ne){I(null);return}const X=ne.dataset.msgId,te=ur(ne),ue=W0(M,te),ge=M.getBoundingClientRect(),Z=G.getBoundingClientRect(),re=M.getClientRects(),be=re.length?re[re.length-1]:ge,ve=ug({left:ge.left-Z.left,top:ge.top-Z.top,right:ge.right-Z.left,bottom:ge.bottom-Z.top,width:ge.width,height:ge.height},Z.width,R?150:110,{left:be.left-Z.left,top:be.top-Z.top,right:be.right-Z.left,bottom:be.bottom-Z.top,width:be.width,height:be.height},R);I({x:ve.left,y:ve.top,transform:ve.transform,text:K,msgId:X,startOffset:ue==null?void 0:ue.start,endOffset:ue==null?void 0:ue.end})},[f,h,R]);k.useEffect(()=>{const q=R?600:250;let K=null,M=null,G=!1;const ae=()=>{var ue;return(((ue=window.getSelection())==null?void 0:ue.toString().trim().length)??0)>=2},ne=()=>{ae()?(M&&(clearTimeout(M),M=null),I(ue=>ue&&null),K&&clearTimeout(K),K=setTimeout(()=>{K=null,!G&&ae()&&B()},q)):M||(M=setTimeout(()=>I(ue=>ue&&null),250))},X=ue=>{var Z;const ge=ue.target;(Z=ge==null?void 0:ge.closest)!=null&&Z.call(ge,"[data-selection-popover]")||(G=!0)},te=()=>{G=!1,K&&(clearTimeout(K),K=null),!M&&ae()&&B()};return document.addEventListener("selectionchange",ne),window.addEventListener("pointerdown",X,!0),window.addEventListener("pointerup",te,!0),window.addEventListener("pointercancel",te,!0),()=>{document.removeEventListener("selectionchange",ne),window.removeEventListener("pointerdown",X,!0),window.removeEventListener("pointerup",te,!0),window.removeEventListener("pointercancel",te,!0),K&&clearTimeout(K),M&&clearTimeout(M)}},[B]);const V=k.useCallback(()=>{var K;if(!O||!f)return;const q=O.text.length>200?O.text.slice(0,200)+"…":O.text;f(q,O.msgId,O.startOffset,O.endOffset),I(null),(K=window.getSelection())==null||K.removeAllRanges()},[O,f]),z=k.useCallback(()=>{const q=N.current;if(!q)return;const K=q.scrollHeight-q.scrollTop-q.clientHeight<80;C.current=K,P(M=>M===!K?M:!K)},[]);k.useEffect(()=>{if(!C.current)return;const q=N.current;q&&(q.scrollTop=q.scrollHeight)},[e,t]);const Y=e.length>0&&e[e.length-1].role==="user";k.useEffect(()=>{if(!Y)return;C.current=!0,P(!1);const q=N.current;q&&(q.scrollTop=q.scrollHeight)},[Y]);const L=k.useCallback(()=>{const q=N.current;q&&(q.scrollTop=q.scrollHeight,C.current=!0,P(!1))},[]);return p.jsxs("div",{className:"relative flex-1 min-h-0",children:[p.jsxs("div",{ref:N,onScroll:z,className:`h-full overflow-y-auto px-3 py-4 space-y-2 relative ${b?"":"px-5 py-6 space-y-6"}`,"data-testid":"chat-stream",children:[e.length===0&&p.jsx("div",{className:"mt-10 mx-auto max-w-md","data-testid":"chat-empty-state",children:u?p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"text-center mb-4",children:[p.jsx("div",{className:"text-4xl mb-2 opacity-30",children:"📖"}),p.jsx("div",{className:"text-body font-bold text-ink-muted mb-1",children:E("chat.empty.greeting")}),p.jsx("div",{className:"text-ink-muted text-label",children:E("chat.empty.overview")})]}),i?p.jsxs("div",{className:"surface-card p-4 mb-4",children:[p.jsx("div",{className:"text-caption font-bold text-brand uppercase tracking-wider mb-2",children:E("chat.empty.summary.title")}),p.jsx("div",{className:"text-body text-ink-muted leading-relaxed whitespace-pre-wrap",children:i})]}):p.jsx("div",{className:"surface-card p-4 mb-4 text-center",children:p.jsx("div",{className:"text-body text-ink-muted",children:E("chat.empty.summary.none")})}),o?p.jsx(p.Fragment,{children:a&&p.jsxs("button",{onClick:a,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:[p.jsx(Zx,{className:"w-4 h-4"}),p.jsx("span",{children:E("chat.empty.start")})]})}):p.jsxs("div",{className:"surface-card p-4 mb-2","data-testid":"keyless-card",children:[p.jsx("div",{className:"text-body font-bold text-ink-muted mb-1",children:E("chat.empty.keyless.title")}),p.jsx("div",{className:"text-label text-ink-muted mb-3",children:E("chat.empty.keyless.desc")}),p.jsxs("button",{onClick:l,className:"btn-3d-brand w-full py-2 text-body font-bold flex items-center justify-center gap-2",children:[p.jsx(Ws,{className:"w-4 h-4"}),p.jsx("span",{children:E("chat.empty.keyless.btn")})]})]})]}):p.jsxs("div",{className:"text-center mt-16","data-testid":"no-node-selected",children:[p.jsx("div",{className:"text-5xl mb-3 opacity-25",children:"🗺️"}),p.jsx("div",{className:"text-body font-bold text-ink-muted mb-1",children:E("chat.empty.no_node.title")}),p.jsx("div",{className:"text-body text-ink-muted max-w-xs mx-auto",children:E("chat.empty.no_node.desc")})]})}),e.map(q=>p.jsx("div",{className:b?"":"contents",children:p.jsx("div",{className:b&&q.role==="assistant"?"surface-card p-4 rounded-2xl shadow-card":void 0,children:p.jsx(QN,{msg:q,onApplyProposal:n,onRejectProposal:r,onUndoProposal:s,onQuizAnswered:T,quizMastery:_,onPickAction:m,onQuizCompleted:g,reviewNextNodeId:y,onStartReviewSession:w,speakingMessageId:v.speakingMessageId,speakingSentence:v.speakingSentence,playingSentence:v.playingSentence,streamTexts:v.streamTexts,onSpeak:v.speak})})},q.id)),t&&p.jsxs("div",{className:"flex items-center gap-1.5 text-body text-brand",children:[p.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),p.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),p.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"})]})]}),D&&e.length>0&&p.jsxs("button",{onClick:L,"data-testid":"scroll-to-bottom","aria-label":E("chat.scroll.bottom"),title:E("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:[p.jsx(pa,{className:"w-5 h-5"}),t&&p.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"})]}),O&&p.jsxs("button",{onClick:V,"data-testid":"save-chat-note-btn","data-selection-popover":!0,style:{left:O.x,top:O.y,transform:O.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:E("chat.note.add.title"),children:[p.jsx(Ri,{className:"w-3 h-3"})," ",E("chat.note.add")]})]})}function _h(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 QN({msg:e,onApplyProposal:t,onRejectProposal:n,onUndoProposal:r,onQuizAnswered:s,quizMastery:i,onPickAction:a,onQuizCompleted:o,reviewNextNodeId:l,onStartReviewSession:u,speakingMessageId:c,speakingSentence:h,playingSentence:f,streamTexts:d,onSpeak:m}){const g=$e(),b=k.useRef(null),y=e.parts.map(v=>v.type==="text"?v.text:"").join("").trim(),w=c===e.id,E=w&&f!=null?f.index:null;k.useEffect(()=>{const v=b.current;if(!v)return;if(E==null){ir(v);return}const T=q0(d??[],E);if(!T)return;E===0&&ig(v);const _=setTimeout(()=>{const A=sg(v,T,{within:'[data-testid="part-text"]'});A&&ag(A,v.closest(".overflow-y-auto"))},30);return()=>clearTimeout(_)},[E,d]),k.useEffect(()=>{E==null&&b.current&&ir(b.current)},[E]);const S=k.useRef(!1);return S.current=E!=null,k.useEffect(()=>()=>{S.current&&ir(document.body)},[]),e.role==="user"?p.jsx("div",{className:"msg-enter flex justify-end","data-testid":"msg-user","data-msg-id":e.id,children:p.jsxs("div",{className:"max-w-[85%] bg-ink/[0.04] rounded-2xl rounded-br-md px-4 py-2.5",children:[p.jsx(GN,{parts:e.parts}),p.jsx("div",{className:"font-medium text-ink-strong whitespace-pre-wrap select-text text-body",children:e.displayText??e.parts.map((v,T)=>v.type==="text"?p.jsx("span",{children:v.text},T):null)})]})}):p.jsxs("div",{className:"msg-enter",ref:b,"data-testid":"msg-assistant","data-msg-id":e.id,children:[p.jsx("div",{className:"min-w-0 space-y-2.5",children:(()=>{const v=zN(e.parts);return e.parts.map((T,_)=>v[_]?p.jsx(ZN,{part:T,msgId:e.id,toolCallIdx:_,onApplyProposal:t,onRejectProposal:n,onUndoProposal:r,onQuizAnswered:s,quizMastery:i,onPickAction:a,onQuizCompleted:o,reviewNextNodeId:l,onStartReviewSession:u},_):null)})()}),m&&y&&p.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[p.jsx("button",{onClick:()=>m(e.id,y),"data-testid":w?"speech-stop-btn":"speech-speak-btn","aria-label":g(w?"chat.speech.stop":"chat.speech.speak"),title:g(w?"chat.speech.stop":"chat.speech.speak"),className:`w-7 h-7 rounded-lg flex items-center justify-center transition ${w?"bg-brand/15 text-brand":"text-ink-muted hover:bg-ink/[0.06] hover:text-ink"}`,children:w?p.jsx(iu,{className:"w-3.5 h-3.5"}):p.jsx(Rm,{className:"w-4 h-4"})}),w&&h&&h.total>0&&p.jsx("span",{className:"text-caption text-ink-muted",children:g("chat.speech.progress").replace("{n}",String(h.index+1)).replace("{total}",String(h.total))})]})]})}function ZN({part:e,msgId:t,toolCallIdx:n,onApplyProposal:r,onRejectProposal:s,onUndoProposal:i,onQuizAnswered:a,quizMastery:o,onPickAction:l,onQuizCompleted:u,reviewNextNodeId:c,onStartReviewSession:h}){const f=V0(e.type==="text"?e.text:"");if(e.type==="text")return p.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:p.jsx(Ip,{remarkPlugins:f.remarkPlugins,rehypePlugins:f.rehypePlugins,components:tI,children:lg(e.text)})});if(e.type==="reasoning")return p.jsx(JN,{text:e.text});if(e.type!=="tool-call")return null;const{toolName:d,state:m,output:g,error:b}=e;return p.jsx(eI,{toolName:d,state:m,output:g,error:b,msgId:t,toolCallIdx:n,onApplyProposal:r,onRejectProposal:s,onUndoProposal:i,onQuizAnswered:a,quizMastery:o,onPickAction:l,onQuizCompleted:u,reviewNextNodeId:c,onStartReviewSession:h})}function JN({text:e}){const t=$e(),[n,r]=k.useState(!1);return p.jsxs("div",{className:"rounded-lg bg-surface-1/60 border border-[var(--border-faint)]","data-testid":"part-reasoning",children:[p.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:[p.jsxs("span",{children:[n?"▾":"▸"," ",t("chat.reasoning.label")]}),p.jsx("span",{className:"text-ink-muted font-normal",children:t("chat.reasoning.chars",{n:e.length})})]}),n&&p.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 eI({toolName:e,state:t,output:n,error:r,msgId:s,toolCallIdx:i,onApplyProposal:a,onRejectProposal:o,onUndoProposal:l,onQuizAnswered:u,quizMastery:c,onPickAction:h,onQuizCompleted:f,reviewNextNodeId:d,onStartReviewSession:m}){const g=$e(),[b,y]=k.useState(!1);k.useEffect(()=>{if(!b)return;const T=window.setTimeout(()=>y(!1),3e3);return()=>window.clearTimeout(T)},[b]);const w=e==="record_answer"||e==="mark_mastered";if(e==="update_learner_profile"&&t==="output-available")return p.jsxs("div",{className:"rounded-xl border border-ink/10 bg-ink/5 p-3 flex items-center gap-2","data-testid":"part-profile-suggest",children:[p.jsx(oy,{className:"w-4 h-4 text-accent shrink-0"}),p.jsx("span",{className:"text-label text-ink-muted",children:g("chat.profile_sent")})]});if(e===Tg&&t==="output-available"&&n&&typeof n=="object"&&n.status==="ended"){const T=n,_=String(T.quality);return p.jsxs("div",{className:"rounded-xl border border-gold/30 bg-gold/5 overflow-hidden","data-testid":"review-outcome-card",children:[p.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 border-b border-[var(--border-faint)]",children:[p.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-lg bg-gold/15 text-gold shrink-0",children:p.jsx(Lc,{className:"w-4 h-4"})}),p.jsx("span",{className:"text-lead font-bold text-ink",children:g("review.outcome.title")}),p.jsx("span",{className:`ml-auto px-2 py-0.5 rounded-full text-label font-bold ${T.quality>=4?"bg-brand/15 text-brand":T.quality>=3?"bg-accent/15 text-accent":"bg-review/15 text-review"}`,"data-testid":"review-outcome-quality",children:g(`review.outcome.quality.${_}`)})]}),p.jsxs("div",{className:"px-4 py-3 space-y-2",children:[T.summary&&p.jsx("div",{className:"text-body text-ink leading-relaxed",children:T.summary}),T.weakPoints&&T.weakPoints.length>0&&p.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[p.jsx("span",{className:"text-caption font-bold text-ink-muted",children:g("review.outcome.weak")}),T.weakPoints.map((A,N)=>p.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-3 text-label text-ink-muted",children:A},N))]}),p.jsxs("div",{className:"flex items-center gap-1.5 text-label text-ink-muted","data-testid":"review-outcome-next",children:[p.jsx(Ax,{className:"w-3.5 h-3.5 shrink-0"}),T.intervalDays===1?g("review.outcome.tomorrow"):g("review.outcome.next",{n:String(T.intervalDays)})]}),d&&m&&p.jsxs("button",{onClick:()=>m(d),"data-testid":"review-outcome-next-lesson",className:"btn-3d-neutral px-3 py-1.5 text-body",children:[p.jsx(Lc,{className:"w-3.5 h-3.5 inline"}),g("review.outcome.nextLesson")]})]})]})}const E=w&&t==="output-available"&&typeof n=="object"&&n!==null?n:null;if(E!=null&&E.proposalId){const T=E.status,_=!!E.undone,A=!!E.canUndo;return T==="applied"&&_?p.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-undone",children:[p.jsx(Fc,{className:"w-4 h-4 text-ink-muted shrink-0"}),p.jsx("span",{className:"text-body text-ink-muted",children:g("chat.proposal.undone")})]}):T==="applied"?p.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:[p.jsx(nu,{className:"w-4 h-4 text-gold shrink-0"}),p.jsx("span",{className:"text-body font-bold text-ink",children:g("chat.proposal.applied")}),A&&l&&p.jsxs("button",{type:"button",onClick:()=>{b?(y(!1),l(E.proposalId,s,i)):y(!0)},"data-testid":b?"proposal-undo-confirm":"proposal-undo",className:`ml-auto px-3 py-1 rounded-full text-caption font-medium flex items-center gap-1 transition-colors ${b?"bg-warning/20 text-warning":"text-ink-muted hover:text-ink-strong hover:bg-ink/[0.06]"}`,children:[p.jsx(Fc,{className:"w-3.5 h-3.5"}),g(b?"chat.proposal.undo_confirm":"chat.proposal.undo")]})]}):T==="rejected"?p.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:[p.jsx(Nx,{className:"w-4 h-4 text-ink-muted shrink-0"}),p.jsx("span",{className:"text-body text-ink-muted",children:g("chat.proposal.rejected")})]}):p.jsxs("div",{className:"proposal-card relative rounded-xl border border-brand/30 bg-brand/5 overflow-hidden","data-testid":"part-proposal",children:[p.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 bg-brand"}),p.jsxs("div",{className:"pl-4 pr-3 py-3",children:[p.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[p.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-lg bg-brand/15 text-brand shrink-0",children:p.jsx(xm,{className:"w-4 h-4"})}),p.jsx("span",{className:"text-lead font-bold text-ink",children:g("chat.proposal.mastered.title")})]}),E.message&&p.jsx("div",{className:"text-body text-ink mb-2 leading-relaxed",children:E.message}),p.jsx("div",{className:"text-caption text-ink-muted mb-3",children:g("chat.proposal.mastered.hint")}),p.jsxs("div",{className:"flex gap-2",children:[p.jsxs("button",{onClick:()=>a==null?void 0:a(E.proposalId,s,i),"data-testid":"proposal-apply",className:"btn-3d-brand px-4 py-1.5 text-body",children:[p.jsx(xn,{className:"w-3.5 h-3.5 inline"}),g("chat.proposal.confirm")]}),p.jsx("button",{onClick:()=>o==null?void 0:o(E.proposalId,s,i),"data-testid":"proposal-reject",className:"btn-3d-neutral px-4 py-1.5 text-body",children:g("chat.proposal.later")})]})]})]})}if(t==="output-available"&&n&&typeof n=="object"&&"artifactType"in n){const T=n.artifactType;return p.jsx("div",{className:"my-1 max-w-full","data-testid":`inline-artifact-${T}`,"data-tool":e,children:p.jsx(k.Suspense,{fallback:null,children:p.jsx(KN,{data:n,onQuizAnswered:u,quizMastery:c,onPickAction:h,onQuizCompleted:f})})})}const v=nI(e,g);return p.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"?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),p.jsxs("span",{className:"text-ink-muted",children:[v,"…"]})]}):t==="output-error"?p.jsxs(p.Fragment,{children:[p.jsx(pm,{className:"w-3.5 h-3.5 text-warning shrink-0"}),p.jsxs("span",{className:"text-warning",children:[v,": ",r]})]}):p.jsxs(p.Fragment,{children:[p.jsx(Mm,{className:"w-3.5 h-3.5 text-ink-faint shrink-0"}),p.jsx("span",{className:"text-ink-muted",children:v})]})})}const tI={pre({children:e,...t}){return p.jsx(xg,{...t,children:e})},a({children:e,...t}){return p.jsx("a",{...t,target:"_blank",rel:"noopener noreferrer",children:e})},table({children:e}){return p.jsx("div",{className:"overflow-x-auto my-4",children:p.jsx("table",{children:e})})}};function nI(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"),end_review_session:t("chat.tool.end_review_session")}[e]??e}const Si={maxPerMessage:4,maxImageBytes:5*1024*1024,maxTextBytes:256*1024},rI=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 Nh(e){const t=e.lastIndexOf(".");return t<=0||t===e.length-1?"":e.slice(t+1).toLowerCase()}function iI(e,t,n){return t&&t.startsWith("image/")||["png","jpg","jpeg","webp","gif","bmp"].includes(Nh(e))?n>Si.maxImageBytes?{ok:!1,reason:"tooLargeImage"}:{ok:!0,kind:"image"}:rI.has(Nh(e))?n>Si.maxTextBytes?{ok:!1,reason:"tooLargeText"}:{ok:!0,kind:"text"}:{ok:!1,reason:"unsupported"}}const Ih=/[\u3400-\u9fff\u3000-\u303f\uff00-\uffef]/,sI=/^[,。、;:?!,.!?;:…—))」』》〉]/;function aI(e,t){if(!t)return e;if(!e)return t;if(/\s$/.test(e)||sI.test(t))return e+t;const n=e[e.length-1];return Ih.test(n)||Ih.test(t[0])?e+t:`${e} ${t}`}function oI(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 lI(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 uI(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 cI(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(h,f){a==null&&(a=f);const d=u==null?0:Math.max(0,f-u);if(u=f,h>=t)o+=d,o>=n&&(c=!0,l=f);else if(i&&c&&l!=null&&f-l>=r)return"auto-stop";return i&&f-a>=s?"auto-stop":"listening"},hadSpeech(){return c}}}const Mo=16e3;function dI(e,t={}){const[n,r]=k.useState(!1),[s,i]=k.useState(!1),[a,o]=k.useState(0),[l,u]=k.useState(null),[c,h]=k.useState(null),f=k.useRef(null),d=k.useRef(null),m=k.useRef(null),g=k.useRef([]),b=k.useRef([]),y=k.useRef(!1),w=k.useRef(null),E=k.useRef(0),S=k.useRef(e);S.current=e;const v=k.useRef(t);v.current=t;const T=k.useRef(!1),_=k.useRef(!1),A=k.useCallback(()=>{var O,I,R;y.current=!1,(O=m.current)==null||O.disconnect(),m.current=null,(I=d.current)==null||I.getTracks().forEach(B=>B.stop()),d.current=null,(R=f.current)==null||R.close().catch(()=>{}),f.current=null,g.current=[],b.current=[],w.current=null,o(0)},[]),N=k.useCallback(()=>{var K;const O=g.current,I=b.current,R=((K=w.current)==null?void 0:K.hadSpeech())??!1;g.current=[],b.current=[];let B=0;for(const M of O)B+=M.length;if(A(),r(!1),B===0)return;if(!R){h("no-speech");return}const V=uI(O,I);let z=0;for(const M of V)z+=M.length;const Y=new Float32Array(z);let L=0;for(const M of V)Y.set(M,L),L+=M.length;const q=oI(Y,Mo);i(!0),h(null),window.api.asrTranscribe(q,v.current.locale).then(M=>{M.ok?S.current(M.text):h(M.reason)}).catch(()=>h("asr-failed")).finally(()=>i(!1))},[A]),C=k.useCallback(()=>{y.current&&N()},[N]),D=k.useCallback(()=>{y.current||T.current||(u(null),T.current=!0,(async()=>{var O;try{if(((O=navigator.mediaDevices)==null?void 0:O.getUserMedia)==null){u(window.isSecureContext?"mic-unavailable":"mic-insecure-context");return}const I=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}}),R=window.AudioContext??window.webkitAudioContext;let B;try{B=new R({sampleRate:Mo})}catch{B=new R}f.current=B,d.current=I,y.current=!0,w.current=cI({autoStop:v.current.autoStop!==!1});const V=B.createMediaStreamSource(I),z=B.createScriptProcessor(4096,1,1);m.current=z;const Y=B.sampleRate/Mo;z.onaudioprocess=q=>{var X;if(!y.current)return;const K=q.inputBuffer.getChannelData(0),M=Y===1?new Float32Array(K):lI(K,Y);g.current.push(M);let G=0;for(let te=0;te<M.length;te++)G+=M[te]*M[te];const ae=Math.sqrt(G/M.length);b.current.push(ae),E.current=E.current*.7+ae*.3,o(Math.min(1,E.current*8)),$b(Math.min(1,E.current*8)),((X=w.current)==null?void 0:X.feed(ae,performance.now()))==="auto-stop"&&y.current&&N()},V.connect(z);const L=B.createGain();L.gain.value=0,z.connect(L),L.connect(B.destination),r(!0),_.current&&(_.current=!1,N())}catch(I){A(),r(!1),u(I instanceof Error?I.message:String(I))}finally{T.current=!1}})())},[A,N]),P=k.useCallback(()=>{y.current?C():T.current&&(_.current=!0)},[C]);return k.useEffect(()=>()=>{y.current&&A()},[A]),{listening:n,transcribing:s,level:a,startError:l,transcribeError:c,clearTranscribeError:()=>h(null),beginHold:D,endHold:P}}function hI(e){return!e||e.input===null||e.input===void 0?null:`$${String(Number(e.input.toFixed(2)))}`}function fI({onOpenModelManager:e}){var g;const t=$e(),[n,r]=k.useState(!1),[s,i]=k.useState(null),[a,o]=k.useState(""),[l,u]=k.useState(""),c=k.useRef(null),h=k.useCallback(async()=>{var b,y;try{const[w,E,S,v]=await Promise.all([se.getProviderPresets(),se.listCustomProviders(),se.getSetting("active_provider"),se.getSetting("active_model")]),T=S??"glm",_=await Promise.all(w.map(async O=>await se.hasSetting(O.apiKeySetting))),A=new Set;w.forEach((O,I)=>{(_[I]||O.id===T)&&A.add(O.id)});const N=[],C=(O,I,R)=>{for(const B of R)N.push({providerId:O,providerLabel:I,modelId:B.id,modelLabel:B.label,vision:(B.capabilities??[]).includes("vision"),contextWindow:B.contextWindow,...B.reasoning!==void 0?{reasoning:B.reasoning}:{},...B.free!==void 0?{free:B.free}:{},...B.pricing!==void 0?{pricing:B.pricing}:{},...B.status!==void 0?{status:B.status}:{}})};for(const O of w)A.has(O.id)&&C(O.id,O.label,O.models);const D=E.filter(O=>O.kind==="llm");for(const O of D)C(O.id,O.label,O.models);const P=v??"";if(P&&!N.some(O=>O.providerId===T&&O.modelId===P)){const O=((b=w.find(I=>I.id===T))==null?void 0:b.label)??((y=D.find(I=>I.id===T))==null?void 0:y.label)??T;N.unshift({providerId:T,providerLabel:O,modelId:P,modelLabel:P,vision:!0,contextWindow:null})}i(N),o(T),u(P)}catch{i([])}},[]);k.useEffect(()=>{h();const b=()=>void h();return window.addEventListener("llm-config-changed",b),()=>window.removeEventListener("llm-config-changed",b)},[h]),k.useEffect(()=>{if(!n)return;const b=w=>{var E;w.target instanceof Node&&((E=c.current)==null?void 0:E.contains(w.target))!==!0&&r(!1)},y=w=>{w.key==="Escape"&&r(!1)};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",y),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",y)}},[n]);const f=async b=>{if(r(!1),!(b.providerId===a&&b.modelId===l))try{await se.setSetting("active_provider",b.providerId),await se.setSetting("active_model",b.modelId),o(b.providerId),u(b.modelId),window.dispatchEvent(new Event("llm-config-changed"))}catch{}},d=((g=s==null?void 0:s.find(b=>b.providerId===a&&b.modelId===l))==null?void 0:g.modelLabel)??l??t("model.picker.label"),m=[];for(const b of s??[]){const y=m[m.length-1];y&&y.label===b.providerLabel?y.rows.push(b):m.push({label:b.providerLabel,rows:[b]})}return p.jsxs("div",{ref:c,className:"relative","data-testid":"composer-model",children:[p.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:[p.jsx(Sx,{className:"w-3 h-3 shrink-0 coarse-only","aria-hidden":!0}),p.jsx("span",{className:"truncate tb-label",children:d}),p.jsx(mm,{className:`w-3 h-3 shrink-0 tb-chevron transition-transform ${n?"":"rotate-180"}`})]}),n&&p.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&&p.jsx("div",{className:"px-3 py-2 text-caption text-ink-faint",children:t("model.picker.noneConfigured")}),m.map(b=>p.jsxs("div",{role:"group","aria-label":b.label,children:[p.jsx("div",{className:"px-3 pt-1.5 pb-0.5 text-caption font-bold text-ink-faint",children:b.label}),b.rows.map(y=>{const w=y.providerId===a&&y.modelId===l,E=y.free?t("model.picker.free"):hI(y.pricing),S=y.pricing&&(y.pricing.input!==null||y.pricing.output!==null)?t("model.picker.price",{i:y.pricing.input===null?"?":String(Number(y.pricing.input.toFixed(2))),o:y.pricing.output===null?"?":String(Number(y.pricing.output.toFixed(2)))}):null,v=y.status==="deprecated";return p.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":w,onClick:()=>void f(y),className:`w-full flex items-center gap-1.5 px-3 py-1.5 text-left transition-colors ${w?"text-brand":"text-ink-strong hover:bg-ink/[0.06]"} ${v?"opacity-55":""}`,children:[p.jsx(xn,{className:`w-3.5 h-3.5 shrink-0 ${w?"opacity-100":"opacity-0"}`}),p.jsx("span",{className:`flex-1 truncate text-label ${v?"line-through decoration-ink-faint":""}`,children:y.modelLabel}),y.reasoning&&p.jsx(fm,{className:"w-3 h-3 shrink-0 text-ink-faint","aria-label":t("model.picker.reasoning")}),y.vision&&p.jsx(Mx,{className:"w-3 h-3 shrink-0 text-ink-faint","aria-label":t("model.picker.vision")}),E&&S&&p.jsx("span",{className:"shrink-0 text-caption text-ink-faint tabular-nums","data-tooltip":S,children:E})]},`${y.providerId}:${y.modelId}`)})]},b.label)),p.jsx("div",{className:"border-t border-[var(--border)] mt-1 pt-1",children:p.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:[p.jsx(ty,{className:"w-3.5 h-3.5"}),t("model.picker.manage")]})})]})]})}const El=5.5,Rh=2*Math.PI*El,br=["system","node","learner","history","draft"],Mh={system:"bg-accent",node:"bg-brand",learner:"bg-gold",history:"bg-ink/50",draft:"bg-exam"};function mI({info:e,historyTokens:t,draftTokens:n}){const r=$e(),[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 f=m=>{var g;m.target instanceof Node&&((g=a.current)==null?void 0:g.contains(m.target))!==!0&&i(!1)},d=m=>{m.key==="Escape"&&i(!1)};return document.addEventListener("pointerdown",f),document.addEventListener("keydown",d),()=>{document.removeEventListener("pointerdown",f),document.removeEventListener("keydown",d)}},[s]),!e)return null;const o={system:e.systemTokens,node:e.nodeTokens,learner:e.learnerTokens,history:t,draft:n},l=br.reduce((f,d)=>f+o[d],0),u=cy(l,e.contextWindow),c=u!==null&&u>=85,h=dy(br.map(f=>o[f]),u??0);return p.jsxs("span",{ref:a,className:"relative inline-flex items-center","data-testid":"composer-context",children:[p.jsxs("button",{type:"button",onClick:()=>i(!s),disabled:e.contextWindow===null,"aria-label":r("context.aria",{p:u!==null?`${u}%`:mr(l)}),"aria-haspopup":"dialog","aria-expanded":s,"data-testid":"composer-context-trigger","data-tooltip":e.contextWindow===null?`${r("context.label")} ~${mr(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:[p.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":!0,className:"shrink-0",children:[p.jsx("circle",{cx:"7",cy:"7",r:El,fill:"none",strokeWidth:"2",className:"stroke-ink/20"}),p.jsx("circle",{cx:"7",cy:"7",r:El,fill:"none",strokeWidth:"2",stroke:"currentColor",strokeLinecap:"round",strokeDasharray:`${Rh*(u??100)/100} ${Rh}`,transform:"rotate(-90 7 7)"})]}),u!==null?p.jsxs("span",{className:"tb-label",children:[u,"%"]}):p.jsxs("span",{className:"tb-label",children:["~",mr(l)]})]}),s&&e.contextWindow!==null&&p.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:[p.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[p.jsx("span",{className:"text-label font-bold text-ink-strong",children:r("context.label")}),p.jsxs("span",{className:`text-caption ${c?"text-warning":"text-ink-muted"}`,children:[r("context.approx")," ",mr(l)," / ",mr(e.contextWindow)]})]}),p.jsx("div",{className:"flex h-2 rounded-full overflow-hidden bg-ink/10 mb-2",role:"img","aria-label":`${u}%`,children:br.map(f=>h[br.indexOf(f)]>0?p.jsx("div",{className:Mh[f],style:{width:`${h[br.indexOf(f)]}%`}},f):null)}),p.jsx("dl",{className:"space-y-1",children:br.map(f=>p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("dt",{className:"flex items-center gap-1.5 text-caption text-ink-muted",children:[p.jsx("span",{className:`w-2 h-2 rounded-sm ${Mh[f]}`,"aria-hidden":!0}),r(`context.${f}`)]}),p.jsxs("dd",{className:"text-caption text-ink-strong tabular-nums",children:["~",mr(o[f])]})]},f))}),e.pricing&&(e.pricing.input!==null||e.pricing.output!==null)&&p.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border-faint)] text-caption text-ink-faint tabular-nums","data-testid":"context-price",children:r("context.price",{i:e.pricing.input===null?"?":String(Number(e.pricing.input.toFixed(2))),o:e.pricing.output===null?"?":String(Number(e.pricing.output.toFixed(2)))})})]})]})}const kl={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}},deepseek:{fast:e=>{e.thinking={type:"disabled"}},deep:e=>{e.thinking={type:"enabled"}}},kimi:{fast:e=>{e.thinking={type:"disabled"}},deep:e=>{e.thinking={type:"enabled"}}},volcano:{fast:e=>{e.thinking={type:"disabled"},e.reasoning_effort="low"},deep:e=>{e.thinking={type:"enabled"}}},stepfun:{fast:e=>{e.enable_thinking=!1},deep:e=>{e.enable_thinking=!0}},"grok-effort":{fast:e=>{e.reasoning_effort="low"},deep:e=>{e.reasoning_effort="high"}}};function pI(e,t,n){if(e==="openai"||e in kl)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":r.includes("deepseek")||s.startsWith("deepseek-")?"deepseek":r.includes("moonshot")||s.startsWith("kimi-")?"kimi":r.includes("volces.com")||s.startsWith("doubao-")?"volcano":r.includes("stepfun")||s.startsWith("step-")?"stepfun":(r.includes("x.ai")||s.startsWith("grok-"))&&/^(grok-3-mini|grok-4\.(?:[3-9]|\d{2,}))/.test(s)?"grok-effort":e}function gI(e,t,n){return t==="anthropic"||t==="google"||e==="openai"||e in kl?!0:pI(e,n==null?void 0:n.baseUrl,n==null?void 0:n.model)in kl}const Po=[{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 bI(){const e=$e(),[t,n]=k.useState(!1),[r,s]=k.useState(""),[i,a]=k.useState(!0),[o,l]=k.useState(!1),u=k.useRef(null),c=k.useRef(null),[h,f]=k.useState("right"),[d,m]=k.useState(0),g=k.useRef(0),[b,y]=k.useState(0);k.useLayoutEffect(()=>{if(!t){y(0),g.current=0,m(0);return}const v=c.current;if(!v)return;const T=v.getBoundingClientRect(),_=T.left-g.current,A=T.right-g.current,N=window.innerWidth;if(b===0){if(_<8&&A<=N-8){f("left"),y(1);return}if(A>N-8&&_>=8){f("right"),y(1);return}y(1)}const C=Math.min(0,N-8-A)+Math.max(0,8-_);C!==g.current&&(g.current=C,m(C))},[t,b]);const w=k.useCallback(async()=>{var v;try{const[T,_,A,N,C]=await Promise.all([se.getSetting("active_provider"),se.getSetting("reasoning_effort"),se.getProviderPresets(),se.listCustomProviders(),se.getSetting("active_model")]),D=T??"glm",P=N.find(B=>B.id===D),O=((v=A.find(B=>B.id===D))==null?void 0:v.protocol)??(P==null?void 0:P.protocol)??"openai-compatible";a(gI(D,O,{baseUrl:P==null?void 0:P.baseUrl,model:C??(P==null?void 0:P.defaultModel)}));const I=await se.getModelMeta(D,C??(P==null?void 0:P.defaultModel)??"").catch(()=>null);l((I==null?void 0:I.reasoning)===!1);const R=_??"";s(R==="fast"||R==="deep"?R:"")}catch{a(!1)}},[]);k.useEffect(()=>{w();const v=()=>void w();return window.addEventListener("llm-config-changed",v),()=>window.removeEventListener("llm-config-changed",v)},[w]),k.useEffect(()=>{if(!t)return;const v=_=>{var A;_.target instanceof Node&&((A=u.current)==null?void 0:A.contains(_.target))!==!0&&n(!1)},T=_=>{_.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",T),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",T)}},[t]);const E=async v=>{if(n(!1),v!==r&&!(v==="deep"&&o)){s(v);try{await se.setSetting("reasoning_effort",v)}catch{s(r)}}},S=Po.find(v=>v.value===r)??Po[0];return p.jsxs("div",{ref:u,className:"relative","data-testid":"composer-effort",children:[p.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:[p.jsx(fm,{className:"w-3 h-3 shrink-0"}),p.jsx("span",{className:"truncate tb-label",children:e(S.labelKey)}),p.jsx(mm,{className:`w-3 h-3 shrink-0 tb-chevron transition-transform ${t?"":"rotate-180"}`})]}),t&&p.jsx("div",{ref:c,role:"menu","aria-label":e("effort.label"),"data-testid":"composer-effort-menu",style:{transform:d?`translateX(${d}px)`:void 0},className:`absolute bottom-full ${h==="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:Po.map(v=>{const T=v.value===r,_=v.value==="deep"&&o;return p.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":T,disabled:_,onClick:()=>void E(v.value),className:`w-full flex items-start gap-1.5 px-3 py-1.5 text-left transition-colors ${T?"text-brand":"text-ink-strong hover:bg-ink/[0.06]"} ${_?"opacity-40 cursor-not-allowed":""}`,children:[p.jsx(xn,{className:`w-3.5 h-3.5 shrink-0 mt-0.5 ${T?"opacity-100":"opacity-0"}`}),p.jsxs("span",{className:"flex-1",children:[p.jsx("span",{className:"block text-label font-bold",children:e(v.labelKey)}),p.jsx("span",{className:"block text-caption text-ink-faint",children:e(_?"effort.not_reasoning":v.descKey)})]})]},v.value||"auto")})})]})}const xI=k.lazy(()=>_e(()=>import("./VoicePanel-DvTnIP2j.js"),__vite__mapDeps([32,1,2,31]),import.meta.url).then(e=>({default:e.VoicePanel}))),yI={direct:"soul.direct",guide:"soul.guide",practice:"soul.practice"},vI={direct:Jt,guide:bm,practice:Ox},EI={direct:"soul.direct.desc",guide:"soul.guide.desc",practice:"soul.practice.desc"},kI=["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 Ph=0;function TI({nodeId:e,agentReady:t,streaming:n,souls:r,activeSoul:s,starterPrompts:i,onPickSoul:a,onSend:o,onStop:l,onLogFriction:u,onOpenModelManager:c,insertText:h,historyTokens:f,reviewMode:d=!1}){const m=$e(),g=ba(),[b,y]=k.useState(""),[w,E]=k.useState([]),[S,v]=k.useState(null),[T,_]=k.useState(null),[A,N]=k.useState(!1),C=k.useRef(null),D=k.useRef(0),[P,O]=k.useState(!0);k.useEffect(()=>{se.getSetting("asr_auto_stop").then(ie=>O(ie!=="0"))},[]);const[I,R]=k.useState(!1);k.useEffect(()=>(Cc(I),()=>Cc(!1)),[I]);const[B,V]=k.useState(""),[z,Y]=k.useState(!1),[L,q]=k.useState(null),K=k.useRef(!1),M=dI(ie=>{V(Ie=>K.current?aI(Ie,ie):ie),K.current=!1,Y(!0)},{locale:g,autoStop:P}),G=M.startError??M.transcribeError;k.useEffect(()=>{if(!G)return;K.current=!1,q(m(G==="no-speech"?"chat.speech.no_speech":G==="model-missing"?"chat.speech.asr_model_missing":G==="engine-unavailable"?"chat.speech.engine_unavailable":G==="custom-provider-missing"?"chat.speech.custom_provider_missing":G==="groq-key-missing"?"chat.speech.groq_key_missing":G==="azure-key-missing"?"chat.speech.azure_stt_key_missing":G==="azure-region-missing"?"chat.speech.azure_stt_region_missing":G==="mic-insecure-context"?"chat.speech.asr_insecure_context":G==="mic-unavailable"?"chat.speech.asr_start_fail":"chat.speech.asr_failed")),M.clearTranscribeError()},[G,M,m]);const ae=L?"error":M.listening?"recording":M.transcribing?"transcribing":z?"review":"idle",ne=(ie,Ie,Be)=>{Wb(),o(ie,Ie,Be)},X=k.useCallback(()=>{K.current=!1,V(""),Y(!1),q(null)},[]),te=k.useCallback(()=>{R(!1),X()},[X]),ue=k.useCallback(()=>{K.current=!0,M.beginHold();const ie=()=>{window.removeEventListener("pointerup",ie),window.removeEventListener("pointercancel",ie),M.endHold()};window.addEventListener("pointerup",ie),window.addEventListener("pointercancel",ie)},[M.beginHold,M.endHold]),ge=k.useCallback(()=>{K.current=!1,q(null)},[]),Z=()=>{const ie=B.trim();!ie||n||!e||(ne(ie),te())};k.useEffect(()=>{h&&y(ie=>ie.trim()?`${ie}
546
+ `)}function ug(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 hh="lookatstudy-tts-settings-changed";function fh(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 mh(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=fh(e.filter(i=>i.default));return r.length>0&&I_(r[0].lang)?r[0]:fh(e)[0]??null}function I_(e){return e.toLowerCase().startsWith("zh")}function BP(e){return`${e.name} · ${e.lang}`}const R_=[["\\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","点点点"]],M_={alpha:"阿尔法",beta:"贝塔",gamma:"伽马",delta:"德尔塔",epsilon:"艾普西隆",zeta:"泽塔",eta:"伊塔",theta:"西塔",iota:"约塔",kappa:"卡帕",lambda:"拉姆达",mu:"缪",nu:"纽",xi:"克西",pi:"派",rho:"柔",sigma:"西格马",tau:"陶",phi:"斐",chi:"凯",psi:"普西",omega:"欧米伽"};function P_(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 ai(e,t){const n=P_(e,t);return n||{body:e[t]??"",end:t+1}}function L_(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=ai(r,s+5),a=ai(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=ai(r,s+6),a=ai(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=ai(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 R_)t=t.split(n).join(` ${r} `);return t=t.replace(/\\([A-Za-z]+)\b/g,(n,r)=>` ${M_[r]??r} `),t=t.replace(/[{}]/g," "),t.replace(/\s+/g," ").trim()}function D_(e){return e.replace(/\$\$([^$]+)\$\$|\$([^$]+)\$/g,(t,n,r)=>{const s=L_(n??r??"");return s?` ${s} `:""})}const ph=new WeakMap;let cg=null;function wo(e){cg=e}function O_(){return cg}const dg=1024;function hg(e){let t=ph.get(e);return t||(t=e.createAnalyser(),t.fftSize=dg,t.smoothingTimeConstant=.55,ph.set(e,t)),t}function F_(e,t){try{const n=hg(e);t.connect(n),n.connect(e.destination)}catch{try{t.connect(e.destination)}catch{}}}const Nr=1024,gh=512,B_=3500,j_=7500,H_=.3,U_=.16,z_=1400,V_=2800,ws=70,fg=new Float64Array(Nr);for(let e=0;e<Nr;e++)fg[e]=.5*(1-Math.cos(2*Math.PI*e/(Nr-1)));function q_(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 h=0;h<o;h++){const f=e[l+h],d=t[l+h],m=e[l+h+o],g=t[l+h+o],b=m*u-g*c,y=m*c+g*u;e[l+h]=f+b,t[l+h]=d+y,e[l+h+o]=f-b,t[l+h+o]=d-y;const w=u*i-c*a;c=u*a+c*i,u=w}}}}function $_(e,t){const n=e.length;let r=0;const s=new Float64Array(n),i=new Float64Array(n);for(let g=0;g<n;g++){const b=e[g];r+=Math.abs(b),s[g]=b*fg[g]}q_(s,i);const a=n>>1,o=t/n,l=new Float64Array(a);let u=0,c=0,h=0,f=0,d=0,m=0;for(let g=0;g<a;g++){const b=g*o;if(b>=t/2-o)break;const y=Math.hypot(s[g],i[g])/a;l[g]=y,u+=y,b>=B_&&b<j_&&(c+=y),b>=Sc.lo&&b<Sc.hi?(h+=y,f+=y*b):b>=Ac.lo&&b<Ac.hi&&(d+=y,m+=y*b)}return{level:n>0?Math.min(1,r/n/.22):0,f1:h>0?f/h:400,f2:d>0?m/d:800,hfRatio:u>0?c/u:0}}function W_(e,t){return e.level<=Ub?"closed":e.hfRatio>=H_?"SS":e.hfRatio>=U_&&e.level<.45?"FV":t==="closed"&&e.f2>=z_&&e.f2<=V_?"L":zb(e.f1,e.f2,e.level)}function Y_(e,t){const n=[],r=(c,h,f,d)=>{if(h<=0)return;const m=n[n.length-1];if(m&&m.viseme===f&&Math.abs(m.t+m.dur-c)<1e-9){m.dur+=h,m.level=Math.max(m.level,d);return}n.push({t:c,dur:h,viseme:f,level:d})};if(e.length<Nr)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=gh/t;for(let c=0;c+Nr<=e.length;c+=gh){const h=e.subarray(c,c+Nr),f=$_(h,t),d=W_(f,s);r(c/t,i,d,f.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<=ws/1e3)l.viseme="closed";else{const c=Math.min(l.dur*.5,ws/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,ws/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 h=n[c];if(h.viseme!=="closed"&&h.dur<ws/1e3){const f=n[c-1];f.dur+=h.dur,n.splice(c,1)}}return{cues:n,duration:a}}function G_(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 K_(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 mg(){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),[h,f]=k.useState(!1),d=k.useRef(null),m=k.useRef(new Map),g=k.useRef(new Map),b=k.useRef(0),y=k.useRef(!1),w=k.useRef([]),E=k.useRef(0),S=k.useRef(0),v=k.useRef(!1),T=k.useRef(null),_=k.useRef(0),A=k.useRef(null),N=k.useRef(null),C=k.useRef(null);C.current||(C.current=()=>{const z=N.current,Y=typeof window<"u"?window.speechSynthesis:void 0;if(!z||z.stopped||!Y)return;if(z.i>=z.sentences.length){N.current=null,T.current=null,t(null),r(null),i(null);return}const L=z.i,q=D_(z.sentences[L]),K=new SpeechSynthesisUtterance(q);z.voice&&(K.voice=z.voice,K.lang=z.voice.lang),K.rate=z.rate,K.onstart=()=>{!N.current||N.current.stopped||i({index:L,total:z.sentences.length,text:q})};const M=()=>{var G;!N.current||N.current.stopped||(N.current.i+=1,(G=C.current)==null||G.call(C))};K.onend=M,K.onerror=M,Y.speak(K)});const D=k.useCallback((z,Y)=>{var M;if(typeof window>"u"||!("speechSynthesis"in window)){c("engine-unavailable");return}const L=b_(Y);if(L.length===0){c("empty-text");return}l.current=L.slice(),o(L.slice()),_.current=L.length,r({index:0,total:L.length,text:L[0]??""});const q=A.current,K=mh(window.speechSynthesis.getVoices(),(q==null?void 0:q.systemVoice)??null);N.current={messageId:z,sentences:L,i:0,stopped:!1,voice:K,rate:bh(q==null?void 0:q.speed)},window.speechSynthesis.cancel(),(M=C.current)==null||M.call(C)},[]),P=()=>{if(!d.current){const z=window.AudioContext??window.webkitAudioContext;d.current=new z}return d.current.resume(),d.current},O=k.useCallback(()=>{v.current&&S.current>=E.current&&!y.current&&(T.current=null,t(null),r(null),i(null))},[]),I=k.useCallback(()=>{const z=d.current;if(!z||y.current)return;const Y=m.current.get(b.current);if(!Y){O();return}const L=b.current;m.current.delete(L),y.current=!0,i({index:L,total:_.current,text:l.current[L]??""}),b.current+=1;const q=z.createBufferSource();q.buffer=Y,F_(z,q),wo({ctx:z,timeline:g.current.get(L)??null,startedAtCtxTime:z.currentTime,analyser:hg(z)}),q.onended=()=>{S.current+=1,y.current=!1,wo(null),I()},w.current.push(q),q.start()},[O]),R=k.useCallback(()=>{for(const z of w.current)try{z.onended=null,z.stop()}catch{}w.current=[],m.current.clear(),g.current.clear(),wo(null),y.current=!1,E.current=0,S.current=0,v.current=!1,T.current=null,b.current=0,_.current=0,l.current=[],o([]),t(null),r(null),i(null),N.current&&(N.current.stopped=!0,N.current=null),typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()},[]),B=k.useCallback(()=>{R(),window.api.ttsStop().catch(()=>{})},[R]),V=k.useCallback((z,Y)=>{var L;if(T.current===z){B();return}if(R(),window.dispatchEvent(new CustomEvent("lookatstudy-speech-start",{detail:z})),c(null),T.current=z,E.current=0,S.current=0,v.current=!1,b.current=0,_.current=0,t(z),r({index:0,total:0,text:""}),((L=A.current)==null?void 0:L.engine)==="system"){D(z,Y);return}P(),window.api.ttsSpeak(Y,z).then(q=>{if(q.ok){q.firstUse&&f(!0);return}R(),q.reason!=="empty-text"&&c(q.reason)}).catch(()=>R())},[D,B,R]);return k.useEffect(()=>{const z=window.api.on("speech:ttsAudio",q=>{if(q.messageId!==T.current)return;const K=P();E.current+=1,_.current=q.sentenceTotal,r({index:q.sentenceIndex,total:q.sentenceTotal,text:q.sentence??""}),q.sentence!=null&&(l.current[q.sentenceIndex]=q.sentence,o(l.current.slice())),K.decodeAudioData(q.wavBytes).then(M=>{var G;if(q.messageId===T.current){m.current.set(q.sentenceIndex,M);try{const ae=(G=q.visemeCues)!=null&&G.length?G_(q.visemeCues):Y_(X_(M),M.sampleRate);ae&&g.current.set(q.sentenceIndex,ae)}catch{}I()}},()=>{q.messageId===T.current&&(E.current-=1,I())})}),Y=window.api.on("speech:ttsDone",q=>{q.messageId===T.current&&(v.current=!0,O())}),L=window.api.on("speech:ttsError",()=>R());return()=>{z(),Y(),L()}},[O,I,R]),k.useEffect(()=>R,[R]),k.useEffect(()=>{const z=Y=>{const L=Y.detail;T.current&&L!==T.current&&R()};return window.addEventListener("lookatstudy-speech-start",z),()=>window.removeEventListener("lookatstudy-speech-start",z)},[R]),k.useEffect(()=>{let z=!0;const Y=()=>{Promise.all([window.api.getSetting("tts_engine"),window.api.getSetting("tts_system_voice"),window.api.getSetting("tts_speed")]).then(([L,q,K])=>{z&&(A.current={engine:(L??"").trim(),systemVoice:q??null,speed:bh(K)})}).catch(()=>{})};return Y(),window.addEventListener(hh,Y),()=>{z=!1,window.removeEventListener(hh,Y)}},[]),k.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const z=()=>{var L;const Y=N.current;!Y||Y.voice||(Y.voice=mh(window.speechSynthesis.getVoices(),((L=A.current)==null?void 0:L.systemVoice)??null))};return window.speechSynthesis.addEventListener("voiceschanged",z),()=>window.speechSynthesis.removeEventListener("voiceschanged",z)},[]),k.useEffect(()=>{Vb(e!==null)},[e]),{speakingMessageId:e,speakingSentence:n,playingSentence:s,streamTexts:a,failReason:u,clearFailReason:()=>c(null),onlineNotice:h,clearOnlineNotice:()=>f(!1),speak:V,stop:B}}function X_(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 bh(e){const t=typeof e=="number"?e:Number.parseFloat(e??"");return Number.isFinite(t)?Math.min(2,Math.max(.5,t)):1}const pg=k.createContext(null);let Q_=0;const Z_={default:4e3,success:4e3,info:4e3,warning:5e3,error:6e3},J_={default:null,success:p.jsx(nu,{className:"w-4 h-4 text-brand shrink-0"}),error:p.jsx(_x,{className:"w-4 h-4 text-warning shrink-0"}),warning:p.jsx(su,{className:"w-4 h-4 text-review shrink-0"}),info:p.jsx(jx,{className:"w-4 h-4 text-accent shrink-0"})};function eN({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=++Q_,u=(o==null?void 0:o.severity)??"default",c=(o==null?void 0:o.duration)??Z_[u],h={id:l,message:a,action:o==null?void 0:o.action,duration:c,severity:u,exiting:!1};n(f=>[...f,h]),window.setTimeout(()=>s(l),c)},[s]);return p.jsxs(pg.Provider,{value:{show:i},children:[e,p.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=>p.jsx(tN,{item:a,onAction:()=>{a.action.onClick(),s(a.id)},onDismiss:()=>s(a.id),onExitDone:()=>r(a.id)},a.id))})]})}function tN({item:e,onAction:t,onDismiss:n,onExitDone:r}){const s=$e(),i=J_[e.severity];return p.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,p.jsx("span",{className:"flex-1",children:e.message}),e.action&&p.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}),p.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:p.jsx(_n,{className:"w-3.5 h-3.5"})})]})}function Mu(){const e=k.useContext(pg);return e||{show:()=>{}}}const gg={typescript:()=>_e(()=>import("./typescript-BPQ3VLAy.js"),[],import.meta.url),tsx:()=>_e(()=>import("./tsx-COt5Ahok.js"),[],import.meta.url),javascript:()=>_e(()=>import("./javascript-wDzz0qaB.js"),[],import.meta.url),jsx:()=>_e(()=>import("./jsx-g9-lgVsj.js"),[],import.meta.url),python:()=>_e(()=>import("./python-B6aJPvgy.js"),[],import.meta.url),go:()=>_e(()=>import("./go-C27-OAKa.js"),[],import.meta.url),rust:()=>_e(()=>import("./rust-B1yitclQ.js"),[],import.meta.url),java:()=>_e(()=>import("./java-CylS5w8V.js"),[],import.meta.url),c:()=>_e(()=>import("./c-BIGW1oBm.js"),[],import.meta.url),cpp:()=>_e(()=>import("./cpp-DddhVWhK.js"),__vite__mapDeps([5,6]),import.meta.url),csharp:()=>_e(()=>import("./csharp-DSvCPggb.js"),[],import.meta.url),ruby:()=>_e(()=>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:()=>_e(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([21,8,9,10,11,12,13,22]),import.meta.url),swift:()=>_e(()=>import("./swift-C2oV4EkX.js"),[],import.meta.url),kotlin:()=>_e(()=>import("./kotlin-BdnUsdx6.js"),[],import.meta.url),lua:()=>_e(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([19,6]),import.meta.url),r:()=>_e(()=>import("./r-Cf5RLm7j.js"),[],import.meta.url),shellscript:()=>_e(()=>import("./shellscript-Yzrsuije.js"),[],import.meta.url),sql:()=>_e(()=>import("./sql-CRqJ_cUM.js"),[],import.meta.url),html:()=>_e(()=>import("./html-pp8916En.js"),__vite__mapDeps([8,9,10]),import.meta.url),css:()=>_e(()=>import("./css-CLj8gQPS.js"),[],import.meta.url),scss:()=>_e(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([23,10]),import.meta.url),xml:()=>_e(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([11,12]),import.meta.url),json:()=>_e(()=>import("./json-Cp-IABpG.js"),[],import.meta.url),yaml:()=>_e(()=>import("./yaml-Buea-lGh.js"),[],import.meta.url),toml:()=>_e(()=>import("./toml-vGWfd6FD.js"),[],import.meta.url),ini:()=>_e(()=>import("./ini-BEwlwnbL.js"),[],import.meta.url),markdown:()=>_e(()=>import("./markdown-Cvjx9yec.js"),[],import.meta.url),dockerfile:()=>_e(()=>import("./dockerfile-BcOcwvcX.js"),[],import.meta.url),makefile:()=>_e(()=>import("./makefile-CHLpvVh8.js"),[],import.meta.url),diff:()=>_e(()=>import("./diff-D97Zzqfu.js"),[],import.meta.url),graphql:()=>_e(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([14,9,15,16,17]),import.meta.url),latex:()=>_e(()=>import("./latex-B2nUCzCX.js"),__vite__mapDeps([24,25]),import.meta.url),vue:()=>_e(()=>import("./vue-CHlpWS_5.js"),__vite__mapDeps([26,10,9,15,22,8]),import.meta.url)},xh={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 nN(e){const t=e.trim().toLowerCase();return t?t in xh?xh[t]||null:t in gg?t:null:null}let oi=null;const yh=new Set;function Pu(){return oi||(oi=(async()=>{const[e,t,n,r]=await Promise.all([_e(()=>import("./core-CwmXubmg.js"),__vite__mapDeps([27,1,2]),import.meta.url),_e(()=>import("./engine-javascript-DBd1bXLz.js"),[],import.meta.url),_e(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url),_e(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url)]);return e.createHighlighterCore({themes:[n.default,r.default],langs:[],engine:t.createJavaScriptRegexEngine({forgiving:!0})})})(),oi.catch(()=>{oi=null})),oi}async function bg(e){const t=nN(e);if(!t)return null;if(yh.has(t))return t;const n=gg[t];if(!n)return null;const r=await Pu(),s=await n();return await r.loadLanguage(s),yh.add(t),t}async function rN(e,t){try{const n=await bg(t);return n?(await Pu()).codeToHtml(e,{lang:n,themes:{light:"github-light",dark:"github-dark"},defaultColor:"dark"}):null}catch{return null}}const iN=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");async function jP(e,t){try{const n=await bg(t);return n?(await Pu()).codeToTokens(e,{lang:n,theme:"github-dark"}).tokens.map(i=>i.map(a=>`<span style="color:${a.color}">${iN(a.content)}</span>`).join("")):null}catch{return null}}function sN(e,t){return e==="mermaid"&&t.trim().length>0}function aN(e){const t=e.trimStart().slice(0,40).toLowerCase();return t.startsWith("sequencediagram")?"sequence":t.startsWith("statediagram")?"state":"flowchart"}const oN=k.lazy(()=>_e(()=>import("./MermaidArtifact-J6xyhs4Y.js").then(e=>e.a),__vite__mapDeps([28,1,2,29]),import.meta.url).then(e=>({default:e.MermaidArtifact})));function lN(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 xg({children:e,...t}){const n=$e(),[r,s]=k.useState(!1),[i,a]=k.useState(null),{lang:o,text:l}=lN(e),u=sN(o,l);k.useEffect(()=>{let h=!0;if(!(!l||u))return rN(l.replace(/\n$/,""),o).then(f=>{h&&f&&a(f)}),()=>{h=!1}},[l,u]);const c=()=>{var h;(h=navigator.clipboard)==null||h.writeText(l).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})};return u?p.jsx("div",{className:"my-3","data-md-diagram":"",children:p.jsx(k.Suspense,{fallback:p.jsx("div",{className:"surface-card min-h-[120px]"}),children:p.jsx(oN,{data:{artifactType:"diagram",title:n("artifact.mermaid.inlineTitle"),diagramType:aN(l),mermaid:l}})})}):p.jsxs("div",{className:"relative group my-3","data-testid":"md-codeblock",children:[p.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:[p.jsx("span",{className:"text-caption font-mono text-ink-faint uppercase tracking-wider",children:o||"code"}),p.jsx("button",{onClick:c,"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?p.jsxs(p.Fragment,{children:[p.jsx(xn,{className:"w-3 h-3 inline"}),n("chat.copied")]}):p.jsxs(p.Fragment,{children:[p.jsx(Rx,{className:"w-3 h-3 inline"}),n("chat.copy")]})})]}),i?p.jsx("div",{className:"md-shiki","data-testid":"md-shiki",dangerouslySetInnerHTML:{__html:i}}):p.jsx("pre",{...t,className:"!mt-0 !rounded-t-none !border-t-0",children:e})]})}const yg=k.lazy(()=>_e(()=>import("./index-CdZ-qnc_.js"),__vite__mapDeps([30,1,2,28,29,31]),import.meta.url).then(e=>({default:e.ArtifactRenderer}))),uN=k.lazy(()=>_e(()=>import("./CanvasStage-Di9Xd_SQ.js").then(e=>e.a),__vite__mapDeps([29,1,2]),import.meta.url).then(e=>({default:e.CanvasStage}))),cN={concept_map:_m,quiz:km,compare_table:sy,diagram:Lx,code_walkthrough:Ix},dN=new Set(["concept_map","quiz","compare_table","diagram","code_walkthrough"]);function hN(e,t){return dN.has(t)?e(`artifact.type.${t}`):e("artifact.type.unknown")}function fN({selectedNode:e,items:t,loading:n,forceTab:r,canvasArtifact:s,onUserTabChange:i,onRemove:a,onTogglePin:o,onRecordQuizResult:l,onSaveContentNote:u,onUpdateNoteComment:c,onJumpToSource:h,onQuoteToChat:f,locale:d}){var v;const m=$e(),[g,b]=k.useState("content"),y=r??g,w=T=>{b(T),i==null||i()},E=e?t.filter(T=>T.nodeId===e.id):[],S=k.useRef(null);return k.useEffect(()=>{var T;(T=S.current)==null||T.scrollTo({top:0})},[e==null?void 0:e.id]),p.jsxs("div",{className:"relative h-full flex flex-col bg-surface-2","data-testid":"notebook-panel",children:[p.jsx("div",{className:"px-3 pt-3 pb-1 shrink-0","data-testid":"notebook-tabs",children:p.jsxs("div",{className:"flex p-1 rounded-lg gap-1 bg-ink/[0.08]",role:"tablist","aria-label":"Notebook",children:[p.jsx(_o,{label:m("notebook.tab.explain"),icon:Jt,active:y==="content",onClick:()=>w("content"),testid:"tab-content"}),p.jsx(_o,{label:m("notebook.tab.notes"),icon:Vx,active:y==="notes",onClick:()=>w("notes"),testid:"tab-notes",badge:E.length>0?String(E.length):void 0}),p.jsx(_o,{label:m("notebook.tab.board"),icon:Wa,active:y==="board",onClick:()=>w("board"),testid:"tab-board"})]})}),p.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 animate-tab-slide",ref:S,role:"tabpanel",children:y==="board"?p.jsx("div",{className:"h-full flex flex-col","data-testid":"board-tab-content",children:s?p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"px-4 pt-3 pb-2 shrink-0 flex items-center gap-2 min-w-0",children:[p.jsx(Wa,{className:"w-4 h-4 text-ink-muted shrink-0"}),p.jsx("span",{className:"text-label font-bold text-ink truncate",children:((v=s.output)==null?void 0:v.title)??s.toolName})]}),p.jsx("div",{className:"flex-1 min-h-0 px-2 pb-2",children:p.jsx("div",{className:"h-full rounded-xl overflow-hidden bg-surface-0/60 border border-[var(--border-faint)]",children:p.jsx(k.Suspense,{fallback:null,children:p.jsx(uN,{testid:"board-canvas-stage",children:p.jsx(yg,{data:s.output,variant:"canvas"})})})})})]}):p.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6",children:[p.jsx(Wa,{className:"w-10 h-10 mb-3 text-ink-muted opacity-30"}),p.jsx("div",{className:"text-body text-ink-muted max-w-sm leading-relaxed",children:m("notebook.board.empty")})]})}):p.jsx(p.Fragment,{children:p.jsx("div",{className:"mx-auto w-full max-w-[960px] min-h-full flex flex-col",children:y==="content"?p.jsx(mN,{selectedNode:e,contentNotes:E.filter(T=>T.artifactType==="user_note"&&T.sourceAnchor),onQuoteToChat:f,onSaveContentNote:u,locale:d}):p.jsx(pN,{items:E,loading:n,selectedNode:e,onRemove:a,onTogglePin:o,onRecordQuizResult:l,onUpdateNoteComment:c,onJumpToSource:h})})})},y)]})}function mN({selectedNode:e,contentNotes:t,onQuoteToChat:n,onSaveContentNote:r,locale:s}){const i=$e(),a=Mu(),o=mg();k.useEffect(()=>{if(o.failReason){const O=o.failReason==="engine-unavailable"?"chat.speech.engine_unavailable":o.failReason==="azure-key-missing"?"chat.speech.azure_key_missing":o.failReason==="azure-region-missing"?"chat.speech.azure_region_missing":o.failReason==="edge-failed"?"chat.speech.edge_failed":"chat.speech.model_missing";a.show(i(O),{severity:"warning"}),o.clearFailReason()}else o.onlineNotice&&(a.show(i("chat.speech.edge_disclosed"),{severity:"info"}),o.clearOnlineNotice())},[o.failReason,o.onlineNotice,a,i,o]);const l=k.useRef(o.stop);l.current=o.stop;const u=e?`content-${e.id}`:null;k.useEffect(()=>()=>{l.current()},[u]);const[c,h]=k.useState(null),f=V0(c??""),[d,m]=k.useState(!1),[g,b]=k.useState(!1),[y,w]=k.useState([]),[E,S]=k.useState(null),v=k.useRef(null),T=k.useRef(null),_=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches;k.useEffect(()=>{if(!e){h(null),b(!1);return}let O=!1;return m(!0),b(!1),se.getNodeContent(e.id,s??void 0).then(I=>{O||h(I)}).catch(()=>{O||(h(null),b(!0))}).finally(()=>{O||m(!1)}),()=>{O=!0}},[e==null?void 0:e.id,s]),k.useEffect(()=>{if(!e){w([]);return}let O=!1;return se.listAssetsByNode(e.id).then(I=>{O||w(I)}).catch(()=>{O||w([])}),()=>{O=!0}},[e==null?void 0:e.id]),k.useEffect(()=>{if(!c||!v.current)return;const O=[];for(const R of t)try{const B=JSON.parse(R.sourceAnchor);if(B.type==="content"){const V=JSON.parse(R.data).text??"";V&&O.push({noteId:R.id,text:V,surrounding:B.surroundingText})}}catch{}const I=setTimeout(()=>{T.current&&(wi()?Q0(T.current,O):K0(T.current,O))},80);return()=>clearTimeout(I)},[c,t]),k.useEffect(()=>{const O=I=>{var V;const R=I.detail;if(!R)return;if(wi()){const z=Z0(R);z&&J0(z);return}const B=(V=T.current)==null?void 0:V.querySelector(`mark[data-note-id="${R}"]`);B&&og(B)};return window.addEventListener("lookatstudy-jump-to-note",O),()=>window.removeEventListener("lookatstudy-jump-to-note",O)},[]);const A=o.speakingMessageId===u&&o.playingSentence!=null?o.playingSentence.index:null;k.useEffect(()=>{const O=T.current;if(!O)return;if(A==null){ir(O);return}const I=q0(o.streamTexts,A);if(!I)return;A===0&&ig(O);const R=setTimeout(()=>{const B=sg(O,I);B&&ag(B,O.closest(".overflow-y-auto"))},30);return()=>clearTimeout(R)},[A,o.streamTexts,u]),k.useEffect(()=>{A==null&&T.current&&ir(T.current)},[A]);const N=k.useRef(!1);N.current=A!=null,k.useEffect(()=>()=>{N.current&&ir(document.body)},[]);const C=k.useCallback(()=>{var ne;if(!n&&!r)return;const O=window.getSelection(),I=(O==null?void 0:O.toString().trim())??"";if(I.length<2||I.length>500){S(null);return}const R=O==null?void 0:O.getRangeAt(0);if(!R||!((ne=v.current)!=null&&ne.contains(R.commonAncestorContainer))){S(null);return}const B=R.getBoundingClientRect(),V=v.current.getBoundingClientRect(),z=T.current;let Y=null;if(z&&z.contains(R.commonAncestorContainer)){const X=ur(z);Y=W0(R,X)}const L=z?ur(z).text:I,q=Y?Y.start:L.indexOf(I),K=q>=0?L.slice(Math.max(0,q-30),q+I.length+30):I,M=R.getClientRects(),G=M.length?M[M.length-1]:B,ae=ug({left:B.left-V.left,top:B.top-V.top,right:B.right-V.left,bottom:B.bottom-V.top,width:B.width,height:B.height},V.width,n?_?190:150:_?140:100,{left:G.left-V.left,top:G.top-V.top,right:G.right-V.left,bottom:G.bottom-V.top,width:G.width,height:G.height},_);S({x:ae.left,y:ae.top,transform:ae.transform,text:I,surrounding:K,offsets:Y??void 0})},[n,r,_]);k.useEffect(()=>{const O=_?600:250;let I=null,R=null,B=!1;const V=()=>{var q;return(((q=window.getSelection())==null?void 0:q.toString().trim().length)??0)>=2},z=()=>{V()?(R&&(clearTimeout(R),R=null),S(q=>q&&null),I&&clearTimeout(I),I=setTimeout(()=>{I=null,!B&&V()&&C()},O)):R||(R=setTimeout(()=>S(q=>q&&null),250))},Y=q=>{var M;const K=q.target;(M=K==null?void 0:K.closest)!=null&&M.call(K,"[data-selection-popover]")||(B=!0)},L=()=>{B=!1,I&&(clearTimeout(I),I=null),!R&&V()&&C()};return document.addEventListener("selectionchange",z),window.addEventListener("pointerdown",Y,!0),window.addEventListener("pointerup",L,!0),window.addEventListener("pointercancel",L,!0),()=>{document.removeEventListener("selectionchange",z),window.removeEventListener("pointerdown",Y,!0),window.removeEventListener("pointerup",L,!0),window.removeEventListener("pointercancel",L,!0),I&&clearTimeout(I),R&&clearTimeout(R)}},[C]);const D=k.useCallback(()=>{var I;if(!E||!n)return;const O=E.text.length>200?E.text.slice(0,200)+"…":E.text;n(i("notebook.quote.template",{text:O})),S(null),(I=window.getSelection())==null||I.removeAllRanges()},[E,n,i]),P=k.useCallback(()=>{var I,R,B;if(!E||!r||!e)return;const O=E.text.length>200?E.text.slice(0,200)+"…":E.text;r(O,{type:"content",surroundingText:E.surrounding,startOffset:(I=E.offsets)==null?void 0:I.start,endOffset:(R=E.offsets)==null?void 0:R.end}),qb(),setTimeout(()=>{if(!T.current)return;if(wi()){const Y=v_(T.current);Y&&dh(Y);return}const V=T.current.querySelectorAll("mark.lookatstudy-underline"),z=V&&V.length>0?V[V.length-1]:null;z&&dh(z)},200),S(null),(B=window.getSelection())==null||B.removeAllRanges()},[E,r,e]);return e?p.jsxs("div",{className:"p-5 relative","data-testid":"node-content",ref:v,children:[!d&&!g&&c&&p.jsx("div",{className:"sticky top-0 z-20 flex justify-end gap-2 -mt-2 pointer-events-none",children:p.jsx("button",{onClick:()=>o.speak(u??"content",c),"data-tooltip":o.speakingMessageId===u?i("chat.speech.stop"):i("chat.speech.read_aloud_node"),"aria-label":o.speakingMessageId===u?i("chat.speech.stop"):i("chat.speech.read_aloud_node"),"data-testid":o.speakingMessageId===u?"node-content-speak-active":"node-content-speak",className:`pointer-events-auto shrink-0 rounded-full p-2 bg-surface-2 shadow-elevated transition-colors ${o.speakingMessageId===u?"text-brand animate-pulse":"text-ink-muted hover:text-ink-strong"}`,children:o.speakingMessageId===u?p.jsx(iu,{className:"w-4 h-4"}):p.jsx(Rm,{className:"w-4 h-4"})})}),p.jsx("div",{className:"text-caption font-bold text-brand uppercase tracking-wider mb-1",children:e.type==="section"?i("notebook.node_type.section"):e.type==="concept"?i("notebook.node_type.concept"):i("notebook.node_type.lesson")}),p.jsx("div",{className:"flex items-start justify-between gap-3 mb-4",children:p.jsx("h2",{className:"text-title font-extrabold text-ink-strong tracking-tight","data-testid":"node-content-title",children:e.title})}),d?p.jsxs("div",{className:"text-body text-ink-muted flex items-center gap-2",children:[p.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),i("notebook.content.loading")]}):g?p.jsxs("div",{className:"text-body text-warning",children:[i("notebook.content.load_failed"),p.jsx("button",{className:"underline ml-1",onClick:()=>{b(!1),m(!0),se.getNodeContent(e.id,s??void 0).then(h).catch(()=>b(!0)).finally(()=>m(!1))},children:i("notebook.content.retry")})]}):c?p.jsx(h_,{fallback:(O,I)=>p.jsxs("div",{className:"prose prose-sm max-w-[80ch] leading-relaxed [&_pre]:max-w-full [&_pre]:overflow-x-auto",children:[p.jsx("div",{className:"text-body text-warning mb-2",children:i("notebook.content.render_failed")}),p.jsxs("pre",{className:"text-caption text-ink-muted whitespace-pre-wrap break-words bg-surface-1 p-3 rounded",children:[c.slice(0,500),c.length>500?`
547
+ `+i("notebook.content.truncated"):""]}),p.jsx("div",{className:"flex gap-2 mt-2",children:p.jsx("button",{className:"text-caption underline text-accent",onClick:I,children:i("notebook.content.retry_render")})})]}),children:p.jsx("div",{ref:T,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:p.jsx(Ip,{remarkPlugins:f.remarkPlugins,rehypePlugins:f.rehypePlugins,components:{pre({children:O,...I}){return p.jsx(xg,{...I,children:O})},a({children:O,...I}){return p.jsx("a",{...I,target:"_blank",rel:"noopener noreferrer",children:O})},img({src:O,alt:I,...R}){return p.jsx(gN,{src:O,alt:I,assets:y,...R})},table({children:O}){return p.jsx("div",{className:"overflow-x-auto my-4",children:p.jsx("table",{children:O})})}},children:lg(c)})})},`${e.id}-${s??"orig"}`):p.jsx("div",{className:"text-body text-ink-muted",children:i("notebook.content.empty")}),y.length>0&&p.jsxs("div",{className:"mt-6 pt-4 border-t border-[var(--border-faint)]",children:[p.jsxs("div",{className:"text-label font-bold text-ink-muted mb-2 flex items-center gap-1",children:[p.jsx(Fx,{className:"w-3.5 h-3.5"}),p.jsx("span",{children:i("notebook.images.heading",{n:y.length})})]}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:y.map(O=>p.jsx(bN,{asset:O},O.id))})]}),E&&p.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&&p.jsxs("button",{onClick:D,"data-testid":"quote-to-chat-btn","aria-label":i("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:[p.jsx(Sm,{className:"w-3 h-3"}),i("notebook.quote.ask")]}),p.jsxs("button",{onClick:P,"data-testid":"save-note-btn","aria-label":i("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:i("notebook.quote.save_note.title"),children:[p.jsx(Ri,{className:"w-3.5 h-3.5"}),i("notebook.quote.add_note")]})]}),e.sourcePath&&p.jsx("div",{className:"mt-6 pt-3 border-t border-[var(--border-faint)] text-label text-ink-muted",children:i("notebook.source.label",{path:e.sourcePath})}),p.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:[p.jsx(Em,{className:"w-3.5 h-3.5 shrink-0 mt-0.5 text-accent"}),p.jsx("span",{children:i("notebook.quote.hint")})]})]}):p.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6",children:[p.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),p.jsx("div",{className:"text-body text-ink-muted max-w-xs",children:i("notebook.empty.select_node")})]})}function pN({items:e,loading:t,selectedNode:n,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o}){const l=$e();if(!n)return p.jsx(vh,{message:l("notebook.empty.notes.title"),icon:"📓"});if(t)return p.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2 text-body text-ink-muted",children:[p.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(g=>["concept_map","compare_table","diagram","code_walkthrough"].includes(g.artifactType)),c=e.filter(g=>g.artifactType==="user_note"),h=e.filter(g=>g.artifactType==="quiz"),f=e.length,d=h.filter(g=>g.lastResult==="correct").length,m=h.filter(g=>g.lastResult==="wrong").length;return f===0?p.jsx(vh,{message:l("notebook.empty.no_notes_message"),icon:"🧩"}):p.jsxs("div",{className:"p-4 space-y-3","data-testid":"notes-list",children:[p.jsx(So,{title:l("notebook.zone.understand"),icon:p.jsx(_m,{className:"w-4 h-4"}),subtitle:l("notebook.zone.understand.subtitle"),count:u.length,testid:"zone-understand",defaultOpen:!1,children:u.length===0?p.jsx(Ao,{hint:l("notebook.zone.understand.empty_hint")}):u.map(g=>p.jsx(Co,{item:g,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o},g.id))}),p.jsx(So,{title:l("notebook.zone.note"),icon:p.jsx(Ri,{className:"w-4 h-4"}),subtitle:l("notebook.zone.note.subtitle"),count:c.length,testid:"zone-note",defaultOpen:!1,children:c.length===0?p.jsx(Ao,{hint:l("notebook.zone.note.empty_hint")}):c.map(g=>p.jsx(Co,{item:g,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o},g.id))}),p.jsx(So,{title:l("notebook.zone.practice"),icon:p.jsx(km,{className:"w-4 h-4"}),subtitle:h.length>0?l("notebook.zone.practice.subtitle_stats",{total:h.length,correct:d,wrong:m}):l("notebook.zone.practice.subtitle_empty"),count:h.length,testid:"zone-practice",defaultOpen:!1,children:h.length===0?p.jsx(Ao,{hint:l("notebook.zone.practice.empty_hint")}):h.map(g=>p.jsx(Co,{item:g,onRemove:r,onTogglePin:s,onRecordQuizResult:i,onUpdateNoteComment:a,onJumpToSource:o},g.id))})]})}function So({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]),p.jsxs("section",{className:"rounded-xl bg-surface-1 overflow-hidden","data-testid":s,children:[p.jsxs("button",{onClick:()=>l(h=>!h),"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:[p.jsx(pa,{className:`w-4 h-4 text-ink-muted transition-transform duration-200 ease-out-back ${o?"":"-rotate-90"}`}),p.jsx("span",{className:"text-body text-ink-strong flex items-center",children:t}),p.jsx("span",{className:"text-body font-bold text-ink",children:e}),p.jsx("span",{className:"text-caption font-bold px-1.5 py-0.5 rounded-full bg-brand/15 text-brand",children:r}),p.jsx("span",{className:"text-label text-ink-muted ml-auto truncate",children:n})]}),p.jsx("div",{className:"grid transition-all duration-200 ease-out-expo",style:{gridTemplateRows:o?"1fr":"0fr"},children:p.jsx("div",{className:"overflow-hidden",children:p.jsx("div",{className:"p-3 space-y-3",children:a})})})]})}function Ao({hint:e}){return p.jsx("div",{className:"text-center py-3 text-body text-ink-muted",children:e})}function Co({item:e,onRemove:t,onTogglePin:n,onRecordQuizResult:r,onUpdateNoteComment:s,onJumpToSource:i}){const a=$e(),[o,l]=k.useState(!1),[u,c]=k.useState(e.notes??""),h=k.useCallback((E,S,v)=>{e.nodeId&&se.recordQuizAnswer(e.nodeId,v).catch(()=>{}),r(e.id,v)},[e.nodeId,e.id,r]),f=e.artifactType==="user_note";let d="",m=null;if(f){try{d=JSON.parse(e.data).text??""}catch{d=e.title??""}try{e.sourceAnchor&&(m=JSON.parse(e.sourceAnchor))}catch{m=null}}let g=null;if(!f)try{g=JSON.parse(e.data)}catch{g=null}const b=new Date(e.createdAt),y=`${b.getMonth()+1}/${b.getDate()} ${b.getHours().toString().padStart(2,"0")}:${b.getMinutes().toString().padStart(2,"0")}`;if(f){const E=e.notes&&e.notes.trim().length>0?e.notes:null,S=()=>{c(E??""),l(!0)},v=()=>{c(E??""),l(!1)},T=()=>{s==null||s(e.id,u),l(!1)};return p.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:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(Xx,{className:"w-4 h-4 text-accent shrink-0 mt-0.5"}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"text-body text-ink leading-relaxed whitespace-pre-wrap",children:d}),s&&o?p.jsxs("div",{className:"mt-2 space-y-1.5","data-testid":`note-comment-edit-${e.id.slice(0,8)}`,children:[p.jsx("textarea",{value:u,onChange:_=>c(_.target.value),rows:2,placeholder:a(E?"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)}`}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("button",{onClick:T,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:[p.jsx(xn,{className:"w-3 h-3"})," ",a("notebook.action.save")]}),p.jsxs("button",{onClick:v,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:[p.jsx(_n,{className:"w-3 h-3"})," ",a("notebook.action.cancel")]})]})]}):E?p.jsxs("div",{className:"mt-2 px-2.5 py-1.5 rounded-lg bg-ink/5",children:[p.jsx("div",{className:"text-label text-ink-muted italic leading-relaxed whitespace-pre-wrap",children:E}),s&&p.jsxs("button",{onClick:S,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:[p.jsx(Ri,{className:"w-2.5 h-2.5"})," ",a("notebook.note.edit_comment")]})]}):s?p.jsxs("button",{onClick:S,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:[p.jsx(Ri,{className:"w-2.5 h-2.5"})," ",a("notebook.note.add_comment")]}):null,m&&i&&p.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"?p.jsxs(p.Fragment,{children:[p.jsx(Jt,{className:"w-3 h-3"}),a("notebook.source.jump_content")]}):p.jsxs(p.Fragment,{children:[p.jsx(Sm,{className:"w-3 h-3"}),a("notebook.source.jump_chat")]})}),p.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[p.jsx("span",{className:"text-caption text-ink-muted",children:y}),p.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:p.jsx(el,{className:"w-3 h-3"})})]})]})]})})}const w=cN[e.artifactType]??Kx;return p.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:[p.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[p.jsx("span",{className:"text-body inline-flex items-center text-ink-strong",children:p.jsx(w,{className:"w-4 h-4"})}),p.jsx("span",{className:"text-label font-bold text-ink-muted flex-1 truncate",children:e.title??hN(a,e.artifactType)}),e.artifactType==="quiz"&&e.lastResult&&p.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?p.jsxs("span",{className:"text-caption text-brand font-bold flex items-center gap-0.5",children:[p.jsx(Oc,{className:"w-2.5 h-2.5"}),a("notebook.note.pinned")]}):null,p.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:p.jsx(Oc,{className:"w-3 h-3"})}),p.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:p.jsx(el,{className:"w-3 h-3"})})]}),p.jsx("div",{className:"text-label",children:g?p.jsx(k.Suspense,{fallback:null,children:p.jsx(yg,{data:g,onQuizAnswered:h})}):p.jsx("div",{className:"text-ink-muted",children:a("notebook.artifact.broken")})}),p.jsx("div",{className:"text-caption text-ink-muted mt-2",children:y})]})}function vh({message:e,icon:t}){return p.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6","data-testid":"empty-notebook",children:[p.jsx("div",{className:"text-4xl mb-3 opacity-30",children:t}),p.jsx("div",{className:"text-body text-ink-muted max-w-xs leading-relaxed",children:e})]})}function _o({label:e,icon:t,active:n,onClick:r,testid:s,badge:i}){return p.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:[p.jsx(t,{className:"w-3 h-3"}),p.jsx("span",{children:e}),i&&p.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 gN({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 h;return(h=c.sourcePath)==null?void 0:h.endsWith(u)})??n.find(c=>c.filename===u)??null},[a,n]);if(k.useEffect(()=>{if(!o){i(null);return}let u=!1;return se.getAssetDataUrl(o.id).then(c=>{u||i(c)}),()=>{u=!0}},[o]),!a)return null;const l=s??a;return p.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 bN({asset:e}){const t=$e(),[n,r]=k.useState(null),[s,i]=k.useState(!1);return k.useEffect(()=>{let a=!1;return se.getAssetDataUrl(e.id).then(o=>{a||r(o)}),()=>{a=!0}},[e.id]),p.jsxs(p.Fragment,{children:[p.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?p.jsx("img",{src:n,alt:e.altText??e.filename,"data-asset-id":e.id,className:"w-full h-24 object-cover",loading:"lazy"}):p.jsx("div",{className:"w-full h-24 flex items-center justify-center text-ink-faint text-caption",children:t("notebook.asset.loading")})}),s&&n&&p.jsxs("div",{className:"fixed inset-0 z-50 bg-black/80 flex items-center justify-center p-8 cursor-pointer",onClick:()=>i(!1),children:[p.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"}),p.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:p.jsx(_n,{className:"w-6 h-6"})})]})]})}const xN=["INTJ","INTP","ENTJ","ENTP","INFJ","INFP","ENFJ","ENFP","ISTJ","ISFJ","ESTJ","ESFJ","ISTP","ISFP","ESTP","ESFP"],vg=["external","introjected","identified","integrated","intrinsic"],yN={start:null,interaction:null,feedback:null,pacing:null};function No(){return{name:null,mbti:null,style:{...yN},motiveStage:null,interests:null,freeNote:null,updatedAt:new Date(0).toISOString()}}function Eg(e){return{start:e.includes("N")?"framework":"analogy",interaction:e.includes("E")?"dialogue":"lecture",feedback:e.includes("T")?"direct":"encouraging",pacing:e.includes("P")?"exploratory":"sequential"}}function Eh(e){var t;return!!(e.name||e.mbti||e.motiveStage||e.freeNote||(((t=e.interests)==null?void 0:t.length)??0)>0||e.style.start||e.style.interaction||e.style.feedback||e.style.pacing)}const vN=8;function EN(e){if(!Array.isArray(e))return null;const t=[];for(const n of e){if(typeof n!="string")continue;const r=n.trim();if(r&&!t.includes(r)&&t.push(r),t.length>=vN)break}return t.length?t:null}function vl(e){return EN((e??"").split(/[,,、;;]+/))}const kN={start:{analogy:{zh:"先具体实例建直觉",en:"concrete examples first"},framework:{zh:"先框架后细节",en:"framework first, details later"}},interaction:{dialogue:{zh:"边讲边问",en:"dialogue-heavy teaching"},lecture:{zh:"讲完一节再答疑",en:"lecture first, Q&A after"}},feedback:{direct:{zh:"直接纠错",en:"direct corrections"},encouraging:{zh:"先肯定再指正",en:"encouraging corrections"}},pacing:{sequential:{zh:"按顺序推进",en:"sequential progression"},exploratory:{zh:"允许跳着学",en:"exploratory jumping"}}};function HP(e,t,n){const r=kN[e][t];return r?n==="en"?r.en:r.zh:""}const TN={external:{nameZh:"为了考试/面试",nameEn:"For an exam",taglineZh:"这场考试/面试在前头等着,得过去。",taglineEn:"The exam or interview is waiting — gotta get past it.",botZh:"行,考点优先,咱们稳稳过。",botEn:"Alright — exam points first, steady pace, we'll pass."},introjected:{nameZh:"为了填满休息时间",nameEn:"To fill free time",taglineZh:"闲着也是闲着,学点总没坏处。",taglineEn:"Got spare time anyway — might as well learn something.",botZh:"轻松学,不赶进度,学到哪算哪。",botEn:"Easy pace, no rush — we go as far as we go."},identified:{nameZh:"未来能用得上",nameEn:"It'll pay off",taglineZh:"这本事存着,总有一天用得上。",taglineEn:"Stash the skill — one day it pays off.",botZh:"好,都往用得上讲。",botEn:"Got it — everything aimed at real use."},integrated:{nameZh:"终身学习",nameEn:"Lifelong learning",taglineZh:"学习这事儿,我打算干一辈子。",taglineEn:"Learning is a lifelong thing for me.",botZh:"同路人,往深了讲。",botEn:"Fellow traveler — let's go deep."},intrinsic:{nameZh:"享受学习过程",nameEn:"For the fun of it",taglineZh:"懂的那个瞬间,本身就挺爽。",taglineEn:"That click when it finally makes sense — love it.",botZh:"那就挑有意思的讲!",botEn:"Then let's pick the fun stuff!"}};function Ir(e,t){const n=TN[e];return t==="en"?{name:n.nameEn,tagline:n.taglineEn,bot:n.botEn}:{name:n.nameZh,tagline:n.taglineZh,bot:n.botZh}}const wN={INTJ:{nameZh:"建筑师",nameEn:"Architect",taglineZh:"要蓝图不要碎片:先给全貌和设计意图,细节他自己会填。",taglineEn:"Wants the blueprint, not fragments: give the big picture and design intent first; he'll fill in details himself.",botZh:"收到,我先给你画地图,路你自己走。",botEn:"Got it — I'll draw the map, you pick the path."},INTP:{nameZh:"逻辑学家",nameEn:"Logician",taglineZh:"定义先行:把概念边界和推理链讲清楚,他自己能走完。",taglineEn:"Definitions first: lay out concept boundaries and the reasoning chain; he can walk the rest.",botZh:"好,我们先把术语掰干净。",botEn:"Alright, let's nail down the terms first."},ENTJ:{nameZh:"指挥官",nameEn:"Commander",taglineZh:"目标导向:直说这知识能干什么、怎么最快上手。",taglineEn:"Goal-driven: say what this knowledge is for and the fastest way to competence.",botZh:"明白,直奔主线。",botEn:"Understood — straight to the main line."},ENTP:{nameZh:"辩论家",nameEn:"Debater",taglineZh:"辩论驱动:抛论点让他攻击,他记住的是自己反驳过的东西;小心他只聊不做题。",taglineEn:"Debate-driven: throw out claims for him to attack — he remembers what he argued against; watch that he doesn't just chat and skip quizzes.",botZh:"来,先过两招。",botEn:"Come on then — let's spar a round."},INFJ:{nameZh:"提倡者",nameEn:"Advocate",taglineZh:"意义驱动:先讲这知识为什么重要、和什么相连。",taglineEn:"Meaning-driven: start with why this matters and what it connects to.",botZh:"好的,从「为什么」讲起。",botEn:"Sure — let's start with the 'why'."},INFP:{nameZh:"调停者",nameEn:"Mediator",taglineZh:"兴趣驱动:用他关心的例子引路,少逼问多启发。",taglineEn:"Interest-driven: lead with examples he cares about; inspire more, interrogate less.",botZh:"嗯,我们挑你最有感觉的部分开始。",botEn:"Hmm — let's start with whatever resonates most."},ENFJ:{nameZh:"主人公",nameEn:"Protagonist",taglineZh:"共鸣驱动:多确认感受,节奏放软,用故事讲。",taglineEn:"Resonance-driven: check in on how it's landing, soften the pace, teach through stories.",botZh:"好呀,我们慢慢来。",botEn:"Of course — let's take it easy."},ENFP:{nameZh:"竞选者",nameEn:"Campaigner",taglineZh:"新鲜感驱动:多变花样、多跳观点,小心他三分钟热度。",taglineEn:"Novelty-driven: vary the angles and keep it fresh; watch for fading enthusiasm.",botZh:"走,今天学点新鲜的!",botEn:"Let's go — something fresh today!"},ISTJ:{nameZh:"物流师",nameEn:"Logistician",taglineZh:"顺序驱动:按地图一格一格来,讲清楚规则和依据。",taglineEn:"Order-driven: follow the map step by step; make rules and rationale explicit.",botZh:"好,按部就班。",botEn:"Good — step by step."},ISFJ:{nameZh:"守卫者",nameEn:"Defender",taglineZh:"稳妥驱动:小步确认,多鼓励,别一次灌太多。",taglineEn:"Steady-driven: small steps with frequent check-ins; encourage; don't dump too much at once.",botZh:"放心,我们一步步来。",botEn:"Don't worry — one step at a time."},ESTJ:{nameZh:"总经理",nameEn:"Executive",taglineZh:"务实驱动:直接给可执行的步骤和检验标准。",taglineEn:"Pragmatic-driven: hand over actionable steps and clear acceptance criteria.",botZh:"行,列个清单开工。",botEn:"Fine — checklist and go."},ESFJ:{nameZh:"执政官",nameEn:"Consul",taglineZh:"陪伴驱动:多互动多反馈,让他感到进度被看见。",taglineEn:"Companion-driven: interact and give feedback often so progress feels seen.",botZh:"一起学,我盯着你的进度。",botEn:"We'll learn together — I'm watching your progress."},ISTP:{nameZh:"鉴赏家",nameEn:"Virtuoso",taglineZh:"动手驱动:少讲理论多上手,例子要真实可拆。",taglineEn:"Hands-on-driven: less theory, more doing; examples must be real and dissectable.",botZh:"直接上手试试?",botEn:"Wanna just dive in?"},ISFP:{nameZh:"探险家",nameEn:"Adventurer",taglineZh:"体验驱动:从具体感受入手,审美和直觉都吃得开。",taglineEn:"Experience-driven: start from concrete impressions; aesthetics and intuition both work.",botZh:"我们从好玩的讲起。",botEn:"Let's start with the fun part."},ESTP:{nameZh:"企业家",nameEn:"Entrepreneur",taglineZh:"实战驱动:先跑起来再补理论,边做边纠。",taglineEn:"Action-driven: run it first, patch theory later; correct while doing.",botZh:"先干了再说。",botEn:"Do it now, talk later."},ESFP:{nameZh:"表演者",nameEn:"Entertainer",taglineZh:"舞台驱动:讲得有声有色,及时给掌声。",taglineEn:"Stage-driven: teach with color and energy; applaud generously and promptly.",botZh:"上课啦,今天包好看!",botEn:"Class is on — promise it'll be a good show!"}};function Io(e,t){const n=wN[e];return t==="en"?{code:e,name:n.nameEn,tagline:n.taglineEn,bot:n.botEn}:{code:e,name:n.nameZh,tagline:n.taglineZh,bot:n.botZh}}function UP({t:e,locale:t,profile:n,onSave:r,onCancel:s,testIdPrefix:i="boot"}){const a=m=>`${i}-edit-${m}`,[o,l]=k.useState({...n,style:{...n.style}}),u=t==="en",c=m=>l(g=>({...g,...m})),[h,f]=k.useState(()=>{var m;return((m=n.interests)==null?void 0:m.join(u?", ":"、"))??""}),d=u?", ":"、";return p.jsxs("section",{className:"flex flex-col gap-4","data-testid":`${i}-editcard`,children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-title font-bold text-ink mb-1",children:e("boot.profile_quiz.title")}),p.jsx("div",{className:"text-label text-ink-muted",children:e("boot.profile_quiz.desc")})]}),p.jsxs("label",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-label text-ink-faint",children:e("boot.card.name.label")}),p.jsx("input",{className:"bg-surface-0 rounded-lg px-3 py-2 text-body text-ink outline-none focus:ring-2 focus:ring-accent",placeholder:e("boot.card.name.placeholder"),value:o.name??"",onChange:m=>c({name:m.target.value||null}),"data-testid":a("name")})]}),p.jsx(kg,{t:e,locale:t,value:o.mbti,onPick:m=>{Rr(),c({mbti:m,style:Eg(m)})}}),p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-label text-ink",children:e("boot.card.motive.label")}),p.jsx("div",{className:"grid grid-cols-1 gap-1.5",role:"radiogroup","aria-label":e("boot.card.motive.label"),children:vg.map(m=>p.jsx("button",{role:"radio","aria-checked":o.motiveStage===m,className:o.motiveStage===m?"btn-3d-brand text-left px-3 py-2.5":"btn-3d-neutral text-left px-3 py-2.5",onClick:()=>c({motiveStage:m}),"data-testid":a(`motive-${m}`),children:Ir(m,t).name},m))}),o.motiveStage&&p.jsxs("div",{className:"reveal-enter rounded-xl bg-surface-0 p-3 flex flex-col gap-1","data-testid":a("motive-flip"),children:[p.jsx("div",{className:"text-label text-ink-muted",children:Ir(o.motiveStage,t).tagline}),p.jsx("div",{className:"text-label text-accent",children:Ir(o.motiveStage,t).bot})]})]}),p.jsxs("label",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-label text-ink-faint",children:e("boot.card.interests.label")}),p.jsx("input",{className:"bg-surface-0 rounded-lg px-3 py-2 text-body text-ink outline-none focus:ring-2 focus:ring-accent",placeholder:e("boot.card.interests.placeholder"),value:h,onChange:m=>{f(m.target.value),c({interests:vl(m.target.value)})},onBlur:()=>{var m;return f(((m=o.interests)==null?void 0:m.join(d))??"")},"data-testid":a("interests")})]}),p.jsxs("label",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-label text-ink-faint",children:e("boot.card.free.label")}),p.jsx("textarea",{className:"bg-surface-0 rounded-lg px-3 py-2 text-body text-ink outline-none focus:ring-2 focus:ring-accent resize-none",rows:2,placeholder:e("boot.card.free.placeholder"),value:o.freeNote??"",onChange:m=>c({freeNote:m.target.value||null}),"data-testid":a("free")})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsxs("button",{className:"btn-3d-brand inline-flex items-center gap-1.5 px-4 py-2",onClick:()=>r({...o,interests:vl(h),updatedAt:new Date().toISOString()}),"data-testid":a("save"),children:[p.jsx(tu,{size:16}),e("boot.profile.save")]}),s&&p.jsxs("button",{className:"btn-3d-neutral inline-flex items-center gap-1.5 px-4 py-2",onClick:s,children:[p.jsx(_n,{size:16}),e("boot.profile.cancel")]})]})]})}function kg({t:e,locale:t,value:n,onPick:r}){return p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx("span",{className:"text-label text-ink",children:e("boot.card.mbti.label")}),p.jsx("div",{className:"grid grid-cols-4 gap-1.5",role:"radiogroup","aria-label":e("boot.card.mbti.label"),"data-testid":"boot-mbti-grid",children:xN.map(s=>p.jsx("button",{role:"radio","aria-checked":n===s,className:n===s?"btn-3d-brand text-label px-1 py-2.5":"btn-3d-neutral text-label px-1 py-2.5",onClick:()=>r(s),"data-testid":`boot-mbti-${s}`,children:s},s))}),n&&p.jsxs("div",{className:"reveal-enter rounded-xl bg-surface-0 p-3 flex flex-col gap-1","data-testid":"boot-mbti-flip",children:[p.jsxs("div",{className:"text-label font-bold text-ink",children:[n," · ",Io(n,t).name]}),p.jsx("div",{className:"text-label text-ink-muted",children:Io(n,t).tagline}),p.jsx("div",{className:"text-label text-accent",children:Io(n,t).bot})]})]})}function SN(e){const t=e.wizardStep;return t<=1&&e.hasKey&&t===1?{scene:"profile_quiz",mood:"cheer",lines:[{key:"boot.profile_quiz.title"},{key:"boot.profile_quiz.desc"}],actions:[{kind:"wizard_next",labelKey:"boot.action.wizard_next"}],welcomeBack:!1}:t<=0?{scene:"welcome_intro",mood:"wave",lines:[{key:"boot.welcome.title"},{key:"boot.welcome.desc",vars:{name:e.name??""}},{key:"boot.welcome.forms"}],actions:[{kind:"wizard_next",labelKey:"boot.action.hello"}],welcomeBack:!1}:t===1?{scene:"key_setup",mood:"thinking",lines:[{key:"boot.key.title"},{key:"boot.key.desc"}],actions:[{kind:"settings_llm",labelKey:"boot.action.go_settings"},{kind:"wizard_next",labelKey:"boot.action.later"}],welcomeBack:!1}:t===2?{scene:"profile_quiz",mood:"cheer",lines:[{key:"boot.profile_quiz.title"},{key:"boot.profile_quiz.desc"}],actions:[{kind:"wizard_next",labelKey:e.profileFilled?"boot.action.done_quiz":"boot.action.wizard_next"}],welcomeBack:!1}:{scene:"course_pick",mood:"star",lines:[{key:"boot.pick.title"},{key:"boot.pick.desc"}],actions:[{kind:"start_import",labelKey:"boot.action.start_import"},{kind:"companion_settings",labelKey:"boot.action.companion"}],welcomeBack:!1}}function AN(e){const t=[];if(e.lastSession&&e.hasCourses)return e.dueCount>0&&t.push({kind:"review",labelKey:"boot.action.review_n"}),e.profileFilled||t.push({kind:"edit_profile",labelKey:"boot.action.edit_profile"}),{scene:"resume_last",mood:"wave",lines:[{key:"boot.resume.title",vars:{course:e.lastSession.courseTitle,node:e.lastSession.nodeTitle??""}},{key:"boot.resume.desc"},...e.dueCount>0?[{key:"boot.resume.due",vars:{n:e.dueCount}}]:[]],actions:[{kind:"resume",labelKey:"boot.action.resume"},...t.slice(0,2)],welcomeBack:!1};if(e.dueCount>0){const n=[];return e.profileFilled||n.push({kind:"edit_profile",labelKey:"boot.action.edit_profile"}),{scene:"review_due",mood:"cheer",lines:[{key:"boot.review.title",vars:{n:e.dueCount}},{key:"boot.review.desc"}],actions:[{kind:"review",labelKey:"boot.action.review"},...n.slice(0,2)],welcomeBack:!1}}return e.streak&&!e.streak.todayDone&&e.streak.atRisk?{scene:"streak_danger",mood:"star",lines:[{key:"boot.streak.title",vars:{hours:Math.max(1,Math.round(e.streak.hoursLeft))}},{key:"boot.streak.desc"}],actions:[{kind:"review",labelKey:"boot.action.keep_flame"},{kind:"pick_course",labelKey:"boot.action.pick_course"}],welcomeBack:!1}:e.suspendedExamNodeTitle?{scene:"exam_suspended",mood:"thinking",lines:[{key:"boot.exam.title",vars:{node:e.suspendedExamNodeTitle}},{key:"boot.exam.desc"}],actions:[{kind:"goto_node",labelKey:"boot.action.continue_exam",target:"exam"},{kind:"review",labelKey:"boot.action.review"}],welcomeBack:!1}:e.nearMasteryNodeTitle?{scene:"near_mastery",mood:"star",lines:[{key:"boot.mastery.title",vars:{node:e.nearMasteryNodeTitle}},{key:"boot.mastery.desc"}],actions:[{kind:"goto_node",labelKey:"boot.action.finish_it",target:"near_mastery"},{kind:"review",labelKey:"boot.action.review"}],welcomeBack:!1}:e.topFrictionNodeTitle?{scene:"friction_revisit",mood:"thinking",lines:[{key:"boot.friction.title",vars:{node:e.topFrictionNodeTitle}},{key:"boot.friction.desc"}],actions:[{kind:"goto_node",labelKey:"boot.action.retry",target:"friction"},{kind:"review",labelKey:"boot.action.review"}],welcomeBack:!1}:{scene:"ready_room",mood:"idle",lines:[{key:"boot.ready.title",vars:{name:e.name??""}},{key:e.profileFilled?"boot.ready.profile_done":"boot.ready.profile_empty"},...e.hasCourses?[{key:"boot.ready.has_courses"}]:[{key:"boot.ready.desc"}],...!e.hasKey&&!e.keyPromptDismissed?[{key:"boot.ready.key_hint"}]:[]],actions:[...e.hasCourses?[{kind:"pick_course",labelKey:"boot.action.pick_course"}]:[{kind:"pick_course",labelKey:"boot.action.import_course"}],{kind:"edit_profile",labelKey:e.profileFilled?"boot.action.view_profile":"boot.action.meet_me"}],welcomeBack:!1}}function CN(e){const t=e.bootDone?AN(e):SN(e);return e.bootDone?{...t,welcomeBack:e.returningAfterDays}:{...t,welcomeBack:!1}}const kh=4,Th=[{id:"cable-vs-wifi",better:"a",zh:{q:"同样一段数据,走网线还是走 WiFi,哪个延迟更低?",a:"网线",b:"WiFi",revealA:"对!网线是全双工专用通道,不受空气里的排队和干扰——打游戏的都懂。",revealB:"差一点!WiFi 是共享无线信道,要排队抢空气;网线是专用通道,延迟更稳更低。"},en:{q:"For the same chunk of data, which has lower latency — Ethernet cable or WiFi?",a:"Ethernet cable",b:"WiFi",revealA:"Correct! Ethernet is a dedicated full-duplex lane — no queuing in the air. Gamers know.",revealB:"Close! WiFi shares the wireless medium and queues for airtime; Ethernet is a dedicated lane with lower, steadier latency."}},{id:"http-vs-https",better:"a",zh:{q:"浏览器地址栏的 https 里的 s,保护的是哪一段?",a:"你电脑到网站之间的传输",b:"网站服务器本身不被黑",revealA:"对!s = 传输加密,防的是路上的偷看和篡改;服务器被黑是另一回事。",revealB:"不是哦——s 只加密'路上'的传输,服务器自己被攻破它管不着。"},en:{q:"In https, what does the 's' actually protect?",a:"The transport between your computer and the site",b:"The server from being hacked",revealA:"Right! s = encrypted transport — it stops eavesdropping and tampering in transit. Server breaches are a different problem.",revealB:"Not quite — the 's' only encrypts the road; if the server itself is compromised, it can't help."}},{id:"ram-vs-disk",better:"b",zh:{q:"断电后数据还在的是?",a:"内存(RAM)",b:"硬盘",revealB:"对!硬盘是持久存储;内存断电即忘——所以'保存'保存的是写进硬盘。",revealA:"恰恰相反——内存断电就忘,硬盘才记得住。'保存'就是从内存写进硬盘。"},en:{q:"Which one keeps its data after a power cut?",a:"RAM",b:"The disk",revealB:"Correct! Disks persist; RAM forgets on power loss — that's why 'save' means writing to disk.",revealA:"Other way around — RAM forgets on power loss; disks remember. 'Saving' means writing from RAM to disk."}},{id:"compile-vs-run",better:"b",zh:{q:"你写的代码,CPU 直接执行的是?",a:"你敲的源代码",b:"翻译后的机器指令",revealB:"对!CPU 只吃自己的指令集;你写的代码先被翻译(编译/解释)成机器指令。",revealA:"不不——CPU 看不懂你敲的语言,它只执行翻译后的机器指令。"},en:{q:"What does the CPU actually execute directly?",a:"The source code you type",b:"Translated machine instructions",revealB:"Correct! The CPU only speaks its own instruction set; your code is translated (compiled/interpreted) first.",revealA:"Nope — the CPU can't read your language; it runs translated machine instructions only."}},{id:"shortcut-ctrl-z",better:"a",zh:{q:"Ctrl+Z 撤销的是?",a:"上一次操作",b:"上一次保存",revealA:"对!撤销栈记的是操作历史,一步一步可以回退——是个'时间倒流'按钮。",revealB:"不是保存——撤销回退的是操作历史,跟保存点无关。"},en:{q:"What does Ctrl+Z undo?",a:"Your last action",b:"Your last save",revealA:"Right! The undo stack records action history — it's a mini time machine.",revealB:"Not saves — undo steps back through actions, not save points."}},{id:"cache-purpose",better:"a",zh:{q:"为什么删了缓存,下次打开 app 反而更慢?",a:"缓存是提前备好的常用数据",b:"删缓存把网络也删慢了",revealA:"对!缓存就是'放得近的备用件',删了它,app 只好重新去老远的地方拉一遍。",revealB:"网络没变慢——是缓存没了,常用数据得重新下载/计算一遍。"},en:{q:"Why is an app slower right after you clear its cache?",a:"Cache holds pre-fetched frequently-used data",b:"Clearing cache slows down your network",revealA:"Right! Cache is 'spare parts kept nearby'; clear it and the app must fetch everything from far away again.",revealB:"Your network didn't change — the cache is gone, so common data must be re-downloaded and recomputed."}}];function _N(e,t){const n=Th[NN(e,Th.length)];return t==="en"?{id:n.id,q:n.en.q,a:n.en.a,b:n.en.b,revealA:n.en.revealA,revealB:n.en.revealB,better:n.better}:{id:n.id,q:n.zh.q,a:n.zh.a,b:n.zh.b,revealA:n.zh.revealA,revealB:n.zh.revealB,better:n.better}}function NN(e,t){let n=2166136261;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619);return Math.abs(n)%t}const IN={wizard_next:p.jsx(tu,{size:16}),settings_llm:p.jsx(ym,{size:16}),pick_course:p.jsx(Jt,{size:16}),start_import:p.jsx(Bx,{size:16}),companion_settings:p.jsx(wx,{size:16}),resume:p.jsx(Am,{size:16}),review:p.jsx(gm,{size:16}),goto_node:p.jsx(vm,{size:16}),edit_profile:p.jsx(Gx,{size:16})},RN={welcome_intro:p.jsx(Ys,{size:22,className:"text-accent"}),key_setup:p.jsx(ym,{size:22,className:"text-warning"}),profile_quiz:p.jsx(xm,{size:22,className:"text-accent"}),course_pick:p.jsx(Jt,{size:22,className:"text-brand"}),resume_last:p.jsx(Am,{size:22,className:"text-brand"}),review_due:p.jsx(gm,{size:22,className:"text-accent"}),streak_danger:p.jsx(ga,{size:22,className:"text-review"}),friction_revisit:p.jsx(vm,{size:22,className:"text-accent"}),near_mastery:p.jsx(Im,{size:22,className:"text-gold"}),exam_suspended:p.jsx(Vi,{size:22,className:"text-warning"}),ready_room:p.jsx(Ys,{size:22,className:"text-accent"})};function MN(e){var w,E;const t=$e(),r=ba()==="en"?"en":"zh-CN",[s,i]=k.useState(null),[a,o]=k.useState(0),[l,u]=k.useState(null),c=k.useRef(!1);k.useEffect(()=>(mi(!0),()=>mi(!1)),[]),k.useEffect(()=>{let S=!0;return se.bootGetState().then(v=>{S&&(i(v),u(T=>T??No()))}).catch(()=>{S&&u(v=>v??No())}),se.profileGet().then(v=>{!S||!v||Eh(v)&&u(T=>T&&Eh(T)?T:v)}).catch(()=>{}),()=>{S=!1}},[]);const h=k.useMemo(()=>s?CN({...s,bootDone:s.bootDone&&a===0,wizardStep:a}):null,[s,a]),f=l??No(),d=k.useCallback(S=>{u(S),se.profileSet(S).then(()=>{var v;return(v=e.onProfileChanged)==null?void 0:v.call(e)}).catch(()=>{})},[e]);k.useEffect(()=>{!s||(h==null?void 0:h.scene)!=="ready_room"||s.hasKey||s.keyPromptDismissed||c.current||(c.current=!0,se.getSetting("key_prompt_count").then(S=>{const v=Number(S??"0")||0;return se.setSetting("key_prompt_count",String(v+1))}).catch(()=>{}))},[s,h]);const m=k.useCallback(()=>{se.setSetting("boot_done","1").catch(()=>{}),i(S=>S&&{...S,bootDone:!0})},[]),g=k.useCallback((S,v)=>{if(s){if(S==="wizard_next")o(T=>Math.min(kh-1,T+1));else if(S==="settings_llm")e.onOpenModelManager();else if(S==="start_import"||S==="pick_course")mi(!1),e.onPickCourse();else if(S==="companion_settings")e.onOpenSettings("companion");else if(S==="edit_profile")e.onOpenProfile();else if(S==="resume"&&s.targets.resume)m(),e.onResume(s.targets.resume.courseId,s.targets.resume.nodeId);else if(S==="review")e.onOpenReview(s.targets.reviewCourseId);else if(S==="goto_node"&&v){m();const T=v==="friction"?s.targets.frictionNodeId:v==="near_mastery"?s.targets.nearMasteryNodeId:s.targets.examNodeId;T&&e.onGotoNode(T,v)}}},[s,h,m,e]);if(!s||!h)return p.jsx("div",{className:"flex-1 flex items-center justify-center","data-testid":"boot-guide-loading",children:p.jsx("div",{className:"text-label text-ink-faint",children:t("boot.welcome.title")})});const b=(s.name??"").trim(),y=(S,v)=>t(S,{name:b?r==="en"?`${b}, `:`${b},`:"",...v});return p.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-8","data-testid":"boot-guide","data-scene":h.scene,"data-boot-done":s.bootDone?"1":"0",children:p.jsxs("div",{className:"mx-auto max-w-md flex flex-col gap-4","data-companion-anchor":"boot-guide",children:[h.welcomeBack&&p.jsx("div",{className:"text-center text-body text-accent font-bold","data-testid":"boot-welcome-back",children:y("boot.welcome_back")}),p.jsxs("section",{className:"surface-card rounded-2xl p-6 shadow-card flex flex-col gap-4","data-testid":`boot-card-${h.scene}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[RN[h.scene],p.jsx("div",{className:"text-title font-bold text-ink",children:y(((w=h.lines[0])==null?void 0:w.key)??"boot.ready.title",(E=h.lines[0])==null?void 0:E.vars)})]}),h.lines.slice(1).map(S=>p.jsx("p",{className:"text-body text-ink-muted leading-relaxed",children:y(S.key,S.vars)},S.key)),!(h.scene==="profile_quiz"&&a===2)&&p.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:h.actions.map(S=>p.jsxs("button",{className:S===h.actions[0]?"btn-3d-brand inline-flex items-center gap-1.5 px-4 py-2":"btn-3d-neutral inline-flex items-center gap-1.5 px-4 py-2",onClick:()=>g(S.kind,S.target),"data-testid":`boot-action-${S.kind}`,children:[IN[S.kind],t(S.labelKey,S.kind==="review"&&s.dueCount>0?{n:s.dueCount}:void 0)]},S.kind+(S.target??"")))}),!s.bootDone&&!(h.scene==="profile_quiz"&&a===2)&&p.jsx("div",{className:"flex gap-1.5","data-testid":"boot-wizard-dots",children:Array.from({length:kh}).map((S,v)=>p.jsx("span",{className:`h-1.5 rounded-full transition-all ${v===a?"w-6 bg-brand":"w-2 bg-neutral-300 dark:bg-neutral-700"}`},v))})]}),!s.bootDone&&a===2?p.jsxs(p.Fragment,{children:[p.jsx(PN,{t,locale:r,profile:f,onPatch:S=>d({...f,...S,style:{...f.style,...S.style},updatedAt:new Date().toISOString()}),onFinish:()=>{m(),o(3)}}),p.jsx("button",{className:"self-start text-label text-ink-faint hover:text-ink transition-colors px-1 py-1.5",onClick:()=>g("wizard_next"),"data-testid":"boot-wizard-skip-quiz",children:t("boot.action.skip_quiz")})]}):null]})})}function PN({t:e,locale:t,profile:n,onPatch:r,onFinish:s}){const[i,a]=k.useState(0),o=k.useMemo(()=>_N(new Date().toISOString().slice(0,10),t),[t]),[l,u]=k.useState(null),[c,h]=k.useState(()=>{var m;return((m=n.interests)==null?void 0:m.join(t==="en"?", ":"、"))??""}),f=t==="en"?", ":"、",d=p.jsx("div",{className:"flex gap-1.5","data-testid":"boot-wizard-subdots",children:[0,1,2].map(m=>p.jsx("span",{className:`h-1.5 rounded-full transition-all ${m===i?"w-6 bg-brand":"w-2 bg-neutral-300 dark:bg-neutral-700"}`},m))});return i===0?p.jsxs("section",{className:"surface-card rounded-2xl p-6 shadow-card flex flex-col gap-4","data-testid":"boot-wizard-card1",children:[d,p.jsxs("label",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-label text-ink-faint",children:e("boot.card.name.label")}),p.jsx("input",{className:"bg-surface-0 rounded-lg px-3 py-2 text-body text-ink outline-none focus:ring-2 focus:ring-accent",placeholder:e("boot.card.name.placeholder"),value:n.name??"",onChange:m=>r({name:m.target.value||null}),"data-testid":"boot-wizard-name"})]}),p.jsx(kg,{t:e,locale:t,value:n.mbti,onPick:m=>{Rr(),r({mbti:m,style:Eg(m)})}}),p.jsx("button",{className:"btn-3d-brand self-start px-4 py-2",onClick:()=>a(1),"data-testid":"boot-wizard-next1",children:n.mbti?e("boot.card.mbti.next"):e("boot.card.mbti.skip")})]}):i===1?p.jsxs("section",{className:"surface-card rounded-2xl p-6 shadow-card flex flex-col gap-4","data-testid":"boot-wizard-card2",children:[d,p.jsx("div",{className:"text-title font-bold text-ink",children:n.name?e("boot.card.motive.named",{name:n.name}):e("boot.card.motive.label")}),p.jsx("div",{className:"grid grid-cols-1 gap-1.5",role:"radiogroup","aria-label":e("boot.card.motive.label"),"data-testid":"boot-motive-grid",children:vg.map(m=>p.jsx("button",{role:"radio","aria-checked":n.motiveStage===m,className:n.motiveStage===m?"btn-3d-brand text-left px-3 py-2.5":"btn-3d-neutral text-left px-3 py-2.5",onClick:()=>{Rr(),r({motiveStage:m})},"data-testid":`boot-wizard-motive-${m}`,children:Ir(m,t).name},m))}),n.motiveStage&&p.jsxs("div",{className:"reveal-enter rounded-xl bg-surface-0 p-3 flex flex-col gap-1","data-testid":"boot-motive-flip",children:[p.jsx("div",{className:"text-label text-ink-muted",children:Ir(n.motiveStage,t).tagline}),p.jsx("div",{className:"text-label text-accent",children:Ir(n.motiveStage,t).bot})]}),p.jsxs("label",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-label text-ink-faint",children:e("boot.card.interests.label")}),p.jsx("input",{className:"bg-surface-0 rounded-lg px-3 py-2 text-body text-ink outline-none focus:ring-2 focus:ring-accent",placeholder:e("boot.card.interests.placeholder"),value:c,onChange:m=>{h(m.target.value),r({interests:vl(m.target.value)})},onBlur:()=>{var m;return h(((m=n.interests)==null?void 0:m.join(f))??"")},"data-testid":"boot-wizard-interests"})]}),p.jsx("button",{className:"btn-3d-brand self-start px-4 py-2",onClick:()=>a(2),"data-testid":"boot-wizard-next2",children:e("boot.card.motive.next")})]}):p.jsxs("section",{className:"surface-card rounded-2xl p-6 shadow-card flex flex-col gap-4","data-testid":"boot-wizard-card3",children:[d,p.jsx("div",{className:"text-title font-bold text-ink",children:e("boot.card.quiz.label")}),p.jsx("div",{className:"text-body text-ink",children:o.q}),l===null?p.jsxs("div",{className:"flex gap-2",role:"radiogroup","aria-label":o.q,children:[p.jsx("button",{role:"radio","aria-checked":!1,className:"btn-3d-neutral flex-1 px-3 py-2.5",onClick:()=>{u("a"),o.better==="a"&&Ar("correct")},"data-testid":"boot-wizard-quiz-a",children:o.a}),p.jsx("button",{role:"radio","aria-checked":!1,className:"btn-3d-neutral flex-1 px-3 py-2.5",onClick:()=>{u("b"),o.better==="b"&&Ar("correct")},"data-testid":"boot-wizard-quiz-b",children:o.b})]}):p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"reveal-enter rounded-xl bg-surface-0 p-3 text-label text-ink leading-relaxed","data-testid":"boot-wizard-quiz-reveal",children:l==="a"?o.revealA:o.revealB}),p.jsxs("button",{className:"btn-3d-brand self-start inline-flex items-center gap-1.5 px-4 py-2",onClick:s,"data-testid":"boot-wizard-finish",children:[p.jsx(tu,{size:16}),e("boot.card.quiz.next")]})]})]})}const wh=[{id:"spacing",zh:"隔一天再复习,比当场连看三遍记得牢——间隔重复是记忆的免费午餐。",en:"Revisiting after a day beats three passes in a row — spacing is memory's free lunch."},{id:"recall",zh:"合上书回想一遍,比再读一遍有效得多。难受的感觉正是记忆在加固。",en:"Close the book and recall — far more effective than rereading. The strain IS the strengthening."},{id:"teach",zh:"学完就假装教一个外行:讲不清的地方,就是你没真懂的地方。",en:"After learning, teach it to a layman: where you can't explain clearly is where you don't understand."},{id:"interleave",zh:"交替练不同的题型,比同一题型连刷十道更接近真实考试的样子。",en:"Mixing problem types beats grinding ten of the same — it looks more like real tests."},{id:"sleep",zh:"睡眠是记忆的保存按钮——熬夜学的,大脑来不及归档。",en:"Sleep is memory's save button — the brain can't file what you crammed at 3am."},{id:"small",zh:"每天 20 分钟胜过每周末 3 小时:习惯的对手是中断,不是时长。",en:"Twenty minutes daily beats three hours on Sunday: habits die from breaks, not from shortness."},{id:"why",zh:"先问「这东西解决什么问题」再学怎么做——带着问题的脑子记得牢。",en:"Ask 'what problem does this solve' before 'how' — a question-loaded brain retains better."},{id:"mistakes",zh:"错题本不是抄题本:只记「我当时为什么会那么想」。",en:"A mistake log isn't for copying problems — record only 'why did I think that'."},{id:"analogy",zh:"新概念配一个你熟悉领域的类比,像给记忆一个挂钩。",en:"Pair every new concept with an analogy from familiar ground — give memory a hook."},{id:"env",zh:"固定的学习角落会形成条件反射:一坐下,大脑就知道该开工了。",en:"A fixed study spot builds a reflex: sit down, and the brain knows it's time."}];function LN(e,t){let n=2166136261;for(let s=0;s<e.length;s++)n^=e.charCodeAt(s),n=Math.imul(n,16777619);const r=wh[Math.abs(n)%wh.length];return{id:r.id,text:t==="en"?r.en:r.zh}}function DN(){const e=$e(),n=ba()==="en"?"en":"zh-CN",[r,s]=k.useState(null);k.useEffect(()=>{let l=!0;return se.bootGetState().then(u=>{l&&s(u)}).catch(()=>{}),()=>{l=!1}},[]);const i=LN(new Date().toISOString().slice(0,10),n),a=(r==null?void 0:r.recap)??null,o=!!a&&(a.totalXp>0||a.masteredCount>0||a.streakDays>0);return p.jsx("div",{className:"h-full overflow-y-auto px-5 py-8","data-testid":"notebook-panel",children:p.jsx("div",{className:"h-full","data-testid":"boot-recap","data-mode":o?"recap":"tips",children:p.jsx("div",{className:"mx-auto max-w-sm flex flex-col gap-4",children:o&&a?p.jsxs("section",{className:"surface-card rounded-2xl p-5 shadow-card flex flex-col gap-4","data-testid":"boot-recap-card",children:[p.jsx("div",{className:"text-label font-bold text-ink",children:e("boot.recap.title")}),p.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[p.jsxs("div",{className:"rounded-xl bg-surface-0 p-3 flex flex-col gap-1","data-testid":"boot-recap-xp",children:[p.jsx(Gs,{size:18,className:"text-brand self-center"}),p.jsx("div",{className:"text-title font-bold text-ink",children:a.totalXp}),p.jsx("div",{className:"text-caption text-ink-muted",children:e("boot.recap.total_xp")})]}),p.jsxs("div",{className:"rounded-xl bg-surface-0 p-3 flex flex-col gap-1","data-testid":"boot-recap-mastered",children:[p.jsx(ru,{size:18,className:"text-gold self-center"}),p.jsx("div",{className:"text-title font-bold text-ink",children:a.masteredCount}),p.jsx("div",{className:"text-caption text-ink-muted",children:e("boot.recap.mastered")})]}),p.jsxs("div",{className:"rounded-xl bg-surface-0 p-3 flex flex-col gap-1","data-testid":"boot-recap-streak",children:[p.jsx(ga,{size:18,className:"text-review self-center"}),p.jsx("div",{className:"text-title font-bold text-ink",children:a.streakDays}),p.jsx("div",{className:"text-caption text-ink-muted",children:e("boot.recap.streak_days")})]})]}),(r==null?void 0:r.lastSession)&&p.jsxs("div",{className:"flex items-start gap-2 text-label text-ink-muted","data-testid":"boot-recap-recent",children:[p.jsx(Jt,{size:15,className:"shrink-0 mt-0.5 text-accent"}),p.jsxs("span",{children:[e("boot.recap.recent"),n==="en"?`: "${r.lastSession.courseTitle}"`:`:「${r.lastSession.courseTitle}」`,r.lastSession.nodeTitle?` · ${r.lastSession.nodeTitle}`:""]})]})]}):p.jsxs("section",{className:"surface-card rounded-2xl p-5 shadow-card flex flex-col gap-3","data-testid":"boot-tips-card",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Em,{size:18,className:"text-accent"}),p.jsx("div",{className:"text-label font-bold text-ink",children:e("boot.recap.tips_title")})]}),p.jsx("p",{className:"text-body text-ink-muted leading-relaxed","data-testid":"boot-tip-text",children:i.text})]})})})})}const Sh=[{bg:"#E8F0FE",fg:"#1a56DB"},{bg:"#E6F4EA",fg:"#137333"},{bg:"#FDF0E6",fg:"#B25000"},{bg:"#F3E8FD",fg:"#6B21A8"},{bg:"#FDE8E8",fg:"#B91C1C"},{bg:"#E0F2F1",fg:"#00695C"},{bg:"#FEF9E7",fg:"#92760B"},{bg:"#ECEFF1",fg:"#455A64"}];function ON(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return Math.abs(t)}function FN(e){const t=(e??"").trim();if(!t)return null;const n=[...t][0]??"",r=/[a-z]/i.test(n)?n.toUpperCase():n,s=Sh[ON(t.toLowerCase())%Sh.length];return{bg:s.bg,fg:s.fg,initial:r}}function BN(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 se.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 g=await se.canvasSave({...m,courseId:e});return n(b=>b.some(y=>y.id===g.id)?b:[g,...b]),g}catch{return null}},[e]),o=k.useCallback(async m=>{if(!e)return null;try{const g=await se.canvasSaveUserNote({...m,courseId:e});return n(b=>[g,...b]),g}catch{return null}},[e]),l=k.useCallback(async(m,g)=>{try{const b=await se.canvasRecordQuizResult(m,g);return b&&n(y=>y.map(w=>w.id===m?b:w)),b}catch{return null}},[]),u=k.useCallback(async(m,g)=>{try{const b=await se.canvasUpdateUserNoteComment(m,g);return b&&n(y=>y.map(w=>w.id===m?b:w)),b}catch{return null}},[]),c=k.useCallback(async m=>{try{await se.canvasDelete(m),n(g=>g.filter(b=>b.id!==m))}catch{}},[]),h=k.useCallback(async m=>{try{const g=await se.canvasTogglePin(m);g&&n(b=>b.map(w=>w.id===m?g:w).sort((w,E)=>E.pinned!==w.pinned?E.pinned-w.pinned:E.createdAt.localeCompare(w.createdAt)))}catch{}},[]),f=k.useCallback(m=>m===null?t:t.filter(g=>g.nodeId===m),[t]),d=k.useCallback((m,g)=>{const b=m===null?t:t.filter(y=>y.nodeId===m);return g==="note"?b.filter(y=>y.artifactType==="user_note"):g==="practice"?b.filter(y=>y.artifactType==="quiz"):b.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:h,byNode:f,byZone:d}}const Ah={small:16,medium:17,large:18},Ch="lookatstudy-font-size",jN="medium";function HN(){const[e,t]=k.useState(()=>{if(typeof localStorage<"u"){const r=localStorage.getItem(Ch);if(r&&r in Ah)return r}return jN});k.useEffect(()=>{document.documentElement.style.fontSize=`${Ah[e]}px`,localStorage.setItem(Ch,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}}function UN(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 zN(e){return e.map((t,n)=>t.type!=="tool-call"||t.state!=="output-error"?!0:!e.some((r,s)=>s>n&&r.type==="tool-call"&&r.toolName===t.toolName&&(r.state==="input-available"||r.state==="output-available")))}const Tg="end_review_session",wg="[[review-kickoff]]";function VN(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n.role==="assistant"&&qN(n.parts))return"ended";if(n.role==="user"&&$N(n.parts).includes(wg))return"open"}return"open"}function qN(e){for(const t of e)if(t.type==="tool-call"&&t.toolName===Tg&&t.state==="output-available")return!0;return!1}function $N(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}const Ro=new Map;function WN({ref_:e,onOpen:t}){const n=$e(),[r,s]=k.useState(e.previewUrl??(e.file?Ro.get(e.file)??null:null));return k.useEffect(()=>{if(r||!e.file)return;let i=!1;return(async()=>{const a=Ro.get(e.file);if(a){i||s(a);return}const o=await se.getAttachmentDataUrl(e.file);o&&!i&&(Ro.set(e.file,o),s(o))})(),()=>{i=!0}},[e.file,r]),r?p.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:p.jsx("img",{src:r,alt:e.name,className:"w-full h-full object-cover"})}):p.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 YN({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]),p.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:[p.jsx("img",{src:e,alt:t,className:"max-w-full max-h-full object-contain rounded-lg shadow-elevated"}),p.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:p.jsx(_n,{className:"w-4 h-4"})})]})}function GN({parts:e}){const t=$e(),[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 p.jsxs("div",{className:"flex flex-col gap-1.5 mb-1","data-testid":"message-attachments",children:[i.length>0&&p.jsx("div",{className:"flex gap-1.5 flex-wrap",children:i.map((o,l)=>p.jsx(WN,{ref_:o,onOpen:u=>r({src:u,name:o.name})},o.file??o.previewUrl??`${o.name}:${l}`))}),a.length>0&&p.jsx("div",{className:"flex gap-1.5 flex-wrap",children:a.map((o,l)=>p.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:[p.jsx(Vi,{className:"w-3 h-3 shrink-0"}),p.jsx("span",{className:"truncate max-w-[12rem]",children:o.name})]},`${o.name}:${l}`))}),n&&p.jsx(YN,{src:n.src,name:n.name,onClose:()=>r(null)})]})}const KN=k.lazy(()=>_e(()=>import("./index-CdZ-qnc_.js"),__vite__mapDeps([30,1,2,28,29,31]),import.meta.url).then(e=>({default:e.ArtifactRenderer})));function XN({messages:e,streaming:t,onApplyProposal:n,onRejectProposal:r,onUndoProposal:s,summary:i,onStartLearning:a,agentReady:o=!0,onOpenModelManager:l,hasNode:u=!0,selectedNodeId:c,threadId:h,onSaveChatNote:f,chatNotes:d,onPickQuizAction:m,onQuizCompleted:g,cardMode:b=!1,reviewNextNodeId:y,onStartReviewSession:w}){const E=$e(),S=Mu(),v=mg();k.useEffect(()=>{if(v.failReason){const q=v.failReason==="engine-unavailable"?"chat.speech.engine_unavailable":v.failReason==="azure-key-missing"?"chat.speech.azure_key_missing":v.failReason==="azure-region-missing"?"chat.speech.azure_region_missing":v.failReason==="edge-failed"?"chat.speech.edge_failed":v.failReason==="custom-provider-missing"?"chat.speech.custom_provider_missing":"chat.speech.model_missing";S.show(E(q),{severity:"warning"}),v.clearFailReason()}},[v.failReason,S,E,v]),k.useEffect(()=>{v.onlineNotice&&(S.show(E("chat.speech.edge_disclosed"),{severity:"info"}),v.clearOnlineNotice())},[v.onlineNotice,S,E,v]);const T=k.useCallback((q,K,M)=>{c&&se.recordQuizAnswer(c,M,q.kc).catch(()=>{})},[c]),[_,A]=k.useState(null);k.useEffect(()=>{if(!c){A(null);return}let q=!1;const K=()=>se.getProgress(c).then(G=>{q||A((G==null?void 0:G.mastery)??null)}).catch(()=>{});K();const M=se.on("state:changed",G=>{G==="mastery"&&K()});return()=>{q=!0,M()}},[c]);const N=k.useRef(null),C=k.useRef(!0),[D,P]=k.useState(!1);k.useEffect(()=>{const q=K=>{const M=K.detail;if(!(M!=null&&M.msgId))return;const G=document.querySelector(`[data-msg-id="${M.msgId}"]`);G&&(G.scrollIntoView({behavior:"smooth",block:"center"}),G.classList.add("ring-2","ring-accent","rounded-lg"),setTimeout(()=>G.classList.remove("ring-2","ring-accent","rounded-lg"),2500))};return window.addEventListener("lookatstudy-highlight-message",q),()=>window.removeEventListener("lookatstudy-highlight-message",q)},[]),k.useEffect(()=>{if(t||!N.current||!d||d.length===0)return;const q=setTimeout(()=>{if(!N.current)return;const K=new Map;for(const M of d)try{const G=JSON.parse(M.sourceAnchor);if(G.type==="chat"&&G.msgId){const ae=JSON.parse(M.data).text??"";if(ae){const ne=K.get(G.msgId)??[];ne.push({noteId:M.id,text:ae}),K.set(G.msgId,ne)}}}catch{}for(const[M,G]of K){const ae=N.current.querySelector(`[data-msg-id="${M}"]`);ae&&(wi()?Q0(ae,G):K0(ae,G))}},150);return()=>clearTimeout(q)},[e,d,t]),k.useEffect(()=>{const q=K=>{var ae;const M=K.detail;if(!M)return;if(wi()){const ne=Z0(M);ne&&J0(ne);return}const G=(ae=N.current)==null?void 0:ae.querySelector(`mark[data-note-id="${M}"]`);G&&og(G)};return window.addEventListener("lookatstudy-jump-to-chat-note",q),()=>window.removeEventListener("lookatstudy-jump-to-chat-note",q)},[]);const[O,I]=k.useState(null),R=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,B=k.useCallback(()=>{if(!f||!h)return;const q=window.getSelection(),K=(q==null?void 0:q.toString().trim())??"";if(K.length<2||K.length>500){I(null);return}const M=q==null?void 0:q.getRangeAt(0);if(!M){I(null);return}const G=N.current;if(!(G!=null&&G.contains(M.commonAncestorContainer))){I(null);return}let ae=M.commonAncestorContainer,ne=null;for(;ae&&ae!==G;){if(ae instanceof HTMLElement&&ae.dataset.msgId){ne=ae;break}ae=ae.parentNode}if(!ne){I(null);return}const X=ne.dataset.msgId,te=ur(ne),ue=W0(M,te),ge=M.getBoundingClientRect(),Z=G.getBoundingClientRect(),re=M.getClientRects(),be=re.length?re[re.length-1]:ge,ve=ug({left:ge.left-Z.left,top:ge.top-Z.top,right:ge.right-Z.left,bottom:ge.bottom-Z.top,width:ge.width,height:ge.height},Z.width,R?150:110,{left:be.left-Z.left,top:be.top-Z.top,right:be.right-Z.left,bottom:be.bottom-Z.top,width:be.width,height:be.height},R);I({x:ve.left,y:ve.top,transform:ve.transform,text:K,msgId:X,startOffset:ue==null?void 0:ue.start,endOffset:ue==null?void 0:ue.end})},[f,h,R]);k.useEffect(()=>{const q=R?600:250;let K=null,M=null,G=!1;const ae=()=>{var ue;return(((ue=window.getSelection())==null?void 0:ue.toString().trim().length)??0)>=2},ne=()=>{ae()?(M&&(clearTimeout(M),M=null),I(ue=>ue&&null),K&&clearTimeout(K),K=setTimeout(()=>{K=null,!G&&ae()&&B()},q)):M||(M=setTimeout(()=>I(ue=>ue&&null),250))},X=ue=>{var Z;const ge=ue.target;(Z=ge==null?void 0:ge.closest)!=null&&Z.call(ge,"[data-selection-popover]")||(G=!0)},te=()=>{G=!1,K&&(clearTimeout(K),K=null),!M&&ae()&&B()};return document.addEventListener("selectionchange",ne),window.addEventListener("pointerdown",X,!0),window.addEventListener("pointerup",te,!0),window.addEventListener("pointercancel",te,!0),()=>{document.removeEventListener("selectionchange",ne),window.removeEventListener("pointerdown",X,!0),window.removeEventListener("pointerup",te,!0),window.removeEventListener("pointercancel",te,!0),K&&clearTimeout(K),M&&clearTimeout(M)}},[B]);const V=k.useCallback(()=>{var K;if(!O||!f)return;const q=O.text.length>200?O.text.slice(0,200)+"…":O.text;f(q,O.msgId,O.startOffset,O.endOffset),I(null),(K=window.getSelection())==null||K.removeAllRanges()},[O,f]),z=k.useCallback(()=>{const q=N.current;if(!q)return;const K=q.scrollHeight-q.scrollTop-q.clientHeight<80;C.current=K,P(M=>M===!K?M:!K)},[]);k.useEffect(()=>{if(!C.current)return;const q=N.current;q&&(q.scrollTop=q.scrollHeight)},[e,t]);const Y=e.length>0&&e[e.length-1].role==="user";k.useEffect(()=>{if(!Y)return;C.current=!0,P(!1);const q=N.current;q&&(q.scrollTop=q.scrollHeight)},[Y]);const L=k.useCallback(()=>{const q=N.current;q&&(q.scrollTop=q.scrollHeight,C.current=!0,P(!1))},[]);return p.jsxs("div",{className:"relative flex-1 min-h-0",children:[p.jsxs("div",{ref:N,onScroll:z,className:`h-full overflow-y-auto px-3 py-4 space-y-2 relative ${b?"":"px-5 py-6 space-y-6"}`,"data-testid":"chat-stream",children:[e.length===0&&p.jsx("div",{className:"mt-10 mx-auto max-w-md","data-testid":"chat-empty-state",children:u?p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"text-center mb-4",children:[p.jsx("div",{className:"text-4xl mb-2 opacity-30",children:"📖"}),p.jsx("div",{className:"text-body font-bold text-ink-muted mb-1",children:E("chat.empty.greeting")}),p.jsx("div",{className:"text-ink-muted text-label",children:E("chat.empty.overview")})]}),i?p.jsxs("div",{className:"surface-card p-4 mb-4",children:[p.jsx("div",{className:"text-caption font-bold text-brand uppercase tracking-wider mb-2",children:E("chat.empty.summary.title")}),p.jsx("div",{className:"text-body text-ink-muted leading-relaxed whitespace-pre-wrap",children:i})]}):p.jsx("div",{className:"surface-card p-4 mb-4 text-center",children:p.jsx("div",{className:"text-body text-ink-muted",children:E("chat.empty.summary.none")})}),o?p.jsx(p.Fragment,{children:a&&p.jsxs("button",{onClick:a,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:[p.jsx(Zx,{className:"w-4 h-4"}),p.jsx("span",{children:E("chat.empty.start")})]})}):p.jsxs("div",{className:"surface-card p-4 mb-2","data-testid":"keyless-card",children:[p.jsx("div",{className:"text-body font-bold text-ink-muted mb-1",children:E("chat.empty.keyless.title")}),p.jsx("div",{className:"text-label text-ink-muted mb-3",children:E("chat.empty.keyless.desc")}),p.jsxs("button",{onClick:l,className:"btn-3d-brand w-full py-2 text-body font-bold flex items-center justify-center gap-2",children:[p.jsx(Ws,{className:"w-4 h-4"}),p.jsx("span",{children:E("chat.empty.keyless.btn")})]})]})]}):p.jsxs("div",{className:"text-center mt-16","data-testid":"no-node-selected",children:[p.jsx("div",{className:"text-5xl mb-3 opacity-25",children:"🗺️"}),p.jsx("div",{className:"text-body font-bold text-ink-muted mb-1",children:E("chat.empty.no_node.title")}),p.jsx("div",{className:"text-body text-ink-muted max-w-xs mx-auto",children:E("chat.empty.no_node.desc")})]})}),e.map(q=>p.jsx("div",{className:b?"":"contents",children:p.jsx("div",{className:b&&q.role==="assistant"?"surface-card p-4 rounded-2xl shadow-card":void 0,children:p.jsx(QN,{msg:q,onApplyProposal:n,onRejectProposal:r,onUndoProposal:s,onQuizAnswered:T,quizMastery:_,onPickAction:m,onQuizCompleted:g,reviewNextNodeId:y,onStartReviewSession:w,speakingMessageId:v.speakingMessageId,speakingSentence:v.speakingSentence,playingSentence:v.playingSentence,streamTexts:v.streamTexts,onSpeak:v.speak})})},q.id)),t&&p.jsxs("div",{className:"flex items-center gap-1.5 text-body text-brand",children:[p.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),p.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),p.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"})]})]}),D&&e.length>0&&p.jsxs("button",{onClick:L,"data-testid":"scroll-to-bottom","aria-label":E("chat.scroll.bottom"),title:E("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:[p.jsx(pa,{className:"w-5 h-5"}),t&&p.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"})]}),O&&p.jsxs("button",{onClick:V,"data-testid":"save-chat-note-btn","data-selection-popover":!0,style:{left:O.x,top:O.y,transform:O.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:E("chat.note.add.title"),children:[p.jsx(Ri,{className:"w-3 h-3"})," ",E("chat.note.add")]})]})}function _h(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 QN({msg:e,onApplyProposal:t,onRejectProposal:n,onUndoProposal:r,onQuizAnswered:s,quizMastery:i,onPickAction:a,onQuizCompleted:o,reviewNextNodeId:l,onStartReviewSession:u,speakingMessageId:c,speakingSentence:h,playingSentence:f,streamTexts:d,onSpeak:m}){const g=$e(),b=k.useRef(null),y=e.parts.map(v=>v.type==="text"?v.text:"").join("").trim(),w=c===e.id,E=w&&f!=null?f.index:null;k.useEffect(()=>{const v=b.current;if(!v)return;if(E==null){ir(v);return}const T=q0(d??[],E);if(!T)return;E===0&&ig(v);const _=setTimeout(()=>{const A=sg(v,T,{within:'[data-testid="part-text"]'});A&&ag(A,v.closest(".overflow-y-auto"))},30);return()=>clearTimeout(_)},[E,d]),k.useEffect(()=>{E==null&&b.current&&ir(b.current)},[E]);const S=k.useRef(!1);return S.current=E!=null,k.useEffect(()=>()=>{S.current&&ir(document.body)},[]),e.role==="user"?p.jsx("div",{className:"msg-enter flex justify-end","data-testid":"msg-user","data-msg-id":e.id,children:p.jsxs("div",{className:"max-w-[85%] bg-ink/[0.04] rounded-2xl rounded-br-md px-4 py-2.5",children:[p.jsx(GN,{parts:e.parts}),p.jsx("div",{className:"font-medium text-ink-strong whitespace-pre-wrap select-text text-body",children:e.displayText??e.parts.map((v,T)=>v.type==="text"?p.jsx("span",{children:v.text},T):null)})]})}):p.jsxs("div",{className:"msg-enter",ref:b,"data-testid":"msg-assistant","data-msg-id":e.id,children:[p.jsx("div",{className:"min-w-0 space-y-2.5",children:(()=>{const v=zN(e.parts);return e.parts.map((T,_)=>v[_]?p.jsx(ZN,{part:T,msgId:e.id,toolCallIdx:_,onApplyProposal:t,onRejectProposal:n,onUndoProposal:r,onQuizAnswered:s,quizMastery:i,onPickAction:a,onQuizCompleted:o,reviewNextNodeId:l,onStartReviewSession:u},_):null)})()}),m&&y&&p.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[p.jsx("button",{onClick:()=>m(e.id,y),"data-testid":w?"speech-stop-btn":"speech-speak-btn","aria-label":g(w?"chat.speech.stop":"chat.speech.speak"),title:g(w?"chat.speech.stop":"chat.speech.speak"),className:`w-7 h-7 rounded-lg flex items-center justify-center transition ${w?"bg-brand/15 text-brand":"text-ink-muted hover:bg-ink/[0.06] hover:text-ink"}`,children:w?p.jsx(iu,{className:"w-3.5 h-3.5"}):p.jsx(Rm,{className:"w-4 h-4"})}),w&&h&&h.total>0&&p.jsx("span",{className:"text-caption text-ink-muted",children:g("chat.speech.progress").replace("{n}",String(h.index+1)).replace("{total}",String(h.total))})]})]})}function ZN({part:e,msgId:t,toolCallIdx:n,onApplyProposal:r,onRejectProposal:s,onUndoProposal:i,onQuizAnswered:a,quizMastery:o,onPickAction:l,onQuizCompleted:u,reviewNextNodeId:c,onStartReviewSession:h}){const f=V0(e.type==="text"?e.text:"");if(e.type==="text")return p.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:p.jsx(Ip,{remarkPlugins:f.remarkPlugins,rehypePlugins:f.rehypePlugins,components:tI,children:lg(e.text)})});if(e.type==="reasoning")return p.jsx(JN,{text:e.text});if(e.type!=="tool-call")return null;const{toolName:d,state:m,output:g,error:b}=e;return p.jsx(eI,{toolName:d,state:m,output:g,error:b,msgId:t,toolCallIdx:n,onApplyProposal:r,onRejectProposal:s,onUndoProposal:i,onQuizAnswered:a,quizMastery:o,onPickAction:l,onQuizCompleted:u,reviewNextNodeId:c,onStartReviewSession:h})}function JN({text:e}){const t=$e(),[n,r]=k.useState(!1);return p.jsxs("div",{className:"rounded-lg bg-surface-1/60 border border-[var(--border-faint)]","data-testid":"part-reasoning",children:[p.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:[p.jsxs("span",{children:[n?"▾":"▸"," ",t("chat.reasoning.label")]}),p.jsx("span",{className:"text-ink-muted font-normal",children:t("chat.reasoning.chars",{n:e.length})})]}),n&&p.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 eI({toolName:e,state:t,output:n,error:r,msgId:s,toolCallIdx:i,onApplyProposal:a,onRejectProposal:o,onUndoProposal:l,onQuizAnswered:u,quizMastery:c,onPickAction:h,onQuizCompleted:f,reviewNextNodeId:d,onStartReviewSession:m}){const g=$e(),[b,y]=k.useState(!1);k.useEffect(()=>{if(!b)return;const T=window.setTimeout(()=>y(!1),3e3);return()=>window.clearTimeout(T)},[b]);const w=e==="record_answer"||e==="mark_mastered";if(e==="update_learner_profile"&&t==="output-available")return p.jsxs("div",{className:"rounded-xl border border-ink/10 bg-ink/5 p-3 flex items-center gap-2","data-testid":"part-profile-suggest",children:[p.jsx(oy,{className:"w-4 h-4 text-accent shrink-0"}),p.jsx("span",{className:"text-label text-ink-muted",children:g("chat.profile_sent")})]});if(e===Tg&&t==="output-available"&&n&&typeof n=="object"&&n.status==="ended"){const T=n,_=String(T.quality);return p.jsxs("div",{className:"rounded-xl border border-gold/30 bg-gold/5 overflow-hidden","data-testid":"review-outcome-card",children:[p.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 border-b border-[var(--border-faint)]",children:[p.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-lg bg-gold/15 text-gold shrink-0",children:p.jsx(Lc,{className:"w-4 h-4"})}),p.jsx("span",{className:"text-lead font-bold text-ink",children:g("review.outcome.title")}),p.jsx("span",{className:`ml-auto px-2 py-0.5 rounded-full text-label font-bold ${T.quality>=4?"bg-brand/15 text-brand":T.quality>=3?"bg-accent/15 text-accent":"bg-review/15 text-review"}`,"data-testid":"review-outcome-quality",children:g(`review.outcome.quality.${_}`)})]}),p.jsxs("div",{className:"px-4 py-3 space-y-2",children:[T.summary&&p.jsx("div",{className:"text-body text-ink leading-relaxed",children:T.summary}),T.weakPoints&&T.weakPoints.length>0&&p.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[p.jsx("span",{className:"text-caption font-bold text-ink-muted",children:g("review.outcome.weak")}),T.weakPoints.map((A,N)=>p.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-3 text-label text-ink-muted",children:A},N))]}),p.jsxs("div",{className:"flex items-center gap-1.5 text-label text-ink-muted","data-testid":"review-outcome-next",children:[p.jsx(Ax,{className:"w-3.5 h-3.5 shrink-0"}),T.intervalDays===1?g("review.outcome.tomorrow"):g("review.outcome.next",{n:String(T.intervalDays)})]}),d&&m&&p.jsxs("button",{onClick:()=>m(d),"data-testid":"review-outcome-next-lesson",className:"btn-3d-neutral px-3 py-1.5 text-body",children:[p.jsx(Lc,{className:"w-3.5 h-3.5 inline"}),g("review.outcome.nextLesson")]})]})]})}const E=w&&t==="output-available"&&typeof n=="object"&&n!==null?n:null;if(E!=null&&E.proposalId){const T=E.status,_=!!E.undone,A=!!E.canUndo;return T==="applied"&&_?p.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-undone",children:[p.jsx(Fc,{className:"w-4 h-4 text-ink-muted shrink-0"}),p.jsx("span",{className:"text-body text-ink-muted",children:g("chat.proposal.undone")})]}):T==="applied"?p.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:[p.jsx(nu,{className:"w-4 h-4 text-gold shrink-0"}),p.jsx("span",{className:"text-body font-bold text-ink",children:g("chat.proposal.applied")}),A&&l&&p.jsxs("button",{type:"button",onClick:()=>{b?(y(!1),l(E.proposalId,s,i)):y(!0)},"data-testid":b?"proposal-undo-confirm":"proposal-undo",className:`ml-auto px-3 py-1 rounded-full text-caption font-medium flex items-center gap-1 transition-colors ${b?"bg-warning/20 text-warning":"text-ink-muted hover:text-ink-strong hover:bg-ink/[0.06]"}`,children:[p.jsx(Fc,{className:"w-3.5 h-3.5"}),g(b?"chat.proposal.undo_confirm":"chat.proposal.undo")]})]}):T==="rejected"?p.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:[p.jsx(Nx,{className:"w-4 h-4 text-ink-muted shrink-0"}),p.jsx("span",{className:"text-body text-ink-muted",children:g("chat.proposal.rejected")})]}):p.jsxs("div",{className:"proposal-card relative rounded-xl border border-brand/30 bg-brand/5 overflow-hidden","data-testid":"part-proposal",children:[p.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 bg-brand"}),p.jsxs("div",{className:"pl-4 pr-3 py-3",children:[p.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[p.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-lg bg-brand/15 text-brand shrink-0",children:p.jsx(xm,{className:"w-4 h-4"})}),p.jsx("span",{className:"text-lead font-bold text-ink",children:g("chat.proposal.mastered.title")})]}),E.message&&p.jsx("div",{className:"text-body text-ink mb-2 leading-relaxed",children:E.message}),p.jsx("div",{className:"text-caption text-ink-muted mb-3",children:g("chat.proposal.mastered.hint")}),p.jsxs("div",{className:"flex gap-2",children:[p.jsxs("button",{onClick:()=>a==null?void 0:a(E.proposalId,s,i),"data-testid":"proposal-apply",className:"btn-3d-brand px-4 py-1.5 text-body",children:[p.jsx(xn,{className:"w-3.5 h-3.5 inline"}),g("chat.proposal.confirm")]}),p.jsx("button",{onClick:()=>o==null?void 0:o(E.proposalId,s,i),"data-testid":"proposal-reject",className:"btn-3d-neutral px-4 py-1.5 text-body",children:g("chat.proposal.later")})]})]})]})}if(t==="output-available"&&n&&typeof n=="object"&&"artifactType"in n){const T=n.artifactType;return p.jsx("div",{className:"my-1 max-w-full","data-testid":`inline-artifact-${T}`,"data-tool":e,children:p.jsx(k.Suspense,{fallback:null,children:p.jsx(KN,{data:n,onQuizAnswered:u,quizMastery:c,onPickAction:h,onQuizCompleted:f})})})}const v=nI(e,g);return p.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"?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),p.jsxs("span",{className:"text-ink-muted",children:[v,"…"]})]}):t==="output-error"?p.jsxs(p.Fragment,{children:[p.jsx(pm,{className:"w-3.5 h-3.5 text-warning shrink-0"}),p.jsxs("span",{className:"text-warning",children:[v,": ",r]})]}):p.jsxs(p.Fragment,{children:[p.jsx(Mm,{className:"w-3.5 h-3.5 text-ink-faint shrink-0"}),p.jsx("span",{className:"text-ink-muted",children:v})]})})}const tI={pre({children:e,...t}){return p.jsx(xg,{...t,children:e})},a({children:e,...t}){return p.jsx("a",{...t,target:"_blank",rel:"noopener noreferrer",children:e})},table({children:e}){return p.jsx("div",{className:"overflow-x-auto my-4",children:p.jsx("table",{children:e})})}};function nI(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"),end_review_session:t("chat.tool.end_review_session")}[e]??e}const Si={maxPerMessage:4,maxImageBytes:5*1024*1024,maxTextBytes:256*1024},rI=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 Nh(e){const t=e.lastIndexOf(".");return t<=0||t===e.length-1?"":e.slice(t+1).toLowerCase()}function iI(e,t,n){return t&&t.startsWith("image/")||["png","jpg","jpeg","webp","gif","bmp"].includes(Nh(e))?n>Si.maxImageBytes?{ok:!1,reason:"tooLargeImage"}:{ok:!0,kind:"image"}:rI.has(Nh(e))?n>Si.maxTextBytes?{ok:!1,reason:"tooLargeText"}:{ok:!0,kind:"text"}:{ok:!1,reason:"unsupported"}}const Ih=/[\u3400-\u9fff\u3000-\u303f\uff00-\uffef]/,sI=/^[,。、;:?!,.!?;:…—))」』》〉]/;function aI(e,t){if(!t)return e;if(!e)return t;if(/\s$/.test(e)||sI.test(t))return e+t;const n=e[e.length-1];return Ih.test(n)||Ih.test(t[0])?e+t:`${e} ${t}`}function oI(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 lI(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 uI(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 cI(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(h,f){a==null&&(a=f);const d=u==null?0:Math.max(0,f-u);if(u=f,h>=t)o+=d,o>=n&&(c=!0,l=f);else if(i&&c&&l!=null&&f-l>=r)return"auto-stop";return i&&f-a>=s?"auto-stop":"listening"},hadSpeech(){return c}}}const Mo=16e3;function dI(e,t={}){const[n,r]=k.useState(!1),[s,i]=k.useState(!1),[a,o]=k.useState(0),[l,u]=k.useState(null),[c,h]=k.useState(null),f=k.useRef(null),d=k.useRef(null),m=k.useRef(null),g=k.useRef([]),b=k.useRef([]),y=k.useRef(!1),w=k.useRef(null),E=k.useRef(0),S=k.useRef(e);S.current=e;const v=k.useRef(t);v.current=t;const T=k.useRef(!1),_=k.useRef(!1),A=k.useCallback(()=>{var O,I,R;y.current=!1,(O=m.current)==null||O.disconnect(),m.current=null,(I=d.current)==null||I.getTracks().forEach(B=>B.stop()),d.current=null,(R=f.current)==null||R.close().catch(()=>{}),f.current=null,g.current=[],b.current=[],w.current=null,o(0)},[]),N=k.useCallback(()=>{var K;const O=g.current,I=b.current,R=((K=w.current)==null?void 0:K.hadSpeech())??!1;g.current=[],b.current=[];let B=0;for(const M of O)B+=M.length;if(A(),r(!1),B===0)return;if(!R){h("no-speech");return}const V=uI(O,I);let z=0;for(const M of V)z+=M.length;const Y=new Float32Array(z);let L=0;for(const M of V)Y.set(M,L),L+=M.length;const q=oI(Y,Mo);i(!0),h(null),window.api.asrTranscribe(q,v.current.locale).then(M=>{M.ok?S.current(M.text):h(M.reason)}).catch(()=>h("asr-failed")).finally(()=>i(!1))},[A]),C=k.useCallback(()=>{y.current&&N()},[N]),D=k.useCallback(()=>{y.current||T.current||(u(null),T.current=!0,(async()=>{var O;try{if(((O=navigator.mediaDevices)==null?void 0:O.getUserMedia)==null){u(window.isSecureContext?"mic-unavailable":"mic-insecure-context");return}const I=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}}),R=window.AudioContext??window.webkitAudioContext;let B;try{B=new R({sampleRate:Mo})}catch{B=new R}f.current=B,d.current=I,y.current=!0,w.current=cI({autoStop:v.current.autoStop!==!1});const V=B.createMediaStreamSource(I),z=B.createScriptProcessor(4096,1,1);m.current=z;const Y=B.sampleRate/Mo;z.onaudioprocess=q=>{var X;if(!y.current)return;const K=q.inputBuffer.getChannelData(0),M=Y===1?new Float32Array(K):lI(K,Y);g.current.push(M);let G=0;for(let te=0;te<M.length;te++)G+=M[te]*M[te];const ae=Math.sqrt(G/M.length);b.current.push(ae),E.current=E.current*.7+ae*.3,o(Math.min(1,E.current*8)),$b(Math.min(1,E.current*8)),((X=w.current)==null?void 0:X.feed(ae,performance.now()))==="auto-stop"&&y.current&&N()},V.connect(z);const L=B.createGain();L.gain.value=0,z.connect(L),L.connect(B.destination),r(!0),_.current&&(_.current=!1,N())}catch(I){A(),r(!1),u(I instanceof Error?I.message:String(I))}finally{T.current=!1}})())},[A,N]),P=k.useCallback(()=>{y.current?C():T.current&&(_.current=!0)},[C]);return k.useEffect(()=>()=>{y.current&&A()},[A]),{listening:n,transcribing:s,level:a,startError:l,transcribeError:c,clearTranscribeError:()=>h(null),beginHold:D,endHold:P}}function hI(e){return!e||e.input===null||e.input===void 0?null:`$${String(Number(e.input.toFixed(2)))}`}function fI({onOpenModelManager:e}){var g;const t=$e(),[n,r]=k.useState(!1),[s,i]=k.useState(null),[a,o]=k.useState(""),[l,u]=k.useState(""),c=k.useRef(null),h=k.useCallback(async()=>{var b,y;try{const[w,E,S,v]=await Promise.all([se.getProviderPresets(),se.listCustomProviders(),se.getSetting("active_provider"),se.getSetting("active_model")]),T=S??"glm",_=await Promise.all(w.map(async O=>await se.hasSetting(O.apiKeySetting))),A=new Set;w.forEach((O,I)=>{(_[I]||O.id===T)&&A.add(O.id)});const N=[],C=(O,I,R)=>{for(const B of R)N.push({providerId:O,providerLabel:I,modelId:B.id,modelLabel:B.label,vision:(B.capabilities??[]).includes("vision"),contextWindow:B.contextWindow,...B.reasoning!==void 0?{reasoning:B.reasoning}:{},...B.free!==void 0?{free:B.free}:{},...B.pricing!==void 0?{pricing:B.pricing}:{},...B.status!==void 0?{status:B.status}:{}})};for(const O of w)A.has(O.id)&&C(O.id,O.label,O.models);const D=E.filter(O=>O.kind==="llm");for(const O of D)C(O.id,O.label,O.models);const P=v??"";if(P&&!N.some(O=>O.providerId===T&&O.modelId===P)){const O=((b=w.find(I=>I.id===T))==null?void 0:b.label)??((y=D.find(I=>I.id===T))==null?void 0:y.label)??T;N.unshift({providerId:T,providerLabel:O,modelId:P,modelLabel:P,vision:!0,contextWindow:null})}i(N),o(T),u(P)}catch{i([])}},[]);k.useEffect(()=>{h();const b=()=>void h();return window.addEventListener("llm-config-changed",b),()=>window.removeEventListener("llm-config-changed",b)},[h]),k.useEffect(()=>{if(!n)return;const b=w=>{var E;w.target instanceof Node&&((E=c.current)==null?void 0:E.contains(w.target))!==!0&&r(!1)},y=w=>{w.key==="Escape"&&r(!1)};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",y),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",y)}},[n]);const f=async b=>{if(r(!1),!(b.providerId===a&&b.modelId===l))try{await se.setSetting("active_provider",b.providerId),await se.setSetting("active_model",b.modelId),o(b.providerId),u(b.modelId),window.dispatchEvent(new Event("llm-config-changed"))}catch{}},d=((g=s==null?void 0:s.find(b=>b.providerId===a&&b.modelId===l))==null?void 0:g.modelLabel)??l??t("model.picker.label"),m=[];for(const b of s??[]){const y=m[m.length-1];y&&y.label===b.providerLabel?y.rows.push(b):m.push({label:b.providerLabel,rows:[b]})}return p.jsxs("div",{ref:c,className:"relative","data-testid":"composer-model",children:[p.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:[p.jsx(Sx,{className:"w-3 h-3 shrink-0 coarse-only","aria-hidden":!0}),p.jsx("span",{className:"truncate tb-label",children:d}),p.jsx(mm,{className:`w-3 h-3 shrink-0 tb-chevron transition-transform ${n?"":"rotate-180"}`})]}),n&&p.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&&p.jsx("div",{className:"px-3 py-2 text-caption text-ink-faint",children:t("model.picker.noneConfigured")}),m.map(b=>p.jsxs("div",{role:"group","aria-label":b.label,children:[p.jsx("div",{className:"px-3 pt-1.5 pb-0.5 text-caption font-bold text-ink-faint",children:b.label}),b.rows.map(y=>{const w=y.providerId===a&&y.modelId===l,E=y.free?t("model.picker.free"):hI(y.pricing),S=y.pricing&&(y.pricing.input!==null||y.pricing.output!==null)?t("model.picker.price",{i:y.pricing.input===null?"?":String(Number(y.pricing.input.toFixed(2))),o:y.pricing.output===null?"?":String(Number(y.pricing.output.toFixed(2)))}):null,v=y.status==="deprecated";return p.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":w,onClick:()=>void f(y),className:`w-full flex items-center gap-1.5 px-3 py-1.5 text-left transition-colors ${w?"text-brand":"text-ink-strong hover:bg-ink/[0.06]"} ${v?"opacity-55":""}`,children:[p.jsx(xn,{className:`w-3.5 h-3.5 shrink-0 ${w?"opacity-100":"opacity-0"}`}),p.jsx("span",{className:`flex-1 truncate text-label ${v?"line-through decoration-ink-faint":""}`,children:y.modelLabel}),y.reasoning&&p.jsx(fm,{className:"w-3 h-3 shrink-0 text-ink-faint","aria-label":t("model.picker.reasoning")}),y.vision&&p.jsx(Mx,{className:"w-3 h-3 shrink-0 text-ink-faint","aria-label":t("model.picker.vision")}),E&&S&&p.jsx("span",{className:"shrink-0 text-caption text-ink-faint tabular-nums","data-tooltip":S,children:E})]},`${y.providerId}:${y.modelId}`)})]},b.label)),p.jsx("div",{className:"border-t border-[var(--border)] mt-1 pt-1",children:p.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:[p.jsx(ty,{className:"w-3.5 h-3.5"}),t("model.picker.manage")]})})]})]})}const El=5.5,Rh=2*Math.PI*El,br=["system","node","learner","history","draft"],Mh={system:"bg-accent",node:"bg-brand",learner:"bg-gold",history:"bg-ink/50",draft:"bg-exam"};function mI({info:e,historyTokens:t,draftTokens:n}){const r=$e(),[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 f=m=>{var g;m.target instanceof Node&&((g=a.current)==null?void 0:g.contains(m.target))!==!0&&i(!1)},d=m=>{m.key==="Escape"&&i(!1)};return document.addEventListener("pointerdown",f),document.addEventListener("keydown",d),()=>{document.removeEventListener("pointerdown",f),document.removeEventListener("keydown",d)}},[s]),!e)return null;const o={system:e.systemTokens,node:e.nodeTokens,learner:e.learnerTokens,history:t,draft:n},l=br.reduce((f,d)=>f+o[d],0),u=cy(l,e.contextWindow),c=u!==null&&u>=85,h=dy(br.map(f=>o[f]),u??0);return p.jsxs("span",{ref:a,className:"relative inline-flex items-center","data-testid":"composer-context",children:[p.jsxs("button",{type:"button",onClick:()=>i(!s),disabled:e.contextWindow===null,"aria-label":r("context.aria",{p:u!==null?`${u}%`:mr(l)}),"aria-haspopup":"dialog","aria-expanded":s,"data-testid":"composer-context-trigger","data-tooltip":e.contextWindow===null?`${r("context.label")} ~${mr(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:[p.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":!0,className:"shrink-0",children:[p.jsx("circle",{cx:"7",cy:"7",r:El,fill:"none",strokeWidth:"2",className:"stroke-ink/20"}),p.jsx("circle",{cx:"7",cy:"7",r:El,fill:"none",strokeWidth:"2",stroke:"currentColor",strokeLinecap:"round",strokeDasharray:`${Rh*(u??100)/100} ${Rh}`,transform:"rotate(-90 7 7)"})]}),u!==null?p.jsxs("span",{className:"tb-label",children:[u,"%"]}):p.jsxs("span",{className:"tb-label",children:["~",mr(l)]})]}),s&&e.contextWindow!==null&&p.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:[p.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[p.jsx("span",{className:"text-label font-bold text-ink-strong",children:r("context.label")}),p.jsxs("span",{className:`text-caption ${c?"text-warning":"text-ink-muted"}`,children:[r("context.approx")," ",mr(l)," / ",mr(e.contextWindow)]})]}),p.jsx("div",{className:"flex h-2 rounded-full overflow-hidden bg-ink/10 mb-2",role:"img","aria-label":`${u}%`,children:br.map(f=>h[br.indexOf(f)]>0?p.jsx("div",{className:Mh[f],style:{width:`${h[br.indexOf(f)]}%`}},f):null)}),p.jsx("dl",{className:"space-y-1",children:br.map(f=>p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("dt",{className:"flex items-center gap-1.5 text-caption text-ink-muted",children:[p.jsx("span",{className:`w-2 h-2 rounded-sm ${Mh[f]}`,"aria-hidden":!0}),r(`context.${f}`)]}),p.jsxs("dd",{className:"text-caption text-ink-strong tabular-nums",children:["~",mr(o[f])]})]},f))}),e.pricing&&(e.pricing.input!==null||e.pricing.output!==null)&&p.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border-faint)] text-caption text-ink-faint tabular-nums","data-testid":"context-price",children:r("context.price",{i:e.pricing.input===null?"?":String(Number(e.pricing.input.toFixed(2))),o:e.pricing.output===null?"?":String(Number(e.pricing.output.toFixed(2)))})})]})]})}const kl={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}},deepseek:{fast:e=>{e.thinking={type:"disabled"}},deep:e=>{e.thinking={type:"enabled"}}},kimi:{fast:e=>{e.thinking={type:"disabled"}},deep:e=>{e.thinking={type:"enabled"}}},volcano:{fast:e=>{e.thinking={type:"disabled"},e.reasoning_effort="low"},deep:e=>{e.thinking={type:"enabled"}}},stepfun:{fast:e=>{e.enable_thinking=!1},deep:e=>{e.enable_thinking=!0}},"grok-effort":{fast:e=>{e.reasoning_effort="low"},deep:e=>{e.reasoning_effort="high"}}};function pI(e,t,n){if(e==="openai"||e in kl)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":r.includes("deepseek")||s.startsWith("deepseek-")?"deepseek":r.includes("moonshot")||s.startsWith("kimi-")?"kimi":r.includes("volces.com")||s.startsWith("doubao-")?"volcano":r.includes("stepfun")||s.startsWith("step-")?"stepfun":(r.includes("x.ai")||s.startsWith("grok-"))&&/^(grok-3-mini|grok-4\.(?:[3-9]|\d{2,}))/.test(s)?"grok-effort":e}function gI(e,t,n){return t==="anthropic"||t==="google"||e==="openai"||e in kl?!0:pI(e,n==null?void 0:n.baseUrl,n==null?void 0:n.model)in kl}const Po=[{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 bI(){const e=$e(),[t,n]=k.useState(!1),[r,s]=k.useState(""),[i,a]=k.useState(!0),[o,l]=k.useState(!1),u=k.useRef(null),c=k.useRef(null),[h,f]=k.useState("right"),[d,m]=k.useState(0),g=k.useRef(0),[b,y]=k.useState(0);k.useLayoutEffect(()=>{if(!t){y(0),g.current=0,m(0);return}const v=c.current;if(!v)return;const T=v.getBoundingClientRect(),_=T.left-g.current,A=T.right-g.current,N=window.innerWidth;if(b===0){if(_<8&&A<=N-8){f("left"),y(1);return}if(A>N-8&&_>=8){f("right"),y(1);return}y(1)}const C=Math.min(0,N-8-A)+Math.max(0,8-_);C!==g.current&&(g.current=C,m(C))},[t,b]);const w=k.useCallback(async()=>{var v;try{const[T,_,A,N,C]=await Promise.all([se.getSetting("active_provider"),se.getSetting("reasoning_effort"),se.getProviderPresets(),se.listCustomProviders(),se.getSetting("active_model")]),D=T??"glm",P=N.find(B=>B.id===D),O=((v=A.find(B=>B.id===D))==null?void 0:v.protocol)??(P==null?void 0:P.protocol)??"openai-compatible";a(gI(D,O,{baseUrl:P==null?void 0:P.baseUrl,model:C??(P==null?void 0:P.defaultModel)}));const I=await se.getModelMeta(D,C??(P==null?void 0:P.defaultModel)??"").catch(()=>null);l((I==null?void 0:I.reasoning)===!1);const R=_??"";s(R==="fast"||R==="deep"?R:"")}catch{a(!1)}},[]);k.useEffect(()=>{w();const v=()=>void w();return window.addEventListener("llm-config-changed",v),()=>window.removeEventListener("llm-config-changed",v)},[w]),k.useEffect(()=>{if(!t)return;const v=_=>{var A;_.target instanceof Node&&((A=u.current)==null?void 0:A.contains(_.target))!==!0&&n(!1)},T=_=>{_.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",T),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",T)}},[t]);const E=async v=>{if(n(!1),v!==r&&!(v==="deep"&&o)){s(v);try{await se.setSetting("reasoning_effort",v)}catch{s(r)}}},S=Po.find(v=>v.value===r)??Po[0];return p.jsxs("div",{ref:u,className:"relative","data-testid":"composer-effort",children:[p.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:[p.jsx(fm,{className:"w-3 h-3 shrink-0"}),p.jsx("span",{className:"truncate tb-label",children:e(S.labelKey)}),p.jsx(mm,{className:`w-3 h-3 shrink-0 tb-chevron transition-transform ${t?"":"rotate-180"}`})]}),t&&p.jsx("div",{ref:c,role:"menu","aria-label":e("effort.label"),"data-testid":"composer-effort-menu",style:{transform:d?`translateX(${d}px)`:void 0},className:`absolute bottom-full ${h==="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:Po.map(v=>{const T=v.value===r,_=v.value==="deep"&&o;return p.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":T,disabled:_,onClick:()=>void E(v.value),className:`w-full flex items-start gap-1.5 px-3 py-1.5 text-left transition-colors ${T?"text-brand":"text-ink-strong hover:bg-ink/[0.06]"} ${_?"opacity-40 cursor-not-allowed":""}`,children:[p.jsx(xn,{className:`w-3.5 h-3.5 shrink-0 mt-0.5 ${T?"opacity-100":"opacity-0"}`}),p.jsxs("span",{className:"flex-1",children:[p.jsx("span",{className:"block text-label font-bold",children:e(v.labelKey)}),p.jsx("span",{className:"block text-caption text-ink-faint",children:e(_?"effort.not_reasoning":v.descKey)})]})]},v.value||"auto")})})]})}const xI=k.lazy(()=>_e(()=>import("./VoicePanel-CSLmne9b.js"),__vite__mapDeps([32,1,2,31]),import.meta.url).then(e=>({default:e.VoicePanel}))),yI={direct:"soul.direct",guide:"soul.guide",practice:"soul.practice"},vI={direct:Jt,guide:bm,practice:Ox},EI={direct:"soul.direct.desc",guide:"soul.guide.desc",practice:"soul.practice.desc"},kI=["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 Ph=0;function TI({nodeId:e,agentReady:t,streaming:n,souls:r,activeSoul:s,starterPrompts:i,onPickSoul:a,onSend:o,onStop:l,onLogFriction:u,onOpenModelManager:c,insertText:h,historyTokens:f,reviewMode:d=!1}){const m=$e(),g=ba(),[b,y]=k.useState(""),[w,E]=k.useState([]),[S,v]=k.useState(null),[T,_]=k.useState(null),[A,N]=k.useState(!1),C=k.useRef(null),D=k.useRef(0),[P,O]=k.useState(!0);k.useEffect(()=>{se.getSetting("asr_auto_stop").then(ie=>O(ie!=="0"))},[]);const[I,R]=k.useState(!1);k.useEffect(()=>(Cc(I),()=>Cc(!1)),[I]);const[B,V]=k.useState(""),[z,Y]=k.useState(!1),[L,q]=k.useState(null),K=k.useRef(!1),M=dI(ie=>{V(Ie=>K.current?aI(Ie,ie):ie),K.current=!1,Y(!0)},{locale:g,autoStop:P}),G=M.startError??M.transcribeError;k.useEffect(()=>{if(!G)return;K.current=!1,q(m(G==="no-speech"?"chat.speech.no_speech":G==="model-missing"?"chat.speech.asr_model_missing":G==="engine-unavailable"?"chat.speech.engine_unavailable":G==="custom-provider-missing"?"chat.speech.custom_provider_missing":G==="groq-key-missing"?"chat.speech.groq_key_missing":G==="azure-key-missing"?"chat.speech.azure_stt_key_missing":G==="azure-region-missing"?"chat.speech.azure_stt_region_missing":G==="mic-insecure-context"?"chat.speech.asr_insecure_context":G==="mic-unavailable"?"chat.speech.asr_start_fail":"chat.speech.asr_failed")),M.clearTranscribeError()},[G,M,m]);const ae=L?"error":M.listening?"recording":M.transcribing?"transcribing":z?"review":"idle",ne=(ie,Ie,Be)=>{Wb(),o(ie,Ie,Be)},X=k.useCallback(()=>{K.current=!1,V(""),Y(!1),q(null)},[]),te=k.useCallback(()=>{R(!1),X()},[X]),ue=k.useCallback(()=>{K.current=!0,M.beginHold();const ie=()=>{window.removeEventListener("pointerup",ie),window.removeEventListener("pointercancel",ie),M.endHold()};window.addEventListener("pointerup",ie),window.addEventListener("pointercancel",ie)},[M.beginHold,M.endHold]),ge=k.useCallback(()=>{K.current=!1,q(null)},[]),Z=()=>{const ie=B.trim();!ie||n||!e||(ne(ie),te())};k.useEffect(()=>{h&&y(ie=>ie.trim()?`${ie}
548
548
 
549
549
  ${h}`:h)},[h]),k.useEffect(()=>{if(!e){_(null);return}let ie=!1;(async()=>{try{const Be=await se.getContextUsage(e,g,d);ie||_(Be)}catch{ie||_(null)}})();const Ie=()=>{se.getContextUsage(e,g,d).then(Be=>{ie||_(Be)}).catch(()=>{})};return window.addEventListener("llm-config-changed",Ie),()=>{ie=!0,window.removeEventListener("llm-config-changed",Ie)}},[e,g,d]),k.useEffect(()=>{if(!S)return;const ie=setTimeout(()=>v(null),3e3);return()=>clearTimeout(ie)},[S]);const re=k.useRef(new Set);k.useEffect(()=>()=>{for(const ie of re.current)URL.revokeObjectURL(ie)},[]);const be=k.useCallback(ie=>{E(Ie=>{const Be=Ie.find(Q=>Q.id===ie);return Be!=null&&Be.previewUrl&&(URL.revokeObjectURL(Be.previewUrl),re.current.delete(Be.previewUrl)),Ie.filter(Q=>Q.id!==ie)})},[]),ve=k.useCallback(async ie=>{if(ie.length===0)return;const Ie=Si.maxPerMessage-w.length;if(Ie<=0){v(m("chat.attach.tooMany",{n:Si.maxPerMessage}));return}const Be=ie.length>Ie?ie.slice(0,Ie):ie;ie.length>Ie&&v(m("chat.attach.tooMany",{n:Si.maxPerMessage}));const Q=[],ee=[];for(const he of Be){const Te=iI(he.name,he.type,he.size);if(!Te.ok){v(Te.reason==="unsupported"?m("chat.attach.unsupported",{name:he.name}):Te.reason==="tooLargeImage"?m("chat.attach.tooLargeImage",{name:he.name}):m("chat.attach.tooLargeText",{name:he.name}));continue}if(Te.kind==="image"){if((T==null?void 0:T.visionCapable)===!1){v(m("chat.attach.visionUnsupported"));continue}const Re=await new Promise(dt=>{const xe=new FileReader;xe.onload=()=>{const De=xe.result;dt(typeof De=="string"?De.slice(De.indexOf(",")+1):null)},xe.onerror=()=>dt(null),xe.readAsDataURL(he)});if(Re===null)continue;const Ze=URL.createObjectURL(he);ee.push(Ze),Q.push({id:++Ph,kind:"image",name:he.name,mime:he.type||"image/png",size:he.size,previewUrl:Ze,base64:Re})}else try{const Re=await he.text();Q.push({id:++Ph,kind:"text",name:he.name,mime:he.type||"text/plain",size:he.size,text:Re})}catch{}}if(Q.length>0){for(const he of ee)re.current.add(he);E(he=>[...he,...Q])}else for(const he of ee)URL.revokeObjectURL(he)},[w.length,T==null?void 0:T.visionCapable,m]),Fe=ie=>{const Ie=ie.trim();if(n||!e||!Ie&&w.length===0)return;const Be=Ie||au("chat.attach.imageOnlyText"),Q=w.map(ee=>({kind:ee.kind,name:ee.name,mime:ee.mime,size:ee.size,data:ee.kind==="image"?ee.base64??"":ee.text??"",...ee.kind==="image"&&ee.previewUrl?{previewUrl:ee.previewUrl}:{}}));ne(Be,void 0,Q.length>0?Q:void 0),y(""),E([])},je=()=>Fe(b),Se=ie=>{n||(ne(ie.message,ie.label),ie.frictionCategory&&(u==null||u(ie.frictionCategory,null)))},Oe=ie=>{const Ie=Array.from(ie.clipboardData.files??[]);Ie.length>0&&(ie.preventDefault(),ve(Ie))},st=ie=>{ie.dataTransfer.types.includes("Files")&&(ie.preventDefault(),D.current+=1,N(!0))},pt=ie=>{ie.dataTransfer.types.includes("Files")&&(D.current=Math.max(0,D.current-1),D.current===0&&N(!1))},me=ie=>{ie.dataTransfer.types.includes("Files")&&(ie.preventDefault(),D.current=0,N(!1),ve(Array.from(ie.dataTransfer.files??[])))},rt=k.useMemo(()=>Pm(b),[b]);return t?p.jsxs("div",{className:"px-5 pb-4 pt-1 shrink-0","data-testid":"composer",children:[!I&&i.length>0&&e&&p.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-2","data-testid":"starter-prompts",children:i.map((ie,Ie)=>p.jsx("button",{onClick:()=>Se(ie),disabled:n,"data-testid":`starter-prompt-${Ie}`,"data-tooltip":ie.hint??ie.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:ie.label},Ie))}),p.jsx("div",{className:`composer-card relative rounded-2xl transition-colors px-3 pt-2 pb-1.5 ${A?"bg-accent/10 ring-1 ring-accent":"bg-ink/[0.05] focus-within:bg-ink/[0.07]"}`,onDragEnter:st,onDragOver:ie=>{ie.dataTransfer.types.includes("Files")&&ie.preventDefault()},onDragLeave:pt,onDrop:me,"data-testid":"composer-card",children:I?p.jsxs(p.Fragment,{children:[ae!=="idle"&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(xI,{view:ae,level:M.level,text:B,onTextChange:V,onSend:Z,onRerecord:X,onContinueHoldStart:ue,onDismissError:ge,errorMessage:L,sendDisabled:n||!e||!B.trim()})}),p.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[p.jsxs("span",{className:"flex items-center gap-1.5 text-label text-ink-muted font-medium",children:[p.jsx(Ms,{className:"w-3.5 h-3.5 text-accent"}),m("chat.speech.dictation")]}),p.jsxs("button",{type:"button",onClick:te,"data-tooltip":m("chat.speech.back_to_keyboard"),"aria-label":m("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:[p.jsx(Hx,{className:"w-3.5 h-3.5"}),p.jsx("span",{children:m("chat.speech.keyboard")})]})]}),p.jsxs("button",{type:"button",onPointerDown:ie=>{ie.preventDefault(),M.beginHold()},onPointerUp:M.endHold,onPointerLeave:M.endHold,onPointerCancel:M.endHold,onContextMenu:ie=>ie.preventDefault(),disabled:!e||ae!=="idle","data-testid":M.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 ${M.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:[p.jsx(Ms,{className:"w-5 h-5"}),M.listening?m("chat.speech.release_to_stop"):m("chat.speech.hold_to_talk")]})]}):p.jsxs(p.Fragment,{children:[r.length>0&&p.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto mb-1","data-testid":"soul-picker",children:[p.jsx("span",{className:"text-body text-ink-faint shrink-0",children:m("chat.soul.label")}),r.map(ie=>{const Ie=s===ie.name,Be=vI[ie.name]??bm,Q=m(EI[ie.name]??"soul.direct.desc");return p.jsxs("button",{onClick:()=>a(ie.name),"data-testid":`soul-pill-${ie.name}`,"data-tooltip":Q,className:`shrink-0 flex items-center gap-1 px-2 py-0.5 rounded-full text-body font-medium transition-colors ${Ie?"bg-brand/15 text-brand":"text-ink-muted hover:text-ink-strong hover:bg-ink/5"}`,children:[p.jsx(Be,{className:"w-3.5 h-3.5"}),p.jsx("span",{children:m(yI[ie.name]??"soul.direct")})]},ie.id)})]}),w.length>0&&p.jsxs("div",{className:"flex gap-1.5 flex-wrap mb-1.5","data-testid":"composer-attachments",children:[(T==null?void 0:T.visionBridgeModel)&&w.some(ie=>ie.kind==="image")&&p.jsxs("div",{className:"w-full flex items-center gap-1 text-caption text-ink-muted","data-testid":"vision-bridge-chip",children:[p.jsx(Jx,{className:"w-3.5 h-3.5 shrink-0"}),p.jsx("span",{children:m("chat.attach.bridgeChip",{model:T.visionBridgeModel})})]}),w.map(ie=>ie.kind==="image"?p.jsxs("div",{className:"relative w-16 h-16 shrink-0",children:[p.jsx("img",{src:ie.previewUrl,alt:ie.name,className:"w-16 h-16 object-cover rounded-lg border border-[var(--border)]"}),p.jsx("button",{type:"button",onClick:()=>be(ie.id),"aria-label":m("chat.attach.remove",{name:ie.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:p.jsx(_n,{className:"w-3 h-3"})})]},ie.id):p.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:[p.jsx(Vi,{className:"w-3 h-3 shrink-0 text-ink-faint"}),p.jsx("span",{className:"truncate max-w-[10rem]",children:ie.name}),p.jsx("button",{type:"button",onClick:()=>be(ie.id),"aria-label":m("chat.attach.remove",{name:ie.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:p.jsx(_n,{className:"w-2.5 h-2.5"})})]},ie.id))]}),S&&p.jsx("div",{className:"text-caption text-warning pb-1",role:"status","data-testid":"composer-notice",children:S}),p.jsxs("div",{className:"flex gap-2 items-end",children:[p.jsx("textarea",{value:b,onChange:ie=>y(ie.target.value),onFocus:()=>mi(!0),onBlur:()=>mi(!1),onKeyDown:ie=>{ie.key==="Enter"&&!ie.shiftKey&&(ie.preventDefault(),je())},onPaste:Oe,placeholder:m(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?p.jsx("button",{onClick:l,"data-testid":"chat-stop",className:"btn-icon-3d-warning shrink-0 w-9 h-9",title:m("chat.stop"),"aria-label":m("chat.stop"),children:p.jsx(iu,{className:"w-3.5 h-3.5 fill-current"})}):p.jsx("button",{onClick:je,disabled:n||!b.trim()&&w.length===0||!e,"data-testid":"chat-send",className:"btn-icon-3d-brand shrink-0 w-9 h-9",title:m("chat.send"),"aria-label":m("chat.send"),children:p.jsx(kx,{className:"w-4 h-4"})})]}),p.jsxs("div",{className:"composer-toolbar flex flex-wrap items-center justify-between gap-x-0.5 gap-y-1 mt-0.5",children:[p.jsx("button",{type:"button",onClick:()=>{X(),R(!0)},disabled:!e,"data-tooltip":m("chat.speech.dictation"),"aria-label":m("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:p.jsx(Ms,{className:"w-3.5 h-3.5"})}),p.jsx("button",{type:"button",onClick:()=>{var ie;return(ie=C.current)==null?void 0:ie.click()},"data-tooltip":m("chat.attach.add"),"aria-label":m("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:p.jsx(Wx,{className:"w-3 h-3"})}),p.jsx("input",{ref:C,type:"file",multiple:!0,accept:kI,className:"hidden",onChange:ie=>{ve(Array.from(ie.target.files??[])),ie.target.value=""}}),p.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-0.5",children:[p.jsx(bI,{}),p.jsx(mI,{info:T,historyTokens:f,draftTokens:rt}),p.jsx(fI,{onOpenModelManager:c})]})]})]})})]}):p.jsx("div",{className:"px-5 pb-4 shrink-0","data-testid":"composer-nokey",children:p.jsxs("div",{className:"flex items-center justify-center gap-3 py-3 text-body text-ink-muted",children:[p.jsx("span",{children:m("chat.no_key.short")}),p.jsx("button",{onClick:c,className:"text-brand hover:underline font-bold",children:m("chat.no_key.cta")})]})})}const Lh={viseme:"closed",open:0};function wI(e){const[t,n]=k.useState(Lh);return k.useEffect(()=>{if(!e){n(Lh);return}const r=new Uint8Array(256),s=new Uint8Array(dg/2);let i=0,a="",o=null,l=0;const u=()=>{const c=O_();if(c){let h,f;if(c.timeline&&c.timeline.cues.length>0){const g=Math.max(0,c.ctx.currentTime-c.startedAtCtxTime),b=K_(c.timeline,g);h=(b==null?void 0:b.viseme)??"closed",f=(b==null?void 0:b.level)??0}else if(c.analyser){const g=c.analyser;g.getByteTimeDomainData(r),g.getByteFrequencyData(s);const b=Yb(r,s,g.context.sampleRate,g.fftSize);h=b.viseme,h!==a.split(":")[0]?(h==="closed"||h===o?h===o&&l++:(o=h,l=1),h!=="closed"&&!(h===o&&l>=2)&&(h=a.split(":")[0]||"closed")):(o=null,l=0),f=b.level}else h="closed",f=0;const d=Gb(h,f),m=h+":"+d;m!==a&&(a=m,n({viseme:h,open:d}))}i=requestAnimationFrame(u)};return i=requestAnimationFrame(u),()=>cancelAnimationFrame(i)},[e]),t}const SI=22,AI=35e-5,Dh=.012,Oh=.12,Fh=.3,CI=16.667,Lo=12,_I=3.2,Bh=56,xr=.6;function NI(e,t,n,r,s=0,i=0){let a=0,o=0;for(const u of r){const c=e-u.x,h=t-u.y,f=Math.hypot(c,h),d=u.r+n,m=d+Bh;if(f>=m)continue;if(f<1e-4){o-=xr;continue}const g=c/f,b=h/f,y=Math.min(1.6,Math.max(0,1-(f-d)/Bh)),w=s*g+i*b,E=w<0?1+Math.min(1.6,-w/4):1;a+=g*xr*y*E,o+=b*xr*y*E}const l=Math.hypot(a,o);return l>xr*2&&(a=a/l*xr*2,o=o/l*xr*2),{x:a,y:o}}function II(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 RI(e,t,n,r,s=CI){const i=Math.max(64,s*s),a=Tl((n.x-e.x)*Dh-t.x*Oh,Fh),o=Tl((n.y-e.y)*Dh-t.y*Oh,Fh);return{fx:a*r/i,fy:o*r/i-r*.001}}function Tl(e,t){return e>t?t:e<-t?-t:e}function MI(e,t,n,r,s,i,a,o,l,u){const c=e-i,h=t-a,f=Math.hypot(c,h),d=s+u;if(f>=d||f<1e-4)return null;const m=c/f,g=h/f,b=n-o,y=r-l,w=b*m+y*g,E=d-f,S=w<0?-w*.9:0;return{nx:m,ny:g,dvx:m*(E*.55+S*.85),dvy:g*(E*.55+S*.85),bfx:-m*S*.02,bfy:-g*S*.02,hitSpeed:-w}}function PI(e,t){return Math.hypot(e,t)<.35?0:Tl(e*.06,.5)}function LI(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,h=e*s[c%5],f=t*i[Math.floor(c/5)];let d=Math.min(h,e-h);for(const m of n){const g=Math.hypot(h-m.x,f-m.y)-m.r;g<d&&(d=g)}d>l+1e-9&&(l=d,o={x:h,y:f})}return o}function DI(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 OI(e){const t=e.radius??SI,{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:AI});s.add(a.world,o);const l=240;let u=[];const c=(d,m)=>{for(const b of u)s.remove(a.world,b);const g=(b,y,w,E)=>n.rectangle(b,y,w,E,{isStatic:!0,restitution:.5});u=[g(-l/2,m/2-160,l,m+640),g(d+l/2,m/2-160,l,m+640),g(d/2,m+l/2,d+l*2,l),g(d/2,-320-l/2,d+l*2,l)];for(const b of u)s.add(a.world,b)};c(e.width,e.height);let h=0,f=e.width;return{body:o,resize(d,m){f=d,c(d,m)},step(d,m,g,b,y){const w=b<h;i.update(a,Math.min(33,Math.max(8,d)));let E=!1;if(!w&&m){const O=y!=null&&y.settle?{x:m.x,y:m.y+Math.sin(b*.0012)*2}:II(m,Math.floor(b/4200),b),I=Math.max(64,d*d),R=RI({x:o.position.x,y:o.position.y},{x:o.velocity.x,y:o.velocity.y},O,o.mass,d),B=NI(o.position.x,o.position.y,t,g,o.velocity.x,o.velocity.y);r.applyForce(o,o.position,{x:R.fx+B.x*o.mass/I,y:R.fy+B.y*o.mass/I}),r.setAngularVelocity(o,o.angularVelocity-o.angle*.06-o.angularVelocity*.08)}{const O=o.velocity,I=Math.hypot(O.x,O.y);I>Lo&&r.setVelocity(o,{x:O.x/I*Lo,y:O.y/I*Lo})}let S=0,v=0,T=0,_=0,A=0;for(const O of g){const I=MI(o.position.x,o.position.y,o.velocity.x,o.velocity.y,t,O.x,O.y,O.vx,O.vy,O.r);I&&(v+=I.nx*Math.min(4,I.dvx),T+=I.ny*Math.min(4,I.dvy),_+=I.dvx*.9,A+=I.dvy*.9,O.isStatic||O.push(I.bfx,I.bfy),I.hitSpeed>S&&(S=I.hitSpeed))}const N=Math.hypot(v,T);N>4&&(v=v/N*4,T=T/N*4);const C=Math.hypot(_,A);C>7&&(_=_/C*7,A=A/C*7),(N>0||C>0)&&(r.setPosition(o,{x:o.position.x+v,y:o.position.y+T}),r.setVelocity(o,{x:o.velocity.x+_,y:o.velocity.y+A})),S>=_I&&!w&&(h=b+900,E=!0);const D=o.position;D.x<t&&(r.setPosition(o,{x:t,y:D.y}),o.velocity.x<0&&r.setVelocity(o,{x:-o.velocity.x*.5,y:o.velocity.y})),D.x>f-t&&(r.setPosition(o,{x:f-t,y:D.y}),o.velocity.x>0&&r.setVelocity(o,{x:-o.velocity.x*.5,y:o.velocity.y}));const P=y==null?void 0:y.ceilY;return P!==void 0&&D.y<P+t&&(r.setPosition(o,{x:D.x,y:P+t}),o.velocity.y<0&&r.setVelocity(o,{x:o.velocity.x,y:-o.velocity.y*.5})),E},dizzyRemaining(d){return Math.max(0,h-d)},throwDizzy(d){h=d+900},dispose(){s.clear(a.world,!1),i.clear(a)}}}const Dt={rail:76,chat:96,notebook:120,titlebar:44};function jh(){const t=document.querySelector('[data-testid="composer-card"]')??document.querySelector('[data-testid="composer"]')??document.querySelector('[data-testid="composer-nokey"]');if(t){const r=t.getBoundingClientRect();return{x:r.right-78,y:r.top-44}}const n=document.querySelector('[data-companion-anchor="boot-guide"]');if(n){const r=n.getBoundingClientRect();return{x:r.right-64,y:r.top+96}}return null}function FI(){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 BI({courseId:e}){const t=k.useSyncExternalStore(Kb,ds),n=wI(t.state.talking),r=Jl(),[s,i]=k.useState(!1),[a,o]=k.useState(null),[l,u]=k.useState("rail"),c=k.useRef("rail"),h=k.useRef(null),[f,d]=k.useState(!1),m=k.useRef(!1),g=k.useRef(null),b=k.useRef(null),y=k.useRef(null),w=k.useRef(null),E=k.useRef(t.state.zone),S=k.useRef(!1),v=k.useRef(null),T=k.useRef(!1),_=k.useRef(0),A=k.useRef(null),[N,C]=k.useState(null),D=k.useRef(0),P=k.useRef(null),O=k.useRef(null),I=k.useRef(null),R=k.useRef(0),B=k.useRef(null),V=k.useRef(0),z=k.useRef({pane:"rail",bucket:-1}),Y=k.useRef(null),L=k.useRef(null);k.useEffect(()=>{var ae,ne,X;if(l===E.current||(E.current=l,r))return;i(!0),(ne=(ae=g.current)==null?void 0:ae.animate)==null||ne.call(ae,[{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"}),(X=g.current)==null||X.classList.add("cp-takeoff"),setTimeout(()=>{var te;return(te=g.current)==null?void 0:te.classList.remove("cp-takeoff")},650);const G=[setTimeout(()=>i(!1),950),setTimeout(()=>{var ue;const te=g.current;!te||l==="rail"||(Xb(),(ue=te.animate)==null||ue.call(te,[{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 te of G)clearTimeout(te)}},[l,r]),k.useEffect(()=>{if(!e)return;let G=!0;return window.api.getDashboard(e).then(ae=>{var ue,ge;if(!G)return;const ne=(ue=ae==null?void 0:ae.frictionByNode)==null?void 0:ue[0];if(!(ne!=null&&ne.nodeId))return;L.current=ne.nodeId;const X=hs(),te=(ge=X.nav)==null?void 0:ge.getBoundingClientRect();if(te)for(const{island:Z,container:re}of X.sections.values()){const be=Z.ball(ne.nodeId);if(!be)continue;const ve=re.getBoundingClientRect(),Fe=ve.left-te.left+be.body.position.x,je=ve.top-te.top+be.body.position.y;I.current={x:Fe,y:Math.max(40,je-92)},R.current=performance.now()+8e3,setTimeout(()=>{G&&Rr()},1200);return}}).catch(()=>{}),()=>{G=!1}},[e]),k.useEffect(()=>{const G=ae=>{const ne=ae.detail,X=L.current;ne!=="mastery"||!X||!e||window.api.getDashboard(e).then(te=>{var ge;((ge=te==null?void 0:te.frictionByNode)==null?void 0:ge.some(Z=>Z.nodeId===X))||(L.current=null,R.current=0,Jb())}).catch(()=>{})};return window.addEventListener("companion-state-changed",G),()=>window.removeEventListener("companion-state-changed",G)},[e]),k.useEffect(()=>Jo(G=>{if(G.kind!=="correct"&&G.kind!=="unlock"||!G.origin||ds().state.examActive)return;const ae=document.elementFromPoint(G.origin.x,G.origin.y);if(!ae)return;const ne=ae.closest('[data-testid="map-rail"]');O.current={x:G.origin.x,y:G.origin.y,until:performance.now()+3e3,pane:ne?"rail":"chat"}}),[]),k.useEffect(()=>{const G=ne=>{const X=B.current;if(!X)return;const te=performance.now(),ue=Math.max(8,te-X.t);B.current={x:ne.clientX,y:ne.clientY,vx:(ne.clientX-X.x)/ue*16.7,vy:(ne.clientY-X.y)/ue*16.7,t:te}},ae=()=>{var re,be,ve,Fe;const ne=B.current;if(!ne)return;B.current=null;const X=Math.hypot(ne.vx,ne.vy),te=b.current;if(te){const je=(re=hs().nav)==null?void 0:re.getBoundingClientRect();je&&pn.Body.setPosition(te.body,{x:Math.min(je.width-24,Math.max(24,ne.x-je.left)),y:Math.min(je.height-24,Math.max(24,ne.y-je.top))}),X>=2.5&&(pn.Body.setVelocity(te.body,{x:ne.vx*.9,y:ne.vy*.9}),te.throwDizzy(performance.now()))}const ue=hs(),ge=((be=ue.nav)==null?void 0:be.getBoundingClientRect())??null;if(!(!!ge&&ge.width>40&&(ue.visible||ds().state.importing))){const je=((ve=document.querySelector("header.app-header"))==null?void 0:ve.getBoundingClientRect())??null;if(!!je&&ne.y>=je.top&&ne.y<=je.bottom)v.current=null;else{const Oe=((Fe=document.querySelector('[data-testid="notebook-panel"]'))==null?void 0:Fe.getBoundingClientRect())??null,st=Oe&&ne.x>=Oe.left&&ne.x<=Oe.right&&ne.y>=Oe.top&&ne.y<=Oe.bottom?"notebook":"chat",pt=((je==null?void 0:je.bottom)??0)+80;v.current={x:Math.min(Math.max(ne.x,60),window.innerWidth-60),y:Math.min(Math.max(ne.y,pt),window.innerHeight-60),pane:st}}}_c(!1,X)};return window.addEventListener("pointermove",G,{passive:!0}),window.addEventListener("pointerup",ae,{passive:!0}),window.addEventListener("pointercancel",ae,{passive:!0}),()=>{window.removeEventListener("pointermove",G),window.removeEventListener("pointerup",ae),window.removeEventListener("pointercancel",ae)}},[]),k.useEffect(()=>{if(!t.enabledLoaded||!t.enabled||t.petMode)return;const G=g.current;if(!G)return;let ae=0,ne=performance.now(),X=0,te=0,ue=0,ge=-1e9,Z=null,re=0,be=0,ve=null,Fe=[];const je=Se=>{var ts,Yr,Gr,ns,hr,rs,is,ss,Dn;ae=requestAnimationFrame(je);const Oe=Math.min(50,Se-ne);ne=Se;const st=hs(),pt=st.nav,me=(pt==null?void 0:pt.getBoundingClientRect())??null,rt=ds().state,ie=!!B.current,Ie=!!me&&me.width>40&&(st.visible||rt.importing);if(Ie&&!T.current&&(v.current=null),T.current=Ie,Se-ge>150){ge=Se,Z=((ts=document.querySelector('[data-testid="notebook-panel"]'))==null?void 0:ts.getBoundingClientRect())??null;const we=((Yr=document.querySelector("header.app-header"))==null?void 0:Yr.getBoundingClientRect())??null;ve=we?{left:we.left,right:we.right,top:we.top,bottom:we.bottom}:null,re=(we==null?void 0:we.bottom)??0,Fe=we?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(Ye=>{const Me=Ye.getBoundingClientRect();return{left:Me.left,right:Me.right,top:Me.top,bottom:Me.bottom}}):[],be=((Gr=document.querySelector('[data-testid="map-rail-topbar"]'))==null?void 0:Gr.getBoundingClientRect().bottom)??0}const Be=Z,Q=()=>Math.max(re,be)-((me==null?void 0:me.top)??0),ee=Math.floor(Se/sx);if(z.current.bucket!==ee&&(z.current={pane:ex(z.current.pane),bucket:ee},Ie&&rt.zone==="roam")){const we=document.querySelector('[data-testid="map-review-badge"]'),Ye=!!we&&we.className.includes("bg-review/20");let Me=null;for(const{island:Ce,container:ye}of st.sections.values()){const Pe=Ce.balls.find(Ae=>!Ae.body.isStatic);if(Pe){const Ae=ye.getBoundingClientRect();Me={x:Ae.left+Pe.body.position.x,y:Ae.top+Pe.body.position.y};break}}const at=R.current>Se?I.current:null,Ke=ax(ee,{hasReview:Ye,hasNext:!!Me,hasFriction:!!at});if(Ke==="review"&&we){const Ce=we.getBoundingClientRect();Y.current={kind:Ke,until:Se+$a,pos:{x:Ce.right+44,y:Ce.bottom+64},fired:!1},z.current.pane="rail"}else Ke==="inspect"&&Me?(Y.current={kind:Ke,until:Se+$a,pos:{x:Me.x+34,y:Me.y-66},fired:!1},z.current.pane="rail"):Ke==="friction"&&at&&(Y.current={kind:Ke,until:Se+$a,pos:{x:at.x,y:at.y},fired:!1},z.current.pane="rail")}const he=Y.current&&Se<Y.current.until?Y.current:null;Y.current&&!he&&(Y.current=null);const Te=ox();if(Te&&Te.seq!==_.current&&!rt.examActive){_.current=Te.seq;let we=Te.x,Ye=Te.y;if((we==null||Ye==null)&&Ie)for(const{island:Me,container:at}of st.sections.values()){const Ke=Me.ball(Te.nodeId);if(Ke){const Ce=at.getBoundingClientRect();we=Ce.left+Ke.body.position.x,Ye=Ce.top+Ke.body.position.y;break}}Ie&&we!=null&&Ye!=null?(A.current={nodeId:Te.nodeId,x:we,y:Ye,until:Se+2400,fired:!1,fly:!0},C({until:Se+2400})):(A.current={nodeId:Te.nodeId,x:0,y:0,until:Se+1600,fired:!0,fly:!1},C({until:Se+1600}))}const Re=!!A.current&&Se<A.current.until;if(A.current&&!Re&&(A.current=null,C(null)),Re&&A.current&&!A.current.fired){const we=A.current;if(we.fired=!0,we.fly&&me)for(const{island:Ye}of st.sections.values()){const Me=Ye.ball(we.nodeId);if(Me&&!Me.body.isStatic){pn.Body.applyForce(Me.body,Me.body.position,{x:.0035,y:-.005});break}}}const Ze=lx();if(Ze&&Ze.seq!==D.current&&!rt.examActive&&(D.current=Ze.seq,Ie&&me)){const we=Q();P.current={x:Math.min(me.width-44,Math.max(44,Ze.x-me.left)),y:Math.min(me.height-44,Math.max(we+52,Ze.y-me.top)),until:Se+3200}}const dt=!!P.current&&Se<P.current.until;P.current&&!dt&&(P.current=null);const xe=!!O.current&&Se<O.current.until;O.current&&!xe&&(O.current=null);const De=C_(),Ve=De?De.startContainer.parentElement??null:null;let pe=null,We=z.current.pane;const ht=rt.examActive?(ns=document.querySelector('[data-testid="exam-timer"]'))==null?void 0:ns.getBoundingClientRect():void 0;if(ht){b.current=null,B.current=null,We="chat";let we;const Ye=ht.right+64,Me=Ye<=window.innerWidth-70||(hr=document.querySelector('[data-testid="exam-progress-bar"]'))==null?void 0:hr.getBoundingClientRect();if(Me&&Me.width>0){const Ke=((rs=document.querySelector('[data-testid="exam-progress-fill"]'))==null?void 0:rs.getBoundingClientRect().right)??Me.left+Me.width/2,Ce=document.querySelector('[data-testid="exam-timer"]'),ye=Ce==null?void 0:Ce.previousElementSibling,Ae=(ye?ye.getBoundingClientRect().right:Me.left+90)+46,St=ht.left-46,Xe=Math.max(Ae,Math.min(St,Ke));we={x:Ae<=St?Xe:Me.left+Me.width/2,y:Math.max(60,Me.top-16)}}else we={x:Math.min(Ye,window.innerWidth-70),y:Math.min(ht.bottom+56,window.innerHeight-90)};const at=y.current??we;pe=Gt(at,we,Oe,Un),ue=Math.max(-.15,Math.min(.15,(pe.x-at.x)*.008))}else if(ie){const we=B.current;b.current=null,pe={x:we.x,y:we.y},ue=Math.max(-.5,Math.min(.5,we.vx*.04)),We=c.current}else if(Ve&&De){const we=Ve.closest('[data-testid="notebook-panel"], [data-testid="chat-stream"]'),Ye=we==null?void 0:we.getBoundingClientRect(),Me=__()??De,at=Me.getClientRects(),Ke=[];for(let Xe=0;Xe<at.length;Xe++){const Ge=at[Xe];Ge.width>1&&Ge.height>1&&Ke.push({left:Ge.left,right:Ge.right,top:Ge.top,bottom:Ge.bottom})}const Ce=Ke.length?Ke[Ke.length-1]:null,ye=Ke.length?Ke[0]:null,Pe=Me.getBoundingClientRect(),Ae=!!(we!=null&&we.closest('[data-testid="chat-stream"]')),St=Ae?Dt.chat:Dt.notebook;if(We=Ae?"chat":"notebook",Ye&&(Ce||Pe.width>0)){const Xe=Nc({left:Pe.left,right:Pe.right,top:Pe.top,bottom:Pe.bottom},Ye,St,{first:ye??void 0,last:Ce??void 0},Ke),Ge={dir:Xe.dir,pane:We};if((((is=h.current)==null?void 0:is.dir)!==Ge.dir||((ss=h.current)==null?void 0:ss.pane)!==Ge.pane)&&(h.current=Ge,o(Ge)),m.current!==Xe.occluding&&(m.current=Xe.occluding,d(Xe.occluding)),r)pe=Xe,ue=0;else{const Nt=y.current??{x:Xe.x,y:Xe.y};pe=Gt(Nt,Xe,Oe,ux,110),ue=Xe.dir==="left"?-.07:Xe.dir==="right"?.07:0}}else{h.current!==null&&(h.current=null,o(null)),m.current&&(m.current=!1,d(!1));const Xe=Ye?{x:Ye.right-70,y:Math.max(Ye.top+96,re+St*.8)}:cx(window.innerHeight,St,re),Ge=y.current??{x:Xe.x,y:Xe.y};pe=Gt(Ge,Xe,Oe,Un),ue=Math.max(-.25,Math.min(.25,(pe.x-Ge.x)*.01))}}else{h.current!==null&&(h.current=null,o(null)),m.current&&(m.current=!1,d(!1));const we=rt.pose==="writing"?N_():null,Ye=rt.zone,Me=(we==null?void 0:we.host)??null,at=we==null?void 0:we.range.getBoundingClientRect(),Ke=!!(Me&&at&&at.width>0);if(we&&Ke){const Ce=Me,ye=Ce.getBoundingClientRect(),Pe=at,Ae=!!Ce.closest('[data-testid="chat-stream"]');We=Ae?"chat":"notebook";{const St=we.block,Xe=[];if(St){const Nt=document.createRange();Nt.selectNodeContents(St);const On=Nt.getClientRects();for(let tn=0;tn<On.length;tn++){const ze=On[tn];ze.width>1&&ze.height>1&&Xe.push({left:ze.left,right:ze.right,top:ze.top,bottom:ze.bottom})}}const Ge=Nc(Pe,ye,Ae?Dt.chat:Dt.notebook,{first:Pe,last:Pe},Xe.length?Xe:void 0);if(b.current=null,r)pe=Ge,ue=0;else{const Nt=y.current??{x:Ge.x,y:Ge.y};pe=Gt(Nt,Ge,Oe,Un),ue=.08}}}else if(xe&&O.current&&O.current.pane!=="rail"){b.current=null;const Ce=O.current;We=Ce.pane==="notebook"?"notebook":"chat";const ye=We==="notebook"?Dt.notebook:Dt.chat,Pe=tx({x:Ce.x,y:Ce.y},ye,window.innerWidth,Math.max(re,be));if(r)pe=Pe,ue=0;else{const Ae=y.current??{x:Pe.x,y:Pe.y};pe=Gt(Ae,Pe,Oe,Un),ue=Math.max(-.2,Math.min(.2,(pe.x-Ae.x)*.01))}}else if(Ye==="chat"&&jh()){b.current=null,We="chat";const Ce=jh();if(r)pe=Ce,ue=0;else{const ye=Rc("chat",Se),Pe=y.current??{x:Ce.x,y:Ce.y};pe=Gt(Pe,{x:Ce.x+ye.x,y:Ce.y+ye.y},Oe,Un),ue=Math.max(-.35,Math.min(.35,(pe.x-Pe.x)*.014))}}else if(Ye==="notebook"&&Be){b.current=null,We="notebook";const Ce=FI()??{x:Be.right-70,y:Be.top+96};if(r)pe=Ce,ue=0;else{const ye=Rc("notebook",Se),Pe=y.current??{x:Ce.x,y:Ce.y};pe=Gt(Pe,{x:Ce.x+ye.x,y:Ce.y+ye.y},Oe,Un),ue=Math.max(-.3,Math.min(.3,(pe.x-Pe.x)*.012))}}else if(Ie&&(Re||dt||Ye==="rail"||Ye==="roam")){const Ce=me.width,ye=me.height;if(We="rail",r)pe={x:me.left+Ce*.5,y:me.top+ye*.5},ue=0;else{if((Ce!==X||ye!==te)&&(X=Ce,te=ye,(Dn=b.current)==null||Dn.resize(Ce,ye),I.current=null),!b.current){b.current=OI({width:Ce,height:ye});const lt=y.current;lt&&pn.Body.setPosition(b.current.body,{x:Math.min(Ce-30,Math.max(30,lt.x-me.left)),y:Math.min(ye-30,Math.max(30,lt.y-me.top))})}const Pe=b.current,Ae=[],St=[];for(const{island:lt,container:Kr}of st.sections.values()){const Et=Kr.getBoundingClientRect();if(Et.bottom<me.top-120||Et.top>me.bottom+120)continue;const Fn=Et.left-me.left,Bn=Et.top-me.top;for(const It of lt.balls)Ae.push({x:Fn+It.body.position.x,y:Bn+It.body.position.y,vx:It.body.velocity.x,vy:It.body.velocity.y,r:Ht,isStatic:It.body.isStatic,push:(jn,vn)=>pn.Body.applyForce(It.body,It.body.position,{x:jn,y:vn})}),St.push({x:Fn+It.body.position.x,y:Bn+It.body.position.y-Ht-20});for(const It of lt.links)for(const jn of It.particles)St.push({x:Fn+jn.position.x,y:Bn+jn.position.y-8})}const Xe=Ye==="roam";let Ge=I.current,Nt=!1;if(dt&&P.current)Ge={x:P.current.x+28,y:P.current.y-52},Nt=!1;else if(Re&&A.current&&A.current.fly)Ge={x:A.current.x-me.left+34,y:A.current.y-me.top-46},Nt=!1;else if(xe&&O.current&&O.current.pane==="rail")Ge={x:O.current.x-me.left+34,y:O.current.y-me.top-46},Nt=!1;else if(he)Ge={x:he.pos.x-me.left,y:he.pos.y-me.top},he.fired||(he.fired=!0,Rr());else if(Xe){const lt=Ic(me,Dt.rail,Se);Ge={x:lt.x-me.left,y:lt.y-me.top}}else{if(rt.mode==="veil"){const lt=DI({x:Pe.body.position.x,y:Pe.body.position.y},St,220);lt&&(Ge=lt,Nt=!0)}(!Ge||Se>R.current)&&(I.current=LI(Ce,ye,Ae,Math.floor(Se/1e3)),R.current=Se+3e3,Ge=I.current)}const On=Pe.step(Oe,Ge,rt.mode==="veil"&&!Xe?[]:Ae,Se,{settle:Nt,ceilY:Q()});if(On&&!S.current&&nx(),S.current=On||Pe.dizzyRemaining(Se)>0,Pe.dizzyRemaining(Se)===0){const lt=Um(st.weather);if(lt.wind>=.3){const Kr=Pe.body.mass;pn.Body.applyForce(Pe.body,Pe.body.position,{x:Hm(Pe.body.position.x,Pe.body.position.y,Se)*lt.wind*jm*Kr*2.2,y:0})}(st.weather==="rain"||st.weather==="storm")&&rt.mode!=="veil"&&Se>V.current&&(V.current=Se+6e3+Math.random()*4e3,G.classList.add("cp-shiver"),setTimeout(()=>G.classList.remove("cp-shiver"),460))}const tn=Pe.body.position,ze={x:me.left+tn.x,y:me.top+tn.y},Ha=y.current??ze;pe=Gt(Ha,ze,Oe,Un),ue=Pe.body.angle+PI(Pe.body.velocity.x,Pe.body.velocity.y)}}else if(b.current=null,Ie&&me){We="rail";const Ce=Ic(me,Dt.rail,Se),ye=y.current??{x:Ce.x,y:Ce.y};pe=Gt(ye,Ce,Oe,dx,140),ue=Math.max(-.25,Math.min(.25,(pe.x-ye.x)*.01))}else if(v.current)if(We=v.current.pane,r)pe={x:v.current.x,y:v.current.y},ue=0;else{const Ce=rx(v.current,Se),ye=y.current??Ce;pe=Gt(ye,Ce,Oe,Mc),ue=Math.max(-.2,Math.min(.2,(pe.x-ye.x)*.01))}else if(ve)if(We="titlebar",r)pe={x:(ve.left+ve.right)/2,y:(ve.top+ve.bottom)/2},ue=0;else{const Ce=ix(ve,Dt.titlebar,Se),ye=y.current??Ce;pe=Gt(ye,Ce,Oe,Mc),ue=0}}if(We==="titlebar"&&pe){const we=Dt.titlebar/2,Ye=pe.x-we,Me=pe.x+we,at=pe.y-we,Ke=pe.y+we,Ce=Fe.some(ye=>Ye<ye.right&&Me>ye.left&&at<ye.bottom&&Ke>ye.top);G.classList.toggle("cp-titlebar-dim",Ce)}else G.classList.contains("cp-titlebar-dim")&&G.classList.remove("cp-titlebar-dim");if(c.current!==We&&(c.current=We,u(We)),!pe){G.style.opacity="0",y.current=null,w.current=null;return}y.current=pe;const Ln=G.offsetWidth||Dt[We],$r=We==="rail"?Math.max(re,be):re;We!=="titlebar"&&pe.y<$r+Ln/2+10&&(pe.y=$r+Ln/2+10),G.style.transform=`translate3d(${(pe.x-Ln/2).toFixed(1)}px, ${(pe.y-Ln/2).toFixed(1)}px, 0) rotate(${(ue*57.2958).toFixed(1)}deg)`;const Wr=w.current;if(Wr){const we=pe.x-Wr.x,Ye=pe.y-Wr.y,at=Math.hypot(we,Ye)/Math.max(1,Oe);if(G.style.setProperty("--cp-speed",Math.min(1,at/.45).toFixed(3)),at>.02){const Ke=(Math.atan2(Ye,we)*57.2958+90+360)%360;G.style.setProperty("--cp-thrust-deg",Ke.toFixed(1)+"deg")}}w.current={x:pe.x,y:pe.y}};return ae=requestAnimationFrame(je),()=>{var Se;cancelAnimationFrame(ae),(Se=b.current)==null||Se.dispose(),b.current=null}},[t.enabledLoaded,t.enabled,t.petMode,r]);const q=k.useRef(0);if(k.useEffect(()=>{const G=g.current;if(!G||t.state.keySeq===q.current||t.state.examActive)return;q.current=t.state.keySeq,G.classList.remove("cp-keypress"),G.offsetWidth,G.classList.add("cp-keypress");const ae=setTimeout(()=>G.classList.remove("cp-keypress"),160);return()=>clearTimeout(ae)},[t.state.keySeq]),!t.enabledLoaded||!t.enabled||t.petMode)return null;const K=s?"flying":t.state.typing?"typing":N||(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,M=a?Dt[a.pane]:Dt[l];return p.jsx("div",{ref:g,className:`cp-creature fixed left-0 top-0 z-40 will-change-transform ${t.state.mode==="veil"?"cp-veil":""} ${f?"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:p.jsx(Qb,{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:K,viseme:n.viseme,openScale:n.open,energyRatio:t.energyRatio,streakLit:t.streakLit,size:M,interactive:!0,ariaLabel:"companion",onPoke:Zb,onGrab:(G,ae)=>{B.current||(B.current={x:G,y:ae,vx:0,vy:0,t:performance.now()},_c(!0))},haloBadge:t.halo,testid:"companion-mascot",keySeq:t.state.keySeq,keySide:t.state.keySide})})}function wl(e){return{messages:[],streaming:!1,streamingMsgId:null,loaded:!1,focusNodeId:null,touched:e}}function Lu(e,t,n){if(e.has(t))return e;const r=new Map(e);return r.set(t,wl(n)),r}function Hh(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 jI(e,t,n,r,s,i){const a=Lu(e,t,s),o=a.get(t);let l=o.streamingMsgId,u=o.messages;if(!(l&&u.some(f=>f.id===l))){const f=u[u.length-1];o.streaming&&f&&f.role==="assistant"?l=f.id:(l=r(),u=[...u,{id:l,role:"assistant",parts:[]}])}const h=new Map(a);return h.set(t,{...o,messages:u.map(f=>f.id===l?{...f,parts:UN(f.parts,n)}:f),streamingMsgId:l,focusNodeId:i??o.focusNodeId,touched:s}),h}function HI(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 Sg(e,t,n,r,s){const i=Lu(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 UI(e,t,n,r){const s=Lu(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 zI(e,t,n,r,s){return Sg(e,t,n,r,s)}function Uh(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 VI=0;const Ss=()=>`msg-v2-${++VI}`,zh=8;function qI(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 $I(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 y=!1;return(async()=>{const w=s.current.get(e);if(w&&(w.loaded||w.messages.length>0)){r(E=>Hh(E,e,Date.now()));return}try{const E=await se.threadGetMessages(e);if(y)return;r(S=>{const v=S.get(e);if(v&&(v.loaded||v.messages.length>0))return Hh(S,e,Date.now());const T=E.map(A=>{const N=qI(A.partsJson);return{id:A.id,role:A.role,parts:N??[{type:"text",text:A.content}],...A.displayText?{displayText:A.displayText}:{}}}),_=new Map(S);return _.set(e,{...v??wl(Date.now()),messages:T,loaded:!0,touched:Date.now()}),Uh(_,zh)})}catch{}})(),()=>{y=!0}},[e]),k.useEffect(()=>{const y=se.on("chat:part",(S,v,T)=>{const _=v??i.current;r(A=>Uh(jI(A,_,S,Ss,Date.now(),T),zh))}),w=se.on("chat:done",(S,v,T)=>{const _=T??i.current;r(A=>HI(A,_,v,Date.now()))}),E=se.on("chat:error",(S,v)=>{const T=v??i.current;r(_=>Sg(_,T,S,Ss,Date.now()))});return()=>{y(),w(),E()}},[]);const a=k.useCallback(async(y,w,E,S)=>{var N;const v=w??e;if(!v||!y.trim()||(N=s.current.get(v))!=null&&N.streaming)return;const T=y.trim(),_={id:Ss(),role:"user",parts:[...(S??[]).map(C=>({type:"attachment",attachment:{kind:C.kind,name:C.name,mime:C.mime,size:C.size,...C.previewUrl?{previewUrl:C.previewUrl}:{}}})),{type:"text",text:T}],...E?{displayText:E}:{}},A=UI(s.current,v,_,Date.now());if(A.accepted){r(A.buckets);try{await se.agentChatThread(v,T,E,t??null,S)}catch(C){const D=C instanceof Error?C.message:String(C);r(P=>zI(P,v,D,Ss,Date.now()))}}},[e,t]),o=k.useCallback(async()=>{if(e){try{await se.abortAgentChatThread(e)}catch{}r(y=>{const w=y.get(e);if(!(w!=null&&w.streaming))return y;const E=new Map(y);return E.set(e,{...w,streaming:!1,streamingMsgId:null,touched:Date.now()}),E})}},[e]),l=k.useCallback(()=>{e&&r(y=>{const w=y.get(e);if(!w)return y;const E=new Map(y);return E.set(e,{...w,messages:[],streamingMsgId:null,loaded:!0,touched:Date.now()}),E})},[e]);k.useEffect(()=>{const y=w=>{const E=w.detail;if(typeof E!="string")return;const v={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"}}[E];v&&a(v.msg,void 0,au(v.labelKey))};return window.addEventListener("lookatstudy-command",y),()=>window.removeEventListener("lookatstudy-command",y)},[a]);const u=k.useCallback((y,w,E)=>{e&&r(S=>{const v=S.get(e);if(!v)return S;const T=new Map(S);return T.set(e,{...v,messages:v.messages.map(_=>{if(_.id!==y)return _;const A=[..._.parts],N=A[w];return N&&N.type==="tool-call"&&(A[w]={...N,output:{...typeof N.output=="object"&&N.output?N.output:{},status:E?"applied":"rejected"}}),{..._,parts:A}})}),T})},[e]),c=k.useCallback((y,w)=>{e&&r(E=>{const S=E.get(e);if(!S)return E;const v=new Map(E);return v.set(e,{...S,messages:S.messages.map(T=>{if(T.id!==y)return T;const _=[...T.parts],A=_[w];return A&&A.type==="tool-call"&&(_[w]={...A,output:{...typeof A.output=="object"&&A.output?A.output:{},undone:!0,canUndo:!1}}),{...T,parts:_}})}),v})},[e]),h=k.useCallback(y=>{e&&r(w=>{const E=w.get(e)??wl(Date.now()),S=new Map(w);return S.set(e,{...E,messages:y,loaded:!0,touched:Date.now()}),S})},[e]),f=e?n.get(e):void 0,d=k.useMemo(()=>(f==null?void 0:f.messages)??[],[f]),m=(f==null?void 0:f.streaming)??!1,g=k.useMemo(()=>Array.from(n.entries()).filter(([,y])=>y.streaming).map(([y])=>y),[n]),b=k.useMemo(()=>Array.from(n.values()).filter(y=>y.streaming&&y.focusNodeId).map(y=>y.focusNodeId).filter((y,w,E)=>E.indexOf(y)===w),[n]);return{messages:d,streaming:m,streamingThreadIds:g,streamingNodeIds:b,send:a,stop:o,clear:l,markProposalStatus:u,markProposalUndone:c,setMessagesForNode:h}}const As=(e,t=60)=>e.length>t?e.slice(0,t)+"…":e;function WI(e,t){return t("quiz.hook.label",{correct:e.correct,total:e.total})}function YI(e,t){const n=e.detail.map((s,i)=>s.correct?t("quiz.hook.lineOk",{n:i+1,prompt:As(s.prompt)}):t("quiz.hook.lineWrong",{n:i+1,prompt:As(s.prompt),chosen:As(s.chosen,30),answer:As(s.answerText,30)})),r=e.title?`《${e.title}》`:"";return t("quiz.hook.message",{title:r,correct:e.correct,total:e.total})+(n.length?`
550
550
  `+n.join(`
@@ -556,4 +556,4 @@ ${h}`:h)},[h]),k.useEffect(()=>{if(!e){_(null);return}let ie=!1;(async()=>{try{c
556
556
  ${v}px !important;
557
557
  ${T}px !important;
558
558
  }
559
- `),()=>{var N;(N=o.current)==null||N.removeAttribute("data-motion-pop-id"),A.contains(_)&&A.removeChild(_)}},[t]),p.jsx(ZR,{isPresent:t,childRef:o,sizeRef:l,pop:i,children:i===!1?e:k.cloneElement(e,{ref:h})})}const eM=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:s,presenceAffectsLayout:i,mode:a,anchorX:o,anchorY:l,root:u})=>{const c=Fu(tM),h=k.useId(),f=k.useRef(n),d=k.useRef(r);sa(()=>{f.current=n,d.current=r});let m=!0,g=k.useMemo(()=>(m=!1,{id:h,initial:t,isPresent:n,custom:s,onExitComplete:b=>{c.set(b,!0);for(const y of c.values())if(!y)return;r&&r()},register:b=>(c.set(b,!1),()=>{var y;c.delete(b),!f.current&&!c.size&&((y=d.current)==null||y.call(d))})}),[n,c,r]);return i&&m&&(g={...g}),k.useMemo(()=>{c.forEach((b,y)=>c.set(y,!1))},[n]),k.useEffect(()=>{!n&&!c.size&&r&&r()},[n]),e=p.jsx(JR,{pop:a==="popLayout",isPresent:n,anchorX:o,anchorY:l,root:u,children:e}),p.jsx(La.Provider,{value:g,children:e})};function tM(){return new Map}function tb(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 Ns=e=>e.key||"";function Gf(e){const t=[];return k.Children.forEach(e,n=>{k.isValidElement(n)&&t.push(n)}),t}const nM=({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,h]=tb(a),f=k.useMemo(()=>Gf(e),[e]),d=a&&!c?[]:f.map(Ns),m=k.useRef(!0),g=k.useRef(f),b=Fu(()=>new Map),y=k.useRef(new Set),[w,E]=k.useState(f),[S,v]=k.useState(f);sa(()=>{a&&!c&&!S.length&&(h==null||h())},[c,a,S.length,h]),sa(()=>{m.current=!1,g.current=f;for(let A=0;A<S.length;A++){const N=Ns(S[A]);d.includes(N)?(b.delete(N),y.current.delete(N)):b.get(N)!==!0&&b.set(N,!1)}},[S,d.length,d.join("-")]);const T=[];if(f!==w){let A=[...f],N=0;for(const C of S){const D=d.indexOf(Ns(C));D===-1?(A.splice(N++,0,C),T.push(C)):N=D+T.length+1}return i==="wait"&&T.length&&(A=T),v(Gf(A)),E(f),null}const{forceRender:_}=k.useContext(Ou);return p.jsx(p.Fragment,{children:S.map(A=>{const N=Ns(A),C=a&&!c?!1:f===S||d.includes(N),D=()=>{if(y.current.has(N))return;if(b.has(N))y.current.add(N),b.set(N,!0);else return;let P=!0;b.forEach(O=>{O||(P=!1)}),P&&(_==null||_(),v(g.current),a&&(h==null||h()),r&&r())};return p.jsx(eM,{isPresent:C,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:s,mode:i,root:u,onExitComplete:C?void 0:D,anchorX:o,anchorY:l,children:A},N)})})},nb=k.createContext({strict:!1}),Kf={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 Xf=!1;function rM(){if(Xf)return;const e={};for(const t in Kf)e[t]={isEnabled:n=>Kf[t].some(r=>!!n[r])};R1(e),Xf=!0}function rb(){return rM(),U4()}function iM(e){const t=rb();for(const n in e)t[n]={...t[n],...e[n]};R1(t)}const ja=k.createContext({});function sM(e,t){if(Ba(e)){const{initial:n,animate:r}=e;return{initial:n===!1||Ui(n)?n:void 0,animate:Ui(r)?r:void 0}}return e.inherit!==!1?t:{}}function aM(e){const{initial:t,animate:n}=sM(e,k.useContext(ja));return k.useMemo(()=>({initial:t,animate:n}),[Qf(t),Qf(n)])}function Qf(e){return Array.isArray(e)?e.join(" "):e}const uc=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ib(e,t,n){for(const r in t)!vt(t[r])&&!B1(r,n)&&(e[r]=t[r])}function oM({transformTemplate:e},t){return k.useMemo(()=>{const n=uc();return ac(n,t,e),Object.assign({},n.vars,n.style)},[t])}function lM(e,t){const n=e.style||{},r={};return ib(r,n,e),Object.assign(r,oM(e,t)),r}function uM(e,t){const n={},r=lM(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 sb=()=>({...uc(),attrs:{}});function cM(e,t,n,r){const s=k.useMemo(()=>{const i=sb();return H1(i,t,z1(r),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};ib(i,e.style,e),s.style={...i,...s.style}}return s}const dM=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 ma(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||dM.has(e)}function hM(e,t){return e.startsWith("on")?!ma(e):(t==null?void 0:t(e))??!ma(e)}function fM(e,t,n,r){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||vt(e[i])||(hM(i,r)||n===!0&&ma(i)||!t&&!ma(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}const mM=["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 cc(e){return typeof e!="string"||e.includes("-")?!1:!!(mM.indexOf(e)>-1||/[A-Z]/u.test(e))}function pM(e,t,n,{latestValues:r},s,i=!1,a,o){const u=(a??cc(e)?cM:uM)(t,r,s,e),c=fM(t,typeof e=="string",i,o),h=e!==k.Fragment?{...c,...u,ref:n}:{},{children:f}=t,d=k.useMemo(()=>vt(f)?f.get():f,[f]);return k.createElement(e,{...h,children:d})}function gM({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,s){return{latestValues:bM(n,r,s,e),renderState:t()}}function bM(e,t,n,r){const s={},i=r(e,{});for(const f in i)s[f]=qs(i[f]);let{initial:a,animate:o}=e;const l=Ba(e),u=N1(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 h=c?o:a;if(h&&typeof h!="boolean"&&!Fa(h)){const f=Array.isArray(h)?h:[h];for(let d=0;d<f.length;d++){const m=Zu(e,f[d]);if(m){const{transitionEnd:g,transition:b,...y}=m;for(const w in y){let E=y[w];if(Array.isArray(E)){const S=c?E.length-1:0;E=E[S]}E!==null&&(s[w]=E)}for(const w in g)s[w]=g[w]}}}return s}const ab=e=>(t,n)=>{const r=k.useContext(ja),s=k.useContext(La),i=()=>gM(e,t,r,s);return n?i():Fu(i)},xM=ab({scrapeMotionValuesFromProps:oc,createRenderState:uc}),yM=ab({scrapeMotionValuesFromProps:V1,createRenderState:sb}),vM=Symbol.for("motionComponentSymbol");function EM(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 ob=k.createContext({});function Er(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function kM(e,t,n,r,s,i){var E,S;const{visualElement:a}=k.useContext(ja),o=k.useContext(nb),l=k.useContext(La),u=k.useContext(lc),c=u.reducedMotion,h=u.skipAnimations,f=k.useRef(null),d=k.useRef(!1);r=r||o.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:a,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:c,skipAnimations:h,isSVG:i}),d.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));const m=f.current,g=k.useContext(ob);m&&!m.projection&&s&&(m.type==="html"||m.type==="svg")&&TM(f.current,n,s,g);const b=k.useRef(!1);k.useInsertionEffect(()=>{m&&b.current&&m.update(n,l)});const y=n[b1],w=k.useRef(!!y&&typeof window<"u"&&!((E=window.MotionHandoffIsComplete)!=null&&E.call(window,y))&&((S=window.MotionHasOptimisedAnimation)==null?void 0:S.call(window,y)));return sa(()=>{d.current=!0,m&&(b.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),w.current&&m.animationState&&m.animationState.animateChanges())}),k.useEffect(()=>{m&&(!w.current&&m.animationState&&m.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{var v;(v=window.MotionHandoffMarkAsComplete)==null||v.call(window,y)}),w.current=!1),m.enteringChildren=void 0)}),m}function TM(e,t,n,r){const{layoutId:s,layout:i,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:u,layoutAnchor:c,layoutCrossfade:h}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:lb(e.parent)),e.projection.setOptions({layoutId:s,layout:i,alwaysMeasureLayout:!!a||o&&Er(o),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:r,crossfade:h,layoutScroll:l,layoutRoot:u,layoutAnchor:c})}function lb(e){if(e)return e.options.allowProjection!==!1?e.projection:lb(e.parent)}function Wo(e,{forwardMotionProps:t=!1,type:n}={},r,s){r&&iM(r);const i=n?n==="svg":cc(e),a=i?yM:xM;function o(u,c){let h;const f={...k.useContext(lc),...u,layoutId:wM(u)},{isStatic:d,isValidProp:m}=f,g=aM(u),b=a(u,d);if(!d&&typeof window<"u"){SM();const y=AM(f);h=y.MeasureLayout,g.visualElement=kM(e,b,f,s,y.ProjectionNode,i)}return p.jsxs(ja.Provider,{value:g,children:[h&&g.visualElement?p.jsx(h,{visualElement:g.visualElement,...f}):null,pM(e,u,EM(b,g.visualElement,c),b,d,t,i,m)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const l=k.forwardRef(o);return l[vM]=e,l}function wM({layoutId:e}){const t=k.useContext(Ou).id;return t&&e!==void 0?t+"-"+e:e}function SM(e,t){k.useContext(nb).strict}function AM(e){const t=rb(),{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 CM(e,t){if(typeof Proxy>"u")return Wo;const n=new Map,r=(i,a)=>Wo(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,Wo(a,void 0,e,t)),n.get(a))})}const _M=(e,t)=>t.isSVG??cc(e)?new rR(t):new Z4(t,{allowProjection:e!==k.Fragment});class NM extends Pn{constructor(t){super(t),t.animationState||(t.animationState=lR(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Fa(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 IM=0;class RM extends Pn{constructor(){super(...arguments),this.id=IM++,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=ar(this.node,a,o);if(l){const{transition:u,transitionEnd:c,...h}=l;for(const f in h)(i=this.node.getValue(f))==null||i.jump(h[f])}}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 MM={animation:{Feature:NM},exit:{Feature:RM}};function es(e){return{point:{x:e.pageX,y:e.pageY}}}const PM=e=>t=>nc(t)&&e(t,es(t));function Ii(e,t,n,r){return zi(e,t,PM(n),r)}const ub=({current:e})=>e?e.ownerDocument.defaultView:null,Zf=(e,t)=>Math.abs(e-t);function LM(e,t){const n=Zf(e.x,t.x),r=Zf(e.y,t.y);return Math.sqrt(n**2+r**2)}const Jf=new Set(["auto","scroll"]);class cb{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=Is(this.lastRawMoveEventInfo,this.transformPagePoint));const m=Yo(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,b=LM(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!b)return;const{point:y}=m,{timestamp:w}=yt;this.history.push({...y,timestamp:w});const{onStart:E,onMove:S}=this.handlers;g||(E&&E(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,m)},this.handlePointerMove=(m,g)=>{this.lastMoveEvent=m,this.lastRawMoveEventInfo=g,this.lastMoveEventInfo=Is(g,this.transformPagePoint),tt.update(this.updatePoint,!0)},this.handlePointerUp=(m,g)=>{this.end();const{onEnd:b,onSessionEnd:y,resumeAnimation:w}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const E=Yo(m.type==="pointercancel"?this.lastMoveEventInfo:Is(g,this.transformPagePoint),this.history);this.startEvent&&b&&b(m,E),y&&y(m,E)},!nc(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=a,this.contextWindow=s||window;const l=es(t),u=Is(l,this.transformPagePoint),{point:c}=u,{timestamp:h}=yt;this.history=[{...c,timestamp:h}];const{onSessionStart:f}=n;f&&f(t,Yo(u,this.history));const d={passive:!0,capture:!0};this.removeListeners=Qi(Ii(this.contextWindow,"pointermove",this.handlePointerMove,d),Ii(this.contextWindow,"pointerup",this.handlePointerUp,d),Ii(this.contextWindow,"pointercancel",this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(t){let n=t.parentElement;for(;n;){const r=getComputedStyle(n);(Jf.has(r.overflowX)||Jf.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),tt.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 Is(e,t){return t?{point:t(e.point)}:e}function em(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Yo({point:e},t){return{point:e,delta:em(e,db(t)),offset:em(e,DM(t)),velocity:OM(t,.1)}}function DM(e){return e[0]}function db(e){return e[e.length-1]}function OM(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const s=db(e);for(;n>=0&&(r=e[n],!(s.timestamp-r.timestamp>$t(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&s.timestamp-r.timestamp>$t(t)*2&&(r=e[1]);const i=Vt(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 FM(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?et(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?et(n,e,r.max):Math.min(e,n)),e}function tm(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 BM(e,{top:t,left:n,bottom:r,right:s}){return{x:tm(e.x,n,s),y:tm(e.y,t,r)}}function nm(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 jM(e,t){return{x:nm(e.x,t.x),y:nm(e.y,t.y)}}function HM(e,t){let n=.5;const r=_t(e),s=_t(t);return s>r?n=ji(t.min,t.max-r,e.min):r>s&&(n=ji(e.min,e.max-s,t.min)),cn(0,1,n)}function UM(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 Xl=.35;function zM(e=Xl){return e===!1?e=0:e===!0&&(e=Xl),{x:rm(e,"left","right"),y:rm(e,"top","bottom")}}function rm(e,t,n){return{min:im(e,t),max:im(e,n)}}function im(e,t){return typeof e=="number"?e:e[t]||0}const VM=new WeakMap;class qM{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=gt(),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=h=>{n&&this.snapToCursor(es(h).point),this.stopAnimation()},a=(h,f)=>{const{drag:d,dragPropagation:m,onDragStart:g}=this.getProps();if(d&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=b4(d),!this.openDragLock))return;this.latestPointerEvent=h,this.latestPanInfo=f,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 w=this.getAxisMotionValue(y).get()||0;if(un.test(w)){const{projection:E}=this.visualElement;if(E&&E.layout){const S=E.layout.layoutBox[y];S&&(w=_t(S)*(parseFloat(w)/100))}}this.originPoint[y]=w}),g&&tt.update(()=>g(h,f),!1,!0),Hl(this.visualElement,"transform");const{animationState:b}=this.visualElement;b&&b.setActive("whileDrag",!0)},o=(h,f)=>{this.latestPointerEvent=h,this.latestPanInfo=f;const{dragPropagation:d,dragDirectionLock:m,onDirectionLock:g,onDrag:b}=this.getProps();if(!d&&!this.openDragLock)return;const{offset:y}=f;if(m&&this.currentDirection===null){this.currentDirection=WM(y),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),b&&tt.update(()=>b(h,f),!1,!0)},l=(h,f)=>{this.latestPointerEvent=h,this.latestPanInfo=f,this.stop(h,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:h}=this.getProps();(h||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:c}=this.getProps();this.panSession=new cb(t,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:r,contextWindow:ub(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&&tt.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||!Rs(t,s,this.currentDirection))return;const i=this.getAxisMotionValue(t);let a=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(a=FM(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&&Er(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=BM(r.layoutBox,t):this.constraints=!1,this.elastic=zM(n),s!==this.constraints&&!Er(t)&&r&&this.constraints&&!this.hasMutatedConstraints&&rn(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=UM(r.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Er(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=W4(r,s.root,this.visualElement.getTransformPagePoint());let a=jM(s.layout.layoutBox,i);if(n){const o=n(V4(a));this.hasMutatedConstraints=!!o,o&&(a=P1(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(!Rs(c,n,this.currentDirection))return;let h=l&&l[c]||{};(a===!0||a===c)&&(h={min:0,max:0});const f=s?200:1e6,d=s?40:1e7,m={type:"inertia",velocity:r?t[c]:0,bounceStiffness:f,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...i,...h};return this.startAxisValueAnimation(c,m)});return Promise.all(u).then(o)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return Hl(this.visualElement,t),r.start(Qu(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(!Rs(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]-et(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!Er(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]=HM({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(!Rs(a,t,null))return;const o=this.getAxisMotionValue(a),{min:l,max:u}=this.constraints[a];o.set(et(l,u,s[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;VM.set(this.visualElement,this);const t=this.visualElement.current,n=Ii(t,"pointerdown",u=>{const{drag:c,dragListener:h=!0}=this.getProps(),f=u.target,d=f!==t&&T4(f);c&&h&&!d&&this.start(u)});let r;const s=()=>{const{dragConstraints:u}=this.getProps();Er(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),r||(r=$M(t,u.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,a=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),tt.read(s);const o=zi(window,"resize",()=>this.scalePositionWithinConstraints()),l=i.addEventListener("didUpdate",(({delta:u,hasLayoutChanged:c})=>{this.isDragging&&c&&(rn(h=>{const f=this.getAxisMotionValue(h);f&&(this.originPoint[h]+=u[h].translate,f.set(f.get()+u[h].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=Xl,dragMomentum:o=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:s,dragConstraints:i,dragElastic:a,dragMomentum:o}}}function sm(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function $M(e,t,n){const r=hf(e,sm(n)),s=hf(t,sm(n));return()=>{r(),s()}}function Rs(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function WM(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class YM extends Pn{constructor(t){super(t),this.removeGroupControls=qt,this.removeListeners=qt,this.controls=new qM(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||qt}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 Go=e=>(t,n)=>{e&&tt.update(()=>e(t,n),!1,!0)};class GM extends Pn{constructor(){super(...arguments),this.removePointerDownListener=qt}onPointerDown(t){this.session=new cb(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ub(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:s}=this.node.getProps();return{onSessionStart:Go(t),onStart:Go(n),onMove:Go(r),onEnd:(i,a)=>{delete this.session,s&&tt.postRender(()=>s(i,a))}}}mount(){this.removePointerDownListener=Ii(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 KM 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()})),$s.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()||tt.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(),tc.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 hb(e){const[t,n]=tb(),r=k.useContext(Ou);return p.jsx(KM,{...e,layoutGroup:r,switchLayoutGroup:k.useContext(ob),isPresent:t,safeToRemove:n})}const XM={pan:{Feature:GM},drag:{Feature:YM,ProjectionNode:eb,MeasureLayout:hb}};function am(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&&tt.postRender(()=>i(t,es(t)))}class QM extends Pn{mount(){const{current:t}=this.node;t&&(this.unmount=y4(t,(n,r)=>(am(this.node,r,"Start"),s=>am(this.node,s,"End"))))}unmount(){}}class ZM extends Pn{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=Qi(zi(this.node.current,"focus",()=>this.onFocus()),zi(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function om(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&&tt.postRender(()=>i(t,es(t)))}class JM extends Pn{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:r}=this.node.props;this.unmount=S4(t,(s,i)=>(om(this.node,i,"Start"),(a,{success:o})=>om(this.node,a,o?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(r==null?void 0:r.tap)===!1})}unmount(){}}const Ql=new WeakMap,Xo=new WeakMap,eP=e=>{const t=Ql.get(e.target);t&&t(e)},tP=e=>{e.forEach(eP)};function nP({root:e,...t}){const n=e||document;Xo.has(n)||Xo.set(n,{});const r=Xo.get(n),s=JSON.stringify(t);return r[s]||(r[s]=new IntersectionObserver(tP,{root:e,...t})),r[s]}function rP(e,t,n){const r=nP(t);return Ql.set(e,n),r.observe(e),()=>{Ql.delete(e),r.unobserve(e)}}const iP={some:0,all:1};class sP extends Pn{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:iP[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:h,onViewportLeave:f}=this.node.getProps(),d=c?h:f;d&&d(u)};this.stopObserver=rP(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(aP(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function aP({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const oP={inView:{Feature:sP},tap:{Feature:JM},focus:{Feature:ZM},hover:{Feature:QM}},lP={layout:{ProjectionNode:eb,MeasureLayout:hb}},uP={...MM,...oP,...XM,...lP},cP=CM(uP,_M),dP=cP;function hP(e){switch(e){case"correct":return{Icon:nu,color:"var(--brand)"};case"wrong":return{Icon:pm,color:"var(--warning)"};case"mastery":case"level-up":return{Icon:ru,color:"var(--gold)"};case"unlock":return{Icon:Ys,color:"var(--brand)"};case"streak":return{Icon:ga,color:"var(--review)"};case"energy-full":return{Icon:Gs,color:"var(--brand)"};case"exam-pass":return{Icon:Tx,color:"var(--exam)"};case"lesson-complete":return{Icon:Im,color:"var(--gold)"};default:return{Icon:Ys,color:"var(--brand)"}}}function fP(){const e=Jl(),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 f=Math.min(window.devicePixelRatio||1,2);a.width=window.innerWidth*f,a.height=window.innerHeight*f,a.style.width=window.innerWidth+"px",a.style.height=window.innerHeight+"px",o.setTransform(f,0,0,f,0,0)};l(),window.addEventListener("resize",l);const u=()=>{o.clearRect(0,0,window.innerWidth,window.innerHeight);const f=n.current;for(let d=f.length-1;d>=0;d--){const m=f[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){f.splice(d,1);continue}const g=Math.min(1,m.life/m.maxLife);o.save(),o.globalAlpha=g,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=f.length>0?requestAnimationFrame(u):0},h=Jo(f=>{var y,w;const d=hx(f.kind),m=Math.round(d.particles*(f.intensity??1)),g=((y=f.origin)==null?void 0:y.x)??window.innerWidth/2,b=((w=f.origin)==null?void 0:w.y)??window.innerHeight/2;for(let E=0;E<m;E++){const S=Math.PI*2*E/m+Math.random()*.3,v=3+Math.random()*6,T=d.durationMs/16*(.7+Math.random()*.5);n.current.push({x:g,y:b,vx:Math.cos(S)*v,vy:Math.sin(S)*v-2,life:T,maxLife:T,color:d.colors[E%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()=>{h(),window.removeEventListener("resize",l),r.current&&cancelAnimationFrame(r.current),r.current=0,n.current=[]}},[e]),k.useEffect(()=>{if(!e)return;let a=0;return Jo(l=>{const u=++a;i({kind:l.kind,id:u}),setTimeout(()=>{u===a&&i(null)},600)})},[e]),e?p.jsx(nM,{children:s&&(()=>{const{Icon:a,color:o}=hP(s.kind);return p.jsx(dP.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:p.jsx(a,{className:"w-24 h-24",color:o,strokeWidth:1.5})},s.id)})()}):p.jsx("canvas",{ref:t,className:"fixed inset-0 pointer-events-none z-[60]","aria-hidden":"true"})}function mP(e,t){const n=e.find(o=>o.id===t&&o.type!=="section");if(!n)return null;const r=e.filter(o=>o.type==="section").sort((o,l)=>o.orderIdx-l.orderIdx),s=o=>e.filter(l=>l.type!=="section"&&l.parentId===o).sort((l,u)=>l.orderIdx-u.orderIdx),i=s(n.parentId).find(o=>o.orderIdx>n.orderIdx);if(i)return i;const a=r.findIndex(o=>o.id===n.parentId);for(let o=a+1;o<r.length;o++){const l=s(r[o].id)[0];if(l)return l}return null}const pP=k.lazy(()=>_e(()=>import("./PersonalProfileModal-B-4B0oxN.js"),__vite__mapDeps([33,1,2]),import.meta.url)),gP=k.lazy(()=>_e(()=>import("./ModelManagerModal-CSOiYXJw.js"),__vite__mapDeps([34,1,2,35]),import.meta.url)),bP=k.lazy(()=>_e(()=>import("./ReviewPanel-ZCLRG73N.js"),__vite__mapDeps([36,1,2]),import.meta.url).then(e=>({default:e.SelfRatingCard}))),xP=k.lazy(()=>_e(()=>import("./SettingsView-BNv73q7Y.js"),__vite__mapDeps([37,1,2,35]),import.meta.url).then(e=>({default:e.SettingsView}))),yP=k.lazy(()=>_e(()=>import("./ExamView-CEaKtO-T.js"),__vite__mapDeps([38,1,2,31]),import.meta.url).then(e=>({default:e.ExamView}))),vP=k.lazy(()=>_e(()=>import("./CommandPalette-BHpA4Ewc.js"),__vite__mapDeps([39,1,2]),import.meta.url).then(e=>({default:e.CommandPalette}))),EP=k.lazy(()=>_e(()=>import("./CompanionBotLab-Bp2oeINT.js"),__vite__mapDeps([40,1,2]),import.meta.url).then(e=>({default:e.CompanionBotLab}))),lm=["direct","guide","practice"];function kP(){var kc;const e=$e(),[t,n]=k.useState([]),[r,s]=k.useState([]),[i,a]=k.useState({}),[o,l]=k.useState(null),[u,c]=k.useState(null),[h,f]=k.useState(null),[d,m]=k.useState(null),g=k.useCallback(H=>{m(H instanceof Error?H.message:String(H)),console.error(H)},[]),[b,y]=k.useState([]),[w,E]=k.useState(null),[S,v]=k.useState([]),[T,_]=k.useState(null),[A,N]=k.useState("map"),[C,D]=k.useState(null),[P,O]=k.useState(new Set),[I,R]=k.useState(null),[B,V]=k.useState(null),z=k.useRef({active:!1,terminate:null}),[Y,L]=k.useState({open:!1,pendingAction:null}),q=k.useRef(null),[K,M]=k.useState(null),[G,ae]=k.useState(!1),[ne,X]=k.useState(!1),[te,ue]=k.useState("main"),ge=k.useCallback((H="main")=>{ue(H),X(!0)},[]),[Z,re]=k.useState(null),[be,ve]=k.useState(!1),[Fe,je]=k.useState(null),[Se,Oe]=k.useState(!0),[st,pt]=k.useState(!0),me=i5(),[rt,ie]=k.useState("notebook"),[Ie,Be]=k.useState("chat"),Q=k.useRef(Ie);Q.current=Ie;const ee=k.useRef(me);k.useEffect(()=>{ee.current!==me&&(me===1?(Oe(!0),pt(!0)):me===2&&ee.current===3&&ie(JI(Q.current)),ee.current=me)},[me]);const he=me===3?Ie==="rail":me===2?rt==="rail":Se,Te=me===3?Ie==="notebook":me===2?rt==="notebook":st,Re=me!==3||Ie==="chat",[Ze,dt]=k.useState(null),[xe,De]=k.useState(null);k.useEffect(()=>{let H=!0;return(async()=>{const[$,oe]=await Promise.all([se.getSetting("pane_width_left"),se.getSetting("pane_width_mid")]);H&&(dt(Vh($,Sl,Ag)),De(Vh(oe,Bi,_g)))})(),()=>{H=!1}},[]);const Ve=me===3?"t3":me===2?he?"t2-rail":"t2-notebook":"t1",We=u5(Ze!=null||xe!=null)||window.innerWidth,ht=l5(Ze,xe,We,Ve),Ln=o5(me,he,Te),$r=k.useRef(null),Wr=Ve==="t2-rail"?Bi:Ai+(ht.mid??Ng(We)),ts=Ai+(Ve==="t2-notebook"?0:ht.rail??Cg),Yr=(H,$)=>{H==="rail"?(dt($),se.setSetting("pane_width_left",$!=null?String($):"")):(De($),se.setSetting("pane_width_mid",$!=null?String($):""))},Gr=()=>{me===1?Oe(H=>!H):me===2?ie(H=>H==="rail"?"notebook":"rail"):Be(H=>H==="rail"?"chat":"rail")},ns=()=>{me===1?pt(H=>!H):me===2?ie(H=>H==="notebook"?"rail":"notebook"):Be(H=>H==="notebook"?"chat":"notebook")},hr=k.useRef(null),rs=H=>{var oe,ke;if(me!==3)return;const $=H.touches[0];hr.current={x:$.clientX,y:$.clientY,multi:H.touches.length>1,noswipe:!!((ke=(oe=H.target).closest)!=null&&ke.call(oe,"[data-noswipe]"))}},is=H=>{const $=hr.current;if(hr.current=null,!$||$.multi||$.noswipe||me!==3)return;const oe=H.changedTouches[0],ke=e5(Q.current,oe.clientX-$.x,oe.clientY-$.y);ke&&Be(ke)},[ss,Dn]=k.useState(!1),[we,Ye]=k.useState(()=>location.hash==="#companion-bot-lab");k.useEffect(()=>{const H=()=>Ye(location.hash==="#companion-bot-lab");return window.addEventListener("hashchange",H),()=>window.removeEventListener("hashchange",H)},[]);const[Me,at]=k.useState(null),[Ke,Ce]=k.useState([]),ye=GI(h,I),Pe=ba(),Ae=$I(ye.activeId,Pe);k.useEffect(()=>{fx(Ae.streaming)},[Ae.streaming]);const[St,Xe]=k.useState(""),Ge=k.useCallback(H=>{Xe(H)},[]),Nt=k.useCallback((H,$,oe)=>{if(H.type==="content"){if(M("content"),oe){const ke=Qe=>{uh(oe)?window.dispatchEvent(new CustomEvent("lookatstudy-jump-to-note",{detail:oe})):Qe>0&&setTimeout(()=>ke(Qe-1),150)};setTimeout(()=>ke(10),100)}}else if(H.threadId!==ye.activeId&&ye.setActiveId(H.threadId),oe){const ke=Qe=>{uh(oe)?window.dispatchEvent(new CustomEvent("lookatstudy-jump-to-chat-note",{detail:oe})):Qe>0&&setTimeout(()=>ke(Qe-1),150)};setTimeout(()=>ke(10),120)}},[ye]),[On,tn]=k.useState(null);k.useEffect(()=>{if(!I){tn(null);return}let H=!1;return se.getNodeSummary(I,Pe).then($=>{H||tn($)}).catch(()=>{H||tn(null)}),()=>{H=!0}},[I,Pe]);const ze=k.useMemo(()=>r.find(H=>H.id===I)??null,[r,I]),Ha=k.useMemo(()=>Ke.map(H=>({...H,label:e(`starter.${H.key}.label`),hint:e(`starter.${H.key}.hint`),message:e(`starter.${H.key}.message`,{title:(ze==null?void 0:ze.title)??""})})),[Ke,ze,e]),lt=k.useRef(null),Kr=k.useCallback(()=>{var H;ze&&((H=lt.current)==null||H.call(lt,e("chat.action.startLearningPrompt",{title:ze.title}),e("chat.action.startLearning",{title:ze.title})))},[ze,e]),Et=k.useCallback(async()=>{try{const[H,$,oe,ke,Qe,Yt]=await Promise.all([se.listCourses(),se.getStreak(),se.listSouls(),se.getActiveSoul(),se.getXpStatus(),se.getDueReviews()]);n(H),l($),v(oe),c(Qe),_(ke),O(new Set(Yt)),h&&!H.some(Lb=>Lb.id===h)&&(f(null),R(null),s([]),a({}),D(null),y([]),E(null))}catch(H){m(H instanceof Error?H.message:String(H))}},[h]);k.useEffect(()=>{Et()},[Et]);const Fn=k.useCallback(async()=>{try{O(new Set(await se.getDueReviews()))}catch{}},[]),Bn=k.useCallback(async()=>{try{at(await se.isAgentReady())}catch{at({ready:!1,missing:e("error.checkReadyFailed")})}},[e]);k.useEffect(()=>{Bn();const H=()=>Bn();return window.addEventListener("llm-config-changed",H),()=>window.removeEventListener("llm-config-changed",H)},[Bn]);const It=k.useRef(0),jn=k.useRef(0);k.useEffect(()=>{It.current=(u==null?void 0:u.todayXp)??0},[u]),k.useEffect(()=>{jn.current=(o==null?void 0:o.currentStreak)??0},[o]);const vn=k.useCallback(async()=>{const H=r.filter(ke=>ke.type==="lesson"||ke.type==="exam"),$=await Promise.all(H.map(async ke=>{const Qe=await se.getProgress(ke.id);return[ke.id,Qe]})),oe={};for(const[ke,Qe]of $)Qe&&(oe[ke]=Qe);a(oe)},[r]);k.useEffect(()=>se.on("state:changed",$=>{$==="xp"?(se.getXpStatus().then(oe=>{c(oe),It.current<100&&oe.todayXp>=100&&Ar("energy-full")}).catch(()=>{}),Fn()):$==="streak"?(se.getStreak().then(oe=>{l(oe),oe.currentStreak>jn.current&&Ar("streak")}).catch(()=>{}),Fn()):$==="mastery"&&(Ar("mastery"),Et(),vn())}),[Et,Fn,vn]),k.useEffect(()=>{h&&(se.getCourseLanguages(h).then(y).catch(()=>y([])),se.getCourseLanguage(h).then(E).catch(()=>E(null)))},[h]),k.useEffect(()=>{h&&(se.getCourseTree(h,w??void 0).then(async H=>{s(H);const $=H.filter(Qe=>Qe.type==="lesson"||Qe.type==="exam"),oe=await Promise.all($.map(async Qe=>{const Yt=await se.getProgress(Qe.id);return[Qe.id,Yt]})),ke={};for(const[Qe,Yt]of oe)Yt&&(ke[Qe]=Yt);a(ke)}).catch(g),se.getDashboard(h).then(D).catch(g))},[h,w,g]),k.useEffect(()=>{if(!I){Ce([]);return}se.getStarterPrompts(I).then(Ce).catch(()=>Ce([]))},[I]),k.useEffect(()=>{const H=$=>{if($.key==="Escape"&&ye.activeId&&(se.abortAgentChatThread(ye.activeId).catch(()=>{}),ae(!1),Dn(!1)),($.ctrlKey||$.metaKey)&&$.key==="k"&&($.preventDefault(),Dn(oe=>!oe)),($.ctrlKey||$.metaKey)&&$.key==="b"&&($.preventDefault(),Gr()),($.ctrlKey||$.metaKey)&&$.key==="Tab"){if($.preventDefault(),z.current.active)return;const oe=ye.threads;if(oe.length>1){const ke=oe.findIndex(Yt=>Yt.id===ye.activeId),Qe=$.shiftKey?(ke-1+oe.length)%oe.length:(ke+1)%oe.length;ye.setActiveId(oe[Qe].id)}}(!($.target instanceof Element)||!$.target.matches("input, textarea, select"))&&($.key==="1"&&N("map"),$.key==="2"&&N("import"),$.key==="s"&&($.ctrlKey||$.metaKey)&&($.preventDefault(),ae(!0)))};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[I]);const Ua=k.useCallback(async H=>{var $;try{if(H.type==="exam"){R(H.id),M("content");return}if((($=i[H.id])==null?void 0:$.status)==="locked"){R(null);return}await se.markNodeAttempted(H.id);const oe=await se.getStreak();await vn(),l(oe),R(H.id),M("content")}catch(oe){g(oe)}},[i,vn,g]),fr=k.useCallback(H=>{if(z.current.active){L({open:!0,pendingAction:H});return}H()},[]),Xr=k.useCallback(H=>{if(dc(null),z.current.active&&H.id!==I){L({open:!0,pendingAction:()=>void Ua(H)});return}Ua(H)},[Ua,I]),as=k.useCallback(()=>{se.profileGet().then(H=>je((H==null?void 0:H.name)??null)).catch(()=>{})},[]);k.useEffect(()=>{as()},[as]);const mb=k.useCallback((H,$)=>{f(H),V($),Et()},[Et]),pb=k.useCallback((H,$)=>{const oe=r.find(ke=>ke.id===H);if(oe){Xr(oe);return}},[r,Xr]),gb=k.useCallback(()=>{ie("rail"),Oe(!0),me===3&&Be("rail"),window.setTimeout(()=>{const H=document.querySelector('[data-testid="map-rail"]');if(H){const $=H.getBoundingClientRect();Qo($.left+$.width*.5,$.top+$.height*.3)}},60)},[me]),[Wt,os]=k.useState(null),[bb,dc]=k.useState(null);k.useEffect(()=>se.on("lesson:mastered",({nodeId:H})=>{r.some($=>$.id===H)&&os({completedId:H,next:mP(r,H)})}),[r]),k.useEffect(()=>se.on("lesson:reverted",()=>{vn()}),[vn]),k.useEffect(()=>{if(!Wt||Wt.next)return;const H=window.setTimeout(()=>os(null),1e4);return()=>window.clearTimeout(H)},[Wt]);const xb=k.useCallback(()=>{const H=Wt==null?void 0:Wt.next;H&&(ie("rail"),Oe(!0),me===3&&Be("rail"),dc(H.id),os(null),window.setTimeout(()=>{const $=document.querySelector(`[data-node-id="${CSS.escape(H.id)}"]`),oe=$==null?void 0:$.getBoundingClientRect();oe&&oe.width>0&&oe.top>=0&&oe.bottom<=window.innerHeight&&(Qo(oe.right+28,oe.top+oe.height/2),Rr())},60))},[Wt,me]);k.useEffect(()=>{if(!B||!h||r.length===0)return;const H=r.find($=>$.id===B);V(null),H&&Xr(H)},[B,r,h,Xr]),k.useEffect(()=>{h&&se.setSetting("last_session",JSON.stringify({courseId:h,nodeId:I})).catch(()=>{})},[h,I]);const yb=k.useCallback(H=>{z.current=H},[]),vb=k.useCallback(async()=>{const H=Y.pendingAction;L({open:!1,pendingAction:null});const $=z.current;if(z.current={active:!1,terminate:null},$.active&&$.terminate)try{await $.terminate()}catch{}H==null||H()},[Y.pendingAction]);xa(q,Y.open),k.useEffect(()=>{if(!Y.open)return;const H=$=>{$.key==="Escape"&&L({open:!1,pendingAction:null})};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[Y.open]);const Eb=async H=>{try{await se.setActiveSoul(H),_(H)}catch($){g($)}},kb=k.useCallback(async(H,$,oe)=>{try{await se.applyProposal(H),Ae.markProposalStatus($,oe,!0)}catch(ke){g(ke)}},[Ae,g]),Tb=k.useCallback(async(H,$,oe)=>{try{await se.rejectProposal(H),Ae.markProposalStatus($,oe,!1)}catch(ke){g(ke)}},[Ae,g]),za=t.find(H=>H.id===h),ls=k.useMemo(()=>{const H=new Set(r.map($=>$.id));return new Set([...P].filter($=>H.has($)))},[P,r]),us=ls.size,wb=k.useMemo(()=>r.filter(H=>H.type==="section").sort((H,$)=>H.orderIdx-$.orderIdx),[r]),Sb=k.useMemo(()=>{const H=lm.map(oe=>S.find(ke=>ke.name===oe)).filter(oe=>!!oe),$=S.filter(oe=>!lm.includes(oe.name));return[...H,...$]},[S]),Lt=BN(h),hc=HN(),it=Mu(),Ab=k.useCallback(async(H,$,oe)=>{try{const ke=await se.undoProposal(H);Ae.markProposalUndone($,oe),it.show(ke.conflicts.length>0?`${e("chat.proposal.undo_done")}(${e("chat.proposal.undo_conflict")})`:e("chat.proposal.undo_done"),{duration:4e3})}catch(ke){g(ke)}},[Ae,g,e,it]);k.useEffect(()=>se.on("exam:status",$=>{if($.status!=="ready"||$.nodeId===I)return;const oe=r.find(ke=>ke.id===$.nodeId);oe&&it.show(e("exam.ready.toast",{title:oe.title}),{duration:4e3})}),[I,r,it,e]);const fc=k.useRef(!1);k.useEffect(()=>{!h||fc.current||(fc.current=!0,se.getUpdateInfo().then(H=>{H!=null&&H.hasUpdate&&(it.show(e("update.available",{version:H.latest}),{severity:"info",duration:8e3,action:{label:e("update.download"),onClick:()=>window.open(H.releaseUrl)}}),se.setSetting("update_prompt_seen",H.latest).catch(()=>{}))}).catch(()=>{}))},[h,it,e]);const Cb=k.useCallback(async H=>{const $=t.find(oe=>oe.id===H);try{await se.deleteCourse(H),it.show(e("import.deleted",{title:($==null?void 0:$.title)??H}),{duration:3e3}),Et()}catch(oe){g(oe)}},[t,Et,g,it,e]),Va=k.useCallback(async(H,$,oe)=>{if(!H.trim()||Ae.streaming)return;if(!ye.activeId){const Qe=await ye.ensureThreadForSend(H,$);if(Qe){Ae.send(H,Qe,$,oe);return}it.show(e("toast.threadCreateFailed"));return}const ke=ye.activeThread;ke&&!ke.title&&ye.update(ke.id,{title:($??H).trim()}),Ae.send(H,void 0,$,oe)},[Ae,ye,it,e]),mc=k.useCallback(async H=>{if(!h)return;const $=r.find(ke=>ke.id===H);if(!$)return;me===3&&Be("chat");const oe=await ye.openOrCreateReview(H,e("review.thread.title",{title:$.title}));if(!oe){it.show(e("toast.threadCreateFailed"));return}I!==H&&(R(H),M("content")),Me!=null&&Me.ready&&!Ae.streamingThreadIds.includes(oe)&&Ae.send(e("review.kickoff.prompt",{title:$.title}),oe,e("review.kickoff.label",{title:$.title}))},[h,r,me,ye,e,it,Me,Ae,I]),pc=k.useRef(Ae.streaming);pc.current=Ae.streaming;const _b=k.useCallback(H=>{const $=YI(H,e),oe=WI(H,e),ke=Qe=>{var Yt;if(!pc.current){(Yt=lt.current)==null||Yt.call(lt,$,oe);return}Qe>0&&setTimeout(()=>ke(Qe-1),2e3)};ke(10)},[e]);lt.current=Va;const gc=new Set(["concept_map","diagram","compare_table","code_walkthrough"]),Qr=k.useMemo(()=>{const H=_h(Ae.messages).filter(oe=>{var ke;return gc.has(((ke=oe.output)==null?void 0:ke.artifactType)??"")});if(H.length)return H[H.length-1];const $=Lt.items.filter(oe=>gc.has(oe.artifactType)).map(oe=>{try{return{id:oe.id,toolName:oe.artifactType,output:JSON.parse(oe.data)}}catch{return null}}).filter(oe=>oe!==null);return $.length?$[$.length-1]:null},[Ae.messages,Lt.items]),bc=k.useRef(new Set);k.useEffect(()=>{!Qr||bc.current.has(Qr.id)||(bc.current.add(Qr.id),Ae.streaming&&M("board"))},[Qr,Ae.streaming]);const Nb=k.useMemo(()=>Ae.messages.reduce((H,$)=>H+$.parts.reduce((oe,ke)=>ke.type==="text"?oe+Pm(ke.text):oe,0),0),[Ae.messages]),xc=k.useRef(!1);k.useEffect(()=>{us>0&&!xc.current&&(xc.current=!0,it.show(e("review.nudge",{n:us}),{duration:4e3}))},[us,it,e]);const yc=k.useMemo(()=>_h(Ae.messages),[Ae.messages]),vc=k.useRef(new Set);k.useEffect(()=>{for(const H of yc){const $=H.output;if(!$||!$.artifactType)continue;const oe=`${$.artifactType}:${JSON.stringify($)}`;vc.current.has(oe)||(vc.current.add(oe),Lt.save({nodeId:I,artifactType:$.artifactType,title:$.title??null,data:$}),it.show(e("toast.artifactSaved"),{duration:3e3}))}},[yc,Lt,I,it,e]),k.useEffect(()=>{A!=="map"&&M(null)},[A]);const[Ib,cs]=k.useState(!1),Hn=((kc=ye.activeThread)==null?void 0:kc.kind)==="review",Rb=k.useMemo(()=>{if(!Hn)return null;for(const H of ls){if(H===I)continue;const $=r.find(oe=>oe.id===H);if($&&$.type==="lesson")return H}return null},[Hn,ls,I,r]),Mb=k.useMemo(()=>{let H=-1;return Ae.messages.forEach(($,oe)=>{$.role==="user"&&$.parts.some(ke=>ke.type==="text"&&ke.text.includes(wg))&&(H=oe)}),H},[Ae.messages]),Pb=Hn&&VN(Ae.messages)==="open",Ec=(ze==null?void 0:ze.type)==="exam";return k.useEffect(()=>{Ec&&window.dispatchEvent(new CustomEvent("companion-exam-enter"))},[Ec]),k.useEffect(()=>{mx(Hn)},[Hn]),p.jsxs("div",{className:"h-[var(--app-height,100vh)] flex flex-col bg-surface-1 text-neutral-900 dark:text-neutral-100 overflow-hidden",children:[p.jsx(wP,{streak:o,xp:u,fontSize:hc.size,onFontBump:hc.bump,onOpenSettings:()=>ae(!0),profileName:Fe,onOpenProfile:()=>ve(!0),leftVisible:he,rightVisible:Te,onToggleLeft:Gr,onToggleRight:ns,tier:me,bottomBar:me===3?p.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:wm,label:e("pane.map"),testid:"t3-btn-rail"},{k:"chat",icon:zx,label:e("pane.chat"),testid:"t3-btn-chat"},{k:"notebook",icon:Yx,label:e("pane.notes"),testid:"t3-btn-notebook"}].map(({k:H,icon:$,label:oe,testid:ke})=>p.jsx("button",{role:"tab","aria-selected":Ie===H,"aria-label":oe,"data-testid":ke,"data-tooltip":oe,onClick:()=>Be(H),className:`w-8 h-7 flex items-center justify-center rounded-md transition-colors ${Ie===H?"bg-brand/20 text-brand":"text-ink-muted active:bg-ink/10"}`,children:p.jsx($,{className:"w-4 h-4"})},H))}):void 0}),d&&p.jsx(CP,{message:d,onClose:()=>m(null)}),p.jsxs("div",{className:"flex-1 flex min-h-0 min-w-0",onTouchStart:rs,onTouchEnd:is,children:[he&&p.jsx(d2,{fullWidth:me===3,width:me===3?null:ht.rail,view:A,onViewChange:N,nextCueNodeId:bb,courseTitle:(za==null?void 0:za.title)??null,courseId:h,courses:t,sections:wb,tree:r,progressMap:i,selectedNodeId:I,dueCount:us,dueNodeIds:ls,overallMastery:(C==null?void 0:C.overallMastery)??0,streak:(o==null?void 0:o.currentStreak)??0,streaming:Ae.streamingThreadIds.length>0,streamingNodeIds:Ae.streamingNodeIds,onJumpNode:H=>{const $=r.find(oe=>oe.id===H);$&&Xr($),me===3&&Be("chat")},onOpenReview:()=>cs(!0),onSelectCourse:H=>fr(()=>{f(H),Et(),se.setSetting("boot_done","1").catch(()=>{})}),onDeleteCourse:H=>fr(()=>{Cb(H)}),onCoursesChanged:()=>{Et()},availableLanguages:b,currentLocale:w,onLocaleChange:async H=>{h&&(await se.setCourseLanguage(h,H),E(H))}}),Ln.rail&&Re&&p.jsx(qh,{side:"rail",ariaLabel:e("pane.resizeRailAria"),tooltip:e("pane.resizeTooltip"),target:()=>document.querySelector('[data-testid="map-rail"]'),clampLive:H=>Al(H,window.innerWidth,Wr),onCommit:H=>Yr("rail",H)}),p.jsxs(p.Fragment,{children:[Re&&p.jsx("div",{ref:$r,className:"relative flex flex-col h-full bg-surface-1 shrink-0 min-w-0 motion-safe:transition-[width] motion-safe:duration-200",style:me===3?{flex:1}:Te?{width:ht.mid!=null?`${ht.mid}px`:a5}:{flex:1},"data-testid":"chat-panel",children:h?(ze==null?void 0:ze.type)==="exam"?p.jsx(k.Suspense,{fallback:null,children:p.jsx(yP,{examNode:ze,locale:Pe,onSessionChange:yb,paused:Y.open,onExamCompleted:()=>{se.getProgress(ze.id).then(H=>{H&&a($=>({...$,[ze.id]:H}))})}})}):p.jsxs(p.Fragment,{children:[p.jsx(KI,{threads:ye.threads,activeThread:ye.activeThread,focusNodeTitle:(ze==null?void 0:ze.title)??null,streamingThreadIds:Ae.streamingThreadIds,onPickThread:H=>{ye.setActiveId(H)},onCreate:()=>{ye.create({title:null}),it.show(e("toast.threadCreated"))},onRename:(H,$)=>{ye.update(H,{title:$}),it.show(e("toast.threadRenamed"))},onArchive:H=>{ye.update(H,{status:"archived"}),it.show(e("toast.threadArchived"),{duration:5e3,action:{label:e("action.undo"),onClick:()=>ye.update(H,{status:"active"})}})},onDelete:H=>{const $=ye.removeWithUndo(H);$&&(it.show(`${e("toast.threadDeleted")}${$.title?`「${$.title}」`:""}`,{duration:5e3,action:{label:e("action.undo"),onClick:()=>{ye.restore($),it.show(e("toast.restored"))}}}),setTimeout(()=>{se.threadDelete($.id).catch(()=>{})},5500))}}),p.jsx(XN,{messages:Ae.messages,streaming:Ae.streaming,onApplyProposal:kb,onRejectProposal:Tb,onUndoProposal:Ab,summary:On,onStartLearning:Me!=null&&Me.ready?Kr:void 0,agentReady:(Me==null?void 0:Me.ready)??!1,onOpenModelManager:()=>ge("main"),hasNode:!!ze,selectedNodeId:I,threadId:ye.activeId,onPickQuizAction:H=>{Va(H)},onQuizCompleted:_b,cardMode:me===3,reviewNextNodeId:Rb,onStartReviewSession:H=>void mc(H),chatNotes:Lt.items.filter(H=>H.artifactType==="user_note"&&H.sourceAnchor),onSaveChatNote:(H,$,oe,ke)=>{!ze||!ye.activeId||(Lt.saveUserNote({nodeId:ze.id,text:H,sourceType:"chat",sourceAnchor:{type:"chat",threadId:ye.activeId,msgId:$,startOffset:oe,endOffset:ke}}),it.show(e("toast.noteSaved"),{duration:2e3}))}}),Hn&&Pb&&!Ae.streaming&&Ae.messages.length>0&&I&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(bP,{nodeId:I},Mb)}),p.jsx(TI,{nodeId:I,reviewMode:Hn,agentReady:(Me==null?void 0:Me.ready)??!1,streaming:Ae.streaming,souls:Sb,activeSoul:T,starterPrompts:Ae.messages.length>0?Ha:[],onPickSoul:Eb,onSend:Va,onStop:Ae.stop,onLogFriction:I?(H,$)=>{se.logFriction(I,H,$),it.show(e("chat.friction.saved"),{duration:2500})}:void 0,onOpenModelManager:()=>ge("main"),insertText:St,historyTokens:Nb})]}):p.jsx("div",{className:"flex-1 flex flex-col min-h-0","data-testid":"chat-no-course",children:p.jsx(MN,{onResume:(H,$)=>fr(()=>mb(H,$)),onOpenReview:H=>fr(()=>{!h&&H&&(f(H),Et(),se.setSetting("boot_done","1").catch(()=>{})),cs(!0)}),onOpenSettings:H=>{re(H??null),ae(!0)},onOpenModelManager:()=>ge("main"),onGotoNode:(H,$)=>fr(()=>pb(H,$)),onPickCourse:gb,onOpenProfile:()=>ve(!0),onProfileChanged:as})})}),Ln.mid&&Re&&p.jsx(qh,{side:"mid",ariaLabel:e("pane.resizeChatAria"),tooltip:e("pane.resizeTooltip"),target:()=>$r.current,clampLive:H=>Ig(H,window.innerWidth,ts),onCommit:H=>Yr("mid",H)}),Te&&p.jsx("main",{className:me===3?"flex-1 min-w-0 bg-surface-2":"flex-1 min-w-[440px] bg-surface-2","data-testid":me===3?"notebook-pane-full":void 0,children:h?p.jsx(fN,{selectedNode:ze,items:Lt.items,loading:Lt.loading,forceTab:K,canvasArtifact:Qr,onUserTabChange:()=>M(null),onRemove:H=>{Lt.remove(H),it.show(e("toast.noteDeleted"))},onTogglePin:H=>{Lt.togglePin(H)},onRecordQuizResult:(H,$)=>{Lt.recordQuizResult(H,$)},onUpdateNoteComment:(H,$)=>{Lt.updateUserNoteComment(H,$)},onSaveContentNote:(H,$)=>{ze&&(Lt.saveUserNote({nodeId:ze.id,text:H,sourceType:"content",sourceAnchor:$}),it.show(e("toast.noteSaved"),{duration:2e3}))},onJumpToSource:Nt,onQuoteToChat:Ge,locale:w}):p.jsx(DN,{})})]})]}),be&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(pP,{onClose:()=>ve(!1),onProfileSaved:as})}),ne&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(gP,{tab:te,onClose:()=>X(!1)})}),G&&p.jsx(SP,{onClose:()=>{ae(!1),re(null)},focusSection:Z,onOpenModelManager:ge}),Ib&&p.jsx(AP,{onClose:()=>cs(!1),tree:r,dashboard:C,progressMap:i,onPickNode:H=>{fr(()=>{cs(!1),mc(H)})}}),Y.open&&p.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50","data-testid":"exam-leave-modal",children:p.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:[p.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[p.jsx(su,{className:"w-5 h-5 text-warning shrink-0"}),p.jsx("span",{className:"text-title font-bold text-ink",children:e("exam.leave.title")})]}),p.jsx("div",{className:"text-body text-ink-muted mb-5 leading-relaxed",children:e("exam.leave.message")}),p.jsxs("div",{className:"flex justify-end gap-2",children:[p.jsx("button",{className:"btn-3d-neutral px-4 py-1.5 text-body",onClick:()=>L({open:!1,pendingAction:null}),"data-testid":"exam-leave-cancel",children:e("exam.leave.cancel")}),p.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 vb(),"data-testid":"exam-leave-confirm",children:e("exam.leave.confirm")})]})]})}),ss&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(vP,{onClose:()=>Dn(!1),onPick:H=>{Dn(!1),TP(H)},hasNode:!!I})}),Wt&&p.jsxs("div",{"data-testid":"next-lesson-card",className:"fixed bottom-24 left-1/2 -translate-x-1/2 z-40 surface-card px-4 py-3 flex items-center gap-3 shadow-elevated max-w-[92vw] toast-enter",role:"status",children:[p.jsx(ru,{className:"w-5 h-5 text-gold shrink-0","aria-hidden":"true"}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"text-body font-bold text-ink",children:e("lesson.next.title")}),Wt.next?p.jsxs("div",{className:"text-label text-ink-muted truncate",children:[e("lesson.next.guide")," · ",Wt.next.title]}):p.jsx("div",{className:"text-label text-ink-muted",children:e("lesson.next.terminal")})]}),Wt.next&&p.jsx("button",{className:"btn-3d-brand text-label px-3 py-1.5 shrink-0",onClick:xb,"data-testid":"next-lesson-go",children:e("lesson.next.button")}),p.jsx("button",{className:"text-ink-faint hover:text-ink shrink-0",onClick:()=>os(null),"aria-label":e("common.close"),"data-testid":"next-lesson-close",children:p.jsx(_n,{className:"w-4 h-4"})})]}),p.jsx(k2,{}),p.jsx(fP,{}),p.jsx(BI,{courseId:h}),we&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(EP,{})})]})}function TP(e){window.dispatchEvent(new CustomEvent("lookatstudy-command",{detail:e}))}function wP({streak:e,xp:t,fontSize:n,onFontBump:r,onOpenSettings:s,profileName:i,onOpenProfile:a,leftVisible:o,rightVisible:l,onToggleLeft:u,onToggleRight:c,tier:h,bottomBar:f}){const d=$e();return f?p.jsx("header",{className:"app-header shrink-0",children:p.jsxs("div",{className:"flex items-center h-12 px-4",children:[p.jsx("div",{className:"flex-1 flex items-center min-w-0",children:t&&p.jsxs("div",{className:"flex items-center gap-1 shrink-0","data-testid":"xp-bar",title:d("header.energy"),children:[p.jsx(Gs,{className:`w-3.5 h-3.5 text-brand ${t.todayXp>=100?"energy-breathe":""}`,fill:t.todayXp>=100?"currentColor":"none","aria-hidden":"true"}),p.jsx("span",{className:"text-label font-bold tabular-nums text-brand",children:t.todayXp})]})}),f,p.jsxs("div",{className:"flex-1 flex items-center justify-end",children:[p.jsx(um,{profileName:i,onOpenProfile:a}),p.jsx("button",{onClick:s,"data-testid":"header-settings","aria-label":d("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:d("header.settings"),children:p.jsx(Ws,{className:"w-4 h-4"})})]})]})}):p.jsx("header",{className:"app-header shrink-0 flex flex-col",children:p.jsxs("div",{className:"flex items-center pt-2.5 pb-3 px-6 justify-between",children:[p.jsx("div",{className:"flex items-center gap-2 min-w-0",children:p.jsxs("h1",{className:"text-body font-extrabold tracking-tight text-neutral-900 dark:text-neutral-100 select-none min-w-0 truncate",children:["Lookat",p.jsx("span",{className:"text-brand",children:"Study"})]})}),p.jsxs("div",{className:"flex items-center gap-3",children:[h!==3&&p.jsxs("div",{className:"flex items-center gap-0.5",children:[p.jsx("button",{onClick:u,"data-testid":"layout-toggle-left",className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${o?"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:d("header.toggleLeft"),children:p.jsx(qx,{className:"w-4 h-4"})}),p.jsx("button",{onClick:c,"data-testid":"layout-toggle-right",className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${l?"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:d("header.toggleRight"),children:p.jsx($x,{className:"w-4 h-4"})})]}),h!==3&&p.jsxs("div",{className:"flex items-center gap-0.5","data-testid":"font-size-control",children:[p.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:d("header.font.smaller"),children:"A-"}),p.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:d("header.font.larger"),children:"A+"})]}),t&&p.jsxs("div",{className:"flex items-center gap-1.5","data-testid":"xp-bar",title:d("header.energy"),children:[p.jsx(Gs,{className:`w-3.5 h-3.5 text-brand ${t.todayXp>=100?"energy-breathe":""}`,fill:t.todayXp>=100?"currentColor":"none","aria-hidden":"true"}),p.jsx("div",{className:"w-16 h-2 bg-neutral-200 dark:bg-neutral-800 rounded-full overflow-hidden",children:p.jsx("div",{className:"h-full rounded-full bg-brand transition-all duration-500",style:{width:`${Math.min(100,Math.max(3,t.todayXp))}%`}})}),p.jsx("span",{className:"text-label font-bold tabular-nums text-brand",children:t.todayXp})]}),t&&p.jsx("div",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-brand/10","data-testid":"level-badge",title:d("header.level.title"),children:p.jsxs("span",{className:"text-label font-bold text-brand",children:["Lv.",t.level]})}),e&&p.jsx(_P,{streak:e}),p.jsx(um,{profileName:i,onOpenProfile:a}),p.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:d("header.settings"),children:p.jsx(Ws,{className:"w-4 h-4"})})]})]})})}function um({profileName:e,onOpenProfile:t}){const n=$e(),r=FN(e);return p.jsx("button",{onClick:t,"data-testid":"header-profile","aria-label":n("profile.header.open"),"data-tooltip":n("profile.header.open"),className:"w-9 h-9 flex items-center justify-center rounded-full transition-transform hover:scale-105 shrink-0",style:r?{backgroundColor:r.bg,color:r.fg}:void 0,children:r?p.jsx("span",{className:"text-label font-bold leading-none",children:r.initial}):p.jsx(ly,{className:"w-4 h-4 text-ink-muted","aria-hidden":"true"})})}function SP({onClose:e,focusSection:t,onOpenModelManager:n}){const r=$e(),s=k.useRef(null);return xa(s,!0),k.useEffect(()=>{if(!t)return;const i=()=>document.getElementById(`settings-section-${t}`),a=[250,700].map(o=>window.setTimeout(()=>{var l;(l=i())==null||l.scrollIntoView({behavior:"smooth",block:"start"})},o));return()=>a.forEach(clearTimeout)},[t]),p.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end","data-testid":"settings-drawer",children:[p.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:e}),p.jsxs("div",{ref:s,role:"dialog","aria-modal":"true","aria-label":r("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:[p.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0",children:[p.jsx("h2",{className:"text-body font-bold",children:r("settings.title")}),p.jsx("button",{onClick:e,"data-testid":"settings-close","aria-label":r("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:"✕"})]}),p.jsx("div",{className:"flex-1 overflow-y-auto",children:p.jsx(k.Suspense,{fallback:null,children:p.jsx(xP,{onOpenModelManager:n})})})]})]})}function AP({onClose:e,tree:t,onPickNode:n,dashboard:r,progressMap:s}){const i=$e(),a=k.useRef(null);xa(a,!0);const[o,l]=k.useState([]);k.useEffect(()=>{se.getAllSrsItems().then(E=>l(E)).catch(()=>l([]))},[]);const u=k.useMemo(()=>new Map(o.map(E=>[E.nodeId,E])),[o]),c=k.useMemo(()=>{const E=new Map(t.map(v=>[v.id,v])),S=o.filter(v=>E.has(v.nodeId));return{overdue:S.filter(v=>v.overdue),short:S.filter(v=>!v.overdue&&v.intervalDays>0&&v.intervalDays<=7),long:S.filter(v=>!v.overdue&&v.intervalDays>7),inactive:S.filter(v=>v.repetitions===0&&!v.overdue)}},[o,t]),h=k.useMemo(()=>t.filter(S=>S.type==="section"&&(S.world??"study")==="study").sort((S,v)=>S.orderIdx-v.orderIdx).map(S=>({section:S,lessons:t.filter(v=>v.parentId===S.id&&v.type==="lesson").sort((v,T)=>v.orderIdx-T.orderIdx)})),[t]),f=k.useMemo(()=>{const E=new Map;for(const S of(r==null?void 0:r.sections)??[])E.set(S.sectionId,S.avgMastery);return E},[r]),d=k.useMemo(()=>t.filter(E=>{var v;const S=(v=s[E.id])==null?void 0:v.status;return E.type==="lesson"&&(E.world??"study")==="study"&&(S==="in_progress"||S==="mastered")}),[t,s]),[m,g]=k.useState(new Set),b=E=>g(S=>{const v=new Set(S);return v.has(E)?v.delete(E):v.add(E),v}),y=E=>{const S=u.get(E);return S?S.overdue?{color:"bg-review",title:i("review.quadrant.overdue")}:S.intervalDays>0&&S.intervalDays<=7?{color:"bg-gold",title:i("review.quadrant.short")}:S.intervalDays>7?{color:"bg-brand",title:i("review.quadrant.long")}:null:null},w=c.overdue.length>0;return p.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end","data-testid":"review-drawer",children:[p.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:e}),p.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:[p.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0",children:[p.jsxs("h2",{className:"text-body font-bold flex items-center gap-1.5",children:[p.jsx(Jt,{className:"w-4 h-4","aria-hidden":"true"})," ",i("review.title")]}),p.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:"✕"})]}),p.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-5","data-testid":"review-panel",children:[d.length>0&&p.jsxs("button",{onClick:()=>{const E=d[Math.floor(Math.random()*d.length)];E&&n(E.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:[p.jsx(ry,{className:"w-4 h-4"}),i("review.interleave")]}),o.length>0&&p.jsxs("div",{children:[p.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2",children:i("review.srsHint")}),p.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(E=>E.items.length>0).map(E=>p.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded-full bg-surface-3",children:[p.jsx("span",{className:`w-2 h-2 rounded-full ${E.dot}`}),p.jsx("span",{className:"text-label text-ink-muted",children:E.label}),p.jsx("span",{className:"text-label font-extrabold text-ink-strong tabular-nums",children:E.items.length})]},E.label))}),w&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"text-label text-ink-faint mb-1.5",children:i("review.overdueQuickHint")}),p.jsx("div",{className:"flex flex-wrap gap-1.5",children:c.overdue.slice(0,8).map(E=>{const S=t.find(v=>v.id===E.nodeId);return S?p.jsx("button",{onClick:()=>n(E.nodeId),"data-testid":`review-overdue-${E.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:S.title},E.nodeId):null})})]})]}),h.length>0&&p.jsxs("div",{children:[p.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2",children:i("review.myProgress")}),p.jsx("div",{className:"space-y-1",children:h.map(({section:E,lessons:S})=>{const v=Math.round((f.get(E.id)??0)*100),T=m.has(E.id),_=S.filter(A=>{var C;const N=(C=s[A.id])==null?void 0:C.status;return N==="in_progress"||N==="mastered"});return p.jsxs("div",{children:[p.jsxs("button",{onClick:()=>b(E.id),className:"w-full flex items-center gap-2 p-2 rounded-lg hover:bg-surface-3 transition-colors",children:[T?p.jsx(pa,{className:"w-3.5 h-3.5 text-ink-muted shrink-0"}):p.jsx(Cx,{className:"w-3.5 h-3.5 text-ink-muted shrink-0"}),p.jsx("span",{className:"text-body text-ink-strong font-bold truncate flex-1 text-left",children:E.title}),_.length>0&&p.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[p.jsx("div",{className:"w-16 h-1.5 bg-surface-3 rounded-full overflow-hidden",children:p.jsx("div",{className:`h-full rounded-full ${v>=100?"bg-gold":"bg-brand"}`,style:{width:`${Math.max(3,v)}%`}})}),p.jsxs("span",{className:"text-label tabular-nums text-ink-muted w-8 text-right",children:[v,"%"]})]})]}),T&&p.jsx("div",{className:"ml-5 mt-0.5 mb-1 space-y-0.5","data-testid":"review-lesson-list",children:S.length===0?p.jsx("div",{className:"text-label text-ink-faint py-1.5 pl-1",children:"—"}):S.map(A=>{const N=s[A.id],C=N?Math.round((N.mastery??0)*100):null,D=y(A.id),P=(N==null?void 0:N.status)==="in_progress"||(N==null?void 0:N.status)==="mastered";return p.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded-lg transition-colors ${(D==null?void 0:D.color)==="bg-review"?"bg-review/8":"hover:bg-surface-3"}`,children:[D?p.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${D.color} shrink-0`,title:D.title}):p.jsx("span",{className:"w-1.5 h-1.5 shrink-0"}),p.jsx("span",{className:`text-label truncate flex-1 ${P?"text-ink-strong":"text-ink-faint"}`,children:A.title}),C!==null&&p.jsxs("span",{className:"text-label tabular-nums text-ink-muted shrink-0 w-8 text-right",children:[C,"%"]}),P&&p.jsx("button",{onClick:()=>n(A.id),"data-testid":`review-lesson-${A.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")})]},A.id)})})]},E.id)})})]}),r&&r.frictionByNode.length>0&&p.jsxs("div",{children:[p.jsx("div",{className:"text-caption font-bold text-review uppercase tracking-wider mb-1.5",children:i("dashboard.mini.struggle")}),r.frictionByNode.map(E=>p.jsxs("button",{onClick:()=>n(E.nodeId),className:"flex items-center gap-2 py-0.5 w-full text-left hover:bg-surface-3 rounded px-1",children:[p.jsxs("span",{className:"text-label text-review font-bold tabular-nums",children:[E.count,"×"]}),p.jsx("span",{className:"text-label text-ink-strong truncate flex-1",children:E.title})]},E.nodeId))]}),d.length===0&&o.length===0&&h.length===0&&p.jsxs("div",{className:"text-center py-16","data-testid":"review-empty",children:[p.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),p.jsx("div",{className:"text-body text-ink-muted",children:i("review.empty.title")}),p.jsx("div",{className:"text-label text-ink-faint mt-1",children:i("review.empty.desc")})]})]})]})]})}function CP({message:e,onClose:t}){const n=$e();return p.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:[p.jsxs("span",{children:["⚠️ ",e]}),p.jsx("button",{className:"ml-3 underline text-warning-light",onClick:t,children:n("action.close")})]})}function _P({streak:e}){const t=$e();return p.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:[p.jsx(ga,{className:"w-4 h-4 text-review flame-flicker"}),p.jsx("span",{className:"text-body font-extrabold text-review",children:e.currentStreak}),e.freezeCount>0&&p.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:[p.jsx(ny,{className:"w-3 h-3 text-review/80","aria-hidden":"true"}),p.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 NP({rejected:e}){const t=navigator.language.startsWith("zh"),[n,r]=eu.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&&_e(async()=>{const{setWebToken:l}=await import("./api-web-C4rSxyIm.js");return{setWebToken:l}},[],import.meta.url).then(({setWebToken:l})=>l(o))};return p.jsx("div",{className:"min-h-[var(--app-height,100vh)] bg-[#0e2a12] flex items-center justify-center p-6",children:p.jsxs("form",{onSubmit:s,className:"w-full max-w-sm text-center",children:[p.jsx("div",{className:"text-4xl mb-3",children:"🎈"}),p.jsx("h1",{className:"text-title font-bold text-white mb-1",children:"LookatStudy"}),p.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&&p.jsx("p",{className:"text-label text-warning-light mb-3",children:t?"上次的令牌被拒绝了,请重新输入":"Previous token was rejected, please re-enter"}),p.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"}),p.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"}),p.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 fb=px.createRoot(document.getElementById("root"));function IP(){fb.render(p.jsx(eu.StrictMode,{children:p.jsx(eN,{children:p.jsx(kP,{})})}))}function cm(e){fb.render(p.jsx(eu.StrictMode,{children:p.jsx(NP,{rejected:e})}))}async function RP(){const{installAppHeight:e}=await _e(async()=>{const{installAppHeight:t}=await import("./app-height-D5bf5z0g.js");return{installAppHeight:t}},[],import.meta.url);if(e(),!window.api){const t=await _e(()=>import("./api-web-C4rSxyIm.js"),[],import.meta.url);if(window.addEventListener(t.TOKEN_REJECTED_EVENT,()=>cm(!0)),!t.hasWebToken()){cm(!1);return}try{await t.installWebApi()}catch(n){console.error("[boot] web api 安装失败:",n)}}IP()}RP();export{_m as $,tu as A,Jt as B,nu as C,Lm as D,su as E,Vi as F,xm as G,Xs as H,OP as I,BP as J,fh as K,Em as L,wm as M,hh as N,Xn as O,UP as P,KS as Q,GS as R,ry as S,ay as T,hy as U,Ca as V,Mm as W,_n as X,_p as Y,Qk as Z,_e as _,se as a,LP as a0,DP as a1,km as a2,sy as a3,jP as a4,Ix as a5,Kx as a6,C2 as a7,Rn as a8,ka as a9,Wm as aa,ep as ab,Md as ac,Dp as ad,$i as ae,dA as af,pm as b,fe as c,xa as d,ey as e,Ms as f,Tm as g,ru as h,ba as i,Mu as j,No as k,Ys as l,fm as m,Fm as n,Io as o,Nm as p,_x as q,xn as r,HP as s,Cm as t,$e as u,mr as v,FP as w,Ew as x,qe as y,Ne as z};
559
+ `),()=>{var N;(N=o.current)==null||N.removeAttribute("data-motion-pop-id"),A.contains(_)&&A.removeChild(_)}},[t]),p.jsx(ZR,{isPresent:t,childRef:o,sizeRef:l,pop:i,children:i===!1?e:k.cloneElement(e,{ref:h})})}const eM=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:s,presenceAffectsLayout:i,mode:a,anchorX:o,anchorY:l,root:u})=>{const c=Fu(tM),h=k.useId(),f=k.useRef(n),d=k.useRef(r);sa(()=>{f.current=n,d.current=r});let m=!0,g=k.useMemo(()=>(m=!1,{id:h,initial:t,isPresent:n,custom:s,onExitComplete:b=>{c.set(b,!0);for(const y of c.values())if(!y)return;r&&r()},register:b=>(c.set(b,!1),()=>{var y;c.delete(b),!f.current&&!c.size&&((y=d.current)==null||y.call(d))})}),[n,c,r]);return i&&m&&(g={...g}),k.useMemo(()=>{c.forEach((b,y)=>c.set(y,!1))},[n]),k.useEffect(()=>{!n&&!c.size&&r&&r()},[n]),e=p.jsx(JR,{pop:a==="popLayout",isPresent:n,anchorX:o,anchorY:l,root:u,children:e}),p.jsx(La.Provider,{value:g,children:e})};function tM(){return new Map}function tb(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 Ns=e=>e.key||"";function Gf(e){const t=[];return k.Children.forEach(e,n=>{k.isValidElement(n)&&t.push(n)}),t}const nM=({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,h]=tb(a),f=k.useMemo(()=>Gf(e),[e]),d=a&&!c?[]:f.map(Ns),m=k.useRef(!0),g=k.useRef(f),b=Fu(()=>new Map),y=k.useRef(new Set),[w,E]=k.useState(f),[S,v]=k.useState(f);sa(()=>{a&&!c&&!S.length&&(h==null||h())},[c,a,S.length,h]),sa(()=>{m.current=!1,g.current=f;for(let A=0;A<S.length;A++){const N=Ns(S[A]);d.includes(N)?(b.delete(N),y.current.delete(N)):b.get(N)!==!0&&b.set(N,!1)}},[S,d.length,d.join("-")]);const T=[];if(f!==w){let A=[...f],N=0;for(const C of S){const D=d.indexOf(Ns(C));D===-1?(A.splice(N++,0,C),T.push(C)):N=D+T.length+1}return i==="wait"&&T.length&&(A=T),v(Gf(A)),E(f),null}const{forceRender:_}=k.useContext(Ou);return p.jsx(p.Fragment,{children:S.map(A=>{const N=Ns(A),C=a&&!c?!1:f===S||d.includes(N),D=()=>{if(y.current.has(N))return;if(b.has(N))y.current.add(N),b.set(N,!0);else return;let P=!0;b.forEach(O=>{O||(P=!1)}),P&&(_==null||_(),v(g.current),a&&(h==null||h()),r&&r())};return p.jsx(eM,{isPresent:C,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:s,mode:i,root:u,onExitComplete:C?void 0:D,anchorX:o,anchorY:l,children:A},N)})})},nb=k.createContext({strict:!1}),Kf={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 Xf=!1;function rM(){if(Xf)return;const e={};for(const t in Kf)e[t]={isEnabled:n=>Kf[t].some(r=>!!n[r])};R1(e),Xf=!0}function rb(){return rM(),U4()}function iM(e){const t=rb();for(const n in e)t[n]={...t[n],...e[n]};R1(t)}const ja=k.createContext({});function sM(e,t){if(Ba(e)){const{initial:n,animate:r}=e;return{initial:n===!1||Ui(n)?n:void 0,animate:Ui(r)?r:void 0}}return e.inherit!==!1?t:{}}function aM(e){const{initial:t,animate:n}=sM(e,k.useContext(ja));return k.useMemo(()=>({initial:t,animate:n}),[Qf(t),Qf(n)])}function Qf(e){return Array.isArray(e)?e.join(" "):e}const uc=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ib(e,t,n){for(const r in t)!vt(t[r])&&!B1(r,n)&&(e[r]=t[r])}function oM({transformTemplate:e},t){return k.useMemo(()=>{const n=uc();return ac(n,t,e),Object.assign({},n.vars,n.style)},[t])}function lM(e,t){const n=e.style||{},r={};return ib(r,n,e),Object.assign(r,oM(e,t)),r}function uM(e,t){const n={},r=lM(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 sb=()=>({...uc(),attrs:{}});function cM(e,t,n,r){const s=k.useMemo(()=>{const i=sb();return H1(i,t,z1(r),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};ib(i,e.style,e),s.style={...i,...s.style}}return s}const dM=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 ma(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||dM.has(e)}function hM(e,t){return e.startsWith("on")?!ma(e):(t==null?void 0:t(e))??!ma(e)}function fM(e,t,n,r){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||vt(e[i])||(hM(i,r)||n===!0&&ma(i)||!t&&!ma(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}const mM=["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 cc(e){return typeof e!="string"||e.includes("-")?!1:!!(mM.indexOf(e)>-1||/[A-Z]/u.test(e))}function pM(e,t,n,{latestValues:r},s,i=!1,a,o){const u=(a??cc(e)?cM:uM)(t,r,s,e),c=fM(t,typeof e=="string",i,o),h=e!==k.Fragment?{...c,...u,ref:n}:{},{children:f}=t,d=k.useMemo(()=>vt(f)?f.get():f,[f]);return k.createElement(e,{...h,children:d})}function gM({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,s){return{latestValues:bM(n,r,s,e),renderState:t()}}function bM(e,t,n,r){const s={},i=r(e,{});for(const f in i)s[f]=qs(i[f]);let{initial:a,animate:o}=e;const l=Ba(e),u=N1(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 h=c?o:a;if(h&&typeof h!="boolean"&&!Fa(h)){const f=Array.isArray(h)?h:[h];for(let d=0;d<f.length;d++){const m=Zu(e,f[d]);if(m){const{transitionEnd:g,transition:b,...y}=m;for(const w in y){let E=y[w];if(Array.isArray(E)){const S=c?E.length-1:0;E=E[S]}E!==null&&(s[w]=E)}for(const w in g)s[w]=g[w]}}}return s}const ab=e=>(t,n)=>{const r=k.useContext(ja),s=k.useContext(La),i=()=>gM(e,t,r,s);return n?i():Fu(i)},xM=ab({scrapeMotionValuesFromProps:oc,createRenderState:uc}),yM=ab({scrapeMotionValuesFromProps:V1,createRenderState:sb}),vM=Symbol.for("motionComponentSymbol");function EM(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 ob=k.createContext({});function Er(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function kM(e,t,n,r,s,i){var E,S;const{visualElement:a}=k.useContext(ja),o=k.useContext(nb),l=k.useContext(La),u=k.useContext(lc),c=u.reducedMotion,h=u.skipAnimations,f=k.useRef(null),d=k.useRef(!1);r=r||o.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:a,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:c,skipAnimations:h,isSVG:i}),d.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));const m=f.current,g=k.useContext(ob);m&&!m.projection&&s&&(m.type==="html"||m.type==="svg")&&TM(f.current,n,s,g);const b=k.useRef(!1);k.useInsertionEffect(()=>{m&&b.current&&m.update(n,l)});const y=n[b1],w=k.useRef(!!y&&typeof window<"u"&&!((E=window.MotionHandoffIsComplete)!=null&&E.call(window,y))&&((S=window.MotionHasOptimisedAnimation)==null?void 0:S.call(window,y)));return sa(()=>{d.current=!0,m&&(b.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),w.current&&m.animationState&&m.animationState.animateChanges())}),k.useEffect(()=>{m&&(!w.current&&m.animationState&&m.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{var v;(v=window.MotionHandoffMarkAsComplete)==null||v.call(window,y)}),w.current=!1),m.enteringChildren=void 0)}),m}function TM(e,t,n,r){const{layoutId:s,layout:i,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:u,layoutAnchor:c,layoutCrossfade:h}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:lb(e.parent)),e.projection.setOptions({layoutId:s,layout:i,alwaysMeasureLayout:!!a||o&&Er(o),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:r,crossfade:h,layoutScroll:l,layoutRoot:u,layoutAnchor:c})}function lb(e){if(e)return e.options.allowProjection!==!1?e.projection:lb(e.parent)}function Wo(e,{forwardMotionProps:t=!1,type:n}={},r,s){r&&iM(r);const i=n?n==="svg":cc(e),a=i?yM:xM;function o(u,c){let h;const f={...k.useContext(lc),...u,layoutId:wM(u)},{isStatic:d,isValidProp:m}=f,g=aM(u),b=a(u,d);if(!d&&typeof window<"u"){SM();const y=AM(f);h=y.MeasureLayout,g.visualElement=kM(e,b,f,s,y.ProjectionNode,i)}return p.jsxs(ja.Provider,{value:g,children:[h&&g.visualElement?p.jsx(h,{visualElement:g.visualElement,...f}):null,pM(e,u,EM(b,g.visualElement,c),b,d,t,i,m)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const l=k.forwardRef(o);return l[vM]=e,l}function wM({layoutId:e}){const t=k.useContext(Ou).id;return t&&e!==void 0?t+"-"+e:e}function SM(e,t){k.useContext(nb).strict}function AM(e){const t=rb(),{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 CM(e,t){if(typeof Proxy>"u")return Wo;const n=new Map,r=(i,a)=>Wo(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,Wo(a,void 0,e,t)),n.get(a))})}const _M=(e,t)=>t.isSVG??cc(e)?new rR(t):new Z4(t,{allowProjection:e!==k.Fragment});class NM extends Pn{constructor(t){super(t),t.animationState||(t.animationState=lR(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Fa(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 IM=0;class RM extends Pn{constructor(){super(...arguments),this.id=IM++,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=ar(this.node,a,o);if(l){const{transition:u,transitionEnd:c,...h}=l;for(const f in h)(i=this.node.getValue(f))==null||i.jump(h[f])}}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 MM={animation:{Feature:NM},exit:{Feature:RM}};function es(e){return{point:{x:e.pageX,y:e.pageY}}}const PM=e=>t=>nc(t)&&e(t,es(t));function Ii(e,t,n,r){return zi(e,t,PM(n),r)}const ub=({current:e})=>e?e.ownerDocument.defaultView:null,Zf=(e,t)=>Math.abs(e-t);function LM(e,t){const n=Zf(e.x,t.x),r=Zf(e.y,t.y);return Math.sqrt(n**2+r**2)}const Jf=new Set(["auto","scroll"]);class cb{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=Is(this.lastRawMoveEventInfo,this.transformPagePoint));const m=Yo(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,b=LM(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!b)return;const{point:y}=m,{timestamp:w}=yt;this.history.push({...y,timestamp:w});const{onStart:E,onMove:S}=this.handlers;g||(E&&E(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,m)},this.handlePointerMove=(m,g)=>{this.lastMoveEvent=m,this.lastRawMoveEventInfo=g,this.lastMoveEventInfo=Is(g,this.transformPagePoint),tt.update(this.updatePoint,!0)},this.handlePointerUp=(m,g)=>{this.end();const{onEnd:b,onSessionEnd:y,resumeAnimation:w}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const E=Yo(m.type==="pointercancel"?this.lastMoveEventInfo:Is(g,this.transformPagePoint),this.history);this.startEvent&&b&&b(m,E),y&&y(m,E)},!nc(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=a,this.contextWindow=s||window;const l=es(t),u=Is(l,this.transformPagePoint),{point:c}=u,{timestamp:h}=yt;this.history=[{...c,timestamp:h}];const{onSessionStart:f}=n;f&&f(t,Yo(u,this.history));const d={passive:!0,capture:!0};this.removeListeners=Qi(Ii(this.contextWindow,"pointermove",this.handlePointerMove,d),Ii(this.contextWindow,"pointerup",this.handlePointerUp,d),Ii(this.contextWindow,"pointercancel",this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(t){let n=t.parentElement;for(;n;){const r=getComputedStyle(n);(Jf.has(r.overflowX)||Jf.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),tt.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 Is(e,t){return t?{point:t(e.point)}:e}function em(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Yo({point:e},t){return{point:e,delta:em(e,db(t)),offset:em(e,DM(t)),velocity:OM(t,.1)}}function DM(e){return e[0]}function db(e){return e[e.length-1]}function OM(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const s=db(e);for(;n>=0&&(r=e[n],!(s.timestamp-r.timestamp>$t(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&s.timestamp-r.timestamp>$t(t)*2&&(r=e[1]);const i=Vt(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 FM(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?et(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?et(n,e,r.max):Math.min(e,n)),e}function tm(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 BM(e,{top:t,left:n,bottom:r,right:s}){return{x:tm(e.x,n,s),y:tm(e.y,t,r)}}function nm(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 jM(e,t){return{x:nm(e.x,t.x),y:nm(e.y,t.y)}}function HM(e,t){let n=.5;const r=_t(e),s=_t(t);return s>r?n=ji(t.min,t.max-r,e.min):r>s&&(n=ji(e.min,e.max-s,t.min)),cn(0,1,n)}function UM(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 Xl=.35;function zM(e=Xl){return e===!1?e=0:e===!0&&(e=Xl),{x:rm(e,"left","right"),y:rm(e,"top","bottom")}}function rm(e,t,n){return{min:im(e,t),max:im(e,n)}}function im(e,t){return typeof e=="number"?e:e[t]||0}const VM=new WeakMap;class qM{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=gt(),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=h=>{n&&this.snapToCursor(es(h).point),this.stopAnimation()},a=(h,f)=>{const{drag:d,dragPropagation:m,onDragStart:g}=this.getProps();if(d&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=b4(d),!this.openDragLock))return;this.latestPointerEvent=h,this.latestPanInfo=f,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 w=this.getAxisMotionValue(y).get()||0;if(un.test(w)){const{projection:E}=this.visualElement;if(E&&E.layout){const S=E.layout.layoutBox[y];S&&(w=_t(S)*(parseFloat(w)/100))}}this.originPoint[y]=w}),g&&tt.update(()=>g(h,f),!1,!0),Hl(this.visualElement,"transform");const{animationState:b}=this.visualElement;b&&b.setActive("whileDrag",!0)},o=(h,f)=>{this.latestPointerEvent=h,this.latestPanInfo=f;const{dragPropagation:d,dragDirectionLock:m,onDirectionLock:g,onDrag:b}=this.getProps();if(!d&&!this.openDragLock)return;const{offset:y}=f;if(m&&this.currentDirection===null){this.currentDirection=WM(y),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),b&&tt.update(()=>b(h,f),!1,!0)},l=(h,f)=>{this.latestPointerEvent=h,this.latestPanInfo=f,this.stop(h,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:h}=this.getProps();(h||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:c}=this.getProps();this.panSession=new cb(t,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:r,contextWindow:ub(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&&tt.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||!Rs(t,s,this.currentDirection))return;const i=this.getAxisMotionValue(t);let a=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(a=FM(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&&Er(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=BM(r.layoutBox,t):this.constraints=!1,this.elastic=zM(n),s!==this.constraints&&!Er(t)&&r&&this.constraints&&!this.hasMutatedConstraints&&rn(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=UM(r.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Er(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=W4(r,s.root,this.visualElement.getTransformPagePoint());let a=jM(s.layout.layoutBox,i);if(n){const o=n(V4(a));this.hasMutatedConstraints=!!o,o&&(a=P1(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(!Rs(c,n,this.currentDirection))return;let h=l&&l[c]||{};(a===!0||a===c)&&(h={min:0,max:0});const f=s?200:1e6,d=s?40:1e7,m={type:"inertia",velocity:r?t[c]:0,bounceStiffness:f,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...i,...h};return this.startAxisValueAnimation(c,m)});return Promise.all(u).then(o)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return Hl(this.visualElement,t),r.start(Qu(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(!Rs(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]-et(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!Er(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]=HM({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(!Rs(a,t,null))return;const o=this.getAxisMotionValue(a),{min:l,max:u}=this.constraints[a];o.set(et(l,u,s[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;VM.set(this.visualElement,this);const t=this.visualElement.current,n=Ii(t,"pointerdown",u=>{const{drag:c,dragListener:h=!0}=this.getProps(),f=u.target,d=f!==t&&T4(f);c&&h&&!d&&this.start(u)});let r;const s=()=>{const{dragConstraints:u}=this.getProps();Er(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),r||(r=$M(t,u.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,a=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),tt.read(s);const o=zi(window,"resize",()=>this.scalePositionWithinConstraints()),l=i.addEventListener("didUpdate",(({delta:u,hasLayoutChanged:c})=>{this.isDragging&&c&&(rn(h=>{const f=this.getAxisMotionValue(h);f&&(this.originPoint[h]+=u[h].translate,f.set(f.get()+u[h].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=Xl,dragMomentum:o=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:s,dragConstraints:i,dragElastic:a,dragMomentum:o}}}function sm(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function $M(e,t,n){const r=hf(e,sm(n)),s=hf(t,sm(n));return()=>{r(),s()}}function Rs(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function WM(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class YM extends Pn{constructor(t){super(t),this.removeGroupControls=qt,this.removeListeners=qt,this.controls=new qM(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||qt}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 Go=e=>(t,n)=>{e&&tt.update(()=>e(t,n),!1,!0)};class GM extends Pn{constructor(){super(...arguments),this.removePointerDownListener=qt}onPointerDown(t){this.session=new cb(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ub(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:s}=this.node.getProps();return{onSessionStart:Go(t),onStart:Go(n),onMove:Go(r),onEnd:(i,a)=>{delete this.session,s&&tt.postRender(()=>s(i,a))}}}mount(){this.removePointerDownListener=Ii(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 KM 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()})),$s.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()||tt.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(),tc.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 hb(e){const[t,n]=tb(),r=k.useContext(Ou);return p.jsx(KM,{...e,layoutGroup:r,switchLayoutGroup:k.useContext(ob),isPresent:t,safeToRemove:n})}const XM={pan:{Feature:GM},drag:{Feature:YM,ProjectionNode:eb,MeasureLayout:hb}};function am(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&&tt.postRender(()=>i(t,es(t)))}class QM extends Pn{mount(){const{current:t}=this.node;t&&(this.unmount=y4(t,(n,r)=>(am(this.node,r,"Start"),s=>am(this.node,s,"End"))))}unmount(){}}class ZM extends Pn{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=Qi(zi(this.node.current,"focus",()=>this.onFocus()),zi(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function om(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&&tt.postRender(()=>i(t,es(t)))}class JM extends Pn{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:r}=this.node.props;this.unmount=S4(t,(s,i)=>(om(this.node,i,"Start"),(a,{success:o})=>om(this.node,a,o?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(r==null?void 0:r.tap)===!1})}unmount(){}}const Ql=new WeakMap,Xo=new WeakMap,eP=e=>{const t=Ql.get(e.target);t&&t(e)},tP=e=>{e.forEach(eP)};function nP({root:e,...t}){const n=e||document;Xo.has(n)||Xo.set(n,{});const r=Xo.get(n),s=JSON.stringify(t);return r[s]||(r[s]=new IntersectionObserver(tP,{root:e,...t})),r[s]}function rP(e,t,n){const r=nP(t);return Ql.set(e,n),r.observe(e),()=>{Ql.delete(e),r.unobserve(e)}}const iP={some:0,all:1};class sP extends Pn{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:iP[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:h,onViewportLeave:f}=this.node.getProps(),d=c?h:f;d&&d(u)};this.stopObserver=rP(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(aP(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function aP({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const oP={inView:{Feature:sP},tap:{Feature:JM},focus:{Feature:ZM},hover:{Feature:QM}},lP={layout:{ProjectionNode:eb,MeasureLayout:hb}},uP={...MM,...oP,...XM,...lP},cP=CM(uP,_M),dP=cP;function hP(e){switch(e){case"correct":return{Icon:nu,color:"var(--brand)"};case"wrong":return{Icon:pm,color:"var(--warning)"};case"mastery":case"level-up":return{Icon:ru,color:"var(--gold)"};case"unlock":return{Icon:Ys,color:"var(--brand)"};case"streak":return{Icon:ga,color:"var(--review)"};case"energy-full":return{Icon:Gs,color:"var(--brand)"};case"exam-pass":return{Icon:Tx,color:"var(--exam)"};case"lesson-complete":return{Icon:Im,color:"var(--gold)"};default:return{Icon:Ys,color:"var(--brand)"}}}function fP(){const e=Jl(),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 f=Math.min(window.devicePixelRatio||1,2);a.width=window.innerWidth*f,a.height=window.innerHeight*f,a.style.width=window.innerWidth+"px",a.style.height=window.innerHeight+"px",o.setTransform(f,0,0,f,0,0)};l(),window.addEventListener("resize",l);const u=()=>{o.clearRect(0,0,window.innerWidth,window.innerHeight);const f=n.current;for(let d=f.length-1;d>=0;d--){const m=f[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){f.splice(d,1);continue}const g=Math.min(1,m.life/m.maxLife);o.save(),o.globalAlpha=g,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=f.length>0?requestAnimationFrame(u):0},h=Jo(f=>{var y,w;const d=hx(f.kind),m=Math.round(d.particles*(f.intensity??1)),g=((y=f.origin)==null?void 0:y.x)??window.innerWidth/2,b=((w=f.origin)==null?void 0:w.y)??window.innerHeight/2;for(let E=0;E<m;E++){const S=Math.PI*2*E/m+Math.random()*.3,v=3+Math.random()*6,T=d.durationMs/16*(.7+Math.random()*.5);n.current.push({x:g,y:b,vx:Math.cos(S)*v,vy:Math.sin(S)*v-2,life:T,maxLife:T,color:d.colors[E%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()=>{h(),window.removeEventListener("resize",l),r.current&&cancelAnimationFrame(r.current),r.current=0,n.current=[]}},[e]),k.useEffect(()=>{if(!e)return;let a=0;return Jo(l=>{const u=++a;i({kind:l.kind,id:u}),setTimeout(()=>{u===a&&i(null)},600)})},[e]),e?p.jsx(nM,{children:s&&(()=>{const{Icon:a,color:o}=hP(s.kind);return p.jsx(dP.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:p.jsx(a,{className:"w-24 h-24",color:o,strokeWidth:1.5})},s.id)})()}):p.jsx("canvas",{ref:t,className:"fixed inset-0 pointer-events-none z-[60]","aria-hidden":"true"})}function mP(e,t){const n=e.find(o=>o.id===t&&o.type!=="section");if(!n)return null;const r=e.filter(o=>o.type==="section").sort((o,l)=>o.orderIdx-l.orderIdx),s=o=>e.filter(l=>l.type!=="section"&&l.parentId===o).sort((l,u)=>l.orderIdx-u.orderIdx),i=s(n.parentId).find(o=>o.orderIdx>n.orderIdx);if(i)return i;const a=r.findIndex(o=>o.id===n.parentId);for(let o=a+1;o<r.length;o++){const l=s(r[o].id)[0];if(l)return l}return null}const pP=k.lazy(()=>_e(()=>import("./PersonalProfileModal-CywAVDIt.js"),__vite__mapDeps([33,1,2]),import.meta.url)),gP=k.lazy(()=>_e(()=>import("./ModelManagerModal-B7H5t5QP.js"),__vite__mapDeps([34,1,2,35]),import.meta.url)),bP=k.lazy(()=>_e(()=>import("./ReviewPanel-BZY64BTO.js"),__vite__mapDeps([36,1,2]),import.meta.url).then(e=>({default:e.SelfRatingCard}))),xP=k.lazy(()=>_e(()=>import("./SettingsView-dG7fUQi5.js"),__vite__mapDeps([37,1,2,35]),import.meta.url).then(e=>({default:e.SettingsView}))),yP=k.lazy(()=>_e(()=>import("./ExamView-Bh2gu61P.js"),__vite__mapDeps([38,1,2,31]),import.meta.url).then(e=>({default:e.ExamView}))),vP=k.lazy(()=>_e(()=>import("./CommandPalette-BjIg1GAx.js"),__vite__mapDeps([39,1,2]),import.meta.url).then(e=>({default:e.CommandPalette}))),EP=k.lazy(()=>_e(()=>import("./CompanionBotLab-Bp2oeINT.js"),__vite__mapDeps([40,1,2]),import.meta.url).then(e=>({default:e.CompanionBotLab}))),lm=["direct","guide","practice"];function kP(){var kc;const e=$e(),[t,n]=k.useState([]),[r,s]=k.useState([]),[i,a]=k.useState({}),[o,l]=k.useState(null),[u,c]=k.useState(null),[h,f]=k.useState(null),[d,m]=k.useState(null),g=k.useCallback(H=>{m(H instanceof Error?H.message:String(H)),console.error(H)},[]),[b,y]=k.useState([]),[w,E]=k.useState(null),[S,v]=k.useState([]),[T,_]=k.useState(null),[A,N]=k.useState("map"),[C,D]=k.useState(null),[P,O]=k.useState(new Set),[I,R]=k.useState(null),[B,V]=k.useState(null),z=k.useRef({active:!1,terminate:null}),[Y,L]=k.useState({open:!1,pendingAction:null}),q=k.useRef(null),[K,M]=k.useState(null),[G,ae]=k.useState(!1),[ne,X]=k.useState(!1),[te,ue]=k.useState("main"),ge=k.useCallback((H="main")=>{ue(H),X(!0)},[]),[Z,re]=k.useState(null),[be,ve]=k.useState(!1),[Fe,je]=k.useState(null),[Se,Oe]=k.useState(!0),[st,pt]=k.useState(!0),me=i5(),[rt,ie]=k.useState("notebook"),[Ie,Be]=k.useState("chat"),Q=k.useRef(Ie);Q.current=Ie;const ee=k.useRef(me);k.useEffect(()=>{ee.current!==me&&(me===1?(Oe(!0),pt(!0)):me===2&&ee.current===3&&ie(JI(Q.current)),ee.current=me)},[me]);const he=me===3?Ie==="rail":me===2?rt==="rail":Se,Te=me===3?Ie==="notebook":me===2?rt==="notebook":st,Re=me!==3||Ie==="chat",[Ze,dt]=k.useState(null),[xe,De]=k.useState(null);k.useEffect(()=>{let H=!0;return(async()=>{const[$,oe]=await Promise.all([se.getSetting("pane_width_left"),se.getSetting("pane_width_mid")]);H&&(dt(Vh($,Sl,Ag)),De(Vh(oe,Bi,_g)))})(),()=>{H=!1}},[]);const Ve=me===3?"t3":me===2?he?"t2-rail":"t2-notebook":"t1",We=u5(Ze!=null||xe!=null)||window.innerWidth,ht=l5(Ze,xe,We,Ve),Ln=o5(me,he,Te),$r=k.useRef(null),Wr=Ve==="t2-rail"?Bi:Ai+(ht.mid??Ng(We)),ts=Ai+(Ve==="t2-notebook"?0:ht.rail??Cg),Yr=(H,$)=>{H==="rail"?(dt($),se.setSetting("pane_width_left",$!=null?String($):"")):(De($),se.setSetting("pane_width_mid",$!=null?String($):""))},Gr=()=>{me===1?Oe(H=>!H):me===2?ie(H=>H==="rail"?"notebook":"rail"):Be(H=>H==="rail"?"chat":"rail")},ns=()=>{me===1?pt(H=>!H):me===2?ie(H=>H==="notebook"?"rail":"notebook"):Be(H=>H==="notebook"?"chat":"notebook")},hr=k.useRef(null),rs=H=>{var oe,ke;if(me!==3)return;const $=H.touches[0];hr.current={x:$.clientX,y:$.clientY,multi:H.touches.length>1,noswipe:!!((ke=(oe=H.target).closest)!=null&&ke.call(oe,"[data-noswipe]"))}},is=H=>{const $=hr.current;if(hr.current=null,!$||$.multi||$.noswipe||me!==3)return;const oe=H.changedTouches[0],ke=e5(Q.current,oe.clientX-$.x,oe.clientY-$.y);ke&&Be(ke)},[ss,Dn]=k.useState(!1),[we,Ye]=k.useState(()=>location.hash==="#companion-bot-lab");k.useEffect(()=>{const H=()=>Ye(location.hash==="#companion-bot-lab");return window.addEventListener("hashchange",H),()=>window.removeEventListener("hashchange",H)},[]);const[Me,at]=k.useState(null),[Ke,Ce]=k.useState([]),ye=GI(h,I),Pe=ba(),Ae=$I(ye.activeId,Pe);k.useEffect(()=>{fx(Ae.streaming)},[Ae.streaming]);const[St,Xe]=k.useState(""),Ge=k.useCallback(H=>{Xe(H)},[]),Nt=k.useCallback((H,$,oe)=>{if(H.type==="content"){if(M("content"),oe){const ke=Qe=>{uh(oe)?window.dispatchEvent(new CustomEvent("lookatstudy-jump-to-note",{detail:oe})):Qe>0&&setTimeout(()=>ke(Qe-1),150)};setTimeout(()=>ke(10),100)}}else if(H.threadId!==ye.activeId&&ye.setActiveId(H.threadId),oe){const ke=Qe=>{uh(oe)?window.dispatchEvent(new CustomEvent("lookatstudy-jump-to-chat-note",{detail:oe})):Qe>0&&setTimeout(()=>ke(Qe-1),150)};setTimeout(()=>ke(10),120)}},[ye]),[On,tn]=k.useState(null);k.useEffect(()=>{if(!I){tn(null);return}let H=!1;return se.getNodeSummary(I,Pe).then($=>{H||tn($)}).catch(()=>{H||tn(null)}),()=>{H=!0}},[I,Pe]);const ze=k.useMemo(()=>r.find(H=>H.id===I)??null,[r,I]),Ha=k.useMemo(()=>Ke.map(H=>({...H,label:e(`starter.${H.key}.label`),hint:e(`starter.${H.key}.hint`),message:e(`starter.${H.key}.message`,{title:(ze==null?void 0:ze.title)??""})})),[Ke,ze,e]),lt=k.useRef(null),Kr=k.useCallback(()=>{var H;ze&&((H=lt.current)==null||H.call(lt,e("chat.action.startLearningPrompt",{title:ze.title}),e("chat.action.startLearning",{title:ze.title})))},[ze,e]),Et=k.useCallback(async()=>{try{const[H,$,oe,ke,Qe,Yt]=await Promise.all([se.listCourses(),se.getStreak(),se.listSouls(),se.getActiveSoul(),se.getXpStatus(),se.getDueReviews()]);n(H),l($),v(oe),c(Qe),_(ke),O(new Set(Yt)),h&&!H.some(Lb=>Lb.id===h)&&(f(null),R(null),s([]),a({}),D(null),y([]),E(null))}catch(H){m(H instanceof Error?H.message:String(H))}},[h]);k.useEffect(()=>{Et()},[Et]);const Fn=k.useCallback(async()=>{try{O(new Set(await se.getDueReviews()))}catch{}},[]),Bn=k.useCallback(async()=>{try{at(await se.isAgentReady())}catch{at({ready:!1,missing:e("error.checkReadyFailed")})}},[e]);k.useEffect(()=>{Bn();const H=()=>Bn();return window.addEventListener("llm-config-changed",H),()=>window.removeEventListener("llm-config-changed",H)},[Bn]);const It=k.useRef(0),jn=k.useRef(0);k.useEffect(()=>{It.current=(u==null?void 0:u.todayXp)??0},[u]),k.useEffect(()=>{jn.current=(o==null?void 0:o.currentStreak)??0},[o]);const vn=k.useCallback(async()=>{const H=r.filter(ke=>ke.type==="lesson"||ke.type==="exam"),$=await Promise.all(H.map(async ke=>{const Qe=await se.getProgress(ke.id);return[ke.id,Qe]})),oe={};for(const[ke,Qe]of $)Qe&&(oe[ke]=Qe);a(oe)},[r]);k.useEffect(()=>se.on("state:changed",$=>{$==="xp"?(se.getXpStatus().then(oe=>{c(oe),It.current<100&&oe.todayXp>=100&&Ar("energy-full")}).catch(()=>{}),Fn()):$==="streak"?(se.getStreak().then(oe=>{l(oe),oe.currentStreak>jn.current&&Ar("streak")}).catch(()=>{}),Fn()):$==="mastery"&&(Ar("mastery"),Et(),vn())}),[Et,Fn,vn]),k.useEffect(()=>{h&&(se.getCourseLanguages(h).then(y).catch(()=>y([])),se.getCourseLanguage(h).then(E).catch(()=>E(null)))},[h]),k.useEffect(()=>{h&&(se.getCourseTree(h,w??void 0).then(async H=>{s(H);const $=H.filter(Qe=>Qe.type==="lesson"||Qe.type==="exam"),oe=await Promise.all($.map(async Qe=>{const Yt=await se.getProgress(Qe.id);return[Qe.id,Yt]})),ke={};for(const[Qe,Yt]of oe)Yt&&(ke[Qe]=Yt);a(ke)}).catch(g),se.getDashboard(h).then(D).catch(g))},[h,w,g]),k.useEffect(()=>{if(!I){Ce([]);return}se.getStarterPrompts(I).then(Ce).catch(()=>Ce([]))},[I]),k.useEffect(()=>{const H=$=>{if($.key==="Escape"&&ye.activeId&&(se.abortAgentChatThread(ye.activeId).catch(()=>{}),ae(!1),Dn(!1)),($.ctrlKey||$.metaKey)&&$.key==="k"&&($.preventDefault(),Dn(oe=>!oe)),($.ctrlKey||$.metaKey)&&$.key==="b"&&($.preventDefault(),Gr()),($.ctrlKey||$.metaKey)&&$.key==="Tab"){if($.preventDefault(),z.current.active)return;const oe=ye.threads;if(oe.length>1){const ke=oe.findIndex(Yt=>Yt.id===ye.activeId),Qe=$.shiftKey?(ke-1+oe.length)%oe.length:(ke+1)%oe.length;ye.setActiveId(oe[Qe].id)}}(!($.target instanceof Element)||!$.target.matches("input, textarea, select"))&&($.key==="1"&&N("map"),$.key==="2"&&N("import"),$.key==="s"&&($.ctrlKey||$.metaKey)&&($.preventDefault(),ae(!0)))};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[I]);const Ua=k.useCallback(async H=>{var $;try{if(H.type==="exam"){R(H.id),M("content");return}if((($=i[H.id])==null?void 0:$.status)==="locked"){R(null);return}await se.markNodeAttempted(H.id);const oe=await se.getStreak();await vn(),l(oe),R(H.id),M("content")}catch(oe){g(oe)}},[i,vn,g]),fr=k.useCallback(H=>{if(z.current.active){L({open:!0,pendingAction:H});return}H()},[]),Xr=k.useCallback(H=>{if(dc(null),z.current.active&&H.id!==I){L({open:!0,pendingAction:()=>void Ua(H)});return}Ua(H)},[Ua,I]),as=k.useCallback(()=>{se.profileGet().then(H=>je((H==null?void 0:H.name)??null)).catch(()=>{})},[]);k.useEffect(()=>{as()},[as]);const mb=k.useCallback((H,$)=>{f(H),V($),Et()},[Et]),pb=k.useCallback((H,$)=>{const oe=r.find(ke=>ke.id===H);if(oe){Xr(oe);return}},[r,Xr]),gb=k.useCallback(()=>{ie("rail"),Oe(!0),me===3&&Be("rail"),window.setTimeout(()=>{const H=document.querySelector('[data-testid="map-rail"]');if(H){const $=H.getBoundingClientRect();Qo($.left+$.width*.5,$.top+$.height*.3)}},60)},[me]),[Wt,os]=k.useState(null),[bb,dc]=k.useState(null);k.useEffect(()=>se.on("lesson:mastered",({nodeId:H})=>{r.some($=>$.id===H)&&os({completedId:H,next:mP(r,H)})}),[r]),k.useEffect(()=>se.on("lesson:reverted",()=>{vn()}),[vn]),k.useEffect(()=>{if(!Wt||Wt.next)return;const H=window.setTimeout(()=>os(null),1e4);return()=>window.clearTimeout(H)},[Wt]);const xb=k.useCallback(()=>{const H=Wt==null?void 0:Wt.next;H&&(ie("rail"),Oe(!0),me===3&&Be("rail"),dc(H.id),os(null),window.setTimeout(()=>{const $=document.querySelector(`[data-node-id="${CSS.escape(H.id)}"]`),oe=$==null?void 0:$.getBoundingClientRect();oe&&oe.width>0&&oe.top>=0&&oe.bottom<=window.innerHeight&&(Qo(oe.right+28,oe.top+oe.height/2),Rr())},60))},[Wt,me]);k.useEffect(()=>{if(!B||!h||r.length===0)return;const H=r.find($=>$.id===B);V(null),H&&Xr(H)},[B,r,h,Xr]),k.useEffect(()=>{h&&se.setSetting("last_session",JSON.stringify({courseId:h,nodeId:I})).catch(()=>{})},[h,I]);const yb=k.useCallback(H=>{z.current=H},[]),vb=k.useCallback(async()=>{const H=Y.pendingAction;L({open:!1,pendingAction:null});const $=z.current;if(z.current={active:!1,terminate:null},$.active&&$.terminate)try{await $.terminate()}catch{}H==null||H()},[Y.pendingAction]);xa(q,Y.open),k.useEffect(()=>{if(!Y.open)return;const H=$=>{$.key==="Escape"&&L({open:!1,pendingAction:null})};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[Y.open]);const Eb=async H=>{try{await se.setActiveSoul(H),_(H)}catch($){g($)}},kb=k.useCallback(async(H,$,oe)=>{try{await se.applyProposal(H),Ae.markProposalStatus($,oe,!0)}catch(ke){g(ke)}},[Ae,g]),Tb=k.useCallback(async(H,$,oe)=>{try{await se.rejectProposal(H),Ae.markProposalStatus($,oe,!1)}catch(ke){g(ke)}},[Ae,g]),za=t.find(H=>H.id===h),ls=k.useMemo(()=>{const H=new Set(r.map($=>$.id));return new Set([...P].filter($=>H.has($)))},[P,r]),us=ls.size,wb=k.useMemo(()=>r.filter(H=>H.type==="section").sort((H,$)=>H.orderIdx-$.orderIdx),[r]),Sb=k.useMemo(()=>{const H=lm.map(oe=>S.find(ke=>ke.name===oe)).filter(oe=>!!oe),$=S.filter(oe=>!lm.includes(oe.name));return[...H,...$]},[S]),Lt=BN(h),hc=HN(),it=Mu(),Ab=k.useCallback(async(H,$,oe)=>{try{const ke=await se.undoProposal(H);Ae.markProposalUndone($,oe),it.show(ke.conflicts.length>0?`${e("chat.proposal.undo_done")}(${e("chat.proposal.undo_conflict")})`:e("chat.proposal.undo_done"),{duration:4e3})}catch(ke){g(ke)}},[Ae,g,e,it]);k.useEffect(()=>se.on("exam:status",$=>{if($.status!=="ready"||$.nodeId===I)return;const oe=r.find(ke=>ke.id===$.nodeId);oe&&it.show(e("exam.ready.toast",{title:oe.title}),{duration:4e3})}),[I,r,it,e]);const fc=k.useRef(!1);k.useEffect(()=>{!h||fc.current||(fc.current=!0,se.getUpdateInfo().then(H=>{H!=null&&H.hasUpdate&&(it.show(e("update.available",{version:H.latest}),{severity:"info",duration:8e3,action:{label:e("update.download"),onClick:()=>window.open(H.releaseUrl)}}),se.setSetting("update_prompt_seen",H.latest).catch(()=>{}))}).catch(()=>{}))},[h,it,e]);const Cb=k.useCallback(async H=>{const $=t.find(oe=>oe.id===H);try{await se.deleteCourse(H),it.show(e("import.deleted",{title:($==null?void 0:$.title)??H}),{duration:3e3}),Et()}catch(oe){g(oe)}},[t,Et,g,it,e]),Va=k.useCallback(async(H,$,oe)=>{if(!H.trim()||Ae.streaming)return;if(!ye.activeId){const Qe=await ye.ensureThreadForSend(H,$);if(Qe){Ae.send(H,Qe,$,oe);return}it.show(e("toast.threadCreateFailed"));return}const ke=ye.activeThread;ke&&!ke.title&&ye.update(ke.id,{title:($??H).trim()}),Ae.send(H,void 0,$,oe)},[Ae,ye,it,e]),mc=k.useCallback(async H=>{if(!h)return;const $=r.find(ke=>ke.id===H);if(!$)return;me===3&&Be("chat");const oe=await ye.openOrCreateReview(H,e("review.thread.title",{title:$.title}));if(!oe){it.show(e("toast.threadCreateFailed"));return}I!==H&&(R(H),M("content")),Me!=null&&Me.ready&&!Ae.streamingThreadIds.includes(oe)&&Ae.send(e("review.kickoff.prompt",{title:$.title}),oe,e("review.kickoff.label",{title:$.title}))},[h,r,me,ye,e,it,Me,Ae,I]),pc=k.useRef(Ae.streaming);pc.current=Ae.streaming;const _b=k.useCallback(H=>{const $=YI(H,e),oe=WI(H,e),ke=Qe=>{var Yt;if(!pc.current){(Yt=lt.current)==null||Yt.call(lt,$,oe);return}Qe>0&&setTimeout(()=>ke(Qe-1),2e3)};ke(10)},[e]);lt.current=Va;const gc=new Set(["concept_map","diagram","compare_table","code_walkthrough"]),Qr=k.useMemo(()=>{const H=_h(Ae.messages).filter(oe=>{var ke;return gc.has(((ke=oe.output)==null?void 0:ke.artifactType)??"")});if(H.length)return H[H.length-1];const $=Lt.items.filter(oe=>gc.has(oe.artifactType)).map(oe=>{try{return{id:oe.id,toolName:oe.artifactType,output:JSON.parse(oe.data)}}catch{return null}}).filter(oe=>oe!==null);return $.length?$[$.length-1]:null},[Ae.messages,Lt.items]),bc=k.useRef(new Set);k.useEffect(()=>{!Qr||bc.current.has(Qr.id)||(bc.current.add(Qr.id),Ae.streaming&&M("board"))},[Qr,Ae.streaming]);const Nb=k.useMemo(()=>Ae.messages.reduce((H,$)=>H+$.parts.reduce((oe,ke)=>ke.type==="text"?oe+Pm(ke.text):oe,0),0),[Ae.messages]),xc=k.useRef(!1);k.useEffect(()=>{us>0&&!xc.current&&(xc.current=!0,it.show(e("review.nudge",{n:us}),{duration:4e3}))},[us,it,e]);const yc=k.useMemo(()=>_h(Ae.messages),[Ae.messages]),vc=k.useRef(new Set);k.useEffect(()=>{for(const H of yc){const $=H.output;if(!$||!$.artifactType)continue;const oe=`${$.artifactType}:${JSON.stringify($)}`;vc.current.has(oe)||(vc.current.add(oe),Lt.save({nodeId:I,artifactType:$.artifactType,title:$.title??null,data:$}),it.show(e("toast.artifactSaved"),{duration:3e3}))}},[yc,Lt,I,it,e]),k.useEffect(()=>{A!=="map"&&M(null)},[A]);const[Ib,cs]=k.useState(!1),Hn=((kc=ye.activeThread)==null?void 0:kc.kind)==="review",Rb=k.useMemo(()=>{if(!Hn)return null;for(const H of ls){if(H===I)continue;const $=r.find(oe=>oe.id===H);if($&&$.type==="lesson")return H}return null},[Hn,ls,I,r]),Mb=k.useMemo(()=>{let H=-1;return Ae.messages.forEach(($,oe)=>{$.role==="user"&&$.parts.some(ke=>ke.type==="text"&&ke.text.includes(wg))&&(H=oe)}),H},[Ae.messages]),Pb=Hn&&VN(Ae.messages)==="open",Ec=(ze==null?void 0:ze.type)==="exam";return k.useEffect(()=>{Ec&&window.dispatchEvent(new CustomEvent("companion-exam-enter"))},[Ec]),k.useEffect(()=>{mx(Hn)},[Hn]),p.jsxs("div",{className:"h-[var(--app-height,100vh)] flex flex-col bg-surface-1 text-neutral-900 dark:text-neutral-100 overflow-hidden",children:[p.jsx(wP,{streak:o,xp:u,fontSize:hc.size,onFontBump:hc.bump,onOpenSettings:()=>ae(!0),profileName:Fe,onOpenProfile:()=>ve(!0),leftVisible:he,rightVisible:Te,onToggleLeft:Gr,onToggleRight:ns,tier:me,bottomBar:me===3?p.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:wm,label:e("pane.map"),testid:"t3-btn-rail"},{k:"chat",icon:zx,label:e("pane.chat"),testid:"t3-btn-chat"},{k:"notebook",icon:Yx,label:e("pane.notes"),testid:"t3-btn-notebook"}].map(({k:H,icon:$,label:oe,testid:ke})=>p.jsx("button",{role:"tab","aria-selected":Ie===H,"aria-label":oe,"data-testid":ke,"data-tooltip":oe,onClick:()=>Be(H),className:`w-8 h-7 flex items-center justify-center rounded-md transition-colors ${Ie===H?"bg-brand/20 text-brand":"text-ink-muted active:bg-ink/10"}`,children:p.jsx($,{className:"w-4 h-4"})},H))}):void 0}),d&&p.jsx(CP,{message:d,onClose:()=>m(null)}),p.jsxs("div",{className:"flex-1 flex min-h-0 min-w-0",onTouchStart:rs,onTouchEnd:is,children:[he&&p.jsx(d2,{fullWidth:me===3,width:me===3?null:ht.rail,view:A,onViewChange:N,nextCueNodeId:bb,courseTitle:(za==null?void 0:za.title)??null,courseId:h,courses:t,sections:wb,tree:r,progressMap:i,selectedNodeId:I,dueCount:us,dueNodeIds:ls,overallMastery:(C==null?void 0:C.overallMastery)??0,streak:(o==null?void 0:o.currentStreak)??0,streaming:Ae.streamingThreadIds.length>0,streamingNodeIds:Ae.streamingNodeIds,onJumpNode:H=>{const $=r.find(oe=>oe.id===H);$&&Xr($),me===3&&Be("chat")},onOpenReview:()=>cs(!0),onSelectCourse:H=>fr(()=>{f(H),Et(),se.setSetting("boot_done","1").catch(()=>{})}),onDeleteCourse:H=>fr(()=>{Cb(H)}),onCoursesChanged:()=>{Et()},availableLanguages:b,currentLocale:w,onLocaleChange:async H=>{h&&(await se.setCourseLanguage(h,H),E(H))}}),Ln.rail&&Re&&p.jsx(qh,{side:"rail",ariaLabel:e("pane.resizeRailAria"),tooltip:e("pane.resizeTooltip"),target:()=>document.querySelector('[data-testid="map-rail"]'),clampLive:H=>Al(H,window.innerWidth,Wr),onCommit:H=>Yr("rail",H)}),p.jsxs(p.Fragment,{children:[Re&&p.jsx("div",{ref:$r,className:"relative flex flex-col h-full bg-surface-1 shrink-0 min-w-0 motion-safe:transition-[width] motion-safe:duration-200",style:me===3?{flex:1}:Te?{width:ht.mid!=null?`${ht.mid}px`:a5}:{flex:1},"data-testid":"chat-panel",children:h?(ze==null?void 0:ze.type)==="exam"?p.jsx(k.Suspense,{fallback:null,children:p.jsx(yP,{examNode:ze,locale:Pe,onSessionChange:yb,paused:Y.open,onExamCompleted:()=>{se.getProgress(ze.id).then(H=>{H&&a($=>({...$,[ze.id]:H}))})}})}):p.jsxs(p.Fragment,{children:[p.jsx(KI,{threads:ye.threads,activeThread:ye.activeThread,focusNodeTitle:(ze==null?void 0:ze.title)??null,streamingThreadIds:Ae.streamingThreadIds,onPickThread:H=>{ye.setActiveId(H)},onCreate:()=>{ye.create({title:null}),it.show(e("toast.threadCreated"))},onRename:(H,$)=>{ye.update(H,{title:$}),it.show(e("toast.threadRenamed"))},onArchive:H=>{ye.update(H,{status:"archived"}),it.show(e("toast.threadArchived"),{duration:5e3,action:{label:e("action.undo"),onClick:()=>ye.update(H,{status:"active"})}})},onDelete:H=>{const $=ye.removeWithUndo(H);$&&(it.show(`${e("toast.threadDeleted")}${$.title?`「${$.title}」`:""}`,{duration:5e3,action:{label:e("action.undo"),onClick:()=>{ye.restore($),it.show(e("toast.restored"))}}}),setTimeout(()=>{se.threadDelete($.id).catch(()=>{})},5500))}}),p.jsx(XN,{messages:Ae.messages,streaming:Ae.streaming,onApplyProposal:kb,onRejectProposal:Tb,onUndoProposal:Ab,summary:On,onStartLearning:Me!=null&&Me.ready?Kr:void 0,agentReady:(Me==null?void 0:Me.ready)??!1,onOpenModelManager:()=>ge("main"),hasNode:!!ze,selectedNodeId:I,threadId:ye.activeId,onPickQuizAction:H=>{Va(H)},onQuizCompleted:_b,cardMode:me===3,reviewNextNodeId:Rb,onStartReviewSession:H=>void mc(H),chatNotes:Lt.items.filter(H=>H.artifactType==="user_note"&&H.sourceAnchor),onSaveChatNote:(H,$,oe,ke)=>{!ze||!ye.activeId||(Lt.saveUserNote({nodeId:ze.id,text:H,sourceType:"chat",sourceAnchor:{type:"chat",threadId:ye.activeId,msgId:$,startOffset:oe,endOffset:ke}}),it.show(e("toast.noteSaved"),{duration:2e3}))}}),Hn&&Pb&&!Ae.streaming&&Ae.messages.length>0&&I&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(bP,{nodeId:I},Mb)}),p.jsx(TI,{nodeId:I,reviewMode:Hn,agentReady:(Me==null?void 0:Me.ready)??!1,streaming:Ae.streaming,souls:Sb,activeSoul:T,starterPrompts:Ae.messages.length>0?Ha:[],onPickSoul:Eb,onSend:Va,onStop:Ae.stop,onLogFriction:I?(H,$)=>{se.logFriction(I,H,$),it.show(e("chat.friction.saved"),{duration:2500})}:void 0,onOpenModelManager:()=>ge("main"),insertText:St,historyTokens:Nb})]}):p.jsx("div",{className:"flex-1 flex flex-col min-h-0","data-testid":"chat-no-course",children:p.jsx(MN,{onResume:(H,$)=>fr(()=>mb(H,$)),onOpenReview:H=>fr(()=>{!h&&H&&(f(H),Et(),se.setSetting("boot_done","1").catch(()=>{})),cs(!0)}),onOpenSettings:H=>{re(H??null),ae(!0)},onOpenModelManager:()=>ge("main"),onGotoNode:(H,$)=>fr(()=>pb(H,$)),onPickCourse:gb,onOpenProfile:()=>ve(!0),onProfileChanged:as})})}),Ln.mid&&Re&&p.jsx(qh,{side:"mid",ariaLabel:e("pane.resizeChatAria"),tooltip:e("pane.resizeTooltip"),target:()=>$r.current,clampLive:H=>Ig(H,window.innerWidth,ts),onCommit:H=>Yr("mid",H)}),Te&&p.jsx("main",{className:me===3?"flex-1 min-w-0 bg-surface-2":"flex-1 min-w-[440px] bg-surface-2","data-testid":me===3?"notebook-pane-full":void 0,children:h?p.jsx(fN,{selectedNode:ze,items:Lt.items,loading:Lt.loading,forceTab:K,canvasArtifact:Qr,onUserTabChange:()=>M(null),onRemove:H=>{Lt.remove(H),it.show(e("toast.noteDeleted"))},onTogglePin:H=>{Lt.togglePin(H)},onRecordQuizResult:(H,$)=>{Lt.recordQuizResult(H,$)},onUpdateNoteComment:(H,$)=>{Lt.updateUserNoteComment(H,$)},onSaveContentNote:(H,$)=>{ze&&(Lt.saveUserNote({nodeId:ze.id,text:H,sourceType:"content",sourceAnchor:$}),it.show(e("toast.noteSaved"),{duration:2e3}))},onJumpToSource:Nt,onQuoteToChat:Ge,locale:w}):p.jsx(DN,{})})]})]}),be&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(pP,{onClose:()=>ve(!1),onProfileSaved:as})}),ne&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(gP,{tab:te,onClose:()=>X(!1)})}),G&&p.jsx(SP,{onClose:()=>{ae(!1),re(null)},focusSection:Z,onOpenModelManager:ge}),Ib&&p.jsx(AP,{onClose:()=>cs(!1),tree:r,dashboard:C,progressMap:i,onPickNode:H=>{fr(()=>{cs(!1),mc(H)})}}),Y.open&&p.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50","data-testid":"exam-leave-modal",children:p.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:[p.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[p.jsx(su,{className:"w-5 h-5 text-warning shrink-0"}),p.jsx("span",{className:"text-title font-bold text-ink",children:e("exam.leave.title")})]}),p.jsx("div",{className:"text-body text-ink-muted mb-5 leading-relaxed",children:e("exam.leave.message")}),p.jsxs("div",{className:"flex justify-end gap-2",children:[p.jsx("button",{className:"btn-3d-neutral px-4 py-1.5 text-body",onClick:()=>L({open:!1,pendingAction:null}),"data-testid":"exam-leave-cancel",children:e("exam.leave.cancel")}),p.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 vb(),"data-testid":"exam-leave-confirm",children:e("exam.leave.confirm")})]})]})}),ss&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(vP,{onClose:()=>Dn(!1),onPick:H=>{Dn(!1),TP(H)},hasNode:!!I})}),Wt&&p.jsxs("div",{"data-testid":"next-lesson-card",className:"fixed bottom-24 left-1/2 -translate-x-1/2 z-40 surface-card px-4 py-3 flex items-center gap-3 shadow-elevated max-w-[92vw] toast-enter",role:"status",children:[p.jsx(ru,{className:"w-5 h-5 text-gold shrink-0","aria-hidden":"true"}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"text-body font-bold text-ink",children:e("lesson.next.title")}),Wt.next?p.jsxs("div",{className:"text-label text-ink-muted truncate",children:[e("lesson.next.guide")," · ",Wt.next.title]}):p.jsx("div",{className:"text-label text-ink-muted",children:e("lesson.next.terminal")})]}),Wt.next&&p.jsx("button",{className:"btn-3d-brand text-label px-3 py-1.5 shrink-0",onClick:xb,"data-testid":"next-lesson-go",children:e("lesson.next.button")}),p.jsx("button",{className:"text-ink-faint hover:text-ink shrink-0",onClick:()=>os(null),"aria-label":e("common.close"),"data-testid":"next-lesson-close",children:p.jsx(_n,{className:"w-4 h-4"})})]}),p.jsx(k2,{}),p.jsx(fP,{}),p.jsx(BI,{courseId:h}),we&&p.jsx(k.Suspense,{fallback:null,children:p.jsx(EP,{})})]})}function TP(e){window.dispatchEvent(new CustomEvent("lookatstudy-command",{detail:e}))}function wP({streak:e,xp:t,fontSize:n,onFontBump:r,onOpenSettings:s,profileName:i,onOpenProfile:a,leftVisible:o,rightVisible:l,onToggleLeft:u,onToggleRight:c,tier:h,bottomBar:f}){const d=$e();return f?p.jsx("header",{className:"app-header shrink-0",children:p.jsxs("div",{className:"flex items-center h-12 px-4",children:[p.jsx("div",{className:"flex-1 flex items-center min-w-0",children:t&&p.jsxs("div",{className:"flex items-center gap-1 shrink-0","data-testid":"xp-bar",title:d("header.energy"),children:[p.jsx(Gs,{className:`w-3.5 h-3.5 text-brand ${t.todayXp>=100?"energy-breathe":""}`,fill:t.todayXp>=100?"currentColor":"none","aria-hidden":"true"}),p.jsx("span",{className:"text-label font-bold tabular-nums text-brand",children:t.todayXp})]})}),f,p.jsxs("div",{className:"flex-1 flex items-center justify-end",children:[p.jsx(um,{profileName:i,onOpenProfile:a}),p.jsx("button",{onClick:s,"data-testid":"header-settings","aria-label":d("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:d("header.settings"),children:p.jsx(Ws,{className:"w-4 h-4"})})]})]})}):p.jsx("header",{className:"app-header shrink-0 flex flex-col",children:p.jsxs("div",{className:"flex items-center pt-2.5 pb-3 px-6 justify-between",children:[p.jsx("div",{className:"flex items-center gap-2 min-w-0",children:p.jsxs("h1",{className:"text-body font-extrabold tracking-tight text-neutral-900 dark:text-neutral-100 select-none min-w-0 truncate",children:["Lookat",p.jsx("span",{className:"text-brand",children:"Study"})]})}),p.jsxs("div",{className:"flex items-center gap-3",children:[h!==3&&p.jsxs("div",{className:"flex items-center gap-0.5",children:[p.jsx("button",{onClick:u,"data-testid":"layout-toggle-left",className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${o?"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:d("header.toggleLeft"),children:p.jsx(qx,{className:"w-4 h-4"})}),p.jsx("button",{onClick:c,"data-testid":"layout-toggle-right",className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${l?"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:d("header.toggleRight"),children:p.jsx($x,{className:"w-4 h-4"})})]}),h!==3&&p.jsxs("div",{className:"flex items-center gap-0.5","data-testid":"font-size-control",children:[p.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:d("header.font.smaller"),children:"A-"}),p.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:d("header.font.larger"),children:"A+"})]}),t&&p.jsxs("div",{className:"flex items-center gap-1.5","data-testid":"xp-bar",title:d("header.energy"),children:[p.jsx(Gs,{className:`w-3.5 h-3.5 text-brand ${t.todayXp>=100?"energy-breathe":""}`,fill:t.todayXp>=100?"currentColor":"none","aria-hidden":"true"}),p.jsx("div",{className:"w-16 h-2 bg-neutral-200 dark:bg-neutral-800 rounded-full overflow-hidden",children:p.jsx("div",{className:"h-full rounded-full bg-brand transition-all duration-500",style:{width:`${Math.min(100,Math.max(3,t.todayXp))}%`}})}),p.jsx("span",{className:"text-label font-bold tabular-nums text-brand",children:t.todayXp})]}),t&&p.jsx("div",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-brand/10","data-testid":"level-badge",title:d("header.level.title"),children:p.jsxs("span",{className:"text-label font-bold text-brand",children:["Lv.",t.level]})}),e&&p.jsx(_P,{streak:e}),p.jsx(um,{profileName:i,onOpenProfile:a}),p.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:d("header.settings"),children:p.jsx(Ws,{className:"w-4 h-4"})})]})]})})}function um({profileName:e,onOpenProfile:t}){const n=$e(),r=FN(e);return p.jsx("button",{onClick:t,"data-testid":"header-profile","aria-label":n("profile.header.open"),"data-tooltip":n("profile.header.open"),className:"w-9 h-9 flex items-center justify-center rounded-full transition-transform hover:scale-105 shrink-0",style:r?{backgroundColor:r.bg,color:r.fg}:void 0,children:r?p.jsx("span",{className:"text-label font-bold leading-none",children:r.initial}):p.jsx(ly,{className:"w-4 h-4 text-ink-muted","aria-hidden":"true"})})}function SP({onClose:e,focusSection:t,onOpenModelManager:n}){const r=$e(),s=k.useRef(null);return xa(s,!0),k.useEffect(()=>{if(!t)return;const i=()=>document.getElementById(`settings-section-${t}`),a=[250,700].map(o=>window.setTimeout(()=>{var l;(l=i())==null||l.scrollIntoView({behavior:"smooth",block:"start"})},o));return()=>a.forEach(clearTimeout)},[t]),p.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end","data-testid":"settings-drawer",children:[p.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:e}),p.jsxs("div",{ref:s,role:"dialog","aria-modal":"true","aria-label":r("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:[p.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0",children:[p.jsx("h2",{className:"text-body font-bold",children:r("settings.title")}),p.jsx("button",{onClick:e,"data-testid":"settings-close","aria-label":r("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:"✕"})]}),p.jsx("div",{className:"flex-1 overflow-y-auto",children:p.jsx(k.Suspense,{fallback:null,children:p.jsx(xP,{onOpenModelManager:n})})})]})]})}function AP({onClose:e,tree:t,onPickNode:n,dashboard:r,progressMap:s}){const i=$e(),a=k.useRef(null);xa(a,!0);const[o,l]=k.useState([]);k.useEffect(()=>{se.getAllSrsItems().then(E=>l(E)).catch(()=>l([]))},[]);const u=k.useMemo(()=>new Map(o.map(E=>[E.nodeId,E])),[o]),c=k.useMemo(()=>{const E=new Map(t.map(v=>[v.id,v])),S=o.filter(v=>E.has(v.nodeId));return{overdue:S.filter(v=>v.overdue),short:S.filter(v=>!v.overdue&&v.intervalDays>0&&v.intervalDays<=7),long:S.filter(v=>!v.overdue&&v.intervalDays>7),inactive:S.filter(v=>v.repetitions===0&&!v.overdue)}},[o,t]),h=k.useMemo(()=>t.filter(S=>S.type==="section"&&(S.world??"study")==="study").sort((S,v)=>S.orderIdx-v.orderIdx).map(S=>({section:S,lessons:t.filter(v=>v.parentId===S.id&&v.type==="lesson").sort((v,T)=>v.orderIdx-T.orderIdx)})),[t]),f=k.useMemo(()=>{const E=new Map;for(const S of(r==null?void 0:r.sections)??[])E.set(S.sectionId,S.avgMastery);return E},[r]),d=k.useMemo(()=>t.filter(E=>{var v;const S=(v=s[E.id])==null?void 0:v.status;return E.type==="lesson"&&(E.world??"study")==="study"&&(S==="in_progress"||S==="mastered")}),[t,s]),[m,g]=k.useState(new Set),b=E=>g(S=>{const v=new Set(S);return v.has(E)?v.delete(E):v.add(E),v}),y=E=>{const S=u.get(E);return S?S.overdue?{color:"bg-review",title:i("review.quadrant.overdue")}:S.intervalDays>0&&S.intervalDays<=7?{color:"bg-gold",title:i("review.quadrant.short")}:S.intervalDays>7?{color:"bg-brand",title:i("review.quadrant.long")}:null:null},w=c.overdue.length>0;return p.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end","data-testid":"review-drawer",children:[p.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:e}),p.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:[p.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0",children:[p.jsxs("h2",{className:"text-body font-bold flex items-center gap-1.5",children:[p.jsx(Jt,{className:"w-4 h-4","aria-hidden":"true"})," ",i("review.title")]}),p.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:"✕"})]}),p.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-5","data-testid":"review-panel",children:[d.length>0&&p.jsxs("button",{onClick:()=>{const E=d[Math.floor(Math.random()*d.length)];E&&n(E.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:[p.jsx(ry,{className:"w-4 h-4"}),i("review.interleave")]}),o.length>0&&p.jsxs("div",{children:[p.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2",children:i("review.srsHint")}),p.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(E=>E.items.length>0).map(E=>p.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded-full bg-surface-3",children:[p.jsx("span",{className:`w-2 h-2 rounded-full ${E.dot}`}),p.jsx("span",{className:"text-label text-ink-muted",children:E.label}),p.jsx("span",{className:"text-label font-extrabold text-ink-strong tabular-nums",children:E.items.length})]},E.label))}),w&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"text-label text-ink-faint mb-1.5",children:i("review.overdueQuickHint")}),p.jsx("div",{className:"flex flex-wrap gap-1.5",children:c.overdue.slice(0,8).map(E=>{const S=t.find(v=>v.id===E.nodeId);return S?p.jsx("button",{onClick:()=>n(E.nodeId),"data-testid":`review-overdue-${E.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:S.title},E.nodeId):null})})]})]}),h.length>0&&p.jsxs("div",{children:[p.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2",children:i("review.myProgress")}),p.jsx("div",{className:"space-y-1",children:h.map(({section:E,lessons:S})=>{const v=Math.round((f.get(E.id)??0)*100),T=m.has(E.id),_=S.filter(A=>{var C;const N=(C=s[A.id])==null?void 0:C.status;return N==="in_progress"||N==="mastered"});return p.jsxs("div",{children:[p.jsxs("button",{onClick:()=>b(E.id),className:"w-full flex items-center gap-2 p-2 rounded-lg hover:bg-surface-3 transition-colors",children:[T?p.jsx(pa,{className:"w-3.5 h-3.5 text-ink-muted shrink-0"}):p.jsx(Cx,{className:"w-3.5 h-3.5 text-ink-muted shrink-0"}),p.jsx("span",{className:"text-body text-ink-strong font-bold truncate flex-1 text-left",children:E.title}),_.length>0&&p.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[p.jsx("div",{className:"w-16 h-1.5 bg-surface-3 rounded-full overflow-hidden",children:p.jsx("div",{className:`h-full rounded-full ${v>=100?"bg-gold":"bg-brand"}`,style:{width:`${Math.max(3,v)}%`}})}),p.jsxs("span",{className:"text-label tabular-nums text-ink-muted w-8 text-right",children:[v,"%"]})]})]}),T&&p.jsx("div",{className:"ml-5 mt-0.5 mb-1 space-y-0.5","data-testid":"review-lesson-list",children:S.length===0?p.jsx("div",{className:"text-label text-ink-faint py-1.5 pl-1",children:"—"}):S.map(A=>{const N=s[A.id],C=N?Math.round((N.mastery??0)*100):null,D=y(A.id),P=(N==null?void 0:N.status)==="in_progress"||(N==null?void 0:N.status)==="mastered";return p.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded-lg transition-colors ${(D==null?void 0:D.color)==="bg-review"?"bg-review/8":"hover:bg-surface-3"}`,children:[D?p.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${D.color} shrink-0`,title:D.title}):p.jsx("span",{className:"w-1.5 h-1.5 shrink-0"}),p.jsx("span",{className:`text-label truncate flex-1 ${P?"text-ink-strong":"text-ink-faint"}`,children:A.title}),C!==null&&p.jsxs("span",{className:"text-label tabular-nums text-ink-muted shrink-0 w-8 text-right",children:[C,"%"]}),P&&p.jsx("button",{onClick:()=>n(A.id),"data-testid":`review-lesson-${A.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")})]},A.id)})})]},E.id)})})]}),r&&r.frictionByNode.length>0&&p.jsxs("div",{children:[p.jsx("div",{className:"text-caption font-bold text-review uppercase tracking-wider mb-1.5",children:i("dashboard.mini.struggle")}),r.frictionByNode.map(E=>p.jsxs("button",{onClick:()=>n(E.nodeId),className:"flex items-center gap-2 py-0.5 w-full text-left hover:bg-surface-3 rounded px-1",children:[p.jsxs("span",{className:"text-label text-review font-bold tabular-nums",children:[E.count,"×"]}),p.jsx("span",{className:"text-label text-ink-strong truncate flex-1",children:E.title})]},E.nodeId))]}),d.length===0&&o.length===0&&h.length===0&&p.jsxs("div",{className:"text-center py-16","data-testid":"review-empty",children:[p.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),p.jsx("div",{className:"text-body text-ink-muted",children:i("review.empty.title")}),p.jsx("div",{className:"text-label text-ink-faint mt-1",children:i("review.empty.desc")})]})]})]})]})}function CP({message:e,onClose:t}){const n=$e();return p.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:[p.jsxs("span",{children:["⚠️ ",e]}),p.jsx("button",{className:"ml-3 underline text-warning-light",onClick:t,children:n("action.close")})]})}function _P({streak:e}){const t=$e();return p.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:[p.jsx(ga,{className:"w-4 h-4 text-review flame-flicker"}),p.jsx("span",{className:"text-body font-extrabold text-review",children:e.currentStreak}),e.freezeCount>0&&p.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:[p.jsx(ny,{className:"w-3 h-3 text-review/80","aria-hidden":"true"}),p.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 NP({rejected:e}){const t=navigator.language.startsWith("zh"),[n,r]=eu.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&&_e(async()=>{const{setWebToken:l}=await import("./api-web-C4rSxyIm.js");return{setWebToken:l}},[],import.meta.url).then(({setWebToken:l})=>l(o))};return p.jsx("div",{className:"min-h-[var(--app-height,100vh)] bg-[#0e2a12] flex items-center justify-center p-6",children:p.jsxs("form",{onSubmit:s,className:"w-full max-w-sm text-center",children:[p.jsx("div",{className:"text-4xl mb-3",children:"🎈"}),p.jsx("h1",{className:"text-title font-bold text-white mb-1",children:"LookatStudy"}),p.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&&p.jsx("p",{className:"text-label text-warning-light mb-3",children:t?"上次的令牌被拒绝了,请重新输入":"Previous token was rejected, please re-enter"}),p.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"}),p.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"}),p.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 fb=px.createRoot(document.getElementById("root"));function IP(){fb.render(p.jsx(eu.StrictMode,{children:p.jsx(eN,{children:p.jsx(kP,{})})}))}function cm(e){fb.render(p.jsx(eu.StrictMode,{children:p.jsx(NP,{rejected:e})}))}async function RP(){const{installAppHeight:e}=await _e(async()=>{const{installAppHeight:t}=await import("./app-height-D5bf5z0g.js");return{installAppHeight:t}},[],import.meta.url);if(e(),!window.api){const t=await _e(()=>import("./api-web-C4rSxyIm.js"),[],import.meta.url);if(window.addEventListener(t.TOKEN_REJECTED_EVENT,()=>cm(!0)),!t.hasWebToken()){cm(!1);return}try{await t.installWebApi()}catch(n){console.error("[boot] web api 安装失败:",n)}}IP()}RP();export{_m as $,tu as A,Jt as B,nu as C,Lm as D,su as E,Vi as F,xm as G,Xs as H,OP as I,BP as J,fh as K,Em as L,wm as M,hh as N,Xn as O,UP as P,KS as Q,GS as R,ry as S,ay as T,hy as U,Ca as V,Mm as W,_n as X,_p as Y,Qk as Z,_e as _,se as a,LP as a0,DP as a1,km as a2,sy as a3,jP as a4,Ix as a5,Kx as a6,C2 as a7,Rn as a8,ka as a9,Wm as aa,ep as ab,Md as ac,Dp as ad,$i as ae,dA as af,pm as b,fe as c,xa as d,ey as e,Ms as f,Tm as g,ru as h,ba as i,Mu as j,No as k,Ys as l,fm as m,Fm as n,Io as o,Nm as p,_x as q,xn as r,HP as s,Cm as t,$e as u,mr as v,FP as w,Ew as x,qe as y,Ne as z};