@waniwani/sdk 0.14.1 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/README.md +5 -5
  2. package/dist/angular-html-GK625GFM.js +2 -0
  3. package/dist/{angular-ts-UPMUIYI3.js → angular-ts-BBPQXDS2.js} +2 -2
  4. package/dist/{angular-ts-A7ZNTSV6.js → angular-ts-DFS2FCNO.js} +2 -2
  5. package/dist/{apl-QBN4KIYA.js → apl-FBR445XW.js} +2 -2
  6. package/dist/{apl-ZTMAKUPW.js → apl-JGB4KP74.js} +2 -2
  7. package/dist/{astro-OQUOYMBE.js → astro-BMSTTQT4.js} +2 -2
  8. package/dist/{astro-ZC25ZSBI.js → astro-K7JGTCPV.js} +2 -2
  9. package/dist/{blade-QBDEYXMB.js → blade-OHP5YUT7.js} +2 -2
  10. package/dist/{blade-BVUO2H7O.js → blade-RWJJQSLU.js} +2 -2
  11. package/dist/chat/embed.js +66 -65
  12. package/dist/chat/embed.js.map +1 -1
  13. package/dist/chat/express-js/index.d.ts +4 -4
  14. package/dist/chat/express-js/index.js.map +1 -1
  15. package/dist/chat/index.d.ts +16 -9
  16. package/dist/chat/index.js +10 -9
  17. package/dist/chat/index.js.map +1 -1
  18. package/dist/chat/next-js/index.d.ts +5 -5
  19. package/dist/chat/next-js/index.js.map +1 -1
  20. package/dist/chat/server/index.d.ts +4 -4
  21. package/dist/chat/server/index.js.map +1 -1
  22. package/dist/chat/styles.css +1 -1
  23. package/dist/{chunk-7PHUBJVC.js → chunk-AI3BZXLG.js} +2 -2
  24. package/dist/{chunk-5JBHQYU5.js → chunk-F4UUXA3U.js} +3 -3
  25. package/dist/{chunk-2RS4JWNJ.js → chunk-HFFYDWFN.js} +2 -2
  26. package/dist/{chunk-AGWJ4LUC.js → chunk-HWHRZFFJ.js} +2 -2
  27. package/dist/{chunk-BFEOSXSG.js → chunk-IPSY5OIT.js} +2 -2
  28. package/dist/{chunk-BKIIYGWO.js → chunk-OHRY6PPX.js} +2 -2
  29. package/dist/{chunk-BNESB5SU.js → chunk-ORTYTFGK.js} +2 -2
  30. package/dist/{chunk-TV2UKRXD.js → chunk-REK5PMSH.js} +2 -2
  31. package/dist/{chunk-KMHU4XIM.js → chunk-SREBMPDB.js} +2 -2
  32. package/dist/{chunk-4OK4GCCR.js → chunk-VDGF5EL2.js} +2 -2
  33. package/dist/{chunk-VNX5AK2O.js → chunk-VNL3EXC2.js} +2 -2
  34. package/dist/{chunk-V6FKURGI.js → chunk-W4SPRY5O.js} +2 -2
  35. package/dist/{chunk-4WLKD7DL.js → chunk-YP6YTC7R.js} +3 -3
  36. package/dist/{cobol-6DNJTKH3.js → cobol-LJNKRWP5.js} +2 -2
  37. package/dist/{cobol-SKJIT3WM.js → cobol-ZFZ6ZP6X.js} +2 -2
  38. package/dist/{code-block-37QAKDTI-IIYKFI5S.js → code-block-37QAKDTI-HV355RRX.js} +2 -2
  39. package/dist/{code-block-37QAKDTI-IJYLCU3C.js → code-block-37QAKDTI-Y3BUEJRG.js} +2 -2
  40. package/dist/cpp-HLYUQ6RF.js +2 -0
  41. package/dist/{crystal-YFCJLEES.js → crystal-UPNOBGN4.js} +2 -2
  42. package/dist/{edge-3LWPZYS7.js → edge-XE5XFLFP.js} +2 -2
  43. package/dist/{elixir-3H7W7YJZ.js → elixir-EXRA4QJX.js} +2 -2
  44. package/dist/{erb-HGSLHT5Y.js → erb-KUYJX32Q.js} +2 -2
  45. package/dist/{erb-AXCKAI43.js → erb-LRUOJBTB.js} +2 -2
  46. package/dist/{glimmer-js-ZXI6Y36F.js → glimmer-js-JA25I4AE.js} +2 -2
  47. package/dist/{glimmer-ts-BJKMFBLF.js → glimmer-ts-CKELYRRF.js} +2 -2
  48. package/dist/graphql-NLMAEKLI.js +3 -0
  49. package/dist/graphql-UN5O7U5U.js +2 -0
  50. package/dist/{hack-KV5GHBVV.js → hack-QIUJFE3G.js} +2 -2
  51. package/dist/haml-JQIESO7E.js +2 -0
  52. package/dist/{handlebars-U44VLSEQ.js → handlebars-UBV5AWUH.js} +2 -2
  53. package/dist/html-AWDHWPK7.js +2 -0
  54. package/dist/html-derivative-QY3ZIV7G.js +2 -0
  55. package/dist/{http-NEPTRAQZ.js → http-7ZVVH3VM.js} +2 -2
  56. package/dist/{http-JSPDAWSO.js → http-KIGXJYY6.js} +2 -2
  57. package/dist/{hurl-V6ZX2Q3F.js → hurl-B6WXEN45.js} +2 -2
  58. package/dist/{hurl-OT2SM4S7.js → hurl-BZB5LDD5.js} +2 -2
  59. package/dist/index.d.ts +9 -9
  60. package/dist/index.js +1 -1
  61. package/dist/index.js.map +1 -1
  62. package/dist/{jinja-CCI3FGLW.js → jinja-AEVQQKWS.js} +2 -2
  63. package/dist/{julia-BWWONBRS.js → julia-75QR2XDN.js} +2 -2
  64. package/dist/{julia-QPZ7EOS6.js → julia-CPV3A4MM.js} +2 -2
  65. package/dist/kb/index.js.map +1 -1
  66. package/dist/legacy/chat/express-js/index.d.ts +4 -4
  67. package/dist/legacy/chat/express-js/index.js.map +1 -1
  68. package/dist/legacy/chat/next-js/index.d.ts +5 -5
  69. package/dist/legacy/chat/next-js/index.js.map +1 -1
  70. package/dist/legacy/index.d.ts +11 -11
  71. package/dist/legacy/index.js +16 -15
  72. package/dist/legacy/index.js.map +1 -1
  73. package/dist/legacy/mcp/react.d.ts +1 -1
  74. package/dist/legacy/mcp/react.js +1 -1
  75. package/dist/legacy/mcp/react.js.map +1 -1
  76. package/dist/{liquid-OSRU4KOW.js → liquid-S4LVU77Y.js} +2 -2
  77. package/dist/mcp/index.d.ts +15 -15
  78. package/dist/mcp/index.js +5 -5
  79. package/dist/mcp/index.js.map +1 -1
  80. package/dist/mcp/react.d.ts +3 -3
  81. package/dist/mcp/react.js +1 -1
  82. package/dist/mcp/react.js.map +1 -1
  83. package/dist/{mcp-apps-client-OFYMQOI3.js → mcp-apps-client-WEXKWHUI.js} +2 -2
  84. package/dist/{mcp-apps-client-OFYMQOI3.js.map → mcp-apps-client-WEXKWHUI.js.map} +1 -1
  85. package/dist/{mcp-apps-client-RY3VD4L7.js → mcp-apps-client-Z5ICFYSR.js} +2 -2
  86. package/dist/{mcp-apps-client-RY3VD4L7.js.map → mcp-apps-client-Z5ICFYSR.js.map} +1 -1
  87. package/dist/{mdc-PDOFYVVO.js → mdc-NDTDGSIG.js} +2 -2
  88. package/dist/{mdc-TEVTGSC7.js → mdc-XWCHWP6B.js} +2 -2
  89. package/dist/mermaid-4DMBBIKO-DV4JRUY5.js +2 -0
  90. package/dist/mermaid-4DMBBIKO-IGH2CKFF.js +3 -0
  91. package/dist/{nim-JPSYX5KC.js → nim-U57UBFBS.js} +2 -2
  92. package/dist/{nim-WGQAUAVA.js → nim-Z6EEJ7SX.js} +2 -2
  93. package/dist/{openai-client-TZIOCMXP.js → openai-client-PUBKF5TI.js} +2 -2
  94. package/dist/{openai-client-TZIOCMXP.js.map → openai-client-PUBKF5TI.js.map} +1 -1
  95. package/dist/{openai-client-XYLENCIC.js → openai-client-VRJPAPFR.js} +2 -2
  96. package/dist/{openai-client-XYLENCIC.js.map → openai-client-VRJPAPFR.js.map} +1 -1
  97. package/dist/{perl-Y3ALUOFJ.js → perl-5IQEFQG3.js} +2 -2
  98. package/dist/{perl-X4IFZB22.js → perl-IZHDGBO6.js} +2 -2
  99. package/dist/php-MNP62HWP.js +3 -0
  100. package/dist/php-UQGWKJAF.js +2 -0
  101. package/dist/{pug-7XNGVJEC.js → pug-XHTBJJNO.js} +2 -2
  102. package/dist/{razor-C2NV2YNT.js → razor-UMC4HKIF.js} +2 -2
  103. package/dist/{rst-WIWCR2KQ.js → rst-6KQSGP2V.js} +2 -2
  104. package/dist/{rst-W5S2XFF7.js → rst-HCGHBPBZ.js} +2 -2
  105. package/dist/ruby-ML25RVXY.js +2 -0
  106. package/dist/ruby-OWE2HOOR.js +3 -0
  107. package/dist/{soy-G2LDZSDN.js → soy-ALTWCQTO.js} +2 -2
  108. package/dist/{svelte-EYZDXUS2.js → svelte-6TT7H4YP.js} +2 -2
  109. package/dist/{templ-KXQ2KV7D.js → templ-WN3SJLUV.js} +2 -2
  110. package/dist/{ts-tags-TCQ23O6Y.js → ts-tags-NAJDOQCO.js} +2 -2
  111. package/dist/{ts-tags-7WGDLEKX.js → ts-tags-XNK5N5RZ.js} +2 -2
  112. package/dist/{twig-JAL4753Y.js → twig-GIY7NVAA.js} +2 -2
  113. package/dist/{twig-C6YWFFZU.js → twig-OEIJ72KK.js} +2 -2
  114. package/dist/{vue-O6SLORWU.js → vue-FIH2DYBE.js} +2 -2
  115. package/dist/{vue-D6SXQNWM.js → vue-V6GLJNYA.js} +2 -2
  116. package/dist/{vue-vine-T6MFB2MU.js → vue-vine-KB45C76H.js} +2 -2
  117. package/package.json +2 -2
  118. package/dist/angular-html-VZSV3CDH.js +0 -2
  119. package/dist/cpp-4EW5XLOK.js +0 -2
  120. package/dist/graphql-KHEFECOG.js +0 -2
  121. package/dist/graphql-YEJQLMOO.js +0 -3
  122. package/dist/haml-6R7X7F2Q.js +0 -2
  123. package/dist/html-MYZBE4UD.js +0 -2
  124. package/dist/html-derivative-OWRPAN3G.js +0 -2
  125. package/dist/mermaid-4DMBBIKO-7EL5WRQI.js +0 -2
  126. package/dist/mermaid-4DMBBIKO-PAA57QRQ.js +0 -3
  127. package/dist/php-3V7EPUAN.js +0 -3
  128. package/dist/php-QERWOQJG.js +0 -2
  129. package/dist/ruby-EYYAUQUG.js +0 -2
  130. package/dist/ruby-LXZJUMFB.js +0 -3
  131. /package/dist/{angular-html-VZSV3CDH.js.map → angular-html-GK625GFM.js.map} +0 -0
  132. /package/dist/{angular-ts-UPMUIYI3.js.map → angular-ts-BBPQXDS2.js.map} +0 -0
  133. /package/dist/{angular-ts-A7ZNTSV6.js.map → angular-ts-DFS2FCNO.js.map} +0 -0
  134. /package/dist/{apl-QBN4KIYA.js.map → apl-FBR445XW.js.map} +0 -0
  135. /package/dist/{apl-ZTMAKUPW.js.map → apl-JGB4KP74.js.map} +0 -0
  136. /package/dist/{astro-OQUOYMBE.js.map → astro-BMSTTQT4.js.map} +0 -0
  137. /package/dist/{astro-ZC25ZSBI.js.map → astro-K7JGTCPV.js.map} +0 -0
  138. /package/dist/{blade-QBDEYXMB.js.map → blade-OHP5YUT7.js.map} +0 -0
  139. /package/dist/{blade-BVUO2H7O.js.map → blade-RWJJQSLU.js.map} +0 -0
  140. /package/dist/{chunk-7PHUBJVC.js.map → chunk-AI3BZXLG.js.map} +0 -0
  141. /package/dist/{chunk-5JBHQYU5.js.map → chunk-F4UUXA3U.js.map} +0 -0
  142. /package/dist/{chunk-2RS4JWNJ.js.map → chunk-HFFYDWFN.js.map} +0 -0
  143. /package/dist/{chunk-AGWJ4LUC.js.map → chunk-HWHRZFFJ.js.map} +0 -0
  144. /package/dist/{chunk-BFEOSXSG.js.map → chunk-IPSY5OIT.js.map} +0 -0
  145. /package/dist/{chunk-BKIIYGWO.js.map → chunk-OHRY6PPX.js.map} +0 -0
  146. /package/dist/{chunk-BNESB5SU.js.map → chunk-ORTYTFGK.js.map} +0 -0
  147. /package/dist/{chunk-TV2UKRXD.js.map → chunk-REK5PMSH.js.map} +0 -0
  148. /package/dist/{chunk-KMHU4XIM.js.map → chunk-SREBMPDB.js.map} +0 -0
  149. /package/dist/{chunk-4OK4GCCR.js.map → chunk-VDGF5EL2.js.map} +0 -0
  150. /package/dist/{chunk-VNX5AK2O.js.map → chunk-VNL3EXC2.js.map} +0 -0
  151. /package/dist/{chunk-V6FKURGI.js.map → chunk-W4SPRY5O.js.map} +0 -0
  152. /package/dist/{chunk-4WLKD7DL.js.map → chunk-YP6YTC7R.js.map} +0 -0
  153. /package/dist/{cobol-6DNJTKH3.js.map → cobol-LJNKRWP5.js.map} +0 -0
  154. /package/dist/{cobol-SKJIT3WM.js.map → cobol-ZFZ6ZP6X.js.map} +0 -0
  155. /package/dist/{code-block-37QAKDTI-IIYKFI5S.js.map → code-block-37QAKDTI-HV355RRX.js.map} +0 -0
  156. /package/dist/{code-block-37QAKDTI-IJYLCU3C.js.map → code-block-37QAKDTI-Y3BUEJRG.js.map} +0 -0
  157. /package/dist/{cpp-4EW5XLOK.js.map → cpp-HLYUQ6RF.js.map} +0 -0
  158. /package/dist/{crystal-YFCJLEES.js.map → crystal-UPNOBGN4.js.map} +0 -0
  159. /package/dist/{edge-3LWPZYS7.js.map → edge-XE5XFLFP.js.map} +0 -0
  160. /package/dist/{elixir-3H7W7YJZ.js.map → elixir-EXRA4QJX.js.map} +0 -0
  161. /package/dist/{erb-HGSLHT5Y.js.map → erb-KUYJX32Q.js.map} +0 -0
  162. /package/dist/{erb-AXCKAI43.js.map → erb-LRUOJBTB.js.map} +0 -0
  163. /package/dist/{glimmer-js-ZXI6Y36F.js.map → glimmer-js-JA25I4AE.js.map} +0 -0
  164. /package/dist/{glimmer-ts-BJKMFBLF.js.map → glimmer-ts-CKELYRRF.js.map} +0 -0
  165. /package/dist/{graphql-KHEFECOG.js.map → graphql-NLMAEKLI.js.map} +0 -0
  166. /package/dist/{graphql-YEJQLMOO.js.map → graphql-UN5O7U5U.js.map} +0 -0
  167. /package/dist/{hack-KV5GHBVV.js.map → hack-QIUJFE3G.js.map} +0 -0
  168. /package/dist/{haml-6R7X7F2Q.js.map → haml-JQIESO7E.js.map} +0 -0
  169. /package/dist/{handlebars-U44VLSEQ.js.map → handlebars-UBV5AWUH.js.map} +0 -0
  170. /package/dist/{html-MYZBE4UD.js.map → html-AWDHWPK7.js.map} +0 -0
  171. /package/dist/{html-derivative-OWRPAN3G.js.map → html-derivative-QY3ZIV7G.js.map} +0 -0
  172. /package/dist/{http-NEPTRAQZ.js.map → http-7ZVVH3VM.js.map} +0 -0
  173. /package/dist/{http-JSPDAWSO.js.map → http-KIGXJYY6.js.map} +0 -0
  174. /package/dist/{hurl-V6ZX2Q3F.js.map → hurl-B6WXEN45.js.map} +0 -0
  175. /package/dist/{hurl-OT2SM4S7.js.map → hurl-BZB5LDD5.js.map} +0 -0
  176. /package/dist/{jinja-CCI3FGLW.js.map → jinja-AEVQQKWS.js.map} +0 -0
  177. /package/dist/{julia-BWWONBRS.js.map → julia-75QR2XDN.js.map} +0 -0
  178. /package/dist/{julia-QPZ7EOS6.js.map → julia-CPV3A4MM.js.map} +0 -0
  179. /package/dist/{liquid-OSRU4KOW.js.map → liquid-S4LVU77Y.js.map} +0 -0
  180. /package/dist/{mdc-PDOFYVVO.js.map → mdc-NDTDGSIG.js.map} +0 -0
  181. /package/dist/{mdc-TEVTGSC7.js.map → mdc-XWCHWP6B.js.map} +0 -0
  182. /package/dist/{mermaid-4DMBBIKO-7EL5WRQI.js.map → mermaid-4DMBBIKO-DV4JRUY5.js.map} +0 -0
  183. /package/dist/{mermaid-4DMBBIKO-PAA57QRQ.js.map → mermaid-4DMBBIKO-IGH2CKFF.js.map} +0 -0
  184. /package/dist/{nim-JPSYX5KC.js.map → nim-U57UBFBS.js.map} +0 -0
  185. /package/dist/{nim-WGQAUAVA.js.map → nim-Z6EEJ7SX.js.map} +0 -0
  186. /package/dist/{perl-Y3ALUOFJ.js.map → perl-5IQEFQG3.js.map} +0 -0
  187. /package/dist/{perl-X4IFZB22.js.map → perl-IZHDGBO6.js.map} +0 -0
  188. /package/dist/{php-3V7EPUAN.js.map → php-MNP62HWP.js.map} +0 -0
  189. /package/dist/{php-QERWOQJG.js.map → php-UQGWKJAF.js.map} +0 -0
  190. /package/dist/{pug-7XNGVJEC.js.map → pug-XHTBJJNO.js.map} +0 -0
  191. /package/dist/{razor-C2NV2YNT.js.map → razor-UMC4HKIF.js.map} +0 -0
  192. /package/dist/{rst-WIWCR2KQ.js.map → rst-6KQSGP2V.js.map} +0 -0
  193. /package/dist/{rst-W5S2XFF7.js.map → rst-HCGHBPBZ.js.map} +0 -0
  194. /package/dist/{ruby-EYYAUQUG.js.map → ruby-ML25RVXY.js.map} +0 -0
  195. /package/dist/{ruby-LXZJUMFB.js.map → ruby-OWE2HOOR.js.map} +0 -0
  196. /package/dist/{soy-G2LDZSDN.js.map → soy-ALTWCQTO.js.map} +0 -0
  197. /package/dist/{svelte-EYZDXUS2.js.map → svelte-6TT7H4YP.js.map} +0 -0
  198. /package/dist/{templ-KXQ2KV7D.js.map → templ-WN3SJLUV.js.map} +0 -0
  199. /package/dist/{ts-tags-TCQ23O6Y.js.map → ts-tags-NAJDOQCO.js.map} +0 -0
  200. /package/dist/{ts-tags-7WGDLEKX.js.map → ts-tags-XNK5N5RZ.js.map} +0 -0
  201. /package/dist/{twig-JAL4753Y.js.map → twig-GIY7NVAA.js.map} +0 -0
  202. /package/dist/{twig-C6YWFFZU.js.map → twig-OEIJ72KK.js.map} +0 -0
  203. /package/dist/{vue-O6SLORWU.js.map → vue-FIH2DYBE.js.map} +0 -0
  204. /package/dist/{vue-D6SXQNWM.js.map → vue-V6GLJNYA.js.map} +0 -0
  205. /package/dist/{vue-vine-T6MFB2MU.js.map → vue-vine-KB45C76H.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as Wr,b as Gr,c as jr,d as wt,e as xt,f as xa,g as zr,h as Vr,i as $r,j as Xr,k as La,l as Kr,m as xo,n as Qr,o as Jr,p as Lt,u as At}from"../chunk-4WLKD7DL.js";import{a as wo,b as hu,c as gu}from"../chunk-R6LESDWJ.js";import{b as Pt,c as gt,d as Hr,e as qr}from"../chunk-PYLRF5BB.js";import{d as f}from"../chunk-LPD7BHH5.js";f();f();f();f();var Ca="text/html+skybridge",Ia="text/html;profile=mcp-app",Zr=async(e,t)=>{let a=e.endsWith("/")?e.slice(0,-1):e;return await(await fetch(`${a}${t}`)).text()};function Yr(e){return{"openai/widgetDescription":e.description,"openai/widgetPrefersBorder":e.prefersBorder,"openai/widgetDomain":e.widgetDomain,...e.widgetCSP&&{"openai/widgetCSP":e.widgetCSP}}}function es(e){let t=e.widgetCSP?{connectDomains:e.widgetCSP.connect_domains,resourceDomains:e.widgetCSP.resource_domains,frameDomains:e.widgetCSP.frame_domains,redirectDomains:e.widgetCSP.redirect_domains}:void 0;return{ui:{...t&&{csp:t},...e.prefersBorder!==void 0&&{prefersBorder:e.prefersBorder}}}}function Lo(e){return{...e.openaiTemplateUri&&{"openai/outputTemplate":e.openaiTemplateUri},"openai/toolInvocation/invoking":e.invoking,"openai/toolInvocation/invoked":e.invoked,"openai/widgetAccessible":!0,"openai/resultCanProduceWidget":!0,...e.mcpTemplateUri&&{ui:{resourceUri:e.mcpTemplateUri,...e.autoHeight&&{autoHeight:!0}}},...e.mcpTemplateUri&&{"ui/resourceUri":e.mcpTemplateUri}}}function ts(e){let{id:t,title:a,description:o,baseUrl:r,htmlPath:s,widgetDomain:n,prefersBorder:i=!0,autoHeight:l=!0}=e,u=e.widgetCSP??{connect_domains:[r],resource_domains:[r]};if(process.env.NODE_ENV==="development")try{let{hostname:L}=new URL(r);(L==="localhost"||L==="127.0.0.1")&&(u={...u,connect_domains:[...u.connect_domains||[],`ws://${L}:*`,`wss://${L}:*`],resource_domains:[...u.resource_domains||[],`http://${L}:*`]})}catch{}let c=`ui://widgets/apps-sdk/${t}.html`,d=`ui://widgets/ext-apps/${t}.html`,p=null,m=()=>(p||(p=Zr(r,s)),p),h=o;async function I(L){let S=await m();L.registerResource(`${t}-openai-widget`,c,{title:a,description:h,mimeType:Ca,_meta:{"openai/widgetDescription":h,"openai/widgetPrefersBorder":i}},async C=>({contents:[{uri:C.href,mimeType:Ca,text:S,_meta:Yr({description:h,prefersBorder:i,widgetDomain:n,widgetCSP:u})}]})),L.registerResource(`${t}-mcp-widget`,d,{title:a,description:h,mimeType:Ia,_meta:{ui:{prefersBorder:i}}},async C=>({contents:[{uri:C.href,mimeType:Ia,text:S,_meta:es({description:h,prefersBorder:i,widgetCSP:u})}]}))}return{id:t,title:a,description:o,openaiUri:c,mcpUri:d,autoHeight:l,register:I}}f();f();f();var wu="waniwani/client";function as(e){if(typeof e=="object"&&e!==null)return e[wu]}function xu(e,t){let{resource:a,description:o,inputSchema:r,annotations:s,autoInjectResultText:n=!0}=e,i=e.id??a?.id,l=e.title??a?.title;if(!i)throw new Error("createTool: `id` is required when no resource is provided");if(!l)throw new Error("createTool: `title` is required when no resource is provided");let u=a?Lo({openaiTemplateUri:a.openaiUri,mcpTemplateUri:a.mcpUri,invoking:e.invoking??"Loading...",invoked:e.invoked??"Loaded",autoHeight:a.autoHeight}):void 0;return{id:i,title:l,description:o,async register(c){c.registerTool(i,{title:l,description:o,inputSchema:r,annotations:s,...u&&{_meta:u}},(async(d,p)=>{let m=p,h=m._meta??{},I=as(m),L=await t(d,{extra:{_meta:h},waniwani:I});return a&&L.data?{content:[{type:"text",text:L.text}],structuredContent:L.data,_meta:{...u,...h,...n===!1?{"waniwani/autoInjectResultText":!1}:{}}}:{content:[{type:"text",text:L.text}],...L.data?{structuredContent:L.data}:{},...n===!1?{_meta:{"waniwani/autoInjectResultText":!1}}:{}}}))}}}async function Lu(e,t){await Promise.all(t.map(a=>a.register(e)))}f();f();import{Fragment as yu,jsx as Rt,jsxs as bu}from"react/jsx-runtime";function Cu(){let e=window.innerBaseUrl,t=window.__wwPassthroughOrigins??[],a=document.documentElement;new MutationObserver(l=>{l.forEach(u=>{if(u.type==="attributes"&&u.target===a){let c=u.attributeName;c&&c!=="suppresshydrationwarning"&&c!=="lang"&&c!=="class"&&c!=="style"&&a.removeAttribute(c)}})}).observe(a,{attributes:!0,attributeOldValue:!0});let r=history.replaceState.bind(history);history.replaceState=(l,u,c)=>{try{let d=new URL(String(c??""),window.location.href);r(null,u,d.pathname+d.search+d.hash)}catch{}};let s=history.pushState.bind(history);history.pushState=(l,u,c)=>{try{let d=new URL(String(c??""),window.location.href);s(null,u,d.pathname+d.search+d.hash)}catch{}};let n=new URL(e).origin,i=window.self!==window.top;if(window.addEventListener("click",l=>{let u=l?.target?.closest("a");if(!u||!u.href)return;let c=new URL(u.href,window.location.href);if(c.origin!==window.location.origin&&c.origin!==n)try{window.openai&&(window.openai?.openExternal({href:u.href}),l.preventDefault())}catch{console.warn("openExternal failed, likely not in OpenAI client")}},!0),i&&window.location.origin!==n){let l=window.fetch;window.fetch=((p,m)=>{let h=typeof p=="string"&&!/^[a-z][a-z0-9+.-]*:/i.test(p)&&!p.startsWith("//"),I;if(typeof p=="string"||p instanceof URL?I=new URL(p,window.location.href):I=new URL(p.url,window.location.href),I.origin===n)return typeof p=="string"||p instanceof URL?p=I.toString():p=new Request(I.toString(),p),l.call(window,p,{...m,mode:"cors"});if(t.indexOf(I.origin)!==-1)return l.call(window,p,m);if(h&&I.origin===window.location.origin){let L=new URL(e);return L.pathname=I.pathname,L.search=I.search,L.hash=I.hash,I=L,p=I.toString(),l.call(window,p,{...m,mode:"cors"})}return l.call(window,p,m)});let u=n.replace(/^http/,"ws"),c=window.WebSocket,d=((p,m)=>{let h=new URL(String(p),window.location.href);if(h.origin===window.location.origin||h.origin===window.location.origin.replace(/^http/,"ws")){let I=new URL(u);return I.pathname=h.pathname,I.search=h.search,I.hash=h.hash,new c(I.toString(),m)}return new c(p,m)});d.prototype=c.prototype,Object.assign(d,{CONNECTING:c.CONNECTING,OPEN:c.OPEN,CLOSING:c.CLOSING,CLOSED:c.CLOSED}),window.WebSocket=d}}var Iu=`(${Cu.toString()})()`;function Su({baseUrl:e,passthroughOrigins:t}){return bu(yu,{children:[Rt("base",{href:e}),Rt("script",{children:`window.innerBaseUrl = ${JSON.stringify(e)}`}),Rt("script",{children:`window.__wwPassthroughOrigins = ${JSON.stringify(t??[])}`}),Rt("script",{children:'window.__isChatGptApp = typeof window.openai !== "undefined";'}),Rt("script",{children:Iu})]})}f();f();import{useCallback as ze,useEffect as Ct,useRef as Co,useState as Oe}from"react";f();var os={theme:"dark",userAgent:{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:"en",maxHeight:800,displayMode:"inline",safeArea:{insets:{top:0,bottom:0,left:0,right:0}},toolInput:{},toolOutput:null,toolResponseMetadata:null,widgetState:null},Mt={...os};function Ft(e){typeof window>"u"||window.openai||(Mt={...os,toolOutput:e??null},window.openai={...Mt,requestDisplayMode:async({mode:t})=>(at("displayMode",t),{mode:t}),callTool:async(t,a)=>(console.log(`[DevMode] callTool: ${t}`,a),{result:JSON.stringify({mock:!0,tool:t,args:a})}),sendFollowUpMessage:async({prompt:t})=>{console.log(`[DevMode] sendFollowUpMessage: ${t}`)},openExternal:({href:t})=>{console.log(`[DevMode] openExternal: ${t}`),window.open(t,"_blank")},setWidgetState:async t=>{at("widgetState",t)}},window.dispatchEvent(new Pt({globals:Mt})))}function at(e,t){typeof window>"u"||!window.openai||(Mt[e]=t,window.openai[e]=t,window.dispatchEvent(new Pt({globals:{[e]:t}})))}function Sa(){return{...Mt}}function Dt(e){at("toolOutput",e)}function Bt(e){at("displayMode",e)}function Et(e){at("theme",e)}import{Fragment as Io,jsx as E,jsxs as $}from"react/jsx-runtime";var ya=150;function rs({className:e}){return $("svg",{className:e,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Dev Controls",children:[E("rect",{x:"4",y:"4",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),E("rect",{x:"10",y:"10",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5",fill:"currentColor",fillOpacity:"0.15"})]})}function ku({className:e}){return E("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:E("path",{d:"M18 6L6 18M6 6l12 12"})})}function Tu({className:e}){return E("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:E("rect",{x:"2",y:"4",width:"12",height:"8",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"})})}function vu({className:e}){return $("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[E("rect",{x:"1.5",y:"3",width:"13",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"}),E("rect",{x:"8.5",y:"7",width:"5",height:"4",rx:"0.75",fill:"currentColor"})]})}function Pu({className:e}){return E("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:E("path",{d:"M2 5.5V3.5C2 2.95 2.45 2.5 3 2.5H5.5M10.5 2.5H13C13.55 2.5 14 2.95 14 3.5V5.5M14 10.5V12.5C14 13.05 13.55 13.5 13 13.5H10.5M5.5 13.5H3C2.45 13.5 2 13.05 2 12.5V10.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function Au({className:e}){return $("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[E("circle",{cx:"8",cy:"8",r:"2.5",stroke:"currentColor",strokeWidth:"1.25"}),E("path",{d:"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.11 4.11l1.06 1.06M10.83 10.83l1.06 1.06M4.11 11.89l1.06-1.06M10.83 5.17l1.06-1.06",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]})}function Ru({className:e}){return E("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:E("path",{d:"M13.5 9.5a5.5 5.5 0 01-7-7 5.5 5.5 0 107 7z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function Mu({className:e}){return $("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[E("path",{d:"M2.5 8a5.5 5.5 0 019.37-3.9M13.5 8a5.5 5.5 0 01-9.37 3.9",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"}),E("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}var Fu=`
1
+ import{a as Io,b as bu,c as ku}from"../chunk-R6LESDWJ.js";import{b as Rt,c as Ct,d as Vr,e as $r}from"../chunk-PYLRF5BB.js";import{a as Xr,b as Kr,c as Qr,d as Jr,e as Zr,f as Sa,g as Yr,h as en,i as tn,j as an,k as So,l as on,m as It,n as St,o as ya,p as yt,u as Mt}from"../chunk-YP6YTC7R.js";import{d as f}from"../chunk-LPD7BHH5.js";f();f();f();f();var ba="text/html+skybridge",ka="text/html;profile=mcp-app",rn=async(e,t)=>{let a=e.endsWith("/")?e.slice(0,-1):e;return await(await fetch(`${a}${t}`)).text()};function nn(e){return{"openai/widgetDescription":e.description,"openai/widgetPrefersBorder":e.prefersBorder,"openai/widgetDomain":e.widgetDomain,...e.widgetCSP&&{"openai/widgetCSP":e.widgetCSP}}}function sn(e){let t=e.widgetCSP?{connectDomains:e.widgetCSP.connect_domains,resourceDomains:e.widgetCSP.resource_domains,frameDomains:e.widgetCSP.frame_domains,redirectDomains:e.widgetCSP.redirect_domains}:void 0;return{ui:{...t&&{csp:t},...e.prefersBorder!==void 0&&{prefersBorder:e.prefersBorder}}}}function yo(e){return{...e.openaiTemplateUri&&{"openai/outputTemplate":e.openaiTemplateUri},"openai/toolInvocation/invoking":e.invoking,"openai/toolInvocation/invoked":e.invoked,"openai/widgetAccessible":!0,"openai/resultCanProduceWidget":!0,...e.mcpTemplateUri&&{ui:{resourceUri:e.mcpTemplateUri,...e.autoHeight&&{autoHeight:!0}}},...e.mcpTemplateUri&&{"ui/resourceUri":e.mcpTemplateUri}}}function ln(e){let{id:t,title:a,description:o,baseUrl:r,htmlPath:n,widgetDomain:s,prefersBorder:i=!0,autoHeight:l=!0}=e,u=e.widgetCSP??{connect_domains:[r],resource_domains:[r]};if(process.env.NODE_ENV==="development")try{let{hostname:L}=new URL(r);(L==="localhost"||L==="127.0.0.1")&&(u={...u,connect_domains:[...u.connect_domains||[],`ws://${L}:*`,`wss://${L}:*`],resource_domains:[...u.resource_domains||[],`http://${L}:*`]})}catch{}let c=`ui://widgets/apps-sdk/${t}.html`,d=`ui://widgets/ext-apps/${t}.html`,p=null,m=()=>(p||(p=rn(r,n)),p),h=o;async function I(L){let S=await m();L.registerResource(`${t}-openai-widget`,c,{title:a,description:h,mimeType:ba,_meta:{"openai/widgetDescription":h,"openai/widgetPrefersBorder":i}},async C=>({contents:[{uri:C.href,mimeType:ba,text:S,_meta:nn({description:h,prefersBorder:i,widgetDomain:s,widgetCSP:u})}]})),L.registerResource(`${t}-mcp-widget`,d,{title:a,description:h,mimeType:ka,_meta:{ui:{prefersBorder:i}}},async C=>({contents:[{uri:C.href,mimeType:ka,text:S,_meta:sn({description:h,prefersBorder:i,widgetCSP:u})}]}))}return{id:t,title:a,description:o,openaiUri:c,mcpUri:d,autoHeight:l,register:I}}f();f();f();var Tu="waniwani/client";function un(e){if(typeof e=="object"&&e!==null)return e[Tu]}function vu(e,t){let{resource:a,description:o,inputSchema:r,annotations:n,autoInjectResultText:s=!0}=e,i=e.id??a?.id,l=e.title??a?.title;if(!i)throw new Error("createTool: `id` is required when no resource is provided");if(!l)throw new Error("createTool: `title` is required when no resource is provided");let u=a?yo({openaiTemplateUri:a.openaiUri,mcpTemplateUri:a.mcpUri,invoking:e.invoking??"Loading...",invoked:e.invoked??"Loaded",autoHeight:a.autoHeight}):void 0;return{id:i,title:l,description:o,async register(c){c.registerTool(i,{title:l,description:o,inputSchema:r,annotations:n,...u&&{_meta:u}},(async(d,p)=>{let m=p,h=m._meta??{},I=un(m),L=await t(d,{extra:{_meta:h},waniwani:I});return a&&L.data?{content:[{type:"text",text:L.text}],structuredContent:L.data,_meta:{...u,...h,...s===!1?{"waniwani/autoInjectResultText":!1}:{}}}:{content:[{type:"text",text:L.text}],...L.data?{structuredContent:L.data}:{},...s===!1?{_meta:{"waniwani/autoInjectResultText":!1}}:{}}}))}}}async function Pu(e,t){await Promise.all(t.map(a=>a.register(e)))}f();f();import{Fragment as Fu,jsx as Ft,jsxs as Du}from"react/jsx-runtime";function Au(){let e=window.innerBaseUrl,t=window.__wwPassthroughOrigins??[],a=document.documentElement;new MutationObserver(l=>{l.forEach(u=>{if(u.type==="attributes"&&u.target===a){let c=u.attributeName;c&&c!=="suppresshydrationwarning"&&c!=="lang"&&c!=="class"&&c!=="style"&&a.removeAttribute(c)}})}).observe(a,{attributes:!0,attributeOldValue:!0});let r=history.replaceState.bind(history);history.replaceState=(l,u,c)=>{try{let d=new URL(String(c??""),window.location.href);r(null,u,d.pathname+d.search+d.hash)}catch{}};let n=history.pushState.bind(history);history.pushState=(l,u,c)=>{try{let d=new URL(String(c??""),window.location.href);n(null,u,d.pathname+d.search+d.hash)}catch{}};let s=new URL(e).origin,i=window.self!==window.top;if(window.addEventListener("click",l=>{let u=l?.target?.closest("a");if(!u||!u.href)return;let c=new URL(u.href,window.location.href);if(c.origin!==window.location.origin&&c.origin!==s)try{window.openai&&(window.openai?.openExternal({href:u.href}),l.preventDefault())}catch{console.warn("openExternal failed, likely not in OpenAI client")}},!0),i&&window.location.origin!==s){let l=window.fetch;window.fetch=((p,m)=>{let h=typeof p=="string"&&!/^[a-z][a-z0-9+.-]*:/i.test(p)&&!p.startsWith("//"),I;if(typeof p=="string"||p instanceof URL?I=new URL(p,window.location.href):I=new URL(p.url,window.location.href),I.origin===s)return typeof p=="string"||p instanceof URL?p=I.toString():p=new Request(I.toString(),p),l.call(window,p,{...m,mode:"cors"});if(t.indexOf(I.origin)!==-1)return l.call(window,p,m);if(h&&I.origin===window.location.origin){let L=new URL(e);return L.pathname=I.pathname,L.search=I.search,L.hash=I.hash,I=L,p=I.toString(),l.call(window,p,{...m,mode:"cors"})}return l.call(window,p,m)});let u=s.replace(/^http/,"ws"),c=window.WebSocket,d=((p,m)=>{let h=new URL(String(p),window.location.href);if(h.origin===window.location.origin||h.origin===window.location.origin.replace(/^http/,"ws")){let I=new URL(u);return I.pathname=h.pathname,I.search=h.search,I.hash=h.hash,new c(I.toString(),m)}return new c(p,m)});d.prototype=c.prototype,Object.assign(d,{CONNECTING:c.CONNECTING,OPEN:c.OPEN,CLOSING:c.CLOSING,CLOSED:c.CLOSED}),window.WebSocket=d}}var Ru=`(${Au.toString()})()`;function Mu({baseUrl:e,passthroughOrigins:t}){return Du(Fu,{children:[Ft("base",{href:e}),Ft("script",{children:`window.innerBaseUrl = ${JSON.stringify(e)}`}),Ft("script",{children:`window.__wwPassthroughOrigins = ${JSON.stringify(t??[])}`}),Ft("script",{children:'window.__isChatGptApp = typeof window.openai !== "undefined";'}),Ft("script",{children:Ru})]})}f();f();import{useCallback as Ve,useEffect as bt,useRef as bo,useState as Ue}from"react";f();var dn={theme:"dark",userAgent:{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:"en",maxHeight:800,displayMode:"inline",safeArea:{insets:{top:0,bottom:0,left:0,right:0}},toolInput:{},toolOutput:null,toolResponseMetadata:null,widgetState:null},Dt={...dn};function Bt(e){typeof window>"u"||window.openai||(Dt={...dn,toolOutput:e??null},window.openai={...Dt,requestDisplayMode:async({mode:t})=>(rt("displayMode",t),{mode:t}),callTool:async(t,a)=>(console.log(`[DevMode] callTool: ${t}`,a),{result:JSON.stringify({mock:!0,tool:t,args:a})}),sendFollowUpMessage:async({prompt:t})=>{console.log(`[DevMode] sendFollowUpMessage: ${t}`)},openExternal:({href:t})=>{console.log(`[DevMode] openExternal: ${t}`),window.open(t,"_blank")},setWidgetState:async t=>{rt("widgetState",t)}},window.dispatchEvent(new Rt({globals:Dt})))}function rt(e,t){typeof window>"u"||!window.openai||(Dt[e]=t,window.openai[e]=t,window.dispatchEvent(new Rt({globals:{[e]:t}})))}function Ta(){return{...Dt}}function Et(e){rt("toolOutput",e)}function _t(e){rt("displayMode",e)}function Nt(e){rt("theme",e)}import{Fragment as ko,jsx as E,jsxs as Q}from"react/jsx-runtime";var va=150;function cn({className:e}){return Q("svg",{className:e,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Dev Controls",children:[E("rect",{x:"4",y:"4",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),E("rect",{x:"10",y:"10",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5",fill:"currentColor",fillOpacity:"0.15"})]})}function Bu({className:e}){return E("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:E("path",{d:"M18 6L6 18M6 6l12 12"})})}function Eu({className:e}){return E("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:E("rect",{x:"2",y:"4",width:"12",height:"8",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"})})}function _u({className:e}){return Q("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[E("rect",{x:"1.5",y:"3",width:"13",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"}),E("rect",{x:"8.5",y:"7",width:"5",height:"4",rx:"0.75",fill:"currentColor"})]})}function Nu({className:e}){return E("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:E("path",{d:"M2 5.5V3.5C2 2.95 2.45 2.5 3 2.5H5.5M10.5 2.5H13C13.55 2.5 14 2.95 14 3.5V5.5M14 10.5V12.5C14 13.05 13.55 13.5 13 13.5H10.5M5.5 13.5H3C2.45 13.5 2 13.05 2 12.5V10.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ou({className:e}){return Q("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[E("circle",{cx:"8",cy:"8",r:"2.5",stroke:"currentColor",strokeWidth:"1.25"}),E("path",{d:"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.11 4.11l1.06 1.06M10.83 10.83l1.06 1.06M4.11 11.89l1.06-1.06M10.83 5.17l1.06-1.06",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]})}function Uu({className:e}){return E("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:E("path",{d:"M13.5 9.5a5.5 5.5 0 01-7-7 5.5 5.5 0 107 7z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function Hu({className:e}){return Q("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[E("path",{d:"M2.5 8a5.5 5.5 0 019.37-3.9M13.5 8a5.5 5.5 0 01-9.37 3.9",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"}),E("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}var qu=`
2
2
  @keyframes devPanelSlideIn {
3
3
  0% {
4
4
  opacity: 0;
@@ -46,28 +46,28 @@ import{a as Wr,b as Gr,c as jr,d as wt,e as xt,f as xa,g as zr,h as Vr,i as $r,j
46
46
  .dev-json-editor::-webkit-scrollbar-thumb:hover {
47
47
  background: rgba(255, 255, 255, 0.15);
48
48
  }
49
- `;function ns({defaultProps:e,widgetPaths:t,children:a}){let[o,r]=Oe(!1),[s,n]=Oe(!1);return Ct(()=>{if(new URLSearchParams(window.location.search).get("platform")==="mcp-apps"){r(!0);return}if(t&&t.length>0){let l=window.location.pathname,u=t.some(c=>l===c||l.startsWith(`${c}/`));n(u),u&&Ft(e)}else Ft(e),n(!0);r(!0)},[e,t]),o?s?$(Io,{children:[E(Du,{children:a}),E(Bu,{defaultProps:e})]}):E(Io,{children:a}):null}function Du({children:e}){return E("div",{className:"min-h-screen bg-[#212121] flex items-center justify-center p-8",children:E("div",{className:"relative w-full max-w-md overflow-hidden rounded-2xl sm:rounded-3xl border border-[#414141]",style:{boxShadow:"0px 0px 0px 1px #414141, 0px 4px 14px rgba(0,0,0,0.24)"},children:e})})}function ss({options:e,value:t,onChange:a}){let o=e.findIndex(r=>r.value===t);return $("div",{className:"relative flex p-0.5 rounded-lg",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:[E("div",{className:"absolute top-0.5 bottom-0.5 rounded-md transition-transform duration-150 ease-out",style:{width:`calc(${100/e.length}% - 2px)`,left:"2px",transform:`translateX(calc(${o*100}% + ${o*2}px))`,background:"rgba(255, 255, 255, 0.1)"}}),e.map(r=>$("button",{type:"button",onClick:()=>a(r.value),className:`
49
+ `;function pn({defaultProps:e,widgetPaths:t,children:a}){let[o,r]=Ue(!1),[n,s]=Ue(!1);return bt(()=>{if(new URLSearchParams(window.location.search).get("platform")==="mcp-apps"){r(!0);return}if(t&&t.length>0){let l=window.location.pathname,u=t.some(c=>l===c||l.startsWith(`${c}/`));s(u),u&&Bt(e)}else Bt(e),s(!0);r(!0)},[e,t]),o?n?Q(ko,{children:[E(Wu,{children:a}),E(Gu,{defaultProps:e})]}):E(ko,{children:a}):null}function Wu({children:e}){return E("div",{className:"min-h-screen bg-[#212121] flex items-center justify-center p-8",children:E("div",{className:"relative w-full max-w-md overflow-hidden rounded-2xl sm:rounded-3xl border border-[#414141]",style:{boxShadow:"0px 0px 0px 1px #414141, 0px 4px 14px rgba(0,0,0,0.24)"},children:e})})}function fn({options:e,value:t,onChange:a}){let o=e.findIndex(r=>r.value===t);return Q("div",{className:"relative flex p-0.5 rounded-lg",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:[E("div",{className:"absolute top-0.5 bottom-0.5 rounded-md transition-transform duration-150 ease-out",style:{width:`calc(${100/e.length}% - 2px)`,left:"2px",transform:`translateX(calc(${o*100}% + ${o*2}px))`,background:"rgba(255, 255, 255, 0.1)"}}),e.map(r=>Q("button",{type:"button",onClick:()=>a(r.value),className:`
50
50
  relative z-10 flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5
51
51
  text-xs font-medium rounded-md transition-colors duration-150
52
52
  ${t===r.value?"text-white":"text-gray-400 hover:text-gray-300"}
53
- `,children:[r.icon,E("span",{className:"capitalize",children:r.label})]},r.value))]})}function Bu({defaultProps:e}){let[t,a]=Oe(()=>typeof window>"u"?!1:localStorage.getItem("dev-controls-open")==="true"),[o,r]=Oe(!1),[s,n]=Oe(t),[i,l]=Oe("inline"),[u,c]=Oe("dark"),[d,p]=Oe(!1),[m,h]=Oe(()=>JSON.stringify(e??{},null,2)),[I,L]=Oe(null),S=Co(null),C=Co(null),g=Co(null);Ct(()=>{let F=Sa();l(F.displayMode),c(F.theme)},[]),Ct(()=>{typeof window>"u"||(window.openai||(window.openai={}),window.openai.safeArea={insets:{top:0,bottom:d?ya:0,left:0,right:0}},window.dispatchEvent(new Pt({globals:{safeArea:window.openai.safeArea}})))},[d]),Ct(()=>{localStorage.setItem("dev-controls-open",String(t))},[t]);let b=ze(()=>{n(!0),requestAnimationFrame(()=>{a(!0)})},[]),P=ze(()=>{r(!0),a(!1),setTimeout(()=>{n(!1),r(!1)},150)},[]),A=ze(()=>{t?P():b()},[t,b,P]);Ct(()=>{let F=Q=>{(Q.metaKey||Q.ctrlKey)&&Q.shiftKey&&Q.key==="d"&&(Q.preventDefault(),A()),Q.key==="Escape"&&t&&P()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[t,A,P]),Ct(()=>{if(!t)return;let F=Q=>{g.current&&!g.current.contains(Q.target)&&P()};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[t,P]);let v=ze(F=>{l(F),Bt(F)},[]),R=ze(F=>{c(F),Et(F)},[]),_=ze(F=>{try{let Q=JSON.parse(F);L(null),Dt(Q)}catch{L("Invalid JSON")}},[]),M=ze(F=>{h(F),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{_(F)},500)},[_]),T=ze(()=>{S.current&&clearTimeout(S.current),_(m)},[_,m]),y=ze(()=>{let F=JSON.stringify(e??{},null,2);h(F),L(null),Dt(e??{}),l("inline"),Bt("inline"),c("dark"),Et("dark")},[e]),B=[{value:"inline",label:"inline",icon:E(Tu,{className:"w-3.5 h-3.5"})},{value:"pip",label:"pip",icon:E(vu,{className:"w-3.5 h-3.5"})},{value:"fullscreen",label:"full",icon:E(Pu,{className:"w-3.5 h-3.5"})}],U=[{value:"light",label:"light",icon:E(Au,{className:"w-3.5 h-3.5"})},{value:"dark",label:"dark",icon:E(Ru,{className:"w-3.5 h-3.5"})}];return $(Io,{children:[E("style",{dangerouslySetInnerHTML:{__html:Fu}}),$("div",{ref:g,className:"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]",children:[$("button",{type:"button",onClick:A,className:"group relative flex items-center justify-center w-11 h-11 rounded-xl transition-all duration-200 ease-out hover:scale-105 active:scale-95",style:{background:"rgba(14, 14, 16, 0.95)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid rgba(255, 255, 255, 0.08)",boxShadow:`
53
+ `,children:[r.icon,E("span",{className:"capitalize",children:r.label})]},r.value))]})}function Gu({defaultProps:e}){let[t,a]=Ue(()=>typeof window>"u"?!1:localStorage.getItem("dev-controls-open")==="true"),[o,r]=Ue(!1),[n,s]=Ue(t),[i,l]=Ue("inline"),[u,c]=Ue("dark"),[d,p]=Ue(!1),[m,h]=Ue(()=>JSON.stringify(e??{},null,2)),[I,L]=Ue(null),S=bo(null),C=bo(null),g=bo(null);bt(()=>{let v=Ta();l(v.displayMode),c(v.theme)},[]),bt(()=>{typeof window>"u"||(window.openai||(window.openai={}),window.openai.safeArea={insets:{top:0,bottom:d?va:0,left:0,right:0}},window.dispatchEvent(new Rt({globals:{safeArea:window.openai.safeArea}})))},[d]),bt(()=>{localStorage.setItem("dev-controls-open",String(t))},[t]);let y=Ve(()=>{s(!0),requestAnimationFrame(()=>{a(!0)})},[]),A=Ve(()=>{r(!0),a(!1),setTimeout(()=>{s(!1),r(!1)},150)},[]),R=Ve(()=>{t?A():y()},[t,y,A]);bt(()=>{let v=q=>{(q.metaKey||q.ctrlKey)&&q.shiftKey&&q.key==="d"&&(q.preventDefault(),R()),q.key==="Escape"&&t&&A()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[t,R,A]),bt(()=>{if(!t)return;let v=q=>{g.current&&!g.current.contains(q.target)&&A()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[t,A]);let P=Ve(v=>{l(v),_t(v)},[]),M=Ve(v=>{c(v),Nt(v)},[]),N=Ve(v=>{try{let q=JSON.parse(v);L(null),Et(q)}catch{L("Invalid JSON")}},[]),D=Ve(v=>{h(v),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{N(v)},500)},[N]),_=Ve(()=>{S.current&&clearTimeout(S.current),N(m)},[N,m]),T=Ve(()=>{let v=JSON.stringify(e??{},null,2);h(v),L(null),Et(e??{}),l("inline"),_t("inline"),c("dark"),Nt("dark")},[e]),B=[{value:"inline",label:"inline",icon:E(Eu,{className:"w-3.5 h-3.5"})},{value:"pip",label:"pip",icon:E(_u,{className:"w-3.5 h-3.5"})},{value:"fullscreen",label:"full",icon:E(Nu,{className:"w-3.5 h-3.5"})}],k=[{value:"light",label:"light",icon:E(Ou,{className:"w-3.5 h-3.5"})},{value:"dark",label:"dark",icon:E(Uu,{className:"w-3.5 h-3.5"})}];return Q(ko,{children:[E("style",{dangerouslySetInnerHTML:{__html:qu}}),Q("div",{ref:g,className:"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]",children:[Q("button",{type:"button",onClick:R,className:"group relative flex items-center justify-center w-11 h-11 rounded-xl transition-all duration-200 ease-out hover:scale-105 active:scale-95",style:{background:"rgba(14, 14, 16, 0.95)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid rgba(255, 255, 255, 0.08)",boxShadow:`
54
54
  0 4px 12px rgba(0, 0, 0, 0.4),
55
55
  0 0 0 1px rgba(255, 255, 255, 0.05),
56
56
  inset 0 1px 0 rgba(255, 255, 255, 0.04)
57
- `},"aria-label":"Toggle Dev Controls","aria-expanded":t,children:[E(rs,{className:`w-5 h-5 transition-all duration-200 ${t?"text-indigo-400 scale-110":"text-gray-300 group-hover:text-white"}`}),E("div",{className:"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",style:{background:"radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%)"}})]}),s&&$("div",{ref:C,className:`absolute bottom-14 right-0 w-80 ${t&&!o?"dev-panel-enter":"dev-panel-exit"}`,style:{maxHeight:"calc(100vh - 120px)",background:"rgba(14, 14, 16, 0.92)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",border:"1px solid rgba(255, 255, 255, 0.06)",borderRadius:"16px",boxShadow:`
57
+ `},"aria-label":"Toggle Dev Controls","aria-expanded":t,children:[E(cn,{className:`w-5 h-5 transition-all duration-200 ${t?"text-indigo-400 scale-110":"text-gray-300 group-hover:text-white"}`}),E("div",{className:"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",style:{background:"radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%)"}})]}),n&&Q("div",{ref:C,className:`absolute bottom-14 right-0 w-80 ${t&&!o?"dev-panel-enter":"dev-panel-exit"}`,style:{maxHeight:"calc(100vh - 120px)",background:"rgba(14, 14, 16, 0.92)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",border:"1px solid rgba(255, 255, 255, 0.06)",borderRadius:"16px",boxShadow:`
58
58
  0 25px 50px -12px rgba(0, 0, 0, 0.6),
59
59
  0 0 0 1px rgba(255, 255, 255, 0.05),
60
60
  inset 0 1px 0 rgba(255, 255, 255, 0.04)
61
- `},children:[$("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[$("div",{className:"flex items-center gap-2",children:[E(rs,{className:"w-4 h-4 text-gray-400"}),E("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),$("div",{className:"flex items-center gap-2",children:[E("span",{className:"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:typeof navigator<"u"&&navigator.platform?.includes("Mac")?"\u2318\u21E7D":"Ctrl+Shift+D"}),E("button",{type:"button",onClick:P,className:"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:E(ku,{className:"w-4 h-4"})})]})]}),$("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[$("div",{children:[E("label",{htmlFor:"display-mode",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Display Mode"}),E(ss,{options:B,value:i,onChange:v})]}),$("div",{children:[E("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),E(ss,{options:U,value:u,onChange:R})]}),$("div",{children:[E("label",{htmlFor:"safe-area",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Safe Area (Chat Input)"}),$("button",{type:"button",onClick:()=>p(!d),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${d?"text-emerald-400":"text-gray-400"}`,style:{background:d?"rgba(34, 197, 94, 0.1)":"rgba(255, 255, 255, 0.04)",border:d?"1px solid rgba(34, 197, 94, 0.3)":"1px solid rgba(255, 255, 255, 0.06)"},children:[E("span",{children:"Mock ChatGPT Input Bar"}),E("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold ${d?"bg-emerald-500/20 text-emerald-400":"bg-gray-500/20 text-gray-500"}`,children:d?"ON":"OFF"})]}),d&&$("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",ya,"px"]})]}),$("div",{children:[E("label",{htmlFor:"widget-props",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Widget Props"}),E("textarea",{value:m,onChange:F=>M(F.target.value),onBlur:T,className:"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors",style:{background:"rgba(0, 0, 0, 0.3)",border:I?"1px solid rgba(239, 68, 68, 0.5)":"1px solid rgba(255, 255, 255, 0.06)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",lineHeight:1.6},onFocus:F=>{I||(F.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:F=>{I||(F.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),I&&$("p",{className:"text-red-400 text-[11px] mt-1.5 flex items-center gap-1",children:[E("svg",{"aria-hidden":"true","aria-label":"Error",className:"w-3 h-3",viewBox:"0 0 16 16",fill:"currentColor",children:E("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"})}),I]})]}),$("button",{type:"button",onClick:y,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-gray-400 transition-all duration-150 hover:text-gray-200",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},onMouseEnter:F=>{F.currentTarget.style.background="rgba(255, 255, 255, 0.08)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.1)"},onMouseLeave:F=>{F.currentTarget.style.background="rgba(255, 255, 255, 0.04)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)"},children:[E(Mu,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),d&&$("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${ya}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[$("div",{className:"w-full max-w-2xl mx-4 px-4 py-3 rounded-2xl bg-[#2f2f2f] border border-[#424242] flex items-center gap-3",children:[E("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:E("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:E("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),E("div",{className:"flex-1 text-gray-400 text-sm",children:"Ask me anything..."}),E("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:E("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:E("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]}),$("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",ya,"px"]})]})]})}f();f();import{useCallback as _u,useContext as Nu,useLayoutEffect as Ou,useMemo as Uu,useRef as is}from"react";f();import{createContext as Eu}from"react";var _t=Eu(null);import{Fragment as ls,jsx as So}from"react/jsx-runtime";var Hu="waniwani:send-follow-up:advanced:",qu=1e4;function us(e){return`${Hu}${e??"default"}`}function Wu(e){try{let t=globalThis.localStorage?.getItem(us(e));if(!t)return null;let a=JSON.parse(t);return typeof a?.at!="number"||typeof a?.byMountId!="string"?null:a}catch{return null}}function Gu(e,t){try{globalThis.localStorage?.setItem(us(e),JSON.stringify({at:Date.now(),byMountId:t}))}catch{}}function yo(){return typeof window>"u"?!1:typeof window.openai=="object"}function ju(){return yo()?window.openai:null}function zu(){return Ou(()=>{let e=document.documentElement,t=document.body,a=e.getAttribute("style"),o=t.getAttribute("style"),r="margin:0!important;padding:0!important;border:0!important;background:transparent!important;background-color:transparent!important;height:0!important;min-height:0!important;max-height:0!important;overflow:hidden!important;";return e.setAttribute("style",r),t.setAttribute("style",r),()=>{a===null?e.removeAttribute("style"):e.setAttribute("style",a),o===null?t.removeAttribute("style"):t.setAttribute("style",o)}},[]),null}function ds(e){let t=Nu(_t),a=is(e);a.current=e;let o=t?.getToolResponseMetadata?.()??null,r=ju()?.toolResponseMetadata??null,s=o??r,n=s&&typeof s.viewUUID=="string"?s.viewUUID:void 0,i=is("");i.current===""&&(i.current=crypto.randomUUID());let l=_u((c,d)=>{yo()&&Gu(n,i.current);try{Promise.resolve(a.current(c)).catch(p=>{console.error("[unstable_useSendFollowUpWithGhostGuard]",p)})}catch(p){console.error("[unstable_useSendFollowUpWithGhostGuard]",p)}},[n]),u=Uu(()=>{let c=i.current;return function({children:p}){if(!yo())return So(ls,{children:p});let m=Wu(n);return m&&m.byMountId!==c&&Date.now()-m.at<qu?So(zu,{}):So(ls,{children:p})}},[n]);return{sendFollowUp:l,Guard:u}}f();import{useCallback as Xu}from"react";f();import Nt,{useCallback as fs,useContext as Vu,useEffect as ps,useState as bo,useSyncExternalStore as $u}from"react";f();async function cs(){let{detectPlatform:e}=await import("../platform-ZNBJH5XX.js");if(e()==="openai"){let{OpenAIWidgetClient:a}=await import("../openai-client-XYLENCIC.js");return new a}else{let{MCPAppsWidgetClient:a}=await import("../mcp-apps-client-RY3VD4L7.js");return new a}}function ms({children:e,loading:t=null,onError:a}){let[o,r]=bo(null),[s,n]=bo(null),[i,l]=bo(!0);return ps(()=>{let u=!0,c=null;async function d(){try{let p=await cs();await p.connect(),u?(c=p,r(p),l(!1)):p.close()}catch(p){u&&(console.error("error",p),n(p instanceof Error?p:new Error(String(p))),l(!1))}}return d(),()=>{u=!1,c?.close()}},[]),ps(()=>{if(!o)return;let u=c=>{document.documentElement.classList.toggle("dark",c==="dark"),document.documentElement.style.colorScheme=c==="dark"?"dark":"auto"};return u(o.getTheme()),o.onThemeChange(u)},[o]),s&&a?Nt.createElement(Nt.Fragment,null,a(s)):i||!o?Nt.createElement(Nt.Fragment,null,t):Nt.createElement(_t.Provider,{value:o},e)}function W(e){let t=Vu(_t);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let a=fs(s=>e==="toolOutput"?t.onToolResult(()=>s()):e==="theme"?t.onThemeChange(()=>s()):e==="displayMode"?t.onDisplayModeChange(()=>s()):e==="safeArea"?t.onSafeAreaChange(()=>s()):e==="maxHeight"?t.onMaxHeightChange(()=>s()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>s()):e==="widgetState"?t.onWidgetStateChange(()=>s()):()=>{},[t,e]),o=fs(()=>e==="toolOutput"?t.getToolOutput():e==="theme"?t.getTheme():e==="displayMode"?t.getDisplayMode():e==="locale"?t.getLocale():e==="safeArea"?t.getSafeArea():e==="maxHeight"?t.getMaxHeight():e==="toolResponseMetadata"?t.getToolResponseMetadata():e==="widgetState"?t.getWidgetState():null,[t,e]),r=$u(a,o,o);return e?r:t}function hs(){let e=W();return Xu((t,a)=>e.callTool(t,a),[e])}f();function gs(){return W("displayMode")}f();f();function ba(){return W("toolOutput")}function ws(){return{data:ba()}}f();import{useSyncExternalStore as Ku}from"react";function xs(){return Ku(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}f();function Ls(){return W("locale")}f();function Cs(){return W("maxHeight")}f();import{useCallback as Qu}from"react";function Is(){let e=W();return Qu(t=>e.openExternal(t),[e])}f();import{useCallback as Ju}from"react";function Ss(){let e=W();return Ju(t=>e.requestDisplayMode(t),[e])}f();function ys(){return W("safeArea")}f();import{useCallback as Zu}from"react";function bs(){let e=W();return Zu((t,a)=>{(async()=>{gt(a?.modelContext)&&await Promise.resolve(e.updateModelContext(a.modelContext)),await Promise.resolve(e.sendFollowUp(t))})().catch(o=>{console.error("Failed to send follow-up message:",o)})},[e])}f();function ks(){return W("theme")}f();function Ts(){return W("toolResponseMetadata")}f();import{useCallback as Yu}from"react";function vs(){let e=W();return Yu(async t=>{await Promise.resolve(e.updateModelContext(t))},[e])}f();import{useCallback as ed,useEffect as td,useState as ad}from"react";function Ps(e){let t=W("widgetState"),[a,o]=ad(()=>t??(typeof e=="function"?e():e??null));td(()=>{o(t)},[t]);let r=ed(s=>{o(n=>{let i=typeof s=="function"?s(n):s;return wo()==="openai"&&i!=null&&window.openai?.setWidgetState(i),i})},[]);return[a,r]}f();import{jsx as ot,jsxs as As}from"react/jsx-runtime";var od=()=>As("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[As("div",{className:"flex gap-2",children:[ot("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),ot("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),ot("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),ot("p",{className:"text-sm font-medium text-transparent bg-clip-text bg-gradient-to-r from-slate-400 via-slate-200 to-slate-400 bg-[length:200%_100%] animate-[shimmer_1.5s_ease-in-out_infinite]",children:"Loading widget..."}),ot("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:ot("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),ot("style",{children:`
61
+ `},children:[Q("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[Q("div",{className:"flex items-center gap-2",children:[E(cn,{className:"w-4 h-4 text-gray-400"}),E("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),Q("div",{className:"flex items-center gap-2",children:[E("span",{className:"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:typeof navigator<"u"&&navigator.platform?.includes("Mac")?"\u2318\u21E7D":"Ctrl+Shift+D"}),E("button",{type:"button",onClick:A,className:"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:E(Bu,{className:"w-4 h-4"})})]})]}),Q("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[Q("div",{children:[E("label",{htmlFor:"display-mode",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Display Mode"}),E(fn,{options:B,value:i,onChange:P})]}),Q("div",{children:[E("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),E(fn,{options:k,value:u,onChange:M})]}),Q("div",{children:[E("label",{htmlFor:"safe-area",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Safe Area (Chat Input)"}),Q("button",{type:"button",onClick:()=>p(!d),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${d?"text-emerald-400":"text-gray-400"}`,style:{background:d?"rgba(34, 197, 94, 0.1)":"rgba(255, 255, 255, 0.04)",border:d?"1px solid rgba(34, 197, 94, 0.3)":"1px solid rgba(255, 255, 255, 0.06)"},children:[E("span",{children:"Mock ChatGPT Input Bar"}),E("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold ${d?"bg-emerald-500/20 text-emerald-400":"bg-gray-500/20 text-gray-500"}`,children:d?"ON":"OFF"})]}),d&&Q("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",va,"px"]})]}),Q("div",{children:[E("label",{htmlFor:"widget-props",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Widget Props"}),E("textarea",{value:m,onChange:v=>D(v.target.value),onBlur:_,className:"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors",style:{background:"rgba(0, 0, 0, 0.3)",border:I?"1px solid rgba(239, 68, 68, 0.5)":"1px solid rgba(255, 255, 255, 0.06)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",lineHeight:1.6},onFocus:v=>{I||(v.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:v=>{I||(v.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),I&&Q("p",{className:"text-red-400 text-[11px] mt-1.5 flex items-center gap-1",children:[E("svg",{"aria-hidden":"true","aria-label":"Error",className:"w-3 h-3",viewBox:"0 0 16 16",fill:"currentColor",children:E("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"})}),I]})]}),Q("button",{type:"button",onClick:T,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-gray-400 transition-all duration-150 hover:text-gray-200",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},onMouseEnter:v=>{v.currentTarget.style.background="rgba(255, 255, 255, 0.08)",v.currentTarget.style.borderColor="rgba(255, 255, 255, 0.1)"},onMouseLeave:v=>{v.currentTarget.style.background="rgba(255, 255, 255, 0.04)",v.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)"},children:[E(Hu,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),d&&Q("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${va}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[Q("div",{className:"w-full max-w-2xl mx-4 px-4 py-3 rounded-2xl bg-[#2f2f2f] border border-[#424242] flex items-center gap-3",children:[E("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:E("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:E("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),E("div",{className:"flex-1 text-gray-400 text-sm",children:"Ask me anything..."}),E("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:E("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:E("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]}),Q("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",va,"px"]})]})]})}f();f();import{useCallback as zu,useContext as Vu,useLayoutEffect as $u,useMemo as Xu,useRef as mn}from"react";f();import{createContext as ju}from"react";var Ot=ju(null);import{Fragment as hn,jsx as To}from"react/jsx-runtime";var Ku="waniwani:send-follow-up:advanced:",Qu=1e4;function gn(e){return`${Ku}${e??"default"}`}function Ju(e){try{let t=globalThis.localStorage?.getItem(gn(e));if(!t)return null;let a=JSON.parse(t);return typeof a?.at!="number"||typeof a?.byMountId!="string"?null:a}catch{return null}}function Zu(e,t){try{globalThis.localStorage?.setItem(gn(e),JSON.stringify({at:Date.now(),byMountId:t}))}catch{}}function vo(){return typeof window>"u"?!1:typeof window.openai=="object"}function Yu(){return vo()?window.openai:null}function ed(){return $u(()=>{let e=document.documentElement,t=document.body,a=e.getAttribute("style"),o=t.getAttribute("style"),r="margin:0!important;padding:0!important;border:0!important;background:transparent!important;background-color:transparent!important;height:0!important;min-height:0!important;max-height:0!important;overflow:hidden!important;";return e.setAttribute("style",r),t.setAttribute("style",r),()=>{a===null?e.removeAttribute("style"):e.setAttribute("style",a),o===null?t.removeAttribute("style"):t.setAttribute("style",o)}},[]),null}function wn(e){let t=Vu(Ot),a=mn(e);a.current=e;let o=t?.getToolResponseMetadata?.()??null,r=Yu()?.toolResponseMetadata??null,n=o??r,s=n&&typeof n.viewUUID=="string"?n.viewUUID:void 0,i=mn("");i.current===""&&(i.current=crypto.randomUUID());let l=zu((c,d)=>{vo()&&Zu(s,i.current);try{Promise.resolve(a.current(c)).catch(p=>{console.error("[unstable_useSendFollowUpWithGhostGuard]",p)})}catch(p){console.error("[unstable_useSendFollowUpWithGhostGuard]",p)}},[s]),u=Xu(()=>{let c=i.current;return function({children:p}){if(!vo())return To(hn,{children:p});let m=Ju(s);return m&&m.byMountId!==c&&Date.now()-m.at<Qu?To(ed,{}):To(hn,{children:p})}},[s]);return{sendFollowUp:l,Guard:u}}f();import{useCallback as od}from"react";f();import Ut,{useCallback as Ln,useContext as td,useEffect as Cn,useState as Po,useSyncExternalStore as ad}from"react";f();async function xn(){let{detectPlatform:e}=await import("../platform-ZNBJH5XX.js");if(e()==="openai"){let{OpenAIWidgetClient:a}=await import("../openai-client-VRJPAPFR.js");return new a}else{let{MCPAppsWidgetClient:a}=await import("../mcp-apps-client-Z5ICFYSR.js");return new a}}function In({children:e,loading:t=null,onError:a}){let[o,r]=Po(null),[n,s]=Po(null),[i,l]=Po(!0);return Cn(()=>{let u=!0,c=null;async function d(){try{let p=await xn();await p.connect(),u?(c=p,r(p),l(!1)):p.close()}catch(p){u&&(console.error("error",p),s(p instanceof Error?p:new Error(String(p))),l(!1))}}return d(),()=>{u=!1,c?.close()}},[]),Cn(()=>{if(!o)return;let u=c=>{document.documentElement.classList.toggle("dark",c==="dark"),document.documentElement.style.colorScheme=c==="dark"?"dark":"auto"};return u(o.getTheme()),o.onThemeChange(u)},[o]),n&&a?Ut.createElement(Ut.Fragment,null,a(n)):i||!o?Ut.createElement(Ut.Fragment,null,t):Ut.createElement(Ot.Provider,{value:o},e)}function j(e){let t=td(Ot);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let a=Ln(n=>e==="toolOutput"?t.onToolResult(()=>n()):e==="theme"?t.onThemeChange(()=>n()):e==="displayMode"?t.onDisplayModeChange(()=>n()):e==="safeArea"?t.onSafeAreaChange(()=>n()):e==="maxHeight"?t.onMaxHeightChange(()=>n()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>n()):e==="widgetState"?t.onWidgetStateChange(()=>n()):()=>{},[t,e]),o=Ln(()=>e==="toolOutput"?t.getToolOutput():e==="theme"?t.getTheme():e==="displayMode"?t.getDisplayMode():e==="locale"?t.getLocale():e==="safeArea"?t.getSafeArea():e==="maxHeight"?t.getMaxHeight():e==="toolResponseMetadata"?t.getToolResponseMetadata():e==="widgetState"?t.getWidgetState():null,[t,e]),r=ad(a,o,o);return e?r:t}function Sn(){let e=j();return od((t,a)=>e.callTool(t,a),[e])}f();function yn(){return j("displayMode")}f();f();function Pa(){return j("toolOutput")}function bn(){return{data:Pa()}}f();import{useSyncExternalStore as rd}from"react";function kn(){return rd(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}f();function Tn(){return j("locale")}f();function vn(){return j("maxHeight")}f();import{useCallback as nd}from"react";function Pn(){let e=j();return nd(t=>e.openExternal(t),[e])}f();import{useCallback as sd}from"react";function An(){let e=j();return sd(t=>e.requestDisplayMode(t),[e])}f();function Rn(){return j("safeArea")}f();import{useCallback as id}from"react";function Mn(){let e=j();return id((t,a)=>{(async()=>{Ct(a?.modelContext)&&await Promise.resolve(e.updateModelContext(a.modelContext)),await Promise.resolve(e.sendFollowUp(t))})().catch(o=>{console.error("Failed to send follow-up message:",o)})},[e])}f();function Fn(){return j("theme")}f();function Dn(){return j("toolResponseMetadata")}f();import{useCallback as ld}from"react";function Bn(){let e=j();return ld(async t=>{await Promise.resolve(e.updateModelContext(t))},[e])}f();import{useCallback as ud,useEffect as dd,useState as cd}from"react";function En(e){let t=j("widgetState"),[a,o]=cd(()=>t??(typeof e=="function"?e():e??null));dd(()=>{o(t)},[t]);let r=ud(n=>{o(s=>{let i=typeof n=="function"?n(s):n;return Io()==="openai"&&i!=null&&window.openai?.setWidgetState(i),i})},[]);return[a,r]}f();import{jsx as nt,jsxs as _n}from"react/jsx-runtime";var fd=()=>_n("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[_n("div",{className:"flex gap-2",children:[nt("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),nt("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),nt("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),nt("p",{className:"text-sm font-medium text-transparent bg-clip-text bg-gradient-to-r from-slate-400 via-slate-200 to-slate-400 bg-[length:200%_100%] animate-[shimmer_1.5s_ease-in-out_infinite]",children:"Loading widget..."}),nt("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:nt("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),nt("style",{children:`
62
62
  @keyframes shimmer {
63
63
  0% { background-position: 200% 0; }
64
64
  100% { background-position: -200% 0; }
65
65
  }
66
- `})]});f();f();f();var rd={debug:0,warn:1,error:2,none:3};function sd(){let e=process.env.WANIWANI_LOG_LEVEL;return e&&e in rd?e:process.env.WANIWANI_DEBUG?"debug":"none"}function Ue(e,t){return t??sd()==="debug"?(...o)=>console.log(`[waniwani:${e}]`,...o):()=>{}}f();function Rs(e){if(e===!0)return{};if(!(e===!1||e===void 0))return e}f();function Ms(){return function(t){return t.headers.set("Access-Control-Allow-Origin","*"),t.headers.set("Access-Control-Allow-Methods","GET, POST, PATCH, OPTIONS"),t.headers.set("Access-Control-Allow-Headers","Content-Type, Authorization, X-Session-Id, X-Client-User-Agent"),t.headers.set("Access-Control-Expose-Headers","X-Session-Id"),t}}function Fs(e){return function(a,o){return e(new Response(JSON.stringify(a),{headers:{"Content-Type":"application/json"},status:o}))}}f();f();var Te=class extends Error{constructor(a,o){super(a);this.status=o;this.name="WaniWaniError"}};f();function Ds(e){let t=e.headers,a=t.get("x-vercel-ip-city")??t.get("cf-ipcity")??void 0,o=a?nd(a):void 0,r=t.get("x-vercel-ip-country")??t.get("cf-ipcountry")??void 0,s=t.get("x-vercel-ip-country-region")??void 0,n=t.get("x-vercel-ip-latitude")??t.get("cf-iplatitude")??void 0,i=t.get("x-vercel-ip-longitude")??t.get("cf-iplongitude")??void 0,l=t.get("x-vercel-ip-timezone")??t.get("cf-iptimezone")??void 0,u=t.get("x-real-ip")??t.get("x-forwarded-for")?.split(",")[0]?.trim()??t.get("cf-connecting-ip")??void 0;return{city:o,country:r,countryRegion:s,latitude:n,longitude:i,timezone:l,ip:u}}function nd(e){try{return decodeURIComponent(e)}catch{return e}}f();function Bs(e,t){if(!gt(t))return e;let a=qr(t);return a?[e,a].filter(Boolean).join(`
66
+ `})]});f();f();f();var pd={debug:0,warn:1,error:2,none:3};function md(){let e=process.env.WANIWANI_LOG_LEVEL;return e&&e in pd?e:process.env.WANIWANI_DEBUG?"debug":"none"}function He(e,t){return t??md()==="debug"?(...o)=>console.log(`[waniwani:${e}]`,...o):()=>{}}f();function Nn(e){if(e===!0)return{};if(!(e===!1||e===void 0))return e}f();function On(){return function(t){return t.headers.set("Access-Control-Allow-Origin","*"),t.headers.set("Access-Control-Allow-Methods","GET, POST, PATCH, OPTIONS"),t.headers.set("Access-Control-Allow-Headers","Content-Type, Authorization, X-Session-Id, X-Client-User-Agent"),t.headers.set("Access-Control-Expose-Headers","X-Session-Id"),t}}function Un(e){return function(a,o){return e(new Response(JSON.stringify(a),{headers:{"Content-Type":"application/json"},status:o}))}}f();f();var ve=class extends Error{constructor(a,o){super(a);this.status=o;this.name="WaniWaniError"}};f();function Hn(e){let t=e.headers,a=t.get("x-vercel-ip-city")??t.get("cf-ipcity")??void 0,o=a?hd(a):void 0,r=t.get("x-vercel-ip-country")??t.get("cf-ipcountry")??void 0,n=t.get("x-vercel-ip-country-region")??void 0,s=t.get("x-vercel-ip-latitude")??t.get("cf-iplatitude")??void 0,i=t.get("x-vercel-ip-longitude")??t.get("cf-iplongitude")??void 0,l=t.get("x-vercel-ip-timezone")??t.get("cf-iptimezone")??void 0,u=t.get("x-real-ip")??t.get("x-forwarded-for")?.split(",")[0]?.trim()??t.get("cf-connecting-ip")??void 0;return{city:o,country:r,countryRegion:n,latitude:s,longitude:i,timezone:l,ip:u}}function hd(e){try{return decodeURIComponent(e)}catch{return e}}f();function qn(e,t){if(!Ct(t))return e;let a=$r(t);return a?[e,a].filter(Boolean).join(`
67
67
 
68
- `):e}function Es(e){let{apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:s,beforeRequest:n,mcpServerUrl:i,resolveConfig:l,debug:u,webSearch:c}=e,d=Ue("chat",u);return async function(m){d("\u2192 POST",m.url);try{let h=await m.json(),I=h.messages??[],L=h.sessionId,S=h.modelContext,C=r,g=typeof h.extra=="object"&&h.extra!==null&&!Array.isArray(h.extra)?h.extra:void 0,b=h.visitorContext??null,P=Ds(m),A={geo:P,client:b};if(d("body parsed \u2014 messages:",I.length,"sessionId:",L??"(none)","geo:",JSON.stringify(P)),n){d("running beforeRequest hook");try{let B=await n({messages:I,sessionId:L,modelContext:S,request:m,visitor:A});B&&(B.messages&&(I=B.messages),B.systemPrompt!==void 0&&(C=B.systemPrompt),B.sessionId!==void 0&&(L=B.sessionId),B.modelContext!==void 0&&(S=B.modelContext)),d("beforeRequest hook done \u2014 messages:",I.length,"sessionId:",L??"(none)")}catch(B){console.error("[waniwani:chat] beforeRequest hook error:",B);let U=B instanceof Te?B.status:400,F=B instanceof Error?B.message:"Request rejected";return d("\u2190 returning",U,"from hook error"),Response.json({error:F},{status:U})}}let v=i??(await l()).mcpServerUrl;d("mcpServerUrl:",v),C=Bs(C,S);let R=`${a}/api/mcp/chat`;d("forwarding to",R);let _=m.headers.get("user-agent"),M=await fetch(R,{method:"POST",headers:{"Content-Type":"application/json","X-WaniWani-Stream-Protocol":"2",...t?{Authorization:`Bearer ${t}`}:{},..._?{"X-Client-User-Agent":_}:{}},body:JSON.stringify({messages:I,mcpServerUrl:v,sessionId:L,source:o,systemPrompt:C,maxSteps:s,visitor:A,webSearch:c,...g&&{extra:g}}),signal:m.signal});if(d("upstream response status:",M.status),!M.ok){let B=await M.text().catch(()=>"");return d("\u2190 returning",M.status,"upstream error:",B),new Response(B,{status:M.status,headers:{"Content-Type":M.headers.get("Content-Type")??"application/json"}})}let T=new Headers({"Content-Type":M.headers.get("Content-Type")??"text/event-stream"}),y=M.headers.get("x-session-id");return y&&T.set("x-session-id",y),d("\u2190 streaming response",M.status,"body null?",M.body===null),new Response(M.body,{status:M.status,headers:T})}catch(h){console.error("[waniwani:chat] handler error:",h);let I=h instanceof Error?h.message:"Unknown error occurred",L=h instanceof Te?h.status:500;return d("\u2190 returning",L,"from caught error"),Response.json({error:I},{status:L})}}}f();function _s(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=Ue("resource",o);return async function(n){r("\u2192 GET",n.toString());try{let i=n.searchParams.get("uri");if(r("uri:",i??"(missing)"),!i)return r("\u2190 400 missing uri"),Response.json({error:"Missing uri query parameter"},{status:400});let l=t??(await a()).mcpServerUrl;r("mcpServerUrl:",l);let u,c;try{[{createMCPClient:u},{StreamableHTTPClientTransport:c}]=await Promise.all([import("@ai-sdk/mcp"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),r("MCP deps loaded")}catch(p){return console.error("[waniwani:resource] MCP deps import failed:",p),Response.json({error:"MCP resource handler requires @ai-sdk/mcp and @modelcontextprotocol/sdk. Install them to enable resource serving."},{status:501})}r("creating MCP client for",l);let d=await u({transport:new c(new URL(l))});try{r("reading resource:",i);let p=await d.readResource({uri:i});r("resource contents count:",p.contents.length);let m=p.contents[0];if(!m)return r("\u2190 404 resource not found"),Response.json({error:"Resource not found"},{status:404});let h;return"text"in m&&typeof m.text=="string"?h=m.text:"blob"in m&&typeof m.blob=="string"&&(h=atob(m.blob)),h?(r("\u2190 200 HTML length:",h.length),new Response(h,{headers:{"Content-Type":"text/html","Cache-Control":"private, max-age=300"}})):(r("\u2190 404 resource has no content, keys:",Object.keys(m)),Response.json({error:"Resource has no content"},{status:404}))}finally{await d.close(),r("MCP client closed")}}catch(i){console.error("[waniwani:resource] handler error:",i);let l=i instanceof Error?i.message:"Unknown error occurred",u=i instanceof Te?i.status:500;return r("\u2190 returning",u,"from caught error"),Response.json({error:l},{status:u})}}}f();function Ns(e){let{mcpServerUrl:t,resolveConfig:a,debug:o,source:r}=e,s=Ue("tool",o);return async function(i){s("\u2192 POST",i.url);try{let l=await i.json(),{name:u,arguments:c}=l,d=i.headers.get("x-session-id")?.trim();if(!u||typeof u!="string")return s("\u2190 400 missing tool name"),Response.json({error:"Missing tool name"},{status:400});s("tool:",u,"args:",JSON.stringify(c),"sessionId:",d||"(none)");let p=t??(await a()).mcpServerUrl;s("mcpServerUrl:",p);let m,h;try{[{Client:m},{StreamableHTTPClientTransport:h}]=await Promise.all([import("@modelcontextprotocol/sdk/client/index.js"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),s("MCP deps loaded")}catch(S){return console.error("[waniwani:tool] MCP deps import failed:",S),Response.json({error:"MCP tool handler requires @modelcontextprotocol/sdk. Install it to enable tool calls."},{status:501})}s("creating MCP client for",p);let I=new h(new URL(p)),L=new m({name:"waniwani-tool-caller",version:"1.0.0"});await L.connect(I);try{s("calling tool:",u);let S={};d&&(S["waniwani/sessionId"]=d),r&&(S["waniwani/source"]=r);let C=await L.callTool({name:u,arguments:c??{},...Object.keys(S).length>0?{_meta:S}:{}});return s("tool result received"),Response.json({content:C.content,structuredContent:C.structuredContent,_meta:C._meta,isError:C.isError})}finally{await L.close(),s("MCP client closed")}}catch(l){console.error("[waniwani:tool] handler error:",l);let u=l instanceof Error?l.message:"Unknown error occurred",c=l instanceof Te?l.status:500;return s("\u2190 returning",c,"from caught error"),Response.json({error:u},{status:c})}}}f();function Os(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=Ue("tools-list",o);return async function(){r("\u2192 GET tools/list");try{let n=t??(await a()).mcpServerUrl;r("mcpServerUrl:",n);let i,l;try{[{createMCPClient:i},{StreamableHTTPClientTransport:l}]=await Promise.all([import("@ai-sdk/mcp"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),r("MCP deps loaded")}catch(c){return console.error("[waniwani:tools-list] MCP deps import failed:",c),Response.json({error:"MCP tools list handler requires @ai-sdk/mcp and @modelcontextprotocol/sdk. Install them to enable tool discovery."},{status:501})}r("creating MCP client for",n);let u=await i({transport:new l(new URL(n))});try{r("listing tools");let c=await u.listTools();r("tools count:",c.tools.length);let d={tools:c.tools.map(p=>({name:p.name,...p.title!==void 0&&{title:p.title},...p.description!==void 0&&{description:p.description},...p.inputSchema!==void 0&&{inputSchema:p.inputSchema},...p.outputSchema!==void 0&&{outputSchema:p.outputSchema},...p.annotations!==void 0&&{annotations:p.annotations},...p._meta!==void 0&&{_meta:p._meta}})),...c.nextCursor!==void 0&&{nextCursor:c.nextCursor}};return r("\u2190 200"),Response.json(d,{headers:{"Cache-Control":"private, max-age=60"}})}finally{await u.close(),r("MCP client closed")}}catch(n){console.error("[waniwani:tools-list] handler error:",n);let i=n instanceof Error?n.message:"Unknown error occurred",l=n instanceof Te?n.status:500;return r("\u2190 returning",l,"from caught error"),Response.json({error:i},{status:l})}}}f();var id=300*1e3;function Us(e,t){let a=null,o=null;return async function(){if(a&&Date.now()<a.expiresAt)return a.config;if(o)return o;o=(async()=>{if(!t)throw new Te("WANIWANI_API_KEY is required for createChatHandler",401);let s=await fetch(`${e}/api/mcp/environments/config`,{method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!s.ok){let i=await s.text().catch(()=>"");throw new Te(`Failed to resolve MCP environment config: ${s.status} ${i}`,s.status)}let n=await s.json();return a={config:n,expiresAt:Date.now()+id},n})();try{return await o}finally{o=null}}}var ld="https://app.waniwani.ai";function Hs(e={}){let{apiKey:t=process.env.WANIWANI_API_KEY,apiUrl:a=ld,source:o,systemPrompt:r,maxSteps:s=5,beforeRequest:n,mcpServerUrl:i,debug:l=!1,webSearch:u}=e,c=Ue("router",l),d=Ms(),p=Fs(d),m=Us(a,t),h=Es({apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:s,beforeRequest:n,mcpServerUrl:i,resolveConfig:m,debug:l,webSearch:Rs(u)}),I=_s({mcpServerUrl:i,resolveConfig:m,debug:l}),L=Os({mcpServerUrl:i,resolveConfig:m,debug:l}),S=Ns({mcpServerUrl:i,resolveConfig:m,debug:l,source:o}),C=process.env.WANIWANI_EVAL==="1";async function g(v){c("\u2192 GET",v.url);try{let R=new URL(v.url),M=R.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",R.pathname,"subRoute:",M),C&&M==="scenarios"){c("dispatching to scenarios handler (proxy to app API)");try{let y=await(await fetch(`${a}/api/mcp/scenarios`,{headers:{...t?{Authorization:`Bearer ${t}`}:{}}})).json();return p(y.data??y,200)}catch{return p([],200)}}if(M==="resource"){c("dispatching to resource handler");let T=await I(R);return c("\u2190 resource handler returned",T.status),d(T)}if(M==="config")return c("dispatching to config handler"),p({debug:l,eval:C},200);if(M==="tools"){c("dispatching to tools-list handler");let T=await L();return c("\u2190 tools-list handler returned",T.status),d(T)}return c("\u2190 404 no matching sub-route for",M),p({error:"Not found"},404)}catch(R){console.error("[waniwani:router] GET handler error:",R);let _=R instanceof Error?R.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}async function b(v){c("\u2192 POST",v.url);try{let R=new URL(v.url),M=R.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",R.pathname,"subRoute:",M),C&&M==="scenarios"){c("dispatching to save-scenario handler (proxy to app API)");try{let y=await v.json(),B=await fetch(`${a}/api/mcp/scenarios`,{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(y)}),U=await B.json();return B.ok?p({ok:!0,scenario:U.data},200):p({error:U.message??"Failed to save scenario"},B.status)}catch(y){let B=y instanceof Error?y.message:"Failed to save scenario";return p({error:B},400)}}if(M==="tool"){c("dispatching to tool handler");let y=await S(v);return c("\u2190 tool handler returned",y.status),d(y)}c("dispatching to chat handler");let T=await h(v);return d(T)}catch(R){console.error("[waniwani:router] POST handler error:",R);let _=R instanceof Error?R.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}async function P(v){c("\u2192 PATCH",v.url);try{let R=new URL(v.url),_=R.pathname.replace(/\/$/,"").split("/").filter(Boolean),M=_.at(-1),T=_.at(-2);if(c("pathname:",R.pathname,"subRoute:",T,"id:",M),C&&T==="scenarios"&&M){c("dispatching to update-scenario handler (proxy to app API)");try{let y=await v.json(),B=await fetch(`${a}/api/mcp/scenarios/${M}`,{method:"PATCH",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(y)}),U=await B.json();return B.ok?p({ok:!0,scenario:U.data},200):p({error:U.message??"Failed to update scenario"},B.status)}catch(y){let B=y instanceof Error?y.message:"Failed to update scenario";return p({error:B},400)}}return c("\u2190 404 no matching sub-route for PATCH",T),p({error:"Not found"},404)}catch(R){console.error("[waniwani:router] PATCH handler error:",R);let _=R instanceof Error?R.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}function A(){return d(new Response(null,{status:204}))}return{handleChat:h,handleResource:I,handleTool:S,routeGet:g,routePost:b,routePatch:P,handleOptions:A}}var qs=!1;function CL(e,t){!qs&&process.env.NODE_ENV!=="test"&&(console.warn("[waniwani-sdk] toNextJsHandler is deprecated; switch to toExpressJsHandler from @waniwani/sdk/express-js. It will be removed in a follow-up release."),qs=!0);let{apiKey:a,apiUrl:o}=e._config,r=t?.debug??process.env.WANIWANI_DEBUG==="1",s=Hs({...t?.chat,apiKey:a,apiUrl:o,source:t?.source,debug:r});return{POST:s.routePost,GET:s.routeGet,PATCH:s.routePatch,OPTIONS:()=>s.handleOptions()}}f();import{forwardRef as tg,useCallback as _r,useEffect as ag,useImperativeHandle as og,useRef as ru,useState as su}from"react";f();f();f();import{forwardRef as dd,createElement as cd}from"react";f();var ka=(...e)=>e.filter((t,a,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===a).join(" ").trim();f();var Ws=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();f();f();var Gs=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,o)=>o?o.toUpperCase():a.toLowerCase());var ko=e=>{let t=Gs(e);return t.charAt(0).toUpperCase()+t.slice(1)};f();import{forwardRef as ud,createElement as Vs}from"react";f();var js={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};f();var zs=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var $s=ud(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:n,...i},l)=>Vs("svg",{ref:l,...js,width:t,height:t,stroke:e,strokeWidth:o?Number(a)*24/Number(t):a,className:ka("lucide",r),...!s&&!zs(i)&&{"aria-hidden":"true"},...i},[...n.map(([u,c])=>Vs(u,c)),...Array.isArray(s)?s:[s]]));var G=(e,t)=>{let a=dd(({className:o,...r},s)=>cd($s,{ref:s,iconNode:t,className:ka(`lucide-${Ws(ko(e))}`,`lucide-${e}`,o),...r}));return a.displayName=ko(e),a};f();var fd=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ot=G("arrow-down",fd);f();var pd=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ut=G("arrow-up",pd);f();var md=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],Ve=G("braces",md);f();var hd=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Ht=G("brain",hd);f();var gd=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],qt=G("check",gd);f();var wd=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],rt=G("chevron-down",wd);f();var xd=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Wt=G("chevron-right",xd);f();var Ld=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],Gt=G("clipboard-copy",Ld);f();var Cd=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],jt=G("file",Cd);f();var Id=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],zt=G("loader",Id);f();var Sd=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Vt=G("paperclip",Sd);f();var yd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],$t=G("square",yd);f();var bd=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],st=G("x",bd);f();var kd=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Xt=G("zap",kd);import{useCallback as Wd}from"react";f();import{useCallback as Je,useMemo as Td,useRef as vd,useState as To}from"react";var Pd={damping:.7,stiffness:.05,mass:1.25},Ad=70,Rd=1e3/60,Md=350,Ta=!1;globalThis.document?.addEventListener("mousedown",()=>{Ta=!0});globalThis.document?.addEventListener("mouseup",()=>{Ta=!1});globalThis.document?.addEventListener("click",()=>{Ta=!1});var Ks=(e={})=>{let[t,a]=To(!1),[o,r]=To(e.initial!==!1),[s,n]=To(!1),i=vd(null);i.current=e;let l=Je(()=>{if(!Ta)return!1;let C=window.getSelection();if(!C||!C.rangeCount)return!1;let g=C.getRangeAt(0);return g.commonAncestorContainer.contains(L.current)||L.current?.contains(g.commonAncestorContainer)},[]),u=Je(C=>{d.isAtBottom=C,r(C)},[]),c=Je(C=>{d.escapedFromLock=C,a(C)},[]),d=Td(()=>{let C;return{escapedFromLock:t,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return L.current?.scrollTop??0},set scrollTop(g){L.current&&(L.current.scrollTop=g,d.ignoreScrollToTop=L.current.scrollTop)},get targetScrollTop(){return!L.current||!S.current?0:L.current.scrollHeight-1-L.current.clientHeight},get calculatedTargetScrollTop(){if(!L.current||!S.current)return 0;let{targetScrollTop:g}=this;if(!e.targetScrollTop)return g;if(C?.targetScrollTop===g)return C.calculatedScrollTop;let b=Math.max(Math.min(e.targetScrollTop(g,{scrollElement:L.current,contentElement:S.current}),g),0);return C={targetScrollTop:g,calculatedScrollTop:b},requestAnimationFrame(()=>{C=void 0}),b},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Ad}}},[]),p=Je((C={})=>{typeof C=="string"&&(C={animation:C}),C.preserveScrollPosition||u(!0);let g=Date.now()+(Number(C.wait)||0),b=Po(i.current,C.animation),{ignoreEscapes:P=!1}=C,A,v=d.calculatedTargetScrollTop;C.duration instanceof Promise?C.duration.finally(()=>{A=Date.now()}):A=g+(C.duration??0);let R=async()=>{let _=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:M}=d,T=performance.now(),y=(T-(d.lastTick??T))/Rd;if(d.animation||(d.animation={behavior:b,promise:_,ignoreEscapes:P}),d.animation.behavior===b&&(d.lastTick=T),l()||g>Date.now())return R();if(M<Math.min(v,d.calculatedTargetScrollTop)){if(d.animation?.behavior===b){if(b==="instant")return d.scrollTop=d.calculatedTargetScrollTop,R();d.velocity=(b.damping*d.velocity+b.stiffness*d.scrollDifference)/b.mass,d.accumulated+=d.velocity*y,d.scrollTop+=d.accumulated,d.scrollTop!==M&&(d.accumulated=0)}return R()}return A>Date.now()?(v=d.calculatedTargetScrollTop,R()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?p({animation:Po(i.current,i.current.resize),ignoreEscapes:P,duration:Math.max(0,A-Date.now())||void 0}):d.isAtBottom)});return _.then(M=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),M))};return C.wait!==!0&&(d.animation=void 0),d.animation?.behavior===b?d.animation.promise:R()},[u,l,d]),m=Je(()=>{c(!0),u(!1)},[c,u]),h=Je(({target:C})=>{if(C!==L.current)return;let{scrollTop:g,ignoreScrollToTop:b}=d,{lastScrollTop:P=g}=d;d.lastScrollTop=g,d.ignoreScrollToTop=void 0,b&&b>g&&(P=b),n(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||g===b)return;if(l()){c(!0),u(!1);return}let A=g>P,v=g<P;if(d.animation?.ignoreEscapes){d.scrollTop=P;return}v&&(c(!0),u(!1)),A&&c(!1),!d.escapedFromLock&&d.isNearBottom&&u(!0)},1)},[c,u,l,d]),I=Je(({target:C,deltaY:g})=>{let b=C;for(;!["scroll","auto"].includes(getComputedStyle(b).overflow);){if(!b.parentElement)return;b=b.parentElement}b===L.current&&g<0&&L.current.scrollHeight>L.current.clientHeight&&!d.animation?.ignoreEscapes&&(c(!0),u(!1))},[c,u,d]),L=Xs(C=>{L.current?.removeEventListener("scroll",h),L.current?.removeEventListener("wheel",I),C?.addEventListener("scroll",h,{passive:!0}),C?.addEventListener("wheel",I,{passive:!0})},[]),S=Xs(C=>{if(d.resizeObserver?.disconnect(),!C)return;let g;d.resizeObserver=new ResizeObserver(([b])=>{let{height:P}=b.contentRect,A=P-(g??P);if(d.resizeDifference=A,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),n(d.isNearBottom),A>=0){let v=Po(i.current,g?i.current.resize:i.current.initial);p({animation:v,wait:!0,preserveScrollPosition:!0,duration:v==="instant"?void 0:Md})}else d.isNearBottom&&(c(!1),u(!0));g=P,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===A&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(C)},[]);return{contentRef:S,scrollRef:L,scrollToBottom:p,stopScroll:m,isAtBottom:o||s,isNearBottom:s,escapedFromLock:t,state:d}};function Xs(e,t){let a=Je(o=>(a.current=o,e(o)),t);return a}var vo=new Map;function Po(...e){let t={...Pd},a=!1;for(let r of e){if(r==="instant"){a=!0;continue}typeof r=="object"&&(a=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let o=JSON.stringify(t);return vo.has(o)||vo.set(o,Object.freeze(t)),a?"instant":vo.get(o)}f();import*as nt from"react";import{createContext as Fd,useContext as Dd,useEffect as Bd,useImperativeHandle as Ed,useLayoutEffect as _d,useMemo as Nd,useRef as Od}from"react";var Qs=Fd(null),Ud=typeof window<"u"?_d:Bd;function Kt({instance:e,children:t,resize:a,initial:o,mass:r,damping:s,stiffness:n,targetScrollTop:i,contextRef:l,...u}){let c=Od(null),d=nt.useCallback((P,A)=>(b?.targetScrollTop??i)?.(P,A)??P,[i]),p=Ks({mass:r,damping:s,stiffness:n,resize:a,initial:o,targetScrollTop:d}),{scrollRef:m,contentRef:h,scrollToBottom:I,stopScroll:L,isAtBottom:S,escapedFromLock:C,state:g}=e??p,b=Nd(()=>({scrollToBottom:I,stopScroll:L,scrollRef:m,isAtBottom:S,escapedFromLock:C,contentRef:h,state:g,get targetScrollTop(){return c.current},set targetScrollTop(P){c.current=P}}),[I,S,h,m,L,C,g]);return Ed(l,()=>b,[b]),Ud(()=>{m.current&&getComputedStyle(m.current).overflow==="visible"&&(m.current.style.overflow="auto")},[]),nt.createElement(Qs.Provider,{value:b},nt.createElement("div",{...u},typeof t=="function"?t(b):t))}(function(e){function t({children:a,scrollClassName:o,...r}){let s=Ao();return nt.createElement("div",{ref:s.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:o},nt.createElement("div",{...r,ref:s.contentRef},typeof a=="function"?a(s):a))}e.Content=t})(Kt||(Kt={}));function Ao(){let e=Dd(Qs);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}f();var Hd=Gr({prefix:"ww"});function D(...e){return Hd(Wr(e))}f();import{jsx as qd}from"react/jsx-runtime";var He=({className:e,variant:t="default",size:a="default",type:o="button",...r})=>qd("button",{type:o,className:D("ww:inline-flex ww:cursor-pointer ww:items-center ww:justify-center ww:rounded-md ww:font-medium ww:transition-colors ww:disabled:pointer-events-none ww:disabled:opacity-50",t==="default"&&"ww:bg-primary ww:text-primary-foreground ww:hover:bg-primary/90",t==="outline"&&"ww:border ww:border-border ww:bg-background ww:hover:bg-accent ww:hover:text-accent-foreground",t==="ghost"&&"ww:hover:bg-accent ww:hover:text-accent-foreground",a==="default"&&"ww:h-9 ww:px-4 ww:py-2 ww:text-sm",a==="sm"&&"ww:h-8 ww:px-3 ww:text-xs",a==="icon"&&"ww:size-9 ww:!rounded-full",a==="icon-sm"&&"ww:size-7 ww:!rounded-full",e),...r});import{jsx as va}from"react/jsx-runtime";var Js=({className:e,...t})=>va(Kt,{className:D("ww:relative ww:flex-1 ww:overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),Zs=({className:e,...t})=>va(Kt.Content,{className:D("ww:flex ww:flex-col ww:gap-6 ww:px-4 ww:py-6 ww:mx-auto ww:w-full ww:max-w-3xl",e),...t}),Ys=({className:e,...t})=>{let{isAtBottom:a,scrollToBottom:o}=Ao(),r=Wd(()=>{o()},[o]);return!a&&va(He,{className:D("ww:absolute ww:bottom-4 ww:left-[50%] ww:translate-x-[-50%] ww:rounded-full",e),onClick:r,size:"icon",variant:"outline",...t,children:va(Ot,{className:"ww:size-4"})})};f();f();import tn from"crypto";f();var en="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Gd=128,it,It,jd=e=>{!it||it.length<e?(it=Buffer.allocUnsafe(e*Gd),tn.randomFillSync(it),It=0):It+e>it.length&&(tn.randomFillSync(it),It=0),It+=e};var Qt=(e=21)=>{jd(e|=0);let t="";for(let a=It-e;a<It;a++)t+=en[it[a]&63];return t};import{createContext as Qd,useCallback as $e,useContext as Jd,useEffect as Do,useMemo as Zd,useRef as Bo,useState as an}from"react";f();f();import{createContext as $d,useContext as Xd,useEffect as XI,useMemo as KI,useState as QI}from"react";f();f();f();f();var Mo={promptInput:{placeholder:"What would you like to know?",uploadFiles:"Upload files",stop:"Stop",submit:"Submit",removeAttachments:"Remove all attachments"},workingIndicator:{default:"On it\u2026"},reasoning:{thinking:"Thinking\u2026",thoughtBrief:"Thought for a few seconds",thoughtForSeconds:e=>`Thought for ${e} second${e===1?"":"s"}`},tool:{copy:"Copy",copied:"Copied",request:"Request",response:"Response",error:"Error"},attachments:{attachmentFallback:"attachment",fileFallback:"file"},threadMenu:{newChat:"New chat",threadHistory:"Thread history",deleteThread:"Delete thread",noPreviousChats:"No previous chats yet.",hiddenThreads:e=>`${e} older thread${e===1?"":"s"} hidden`},chatQueue:{attachmentFallback:"(attachment)",removeFromQueue:"Remove from queue",queued:e=>`${e} queued`},poweredBy:{label:"AI agent powered by"},aiDisclaimer:{default:"can make mistakes"},exportSession:{saving:"saving...",saved:"saved",error:"error",export:"export",tooltip:"Save scenario to WaniWani"},widgetErrorBoundary:{failedToLoad:"Widget failed to load",retry:"Retry"},launcher:{prompt:"Ask anything\u2026",open:"Open chat",close:"Close chat",minimize:"Minimize"}};f();f();import{jsx as oS}from"react/jsx-runtime";var Kd=$d(null);function z(){let e=Xd(Kd);return e||{locale:"en",t:Mo,ready:!0}}f();function Fo(e,t){let a=Date.now()-e;if(a<6e4)try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"narrow"}).format(0,"second")}catch{return"just now"}let o,r;a<60*6e4?(o=-Math.floor(a/6e4),r="minute"):a<1440*6e4?(o=-Math.floor(a/(60*6e4)),r="hour"):(o=-Math.floor(a/(1440*6e4)),r="day");try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"short"}).format(o,r)}catch{return`${Math.abs(o)}${r==="minute"?"m":r==="hour"?"h":"d"} ago`}}import{jsx as Ee,jsxs as dn}from"react/jsx-runtime";var Yd=async e=>{try{let a=await(await fetch(e)).blob();return new Promise(o=>{let r=new FileReader;r.onloadend=()=>o(r.result),r.onerror=()=>o(null),r.readAsDataURL(a)})}catch{return null}},on=Qd(null),rn=()=>{let e=Jd(on);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},sn=({className:e,accept:t,multiple:a,globalDrop:o,maxFiles:r,maxFileSize:s,onSubmit:n,children:i,...l})=>{let{t:u}=z(),c=Bo(null),d=Bo(null),[p,m]=an([]),h=Bo(p);Do(()=>{h.current=p},[p]);let I=$e(()=>{c.current?.click()},[]),L=$e(A=>{let v=[...A];if(v.length===0)return;let R=M=>s?M.size<=s:!0,_=v.filter(R);m(M=>{let T=typeof r=="number"?Math.max(0,r-M.length):void 0,y=typeof T=="number"?_.slice(0,T):_;return[...M,...y.map(B=>({filename:B.name,id:Qt(),mediaType:B.type,type:"file",url:URL.createObjectURL(B)}))]})},[r,s]),S=$e(A=>{m(v=>{let R=v.find(_=>_.id===A);return R?.url&&URL.revokeObjectURL(R.url),v.filter(_=>_.id!==A)})},[]),C=$e(()=>{m(A=>{for(let v of A)v.url&&URL.revokeObjectURL(v.url);return[]})},[]);Do(()=>()=>{for(let A of h.current)A.url&&URL.revokeObjectURL(A.url)},[]);let g=$e(A=>{A.currentTarget.files&&L(A.currentTarget.files),A.currentTarget.value=""},[L]);Do(()=>{if(!o)return;let A=R=>{R.dataTransfer?.types?.includes("Files")&&R.preventDefault()},v=R=>{R.dataTransfer?.types?.includes("Files")&&R.preventDefault(),R.dataTransfer?.files&&R.dataTransfer.files.length>0&&L(R.dataTransfer.files)};return document.addEventListener("dragover",A),document.addEventListener("drop",v),()=>{document.removeEventListener("dragover",A),document.removeEventListener("drop",v)}},[L,o]);let b=$e(async A=>{A.preventDefault();let v=A.currentTarget,_=new FormData(v).get("message")||"";v.reset();let M=await Promise.all(p.map(async({id:T,...y})=>{if(y.url?.startsWith("blob:")){let B=await Yd(y.url);return{...y,url:B??y.url}}return y}));try{let T=n({files:M,text:_},A);T instanceof Promise&&await T,C()}catch{}},[p,n,C]),P=Zd(()=>({add:L,clear:C,files:p,openFileDialog:I,remove:S}),[p,L,S,C,I]);return dn(on.Provider,{value:P,children:[Ee("input",{accept:t,"aria-label":u.promptInput.uploadFiles,className:"ww:hidden",multiple:a,onChange:g,ref:c,title:u.promptInput.uploadFiles,type:"file"}),Ee("form",{className:D("ww:flex ww:w-full ww:flex-col ww:rounded-lg ww:border ww:border-border ww:bg-background",e),onSubmit:b,ref:d,...l,children:i})]})};var nn=({onChange:e,onKeyDown:t,className:a,placeholder:o,...r})=>{let{t:s}=z(),n=rn(),[i,l]=an(!1),u=o??s.promptInput.placeholder,c=$e(p=>{if(t?.(p),!p.defaultPrevented){if(p.key==="Enter"){if(i||p.nativeEvent.isComposing||p.shiftKey)return;p.preventDefault();let{form:m}=p.currentTarget;if(m?.querySelector('button[type="submit"]')?.disabled)return;m?.requestSubmit()}if(p.key==="Backspace"&&p.currentTarget.value===""&&n.files.length>0){p.preventDefault();let m=n.files.at(-1);m&&n.remove(m.id)}}},[t,i,n]),d=$e(p=>{let m=p.clipboardData?.items;if(!m)return;let h=[];for(let I of m)if(I.kind==="file"){let L=I.getAsFile();L&&h.push(L)}h.length>0&&(p.preventDefault(),n.add(h))},[n]);return Ee("textarea",{className:D("ww:field-sizing-content ww:max-h-48 ww:min-h-0 ww:w-full ww:resize-none ww:border-0 ww:bg-transparent ww:px-3 ww:py-2 ww:text-base ww:sm:text-sm ww:outline-none ww:placeholder:text-muted-foreground",a),name:"message",onCompositionEnd:()=>l(!1),onCompositionStart:()=>l(!0),onKeyDown:c,onPaste:d,placeholder:u,onChange:e,...r})},ln=({className:e,status:t,onStop:a,onClick:o,children:r,...s})=>{let{t:n}=z(),i=t==="submitted"||t==="streaming",l=Ee(Ut,{className:"ww:size-4"});t==="submitted"?l=Ee(zt,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(l=Ee($t,{className:"ww:size-4"}));let u=$e(c=>{if(i&&a){c.preventDefault(),a();return}o?.(c)},[i,a,o]);return Ee(He,{"aria-label":i?n.promptInput.stop:n.promptInput.submit,className:D("ww:bg-foreground ww:text-background ww:hover:bg-foreground ww:rounded-full",e),onClick:u,size:"icon-sm",type:i&&a?"button":"submit",variant:"ghost",...s,children:r??l})},un=({className:e,children:t,...a})=>{let{t:o}=z(),r=rn();return r.files.length>0?dn(He,{className:D("ww:group ww:relative",e),onClick:()=>r.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":o.promptInput.removeAttachments,...a,children:[Ee("span",{className:"ww:flex ww:size-5 ww:items-center ww:justify-center ww:rounded-full ww:bg-primary ww:text-[10px] ww:font-medium ww:text-primary-foreground ww:transition-opacity ww:group-hover:opacity-0",children:r.files.length}),Ee(st,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]}):Ee(He,{className:D(e),onClick:()=>r.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??Ee(Vt,{className:"ww:size-4"})})};f();import{memo as ec,useCallback as tc}from"react";f();import{jsx as St}from"react/jsx-runtime";var cn=({className:e,...t})=>St("div",{className:D("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),fn=({className:e,...t})=>St("li",{className:D("ww:group ww:flex ww:items-center ww:gap-2 ww:rounded-md ww:px-2 ww:py-1 ww:text-sm ww:transition-colors ww:hover:bg-muted",e),...t}),pn=({className:e,...t})=>St("span",{className:D("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),mn=({className:e,...t})=>St("span",{className:D("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),hn=({className:e,...t})=>St("div",{className:D("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),gn=({className:e,...t})=>St(He,{className:D("ww:size-auto ww:rounded ww:p-1 ww:text-muted-foreground ww:hover:bg-muted-foreground/10 ww:hover:text-foreground",e),size:"icon",type:"button",variant:"ghost",...t});import{jsx as Ze,jsxs as Ln}from"react/jsx-runtime";var wn=ec(({message:e,onRemove:t})=>{let{t:a}=z(),o=tc(()=>t(e.id),[t,e.id]);return Ln(fn,{children:[Ze(pn,{}),Ze(mn,{children:e.text||a.chatQueue.attachmentFallback}),Ze(hn,{children:Ze(gn,{"aria-label":a.chatQueue.removeFromQueue,onClick:o,children:Ze(st,{className:"ww:size-3"})})})]})});wn.displayName="ChatQueueItem";function xn({queuedMessages:e,onRemove:t,className:a}){let{t:o}=z();return e.length===0?null:Ln(cn,{className:D("ww:border-t ww:border-border",a),children:[Ze("div",{className:"ww:text-[11px] ww:font-medium ww:text-muted-foreground ww:px-2",children:o.chatQueue.queued(e.length)}),Ze("ul",{children:e.map(r=>Ze(wn,{message:r,onRemove:t},r.id))})]})}f();import{useState as Cn}from"react";import{jsx as ac}from"react/jsx-runtime";function In({messages:e,evalEnabled:t,api:a="/api/waniwani"}){let{t:o}=z(),[r,s]=Cn(!1),[n,i]=Cn(null),l=async()=>{let c={name:`session-${new Date().toISOString().slice(0,19)}`,type:"functional",messages:e,mode:"manual"};s(!0),i(null);try{let d=await fetch(`${a}/scenarios`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok)throw new Error(`${d.status}`);i("saved")}catch{i("error")}finally{s(!1),setTimeout(()=>i(null),2e3)}};if(!t||e.length===0)return null;let u=r?o.exportSession.saving:n==="saved"?o.exportSession.saved:n==="error"?o.exportSession.error:o.exportSession.export;return ac("button",{type:"button",onClick:l,disabled:r,title:o.exportSession.tooltip,className:"ww:ml-auto ww:text-[10px] ww:font-mono ww:uppercase ww:tracking-wider ww:text-muted-foreground hover:ww:text-foreground ww:cursor-pointer ww:transition-colors ww:disabled:opacity-40",children:u})}f();f();import{jsx as Jt,jsxs as rc}from"react/jsx-runtime";var Sn=({files:e,className:t,...a})=>e.length===0?null:Jt("div",{className:D("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((o,r)=>Jt(oc,{file:o},r))});function oc({file:e}){let{t}=z();return e.mediaType?.startsWith("image/")&&e.url?Jt("img",{src:e.url,alt:e.filename??t.attachments.attachmentFallback,className:"ww:h-16 ww:max-w-32 ww:rounded ww:object-cover"}):rc("span",{className:"ww:inline-flex ww:items-center ww:gap-1.5 ww:rounded ww:bg-background/20 ww:px-2 ww:py-1 ww:text-xs",children:[Jt(jt,{className:"ww:size-3 ww:shrink-0"}),Jt("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??t.attachments.fileFallback})]})}f();import{createContext as lc,useCallback as uc,useContext as dc,useEffect as yn,useMemo as cc,useRef as fc,useState as Eo}from"react";f();import{memo as sc}from"react";import{jsx as ic}from"react/jsx-runtime";var nc=({as:e="span",className:t,duration:a=2,style:o,children:r,...s})=>{let n={backgroundImage:"linear-gradient(90deg, var(--ww-color-muted-foreground) 0%, var(--ww-color-muted-foreground) 40%, var(--ww-color-foreground) 50%, var(--ww-color-muted-foreground) 60%, var(--ww-color-muted-foreground) 100%)",backgroundSize:"250% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",animation:`ww-shimmer ${a}s linear infinite`,...o};return ic(e,{"data-waniwani-shimmer":"",className:D("ww:inline-block",t),style:n,...s,children:r})},Xe=sc(nc);Xe.displayName="Shimmer";import{jsx as ce,jsxs as Zt}from"react/jsx-runtime";var pc=1e3,bn=lc(null);function kn(){let e=dc(bn);if(!e)throw new Error("ChainOfThought components must be used within <ChainOfThought>");return e}function Tn({className:e,isWorking:t=!1,open:a,defaultOpen:o,onOpenChange:r,children:s,...n}){let i=o??t,l=a!==void 0,[u,c]=Eo(i),d=l?a:u,p=uc(S=>{l||c(S),r?.(S)},[l,r]),m=fc(t),[h,I]=Eo(!1);yn(()=>{t&&(m.current=!0,I(!1),l||c(!0))},[t,l]),yn(()=>{if(m.current&&!t&&d&&!h){let S=setTimeout(()=>{p(!1),I(!0)},pc);return()=>clearTimeout(S)}},[t,d,h,p]);let L=cc(()=>({open:d,setOpen:p,isWorking:t}),[d,p,t]);return ce(bn.Provider,{value:L,children:ce("div",{className:D("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":d?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...n,children:s})})}function vn({className:e,label:t,children:a,...o}){let{open:r,setOpen:s,isWorking:n}=kn(),i=a??(n?ce(Xe,{duration:1.6,children:t??""}):t);return Zt("button",{type:"button",onClick:()=>s(!r),"aria-expanded":r,className:D("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),...o,children:[ce(Ve,{className:"ww:size-4 ww:shrink-0"}),ce("span",{className:"ww:truncate",children:i}),ce(rt,{className:D("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function Pn({className:e,children:t,...a}){let{open:o}=kn();return ce("div",{className:D("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:ce("div",{className:"ww:min-h-0 ww:overflow-hidden",children:ce("div",{className:D("ww:flex ww:flex-col",e),...a,children:t})})})}function _o({className:e,title:t,state:a,isLast:o=!1,children:r,...s}){let n=a==="input-available"||a==="input-streaming",i=a==="output-error",l=r!=null,[u,c]=Eo(!1),d=t??"",p=n?ce(Xe,{duration:1.6,children:d}):ce("span",{className:"ww:truncate",children:d});return Zt("div",{className:D("ww:flex ww:gap-3",e),...s,children:[Zt("div",{className:"ww:flex ww:flex-col ww:items-center ww:self-stretch",children:[ce("span",{className:D("ww:mt-[7px] ww:size-1.5 ww:shrink-0 ww:rounded-full",i?"ww:bg-destructive":n?"ww:animate-pulse ww:bg-foreground":"ww:bg-muted-foreground")}),!o&&ce("span",{className:"ww:w-px ww:flex-1 ww:bg-border"})]}),Zt("div",{className:D("ww:min-w-0 ww:flex-1",!o&&"ww:pb-2"),children:[l?Zt("button",{type:"button",onClick:()=>c(m=>!m),"aria-expanded":u,className:"ww:flex ww:w-full ww:items-center ww:gap-1.5 ww:text-left ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",children:[p,ce(rt,{className:D("ww:size-3.5 ww:shrink-0 ww:transition-transform ww:duration-200",u&&"ww:rotate-180")})]}):ce("div",{className:"ww:flex ww:items-center ww:text-sm ww:text-muted-foreground",children:p}),l&&ce("div",{className:D("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",u?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:ce("div",{className:"ww:min-h-0 ww:overflow-hidden",children:ce("div",{className:"ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",children:r})})})]})]})}f();f();f();f();f();f();var pe={carriageReturn:-5,lineFeed:-4,carriageReturnLineFeed:-3,horizontalTab:-2,virtualSpace:-1,eof:null,nul:0,soh:1,stx:2,etx:3,eot:4,enq:5,ack:6,bel:7,bs:8,ht:9,lf:10,vt:11,ff:12,cr:13,so:14,si:15,dle:16,dc1:17,dc2:18,dc3:19,dc4:20,nak:21,syn:22,etb:23,can:24,em:25,sub:26,esc:27,fs:28,gs:29,rs:30,us:31,space:32,exclamationMark:33,quotationMark:34,numberSign:35,dollarSign:36,percentSign:37,ampersand:38,apostrophe:39,leftParenthesis:40,rightParenthesis:41,asterisk:42,plusSign:43,comma:44,dash:45,dot:46,slash:47,digit0:48,digit1:49,digit2:50,digit3:51,digit4:52,digit5:53,digit6:54,digit7:55,digit8:56,digit9:57,colon:58,semicolon:59,lessThan:60,equalsTo:61,greaterThan:62,questionMark:63,atSign:64,uppercaseA:65,uppercaseB:66,uppercaseC:67,uppercaseD:68,uppercaseE:69,uppercaseF:70,uppercaseG:71,uppercaseH:72,uppercaseI:73,uppercaseJ:74,uppercaseK:75,uppercaseL:76,uppercaseM:77,uppercaseN:78,uppercaseO:79,uppercaseP:80,uppercaseQ:81,uppercaseR:82,uppercaseS:83,uppercaseT:84,uppercaseU:85,uppercaseV:86,uppercaseW:87,uppercaseX:88,uppercaseY:89,uppercaseZ:90,leftSquareBracket:91,backslash:92,rightSquareBracket:93,caret:94,underscore:95,graveAccent:96,lowercaseA:97,lowercaseB:98,lowercaseC:99,lowercaseD:100,lowercaseE:101,lowercaseF:102,lowercaseG:103,lowercaseH:104,lowercaseI:105,lowercaseJ:106,lowercaseK:107,lowercaseL:108,lowercaseM:109,lowercaseN:110,lowercaseO:111,lowercaseP:112,lowercaseQ:113,lowercaseR:114,lowercaseS:115,lowercaseT:116,lowercaseU:117,lowercaseV:118,lowercaseW:119,lowercaseX:120,lowercaseY:121,lowercaseZ:122,leftCurlyBrace:123,verticalBar:124,rightCurlyBrace:125,tilde:126,del:127,byteOrderMarker:65279,replacementCharacter:65533};f();var qe={attentionSideAfter:2,attentionSideBefore:1,atxHeadingOpeningFenceSizeMax:6,autolinkDomainSizeMax:63,autolinkSchemeSizeMax:32,cdataOpeningString:"CDATA[",characterGroupPunctuation:2,characterGroupWhitespace:1,characterReferenceDecimalSizeMax:7,characterReferenceHexadecimalSizeMax:6,characterReferenceNamedSizeMax:31,codeFencedSequenceSizeMin:3,contentTypeContent:"content",contentTypeDocument:"document",contentTypeFlow:"flow",contentTypeString:"string",contentTypeText:"text",hardBreakPrefixSizeMin:2,htmlBasic:6,htmlCdata:5,htmlComment:2,htmlComplete:7,htmlDeclaration:4,htmlInstruction:3,htmlRawSizeMax:8,htmlRaw:1,linkResourceDestinationBalanceMax:32,linkReferenceSizeMax:999,listItemValueSizeMax:10,numericBaseDecimal:10,numericBaseHexadecimal:16,tabSize:4,thematicBreakMarkerCountMin:3,v8MaxSafeChunkSize:1e4};f();var Pe={data:"data",whitespace:"whitespace",lineEnding:"lineEnding",lineEndingBlank:"lineEndingBlank",linePrefix:"linePrefix",lineSuffix:"lineSuffix",atxHeading:"atxHeading",atxHeadingSequence:"atxHeadingSequence",atxHeadingText:"atxHeadingText",autolink:"autolink",autolinkEmail:"autolinkEmail",autolinkMarker:"autolinkMarker",autolinkProtocol:"autolinkProtocol",characterEscape:"characterEscape",characterEscapeValue:"characterEscapeValue",characterReference:"characterReference",characterReferenceMarker:"characterReferenceMarker",characterReferenceMarkerNumeric:"characterReferenceMarkerNumeric",characterReferenceMarkerHexadecimal:"characterReferenceMarkerHexadecimal",characterReferenceValue:"characterReferenceValue",codeFenced:"codeFenced",codeFencedFence:"codeFencedFence",codeFencedFenceSequence:"codeFencedFenceSequence",codeFencedFenceInfo:"codeFencedFenceInfo",codeFencedFenceMeta:"codeFencedFenceMeta",codeFlowValue:"codeFlowValue",codeIndented:"codeIndented",codeText:"codeText",codeTextData:"codeTextData",codeTextPadding:"codeTextPadding",codeTextSequence:"codeTextSequence",content:"content",definition:"definition",definitionDestination:"definitionDestination",definitionDestinationLiteral:"definitionDestinationLiteral",definitionDestinationLiteralMarker:"definitionDestinationLiteralMarker",definitionDestinationRaw:"definitionDestinationRaw",definitionDestinationString:"definitionDestinationString",definitionLabel:"definitionLabel",definitionLabelMarker:"definitionLabelMarker",definitionLabelString:"definitionLabelString",definitionMarker:"definitionMarker",definitionTitle:"definitionTitle",definitionTitleMarker:"definitionTitleMarker",definitionTitleString:"definitionTitleString",emphasis:"emphasis",emphasisSequence:"emphasisSequence",emphasisText:"emphasisText",escapeMarker:"escapeMarker",hardBreakEscape:"hardBreakEscape",hardBreakTrailing:"hardBreakTrailing",htmlFlow:"htmlFlow",htmlFlowData:"htmlFlowData",htmlText:"htmlText",htmlTextData:"htmlTextData",image:"image",label:"label",labelText:"labelText",labelLink:"labelLink",labelImage:"labelImage",labelMarker:"labelMarker",labelImageMarker:"labelImageMarker",labelEnd:"labelEnd",link:"link",paragraph:"paragraph",reference:"reference",referenceMarker:"referenceMarker",referenceString:"referenceString",resource:"resource",resourceDestination:"resourceDestination",resourceDestinationLiteral:"resourceDestinationLiteral",resourceDestinationLiteralMarker:"resourceDestinationLiteralMarker",resourceDestinationRaw:"resourceDestinationRaw",resourceDestinationString:"resourceDestinationString",resourceMarker:"resourceMarker",resourceTitle:"resourceTitle",resourceTitleMarker:"resourceTitleMarker",resourceTitleString:"resourceTitleString",setextHeading:"setextHeading",setextHeadingText:"setextHeadingText",setextHeadingLine:"setextHeadingLine",setextHeadingLineSequence:"setextHeadingLineSequence",strong:"strong",strongSequence:"strongSequence",strongText:"strongText",thematicBreak:"thematicBreak",thematicBreakSequence:"thematicBreakSequence",blockQuote:"blockQuote",blockQuotePrefix:"blockQuotePrefix",blockQuoteMarker:"blockQuoteMarker",blockQuotePrefixWhitespace:"blockQuotePrefixWhitespace",listOrdered:"listOrdered",listUnordered:"listUnordered",listItemIndent:"listItemIndent",listItemMarker:"listItemMarker",listItemPrefix:"listItemPrefix",listItemPrefixWhitespace:"listItemPrefixWhitespace",listItemValue:"listItemValue",chunkDocument:"chunkDocument",chunkContent:"chunkContent",chunkFlow:"chunkFlow",chunkText:"chunkText",chunkString:"chunkString"};f();f();f();function An(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}function Rn(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function Mn(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e>=94192&&e<=94198||e>=94208&&e<=101589||e>=101631&&e<=101662||e>=101760&&e<=101874||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128728||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129674||e>=129678&&e<=129734||e===129736||e>=129741&&e<=129756||e>=129759&&e<=129770||e>=129775&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}function Fn(e){return An(e)?"ambiguous":Rn(e)?"fullwidth":e===8361||e>=65377&&e<=65470||e>=65474&&e<=65479||e>=65482&&e<=65487||e>=65490&&e<=65495||e>=65498&&e<=65500||e>=65512&&e<=65518?"halfwidth":e>=32&&e<=126||e===162||e===163||e===165||e===166||e===172||e===175||e>=10214&&e<=10221||e===10629||e===10630?"narrow":Mn(e)?"wide":"neutral"}function mc(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Dn(e){return mc(e),Fn(e)}var hc=Object.defineProperty,gc=(e,t,a)=>t in e?hc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,wc=(e,t,a)=>gc(e,typeof t!="symbol"?t+"":t,a);function xc(e){return new RegExp("^\\p{Emoji_Presentation}","u").test(String.fromCodePoint(e))}function Lc(e){if(!e||e<4352)return!1;switch(Dn(e)){case"fullwidth":case"halfwidth":return!0;case"wide":return!xc(e);case"narrow":return!1;case"ambiguous":return 917760<=e&&e<=917999?null:!1;case"neutral":return new RegExp("^\\p{sc=Hangul}","u").test(String.fromCodePoint(e))}}function Cc(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function Ic(e){return e!==null&&e>=65024&&e<=65038}var Sc=Bn(new RegExp("\\p{P}|\\p{S}","u")),yc=Bn(/\s/);function Bn(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCodePoint(a))}}var Ae;(e=>{e.spaceOrPunctuation=3,e.cjk=4096,e.cjkPunctuation=4098,e.ivs=8192,e.cjkOrIvs=12288,e.nonEmojiGeneralUseVS=16384,e.variationSelector=24576,e.ivsToCjkRightShift=1})(Ae||(Ae={}));function Ye(e){if(e===pe.eof||jr(e)||yc(e))return qe.characterGroupWhitespace;let t=0;if(e>=4352){if(Ic(e))return Ae.nonEmojiGeneralUseVS;switch(Lc(e)){case null:return Ae.ivs;case!0:t|=Ae.cjk;break}}return Sc(e)&&(t|=qe.characterGroupPunctuation),t}function Pa(e,t,a){if(!kc(e))return e;let o=t(),r=Ye(o);return!o||lt(r)?e:Cc(o,a)?Ae.cjkPunctuation:bc(r)}function bc(e){return e&~Ae.ivs}function lt(e){return!!(e&qe.characterGroupWhitespace)}function yt(e){return(e&Ae.cjkPunctuation)===qe.characterGroupPunctuation}function Yt(e){return!!(e&Ae.cjk)}function En(e){return e===Ae.ivs}function _n(e){return!!(e&Ae.cjkOrIvs)}function kc(e){return e===Ae.nonEmojiGeneralUseVS}function No(e){return!!(e&Ae.spaceOrPunctuation)}function Aa(e){return!!(e&&e>=55296&&e<=56319)}function Ra(e){return!!(e&&e>=56320&&e<=57343)}function Ma(e,t,a){if(t._bufferIndex<2)return e;let r=a({start:{...t,_bufferIndex:t._bufferIndex-2},end:t}).codePointAt(0);return r&&r>=65536?r:e}function Tc(e,t,a){let o=e>=65536?2:1;if(t._bufferIndex<1+o)return null;let r=t._bufferIndex-o-2,s=a({start:{...t,_bufferIndex:r>=0?r:0},end:{...t,_bufferIndex:t._bufferIndex-o}}),n=s.charCodeAt(s.length-1);if(Number.isNaN(n))return null;if(s.length<2||n<56320||57343<n)return n;let i=s.codePointAt(0);return i&&i>=65536?i:n}var Fa=class{constructor(e,t,a){this.previousCode=e,this.nowPoint=t,this.sliceSerialize=a,wc(this,"cachedValue")}value(){return this.cachedValue===void 0&&(this.cachedValue=Tc(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function Da(e,t,a){let o=a({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return o&&o>=65536?o:e}var Oo={name:"attention",resolveAll:vc,tokenize:Pc};function vc(e,t){let a=-1,o,r,s,n,i,l,u,c;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(o=a;o--;)if(e[o][0]==="exit"&&e[o][1].type==="attentionSequence"&&e[o][1]._open&&t.sliceSerialize(e[o][1]).charCodeAt(0)===t.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[o][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[o][1].end.offset-e[o][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;l=e[o][1].end.offset-e[o][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;let d={...e[o][1].end},p={...e[a][1].start};Nn(d,-l),Nn(p,l),n={type:l>1?Pe.strongSequence:Pe.emphasisSequence,start:d,end:{...e[o][1].end}},i={type:l>1?Pe.strongSequence:Pe.emphasisSequence,start:{...e[a][1].start},end:p},s={type:l>1?Pe.strongText:Pe.emphasisText,start:{...e[o][1].end},end:{...e[a][1].start}},r={type:l>1?Pe.strong:Pe.emphasis,start:{...n.start},end:{...i.end}},e[o][1].end={...n.start},e[a][1].start={...i.end},u=[],e[o][1].end.offset-e[o][1].start.offset&&(u=xt(u,[["enter",e[o][1],t],["exit",e[o][1],t]])),u=xt(u,[["enter",r,t],["enter",n,t],["exit",n,t],["enter",s,t]]),t.parser.constructs.insideSpan.null,u=xt(u,xa(t.parser.constructs.insideSpan.null,e.slice(o+1,a),t)),u=xt(u,[["exit",s,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[a][1].end.offset-e[a][1].start.offset?(c=2,u=xt(u,[["enter",e[a][1],t],["exit",e[a][1],t]])):c=0,wt(e,o-1,a-o+3,u),a=o+u.length-c-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function Pc(e,t){let a=this.parser.constructs.attentionMarkers.null,{now:o,sliceSerialize:r,previous:s}=this,n=Ra(s)?Ma(s,o(),r):s,i=Ye(n),l=new Fa(n,o(),r),u=Pa(i,l.value.bind(l),n),c;return d;function d(m){return m===pe.asterisk||pe.underscore,c=m,e.enter("attentionSequence"),p(m)}function p(m){if(m===c)return e.consume(m),p;let h=e.exit("attentionSequence"),I=Aa(m)?Da(m,o(),r):m,L=Ye(I);let S=yt(u),C=S||lt(u),g=yt(L),b=g||lt(L),P=_n(u),A=!b||g&&(C||P)||a.includes(m),v=!C||S&&(b||Yt(L))||a.includes(n);return h._open=!!(c===pe.asterisk?A:A&&(No(u)||!v)),h._close=!!(c===pe.asterisk?v:v&&(No(L)||!A)),t(m)}}function Nn(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function On(){return{text:{[pe.asterisk]:Oo,[pe.underscore]:Oo},insideSpan:{null:[Oo]}}}function Un(){let e=this.data();(e.micromarkExtensions||(e.micromarkExtensions=[])).push(On())}f();f();function Hn(e){let a=(e||{}).singleTilde,o={name:"strikethrough",tokenize:s,resolveAll:r};return a==null&&(a=!0),{text:{[pe.tilde]:o},insideSpan:{null:[o]},attentionMarkers:{null:[pe.tilde]}};function r(n,i){let l=-1;for(;++l<n.length;)if(n[l][0]==="enter"&&n[l][1].type==="strikethroughSequenceTemporary"&&n[l][1]._close){let u=l;for(;u--;)if(n[u][0]==="exit"&&n[u][1].type==="strikethroughSequenceTemporary"&&n[u][1]._open&&n[l][1].end.offset-n[l][1].start.offset===n[u][1].end.offset-n[u][1].start.offset){n[l][1].type="strikethroughSequence",n[u][1].type="strikethroughSequence";let c={type:"strikethrough",start:Object.assign({},n[u][1].start),end:Object.assign({},n[l][1].end)},d={type:"strikethroughText",start:Object.assign({},n[u][1].end),end:Object.assign({},n[l][1].start)},p=[["enter",c,i],["enter",n[u][1],i],["exit",n[u][1],i],["enter",d,i]],m=i.parser.constructs.insideSpan.null;m&&wt(p,p.length,0,xa(m,n.slice(u+1,l),i)),wt(p,p.length,0,[["exit",d,i],["enter",n[l][1],i],["exit",n[l][1],i],["exit",c,i]]),wt(n,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<n.length;)n[l][1].type==="strikethroughSequenceTemporary"&&(n[l][1].type=Pe.data);return n}function s(n,i,l){let{now:u,sliceSerialize:c,previous:d}=this,p=Ra(d)?Ma(d,u(),c):d,m=Ye(p),h=new Fa(p,u(),c),I=Pa(m,h.value.bind(h),p),L=this.events,S=0;return C;function C(b){return pe.tilde,p===pe.tilde&&L[L.length-1][1].type!==Pe.characterEscape?l(b):(n.enter("strikethroughSequenceTemporary"),g(b))}function g(b){let P=Ye(p);if(b===pe.tilde)return S>1?l(b):(n.consume(b),S++,g);if(S<2&&!a)return l(b);let A=n.exit("strikethroughSequenceTemporary"),v=Aa(b)?Da(b,u(),c):b,R=Ye(v),M=yt(I)||lt(I),y=yt(R)||lt(R),B=Yt(I)||En(P);return A._open=!y||R===qe.attentionSideAfter&&(M||B),A._close=!M||P===qe.attentionSideAfter&&(y||Yt(R)),i(b)}}}function qn(e){let t=this.data();(t.micromarkExtensions||(t.micromarkExtensions=[])).push(Hn(e))}var Ac=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),Rc=/^(https?:\/\/|mailto:|www\.)/i,Mc=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type==="text"&&t.value===e.url},Fc=e=>{let t=0;for(let a of e){if(Ac.has(a))return t;t+=a.length}return null},Dc=(e,t)=>({...t,url:e,children:[{type:"text",value:e}]}),Bc=e=>({type:"text",value:e}),Ec=()=>e=>{zr(e,"link",(t,a,o)=>{if(!o||typeof a!="number"||!Mc(t)||!Rc.test(t.url))return;let r=Fc(t.url);if(r===null||r===0)return;let s=t.url.slice(0,r),n=t.url.slice(r),i=Dc(s,t),l=Bc(n);return o.children.splice(a,1,i,l),a+1})};function _c(){let e=[Un],t=[Ec,qn],a=[...e,...t];return{name:"cjk",type:"cjk",remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:a}}var Uo=_c();f();f();f();f();f();var Z=class extends Error{constructor(t){super(t),this.name="ShikiError"}};f();function Nc(e){return Ko(e)}function Ko(e){return Array.isArray(e)?Oc(e):e instanceof RegExp?e:typeof e=="object"?Uc(e):e}function Oc(e){let t=[];for(let a=0,o=e.length;a<o;a++)t[a]=Ko(e[a]);return t}function Uc(e){let t={};for(let a in e)t[a]=Ko(e[a]);return t}function Qn(e,...t){return t.forEach(a=>{for(let o in a)e[o]=a[o]}),e}function Jn(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Jn(e.substring(0,e.length-1)):e.substr(~t+1)}var Ho=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Ba=class{static hasCaptures(e){return e===null?!1:(Ho.lastIndex=0,Ho.test(e))}static replaceCaptures(e,t,a){return e.replace(Ho,(o,r,s,n)=>{let i=a[parseInt(r||s,10)];if(i){let l=t.substring(i.start,i.end);for(;l[0]===".";)l=l.substring(1);switch(n){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return o})}};function Zn(e,t){return e<t?-1:e>t?1:0}function Yn(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let a=e.length,o=t.length;if(a===o){for(let r=0;r<a;r++){let s=Zn(e[r],t[r]);if(s!==0)return s}return 0}return a-o}function Wn(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function ei(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var ti=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},aa=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(Wc(e),t)}static createFromParsedTheme(e,t){return jc(e,t)}_cachedMatchRoot=new ti(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,o=this._cachedMatchRoot.get(t).find(r=>Hc(e.parent,r.parentScopes));return o?new ai(o.fontStyle,o.foreground,o.background):null}},qo=class Ea{constructor(t,a){this.parent=t,this.scopeName=a}static push(t,a){for(let o of a)t=new Ea(t,o);return t}static from(...t){let a=null;for(let o=0;o<t.length;o++)a=new Ea(a,t[o]);return a}push(t){return new Ea(this,t)}getSegments(){let t=this,a=[];for(;t;)a.push(t.scopeName),t=t.parent;return a.reverse(),a}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){let a=[],o=this;for(;o&&o!==t;)a.push(o.scopeName),o=o.parent;return o===t?a.reverse():void 0}};function Hc(e,t){if(t.length===0)return!0;for(let a=0;a<t.length;a++){let o=t[a],r=!1;if(o===">"){if(a===t.length-1)return!1;o=t[++a],r=!0}for(;e&&!qc(e.scopeName,o);){if(r)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function qc(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var ai=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function Wc(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,a=[],o=0;for(let r=0,s=t.length;r<s;r++){let n=t[r];if(!n.settings)continue;let i;if(typeof n.scope=="string"){let d=n.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),i=d.split(",")}else Array.isArray(n.scope)?i=n.scope:i=[""];let l=-1;if(typeof n.settings.fontStyle=="string"){l=0;let d=n.settings.fontStyle.split(" ");for(let p=0,m=d.length;p<m;p++)switch(d[p]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let u=null;typeof n.settings.foreground=="string"&&Wn(n.settings.foreground)&&(u=n.settings.foreground);let c=null;typeof n.settings.background=="string"&&Wn(n.settings.background)&&(c=n.settings.background);for(let d=0,p=i.length;d<p;d++){let h=i[d].trim().split(" "),I=h[h.length-1],L=null;h.length>1&&(L=h.slice(0,h.length-1),L.reverse()),a[o++]=new Gc(I,L,r,l,u,c)}}return a}var Gc=class{constructor(e,t,a,o,r,s){this.scope=e,this.parentScopes=t,this.index=a,this.fontStyle=o,this.foreground=r,this.background=s}},me=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(me||{});function jc(e,t){e.sort((l,u)=>{let c=Zn(l.scope,u.scope);return c!==0||(c=Yn(l.parentScopes,u.parentScopes),c!==0)?c:l.index-u.index});let a=0,o="#000000",r="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(a=l.fontStyle),l.foreground!==null&&(o=l.foreground),l.background!==null&&(r=l.background)}let s=new zc(t),n=new ai(a,s.getId(o),s.getId(r)),i=new $c(new Go(0,null,-1,0,0),[]);for(let l=0,u=e.length;l<u;l++){let c=e[l];i.insert(0,c.scope,c.parentScopes,c.fontStyle,s.getId(c.foreground),s.getId(c.background))}return new aa(s,n,i)}var zc=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,a=e.length;t<a;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Vc=Object.freeze([]),Go=class oi{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,o,r,s){this.scopeDepth=t,this.parentScopes=a||Vc,this.fontStyle=o,this.foreground=r,this.background=s}clone(){return new oi(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let a=[];for(let o=0,r=t.length;o<r;o++)a[o]=t[o].clone();return a}acceptOverwrite(t,a,o,r){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,a!==-1&&(this.fontStyle=a),o!==0&&(this.foreground=o),r!==0&&(this.background=r)}},$c=class jo{constructor(t,a=[],o={}){this._mainRule=t,this._children=o,this._rulesWithParentScopes=a}_rulesWithParentScopes;static _cmpBySpecificity(t,a){if(t.scopeDepth!==a.scopeDepth)return a.scopeDepth-t.scopeDepth;let o=0,r=0;for(;t.parentScopes[o]===">"&&o++,a.parentScopes[r]===">"&&r++,!(o>=t.parentScopes.length||r>=a.parentScopes.length);){let s=a.parentScopes[r].length-t.parentScopes[o].length;if(s!==0)return s;o++,r++}return a.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let o=t.indexOf("."),r,s;if(o===-1?(r=t,s=""):(r=t.substring(0,o),s=t.substring(o+1)),this._children.hasOwnProperty(r))return this._children[r].match(s)}let a=this._rulesWithParentScopes.concat(this._mainRule);return a.sort(jo._cmpBySpecificity),a}insert(t,a,o,r,s,n){if(a===""){this._doInsertHere(t,o,r,s,n);return}let i=a.indexOf("."),l,u;i===-1?(l=a,u=""):(l=a.substring(0,i),u=a.substring(i+1));let c;this._children.hasOwnProperty(l)?c=this._children[l]:(c=new jo(this._mainRule.clone(),Go.cloneArr(this._rulesWithParentScopes)),this._children[l]=c),c.insert(t+1,u,o,r,s,n)}_doInsertHere(t,a,o,r,s){if(a===null){this._mainRule.acceptOverwrite(t,o,r,s);return}for(let n=0,i=this._rulesWithParentScopes.length;n<i;n++){let l=this._rulesWithParentScopes[n];if(Yn(l.parentScopes,a)===0){l.acceptOverwrite(t,o,r,s);return}}o===-1&&(o=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new Go(t,a,o,r,s))}},dt=class Fe{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=Fe.getLanguageId(t),o=Fe.getTokenType(t),r=Fe.getFontStyle(t),s=Fe.getForeground(t),n=Fe.getBackground(t);console.log({languageId:a,tokenType:o,fontStyle:r,foreground:s,background:n})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,a,o,r,s,n,i){let l=Fe.getLanguageId(t),u=Fe.getTokenType(t),c=Fe.containsBalancedBrackets(t)?1:0,d=Fe.getFontStyle(t),p=Fe.getForeground(t),m=Fe.getBackground(t);return a!==0&&(l=a),o!==8&&(u=o),r!==null&&(c=r?1:0),s!==-1&&(d=s),n!==0&&(p=n),i!==0&&(m=i),(l<<0|u<<8|c<<10|d<<11|p<<15|m<<24)>>>0}};function Na(e,t){let a=[],o=Xc(e),r=o.next();for(;r!==null;){let l=0;if(r.length===2&&r.charAt(1)===":"){switch(r.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${r} in scope selector`)}r=o.next()}let u=n();if(a.push({matcher:u,priority:l}),r!==",")break;r=o.next()}return a;function s(){if(r==="-"){r=o.next();let l=s();return u=>!!l&&!l(u)}if(r==="("){r=o.next();let l=i();return r===")"&&(r=o.next()),l}if(Gn(r)){let l=[];do l.push(r),r=o.next();while(Gn(r));return u=>t(l,u)}return null}function n(){let l=[],u=s();for(;u;)l.push(u),u=s();return c=>l.every(d=>d(c))}function i(){let l=[],u=n();for(;u&&(l.push(u),r==="|"||r===",");){do r=o.next();while(r==="|"||r===",");u=n()}return c=>l.some(d=>d(c))}}function Gn(e){return!!e&&!!e.match(/[\w\.:]+/)}function Xc(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,a=t.exec(e);return{next:()=>{if(!a)return null;let o=a[0];return a=t.exec(e),o}}}function ri(e){typeof e.dispose=="function"&&e.dispose()}var oa=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Kc=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Qc=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Jc=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new oa(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Qc;for(let a of e)Zc(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof oa){if(this.seenFullScopeRequests.has(a.scopeName))continue;this.seenFullScopeRequests.add(a.scopeName),this.Q.push(a)}else{if(this.seenFullScopeRequests.has(a.scopeName)||this.seenPartialScopeRequests.has(a.toKey()))continue;this.seenPartialScopeRequests.add(a.toKey()),this.Q.push(a)}}};function Zc(e,t,a,o){let r=a.lookup(e.scopeName);if(!r){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let s=a.lookup(t);e instanceof oa?_a({baseGrammar:s,selfGrammar:r},o):zo(e.ruleName,{baseGrammar:s,selfGrammar:r,repository:r.repository},o);let n=a.injections(e.scopeName);if(n)for(let i of n)o.add(new oa(i))}function zo(e,t,a){if(t.repository&&t.repository[e]){let o=t.repository[e];Oa([o],t,a)}}function _a(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Oa(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Oa(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Oa(e,t,a){for(let o of e){if(a.visitedRule.has(o))continue;a.visitedRule.add(o);let r=o.repository?Qn({},t.repository,o.repository):t.repository;Array.isArray(o.patterns)&&Oa(o.patterns,{...t,repository:r},a);let s=o.include;if(!s)continue;let n=si(s);switch(n.kind){case 0:_a({...t,selfGrammar:t.baseGrammar},a);break;case 1:_a(t,a);break;case 2:zo(n.ruleName,{...t,repository:r},a);break;case 3:case 4:let i=n.scopeName===t.selfGrammar.scopeName?t.selfGrammar:n.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(i){let l={baseGrammar:t.baseGrammar,selfGrammar:i,repository:r};n.kind===4?zo(n.ruleName,l,a):_a(l,a)}else n.kind===4?a.add(new Kc(n.scopeName,n.ruleName)):a.add(new oa(n.scopeName));break}}}var Yc=class{kind=0},ef=class{kind=1},tf=class{constructor(e){this.ruleName=e}kind=2},af=class{constructor(e){this.scopeName=e}kind=3},of=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function si(e){if(e==="$base")return new Yc;if(e==="$self")return new ef;let t=e.indexOf("#");if(t===-1)return new af(e);if(t===0)return new tf(e.substring(1));{let a=e.substring(0,t),o=e.substring(t+1);return new of(a,o)}}var rf=/\\(\d+)/,jn=/\\(\d+)/g;var sf=-1,ni=-2;var na=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,a,o){this.$location=e,this.id=t,this._name=a||null,this._nameIsCapturing=Ba.hasCaptures(this._name),this._contentName=o||null,this._contentNameIsCapturing=Ba.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Jn(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Ba.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Ba.replaceCaptures(this._contentName,e,t)}},nf=class extends na{retokenizeCapturedWithRuleId;constructor(e,t,a,o,r){super(e,t,a,o),this.retokenizeCapturedWithRuleId=r}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,a,o){throw new Error("Not supported!")}},lf=class extends na{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,null),this._match=new ra(o,this.id),this.captures=r,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new sa,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},zn=class extends na{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,o),this.patterns=r.patterns,this.hasMissingPatterns=r.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let a of this.patterns)e.getRule(a).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new sa,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Vo=class extends na{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r,s,n,i,l,u){super(e,t,a,o),this._begin=new ra(r,this.id),this.beginCaptures=s,this._end=new ra(n||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=l||!1,this.patterns=u.patterns,this.hasMissingPatterns=u.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e,t).compileAG(e,a,o)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new sa;for(let a of this.patterns)e.getRule(a).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Ua=class extends na{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,a,o,r,s,n,i,l){super(e,t,a,o),this._begin=new ra(r,this.id),this.beginCaptures=s,this.whileCaptures=i,this._while=new ra(n,ni),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new sa;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,a,o){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,a,o)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new sa,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},ii=class Le{static createCaptureRule(t,a,o,r,s){return t.registerRule(n=>new nf(a,n,o,r,s))}static getCompiledRuleId(t,a,o){return t.id||a.registerRule(r=>{if(t.id=r,t.match)return new lf(t.$vscodeTextmateLocation,t.id,t.name,t.match,Le._compileCaptures(t.captures,a,o));if(typeof t.begin>"u"){t.repository&&(o=Qn({},o,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new zn(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Le._compilePatterns(s,a,o))}return t.while?new Ua(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Le._compileCaptures(t.beginCaptures||t.captures,a,o),t.while,Le._compileCaptures(t.whileCaptures||t.captures,a,o),Le._compilePatterns(t.patterns,a,o)):new Vo(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Le._compileCaptures(t.beginCaptures||t.captures,a,o),t.end,Le._compileCaptures(t.endCaptures||t.captures,a,o),t.applyEndPatternLast,Le._compilePatterns(t.patterns,a,o))}),t.id}static _compileCaptures(t,a,o){let r=[];if(t){let s=0;for(let n in t){if(n==="$vscodeTextmateLocation")continue;let i=parseInt(n,10);i>s&&(s=i)}for(let n=0;n<=s;n++)r[n]=null;for(let n in t){if(n==="$vscodeTextmateLocation")continue;let i=parseInt(n,10),l=0;t[n].patterns&&(l=Le.getCompiledRuleId(t[n],a,o)),r[i]=Le.createCaptureRule(a,t[n].$vscodeTextmateLocation,t[n].name,t[n].contentName,l)}}return r}static _compilePatterns(t,a,o){let r=[];if(t)for(let s=0,n=t.length;s<n;s++){let i=t[s],l=-1;if(i.include){let u=si(i.include);switch(u.kind){case 0:case 1:l=Le.getCompiledRuleId(o[i.include],a,o);break;case 2:let c=o[u.ruleName];c&&(l=Le.getCompiledRuleId(c,a,o));break;case 3:case 4:let d=u.scopeName,p=u.kind===4?u.ruleName:null,m=a.getExternalGrammar(d,o);if(m)if(p){let h=m.repository[p];h&&(l=Le.getCompiledRuleId(h,a,m.repository))}else l=Le.getCompiledRuleId(m.repository.$self,a,m.repository);break}}else l=Le.getCompiledRuleId(i,a,o);if(l!==-1){let u=a.getRule(l),c=!1;if((u instanceof zn||u instanceof Vo||u instanceof Ua)&&u.hasMissingPatterns&&u.patterns.length===0&&(c=!0),c)continue;r.push(l)}}return{patterns:r,hasMissingPatterns:(t?t.length:0)!==r.length}}},ra=class li{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,a){if(t&&typeof t=="string"){let o=t.length,r=0,s=[],n=!1;for(let i=0;i<o;i++)if(t.charAt(i)==="\\"&&i+1<o){let u=t.charAt(i+1);u==="z"?(s.push(t.substring(r,i)),s.push("$(?!\\n)(?<!\\n)"),r=i+2):(u==="A"||u==="G")&&(n=!0),i++}this.hasAnchor=n,r===0?this.source=t:(s.push(t.substring(r,o)),this.source=s.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=a,typeof this.source=="string"?this.hasBackReferences=rf.test(this.source):this.hasBackReferences=!1}clone(){return new li(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,a){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let o=a.map(r=>t.substring(r.start,r.end));return jn.lastIndex=0,this.source.replace(jn,(r,s)=>ei(o[parseInt(s,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],a=[],o=[],r=[],s,n,i,l;for(s=0,n=this.source.length;s<n;s++)i=this.source.charAt(s),t[s]=i,a[s]=i,o[s]=i,r[s]=i,i==="\\"&&s+1<n&&(l=this.source.charAt(s+1),l==="A"?(t[s+1]="\uFFFF",a[s+1]="\uFFFF",o[s+1]="A",r[s+1]="A"):l==="G"?(t[s+1]="\uFFFF",a[s+1]="G",o[s+1]="\uFFFF",r[s+1]="G"):(t[s+1]=l,a[s+1]=l,o[s+1]=l,r[s+1]=l),s++);return{A0_G0:t.join(""),A0_G1:a.join(""),A1_G0:o.join(""),A1_G1:r.join("")}}resolveAnchors(t,a){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?a?this._anchorCache.A1_G1:this._anchorCache.A1_G0:a?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},sa=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(a=>a.source);this._cached=new Vn(e,t,this._items.map(a=>a.ruleId))}return this._cached}compileAG(e,t,a){return this._hasAnchors?t?a?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G0):a?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,a){let o=this._items.map(r=>r.resolveAnchors(t,a));return new Vn(e,o,this._items.map(r=>r.ruleId))}},Vn=class{constructor(e,t,a){this.regExps=t,this.rules=a,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){let e=[];for(let t=0,a=this.rules.length;t<a;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
69
- `)}findNextMatchSync(e,t,a){let o=this.scanner.findNextMatchSync(e,t,a);return o?{ruleId:this.rules[o.index],captureIndices:o.captureIndices}:null}},Wo=class{constructor(e,t){this.languageId=e,this.tokenType=t}},uf=class $o{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,a){this._defaultAttributes=new Wo(t,8),this._embeddedLanguagesMatcher=new df(Object.entries(a||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?$o._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Wo(0,0);_getBasicScopeAttributes=new ti(t=>{let a=this._scopeToLanguage(t),o=this._toStandardTokenType(t);return new Wo(a,o)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let a=t.match($o.STANDARD_TOKEN_TYPE_REGEXP);if(!a)return 8;switch(a[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},df=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([a,o])=>ei(a));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},tb={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},ui=!1,$n=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function di(e,t,a,o,r,s,n,i){let l=t.content.length,u=!1,c=-1;if(n){let m=cf(e,t,a,o,r,s);r=m.stack,o=m.linePos,a=m.isFirstLine,c=m.anchorPosition}let d=Date.now();for(;!u;){if(i!==0&&Date.now()-d>i)return new $n(r,!0);p()}return new $n(r,!1);function p(){let m=ff(e,t,a,o,r,c);if(!m){s.produce(r,l),u=!0;return}let h=m.captureIndices,I=m.matchedRuleId,L=h&&h.length>0?h[0].end>o:!1;if(I===sf){let S=r.getRule(e);s.produce(r,h[0].start),r=r.withContentNameScopesList(r.nameScopesList),ea(e,t,a,r,s,S.endCaptures,h),s.produce(r,h[0].end);let C=r;if(r=r.parent,c=C.getAnchorPos(),!L&&C.getEnterPos()===o){r=C,s.produce(r,l),u=!0;return}}else{let S=e.getRule(I);s.produce(r,h[0].start);let C=r,g=S.getName(t.content,h),b=r.contentNameScopesList.pushAttributed(g,e);if(r=r.push(I,o,c,h[0].end===l,null,b,b),S instanceof Vo){let P=S;ea(e,t,a,r,s,P.beginCaptures,h),s.produce(r,h[0].end),c=h[0].end;let A=P.getContentName(t.content,h),v=b.pushAttributed(A,e);if(r=r.withContentNameScopesList(v),P.endHasBackReferences&&(r=r.withEndRule(P.getEndWithResolvedBackReferences(t.content,h))),!L&&C.hasSameRuleAs(r)){r=r.pop(),s.produce(r,l),u=!0;return}}else if(S instanceof Ua){let P=S;ea(e,t,a,r,s,P.beginCaptures,h),s.produce(r,h[0].end),c=h[0].end;let A=P.getContentName(t.content,h),v=b.pushAttributed(A,e);if(r=r.withContentNameScopesList(v),P.whileHasBackReferences&&(r=r.withEndRule(P.getWhileWithResolvedBackReferences(t.content,h))),!L&&C.hasSameRuleAs(r)){r=r.pop(),s.produce(r,l),u=!0;return}}else if(ea(e,t,a,r,s,S.captures,h),s.produce(r,h[0].end),r=r.pop(),!L){r=r.safePop(),s.produce(r,l),u=!0;return}}h[0].end>o&&(o=h[0].end,a=!1)}}function cf(e,t,a,o,r,s){let n=r.beginRuleCapturedEOL?0:-1,i=[];for(let l=r;l;l=l.pop()){let u=l.getRule(e);u instanceof Ua&&i.push({rule:u,stack:l})}for(let l=i.pop();l;l=i.pop()){let{ruleScanner:u,findOptions:c}=hf(l.rule,e,l.stack.endRule,a,o===n),d=u.findNextMatchSync(t,o,c);if(d){if(d.ruleId!==ni){r=l.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(s.produce(l.stack,d.captureIndices[0].start),ea(e,t,a,l.stack,s,l.rule.whileCaptures,d.captureIndices),s.produce(l.stack,d.captureIndices[0].end),n=d.captureIndices[0].end,d.captureIndices[0].end>o&&(o=d.captureIndices[0].end,a=!1))}else{r=l.stack.pop();break}}return{stack:r,linePos:o,anchorPosition:n,isFirstLine:a}}function ff(e,t,a,o,r,s){let n=pf(e,t,a,o,r,s),i=e.getInjections();if(i.length===0)return n;let l=mf(i,e,t,a,o,r,s);if(!l)return n;if(!n)return l;let u=n.captureIndices[0].start,c=l.captureIndices[0].start;return c<u||l.priorityMatch&&c===u?l:n}function pf(e,t,a,o,r,s){let n=r.getRule(e),{ruleScanner:i,findOptions:l}=ci(n,e,r.endRule,a,o===s),u=i.findNextMatchSync(t,o,l);return u?{captureIndices:u.captureIndices,matchedRuleId:u.ruleId}:null}function mf(e,t,a,o,r,s,n){let i=Number.MAX_VALUE,l=null,u,c=0,d=s.contentNameScopesList.getScopeNames();for(let p=0,m=e.length;p<m;p++){let h=e[p];if(!h.matcher(d))continue;let I=t.getRule(h.ruleId),{ruleScanner:L,findOptions:S}=ci(I,t,null,o,r===n),C=L.findNextMatchSync(a,r,S);if(!C)continue;let g=C.captureIndices[0].start;if(!(g>=i)&&(i=g,l=C.captureIndices,u=C.ruleId,c=h.priority,i===r))break}return l?{priorityMatch:c===-1,captureIndices:l,matchedRuleId:u}:null}function ci(e,t,a,o,r){if(ui){let n=e.compile(t,a),i=fi(o,r);return{ruleScanner:n,findOptions:i}}return{ruleScanner:e.compileAG(t,a,o,r),findOptions:0}}function hf(e,t,a,o,r){if(ui){let n=e.compileWhile(t,a),i=fi(o,r);return{ruleScanner:n,findOptions:i}}return{ruleScanner:e.compileWhileAG(t,a,o,r),findOptions:0}}function fi(e,t){let a=0;return e||(a|=1),t||(a|=4),a}function ea(e,t,a,o,r,s,n){if(s.length===0)return;let i=t.content,l=Math.min(s.length,n.length),u=[],c=n[0].end;for(let d=0;d<l;d++){let p=s[d];if(p===null)continue;let m=n[d];if(m.length===0)continue;if(m.start>c)break;for(;u.length>0&&u[u.length-1].endPos<=m.start;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop();if(u.length>0?r.produceFromScopes(u[u.length-1].scopes,m.start):r.produce(o,m.start),p.retokenizeCapturedWithRuleId){let I=p.getName(i,n),L=o.contentNameScopesList.pushAttributed(I,e),S=p.getContentName(i,n),C=L.pushAttributed(S,e),g=o.push(p.retokenizeCapturedWithRuleId,m.start,-1,!1,null,L,C),b=e.createOnigString(i.substring(0,m.end));di(e,b,a&&m.start===0,m.start,g,r,!1,0),ri(b);continue}let h=p.getName(i,n);if(h!==null){let L=(u.length>0?u[u.length-1].scopes:o.contentNameScopesList).pushAttributed(h,e);u.push(new gf(L,m.end))}}for(;u.length>0;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var gf=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function wf(e,t,a,o,r,s,n,i){return new Lf(e,t,a,o,r,s,n,i)}function Xn(e,t,a,o,r){let s=Na(t,Ha),n=ii.getCompiledRuleId(a,o,r.repository);for(let i of s)e.push({debugSelector:t,matcher:i.matcher,ruleId:n,grammar:r,priority:i.priority})}function Ha(e,t){if(t.length<e.length)return!1;let a=0;return e.every(o=>{for(let r=a;r<t.length;r++)if(xf(t[r],o))return a=r+1,!0;return!1})}function xf(e,t){if(!e)return!1;if(e===t)return!0;let a=t.length;return e.length>a&&e.substr(0,a)===t&&e[a]==="."}var Lf=class{constructor(e,t,a,o,r,s,n,i){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=i,this._basicScopeAttributesProvider=new uf(a,o),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=n,this._grammar=Kn(t,null),this._injections=null,this._tokenTypeMatchers=[],r)for(let l of Object.keys(r)){let u=Na(l,Ha);for(let c of u)this._tokenTypeMatchers.push({matcher:c.matcher,type:r[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:r=>r===this._rootScopeName?this._grammar:this.getExternalGrammar(r),injections:r=>this._grammarRepository.injections(r)},t=[],a=this._rootScopeName,o=e.lookup(a);if(o){let r=o.injections;if(r)for(let n in r)Xn(t,n,r[n],this,o);let s=this._grammarRepository.injections(a);s&&s.forEach(n=>{let i=this.getExternalGrammar(n);if(i){let l=i.injectionSelector;l&&Xn(t,l,i,this,i)}})}return t.sort((r,s)=>r.priority-s.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,a=e(t);return this._ruleId2desc[t]=a,a}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let a=this._grammarRepository.lookup(e);if(a)return this._includedGrammars[e]=Kn(a,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,a=0){let o=this._tokenize(e,t,!1,a);return{tokens:o.lineTokens.getResult(o.ruleStack,o.lineLength),ruleStack:o.ruleStack,stoppedEarly:o.stoppedEarly}}tokenizeLine2(e,t,a=0){let o=this._tokenize(e,t,!0,a);return{tokens:o.lineTokens.getBinaryResult(o.ruleStack,o.lineLength),ruleStack:o.ruleStack,stoppedEarly:o.stoppedEarly}}_tokenize(e,t,a,o){this._rootId===-1&&(this._rootId=ii.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let r;if(!t||t===Xo.NULL){r=!0;let u=this._basicScopeAttributesProvider.getDefaultAttributes(),c=this.themeProvider.getDefaults(),d=dt.set(0,u.languageId,u.tokenType,null,c.fontStyle,c.foregroundId,c.backgroundId),p=this.getRule(this._rootId).getName(null,null),m;p?m=ta.createRootAndLookUpScopeName(p,d,this):m=ta.createRoot("unknown",d),t=new Xo(null,this._rootId,-1,-1,!1,null,m,m)}else r=!1,t.reset();e=e+`
70
- `;let s=this.createOnigString(e),n=s.content.length,i=new If(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=di(this,s,r,0,t,i,!0,o);return ri(s),{lineLength:n,lineTokens:i,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function Kn(e,t){return e=Nc(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var ta=class We{constructor(t,a,o){this.parent=t,this.scopePath=a,this.tokenAttributes=o}static fromExtension(t,a){let o=t,r=t?.scopePath??null;for(let s of a)r=qo.push(r,s.scopeNames),o=new We(o,r,s.encodedTokenAttributes);return o}static createRoot(t,a){return new We(null,new qo(null,t),a)}static createRootAndLookUpScopeName(t,a,o){let r=o.getMetadataForScope(t),s=new qo(null,t),n=o.themeProvider.themeMatch(s),i=We.mergeAttributes(a,r,n);return new We(null,s,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return We.equals(this,t)}static equals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.scopeName!==a.scopeName||t.tokenAttributes!==a.tokenAttributes)return!1;t=t.parent,a=a.parent}while(!0)}static mergeAttributes(t,a,o){let r=-1,s=0,n=0;return o!==null&&(r=o.fontStyle,s=o.foregroundId,n=o.backgroundId),dt.set(t,a.languageId,a.tokenType,null,r,s,n)}pushAttributed(t,a){if(t===null)return this;if(t.indexOf(" ")===-1)return We._pushAttributed(this,t,a);let o=t.split(/ /g),r=this;for(let s of o)r=We._pushAttributed(r,s,a);return r}static _pushAttributed(t,a,o){let r=o.getMetadataForScope(a),s=t.scopePath.push(a),n=o.themeProvider.themeMatch(s),i=We.mergeAttributes(t.tokenAttributes,r,n);return new We(t,s,i)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let a=[],o=this;for(;o&&o!==t;)a.push({encodedTokenAttributes:o.tokenAttributes,scopeNames:o.scopePath.getExtensionIfDefined(o.parent?.scopePath??null)}),o=o.parent;return o===t?a.reverse():void 0}},Xo=class ut{constructor(t,a,o,r,s,n,i,l){this.parent=t,this.ruleId=a,this.beginRuleCapturedEOL=s,this.endRule=n,this.nameScopesList=i,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=o,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new ut(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:ut._equals(this,t)}static _equals(t,a){return t===a?!0:this._structuralEquals(t,a)?ta.equals(t.contentNameScopesList,a.contentNameScopesList):!1}static _structuralEquals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.depth!==a.depth||t.ruleId!==a.ruleId||t.endRule!==a.endRule)return!1;t=t.parent,a=a.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){ut._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,a,o,r,s,n,i){return new ut(this,t,a,o,r,s,n,i)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,a){return this.parent&&(a=this.parent._writeString(t,a)),t[a++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,a}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new ut(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let a=this;for(;a&&a._enterPos===t._enterPos;){if(a.ruleId===t.ruleId)return!0;a=a.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,a){let o=ta.fromExtension(t?.nameScopesList??null,a.nameScopesList);return new ut(t,a.ruleId,a.enterPos??-1,a.anchorPos??-1,a.beginRuleCapturedEOL,a.endRule,o,ta.fromExtension(o,a.contentNameScopesList))}},Cf=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(a=>a==="*"?(this.allowAny=!0,[]):Na(a,Ha).map(o=>o.matcher)),this.unbalancedBracketScopes=t.flatMap(a=>Na(a,Ha).map(o=>o.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},If=class{constructor(e,t,a,o){this.balancedBracketSelectors=o,this._emitBinaryTokens=e,this._tokenTypeOverrides=a,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let o=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let s=e?.getScopeNames()??[];for(let n of this._tokenTypeOverrides)n.matcher(s)&&(o=dt.set(o,0,n.type,null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(s))}if(r&&(o=dt.set(o,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===o){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(o),this._lastTokenEndIndex=t;return}let a=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:a}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let a=new Uint32Array(this._binaryTokens.length);for(let o=0,r=this._binaryTokens.length;o<r;o++)a[o]=this._binaryTokens[o];return a}},Sf=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,a,o,r){if(!this._grammars.has(e)){let s=this._rawGrammars.get(e);if(!s)return null;this._grammars.set(e,wf(e,s,t,a,o,r,this,this._onigLib))}return this._grammars.get(e)}},pi=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Sf(aa.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(aa.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,a){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:a})}loadGrammarWithConfiguration(e,t,a){return this._loadGrammar(e,t,a.embeddedLanguages,a.tokenTypes,new Cf(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,o,r){let s=new Jc(this._syncRegistry,e);for(;s.Q.length>0;)s.Q.map(n=>this._loadSingleGrammar(n.scopeName)),s.processQueue();return this._grammarForScopeName(e,t,a,o,r)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let a=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,a)}}addGrammar(e,t=[],a=0,o=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,a,o)}_grammarForScopeName(e,t=0,a=null,o=null,r=null){return this._syncRegistry.grammarForScopeName(e,t,a,o,r)}},qa=Xo.NULL;f();f();f();f();f();f();var yf=/["&'<>`]/g,bf=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,kf=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Tf=/[|\\{}()[\]^$+*?.]/g,mi=new WeakMap;function hi(e,t){if(e=e.replace(t.subset?vf(t.subset):yf,o),t.subset||t.escapeOnly)return e;return e.replace(bf,a).replace(kf,o);function a(r,s,n){return t.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,n.charCodeAt(s+2),t)}function o(r,s,n){return t.format(r.charCodeAt(0),n.charCodeAt(s+1),t)}}function vf(e){let t=mi.get(e);return t||(t=Pf(e),mi.set(e,t)),t}function Pf(e){let t=[],a=-1;for(;++a<e.length;)t.push(e[a].replace(Tf,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}f();f();var Af=/[\dA-Fa-f]/;function gi(e,t,a){let o="&#x"+e.toString(16).toUpperCase();return a&&t&&!Af.test(String.fromCharCode(t))?o:o+";"}f();var Rf=/\d/;function wi(e,t,a){let o="&#"+String(e);return a&&t&&!Rf.test(String.fromCharCode(t))?o:o+";"}f();f();var xi=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];f();var Wa={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};f();var Li=["cent","copy","divide","gt","lt","not","para","times"];var Ci={}.hasOwnProperty,Qo={},Ga;for(Ga in Wa)Ci.call(Wa,Ga)&&(Qo[Wa[Ga]]=Ga);var Mf=/[^\dA-Za-z]/;function Ii(e,t,a,o){let r=String.fromCharCode(e);if(Ci.call(Qo,r)){let s=Qo[r],n="&"+s;return a&&xi.includes(s)&&!Li.includes(s)&&(!o||t&&t!==61&&Mf.test(String.fromCharCode(t)))?n:n+";"}return""}function Si(e,t,a){let o=gi(e,t,a.omitOptionalSemicolons),r;if((a.useNamedReferences||a.useShortestReferences)&&(r=Ii(e,t,a.omitOptionalSemicolons,a.attribute)),(a.useShortestReferences||!r)&&a.useShortestReferences){let s=wi(e,t,a.omitOptionalSemicolons);s.length<o.length&&(o=s)}return r&&(!a.useShortestReferences||r.length<o.length)?r:o}function Ke(e,t){return hi(e,Object.assign({format:Si},t))}var Ff=/^>|^->|<!--|-->|--!>|<!-$/g,Df=[">"],Bf=["<",">"];function yi(e,t,a,o){return o.settings.bogusComments?"<?"+Ke(e.value,Object.assign({},o.settings.characterReferences,{subset:Df}))+">":"<!--"+e.value.replace(Ff,r)+"-->";function r(s){return Ke(s,Object.assign({},o.settings.characterReferences,{subset:Bf}))}}f();function bi(e,t,a,o){return"<!"+(o.settings.upperDoctype?"DOCTYPE":"doctype")+(o.settings.tightDoctype?"":" ")+"html>"}f();f();f();var oe=ki(1),Jo=ki(-1),Ef=[];function ki(e){return t;function t(a,o,r){let s=a?a.children:Ef,n=(o||0)+e,i=s[n];if(!r)for(;i&&Lt(i);)n+=e,i=s[n];return i}}f();var _f={}.hasOwnProperty;function ja(e){return t;function t(a,o,r){return _f.call(e,a.tagName)&&e[a.tagName](a,o,r)}}var ia=ja({body:Of,caption:Zo,colgroup:Zo,dd:Wf,dt:qf,head:Zo,html:Nf,li:Hf,optgroup:Gf,option:jf,p:Uf,rp:Ti,rt:Ti,tbody:Vf,td:vi,tfoot:$f,th:vi,thead:zf,tr:Xf});function Zo(e,t,a){let o=oe(a,t,!0);return!o||o.type!=="comment"&&!(o.type==="text"&&Lt(o.value.charAt(0)))}function Nf(e,t,a){let o=oe(a,t);return!o||o.type!=="comment"}function Of(e,t,a){let o=oe(a,t);return!o||o.type!=="comment"}function Uf(e,t,a){let o=oe(a,t);return o?o.type==="element"&&(o.tagName==="address"||o.tagName==="article"||o.tagName==="aside"||o.tagName==="blockquote"||o.tagName==="details"||o.tagName==="div"||o.tagName==="dl"||o.tagName==="fieldset"||o.tagName==="figcaption"||o.tagName==="figure"||o.tagName==="footer"||o.tagName==="form"||o.tagName==="h1"||o.tagName==="h2"||o.tagName==="h3"||o.tagName==="h4"||o.tagName==="h5"||o.tagName==="h6"||o.tagName==="header"||o.tagName==="hgroup"||o.tagName==="hr"||o.tagName==="main"||o.tagName==="menu"||o.tagName==="nav"||o.tagName==="ol"||o.tagName==="p"||o.tagName==="pre"||o.tagName==="section"||o.tagName==="table"||o.tagName==="ul"):!a||!(a.type==="element"&&(a.tagName==="a"||a.tagName==="audio"||a.tagName==="del"||a.tagName==="ins"||a.tagName==="map"||a.tagName==="noscript"||a.tagName==="video"))}function Hf(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&o.tagName==="li"}function qf(e,t,a){let o=oe(a,t);return!!(o&&o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd"))}function Wf(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd")}function Ti(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&(o.tagName==="rp"||o.tagName==="rt")}function Gf(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&o.tagName==="optgroup"}function jf(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&(o.tagName==="option"||o.tagName==="optgroup")}function zf(e,t,a){let o=oe(a,t);return!!(o&&o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot"))}function Vf(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot")}function $f(e,t,a){return!oe(a,t)}function Xf(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&o.tagName==="tr"}function vi(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&(o.tagName==="td"||o.tagName==="th")}f();var Pi=ja({body:Jf,colgroup:Zf,head:Qf,html:Kf,tbody:Yf});function Kf(e){let t=oe(e,-1);return!t||t.type!=="comment"}function Qf(e){let t=new Set;for(let o of e.children)if(o.type==="element"&&(o.tagName==="base"||o.tagName==="title")){if(t.has(o.tagName))return!1;t.add(o.tagName)}let a=e.children[0];return!a||a.type==="element"}function Jf(e){let t=oe(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Lt(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function Zf(e,t,a){let o=Jo(a,t),r=oe(e,-1,!0);return a&&o&&o.type==="element"&&o.tagName==="colgroup"&&ia(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function Yf(e,t,a){let o=Jo(a,t),r=oe(e,-1);return a&&o&&o.type==="element"&&(o.tagName==="thead"||o.tagName==="tbody")&&ia(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}var za={name:[[`
68
+ `):e}function Wn(e){let{apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:n,beforeRequest:s,mcpServerUrl:i,resolveConfig:l,debug:u,webSearch:c}=e,d=He("chat",u);return async function(m){d("\u2192 POST",m.url);try{let h=await m.json(),I=h.messages??[],L=h.sessionId,S=h.modelContext,C=r,g=typeof h.extra=="object"&&h.extra!==null&&!Array.isArray(h.extra)?h.extra:void 0,y=h.visitorContext??null,A=Hn(m),R={geo:A,client:y};if(d("body parsed \u2014 messages:",I.length,"sessionId:",L??"(none)","geo:",JSON.stringify(A)),s){d("running beforeRequest hook");try{let B=await s({messages:I,sessionId:L,modelContext:S,request:m,visitor:R});B&&(B.messages&&(I=B.messages),B.systemPrompt!==void 0&&(C=B.systemPrompt),B.sessionId!==void 0&&(L=B.sessionId),B.modelContext!==void 0&&(S=B.modelContext)),d("beforeRequest hook done \u2014 messages:",I.length,"sessionId:",L??"(none)")}catch(B){console.error("[waniwani:chat] beforeRequest hook error:",B);let k=B instanceof ve?B.status:400,v=B instanceof Error?B.message:"Request rejected";return d("\u2190 returning",k,"from hook error"),Response.json({error:v},{status:k})}}let P=i??(await l()).mcpServerUrl;d("mcpServerUrl:",P),C=qn(C,S);let M=`${a}/api/mcp/chat`;d("forwarding to",M);let N=m.headers.get("user-agent"),D=await fetch(M,{method:"POST",headers:{"Content-Type":"application/json","X-WaniWani-Stream-Protocol":"2",...t?{Authorization:`Bearer ${t}`}:{},...N?{"X-Client-User-Agent":N}:{}},body:JSON.stringify({messages:I,mcpServerUrl:P,sessionId:L,source:o,systemPrompt:C,maxSteps:n,visitor:R,webSearch:c,...g&&{extra:g}}),signal:m.signal});if(d("upstream response status:",D.status),!D.ok){let B=await D.text().catch(()=>"");return d("\u2190 returning",D.status,"upstream error:",B),new Response(B,{status:D.status,headers:{"Content-Type":D.headers.get("Content-Type")??"application/json"}})}let _=new Headers({"Content-Type":D.headers.get("Content-Type")??"text/event-stream"}),T=D.headers.get("x-session-id");return T&&_.set("x-session-id",T),d("\u2190 streaming response",D.status,"body null?",D.body===null),new Response(D.body,{status:D.status,headers:_})}catch(h){console.error("[waniwani:chat] handler error:",h);let I=h instanceof Error?h.message:"Unknown error occurred",L=h instanceof ve?h.status:500;return d("\u2190 returning",L,"from caught error"),Response.json({error:I},{status:L})}}}f();function Gn(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=He("resource",o);return async function(s){r("\u2192 GET",s.toString());try{let i=s.searchParams.get("uri");if(r("uri:",i??"(missing)"),!i)return r("\u2190 400 missing uri"),Response.json({error:"Missing uri query parameter"},{status:400});let l=t??(await a()).mcpServerUrl;r("mcpServerUrl:",l);let u,c;try{[{createMCPClient:u},{StreamableHTTPClientTransport:c}]=await Promise.all([import("@ai-sdk/mcp"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),r("MCP deps loaded")}catch(p){return console.error("[waniwani:resource] MCP deps import failed:",p),Response.json({error:"MCP resource handler requires @ai-sdk/mcp and @modelcontextprotocol/sdk. Install them to enable resource serving."},{status:501})}r("creating MCP client for",l);let d=await u({transport:new c(new URL(l))});try{r("reading resource:",i);let p=await d.readResource({uri:i});r("resource contents count:",p.contents.length);let m=p.contents[0];if(!m)return r("\u2190 404 resource not found"),Response.json({error:"Resource not found"},{status:404});let h;return"text"in m&&typeof m.text=="string"?h=m.text:"blob"in m&&typeof m.blob=="string"&&(h=atob(m.blob)),h?(r("\u2190 200 HTML length:",h.length),new Response(h,{headers:{"Content-Type":"text/html","Cache-Control":"private, max-age=300"}})):(r("\u2190 404 resource has no content, keys:",Object.keys(m)),Response.json({error:"Resource has no content"},{status:404}))}finally{await d.close(),r("MCP client closed")}}catch(i){console.error("[waniwani:resource] handler error:",i);let l=i instanceof Error?i.message:"Unknown error occurred",u=i instanceof ve?i.status:500;return r("\u2190 returning",u,"from caught error"),Response.json({error:l},{status:u})}}}f();function jn(e){let{mcpServerUrl:t,resolveConfig:a,debug:o,source:r}=e,n=He("tool",o);return async function(i){n("\u2192 POST",i.url);try{let l=await i.json(),{name:u,arguments:c}=l,d=i.headers.get("x-session-id")?.trim();if(!u||typeof u!="string")return n("\u2190 400 missing tool name"),Response.json({error:"Missing tool name"},{status:400});n("tool:",u,"args:",JSON.stringify(c),"sessionId:",d||"(none)");let p=t??(await a()).mcpServerUrl;n("mcpServerUrl:",p);let m,h;try{[{Client:m},{StreamableHTTPClientTransport:h}]=await Promise.all([import("@modelcontextprotocol/sdk/client/index.js"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),n("MCP deps loaded")}catch(S){return console.error("[waniwani:tool] MCP deps import failed:",S),Response.json({error:"MCP tool handler requires @modelcontextprotocol/sdk. Install it to enable tool calls."},{status:501})}n("creating MCP client for",p);let I=new h(new URL(p)),L=new m({name:"waniwani-tool-caller",version:"1.0.0"});await L.connect(I);try{n("calling tool:",u);let S={};d&&(S["waniwani/sessionId"]=d),r&&(S["waniwani/source"]=r);let C=await L.callTool({name:u,arguments:c??{},...Object.keys(S).length>0?{_meta:S}:{}});return n("tool result received"),Response.json({content:C.content,structuredContent:C.structuredContent,_meta:C._meta,isError:C.isError})}finally{await L.close(),n("MCP client closed")}}catch(l){console.error("[waniwani:tool] handler error:",l);let u=l instanceof Error?l.message:"Unknown error occurred",c=l instanceof ve?l.status:500;return n("\u2190 returning",c,"from caught error"),Response.json({error:u},{status:c})}}}f();function zn(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=He("tools-list",o);return async function(){r("\u2192 GET tools/list");try{let s=t??(await a()).mcpServerUrl;r("mcpServerUrl:",s);let i,l;try{[{createMCPClient:i},{StreamableHTTPClientTransport:l}]=await Promise.all([import("@ai-sdk/mcp"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),r("MCP deps loaded")}catch(c){return console.error("[waniwani:tools-list] MCP deps import failed:",c),Response.json({error:"MCP tools list handler requires @ai-sdk/mcp and @modelcontextprotocol/sdk. Install them to enable tool discovery."},{status:501})}r("creating MCP client for",s);let u=await i({transport:new l(new URL(s))});try{r("listing tools");let c=await u.listTools();r("tools count:",c.tools.length);let d={tools:c.tools.map(p=>({name:p.name,...p.title!==void 0&&{title:p.title},...p.description!==void 0&&{description:p.description},...p.inputSchema!==void 0&&{inputSchema:p.inputSchema},...p.outputSchema!==void 0&&{outputSchema:p.outputSchema},...p.annotations!==void 0&&{annotations:p.annotations},...p._meta!==void 0&&{_meta:p._meta}})),...c.nextCursor!==void 0&&{nextCursor:c.nextCursor}};return r("\u2190 200"),Response.json(d,{headers:{"Cache-Control":"private, max-age=60"}})}finally{await u.close(),r("MCP client closed")}}catch(s){console.error("[waniwani:tools-list] handler error:",s);let i=s instanceof Error?s.message:"Unknown error occurred",l=s instanceof ve?s.status:500;return r("\u2190 returning",l,"from caught error"),Response.json({error:i},{status:l})}}}f();var gd=300*1e3;function Vn(e,t){let a=null,o=null;return async function(){if(a&&Date.now()<a.expiresAt)return a.config;if(o)return o;o=(async()=>{if(!t)throw new ve("WANIWANI_API_KEY is required for createChatHandler",401);let n=await fetch(`${e}/api/mcp/environments/config`,{method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!n.ok){let i=await n.text().catch(()=>"");throw new ve(`Failed to resolve MCP environment config: ${n.status} ${i}`,n.status)}let s=await n.json();return a={config:s,expiresAt:Date.now()+gd},s})();try{return await o}finally{o=null}}}var wd="https://app.waniwani.ai";function $n(e={}){let{apiKey:t=process.env.WANIWANI_API_KEY,apiUrl:a=wd,source:o,systemPrompt:r,maxSteps:n=5,beforeRequest:s,mcpServerUrl:i,debug:l=!1,webSearch:u}=e,c=He("router",l),d=On(),p=Un(d),m=Vn(a,t),h=Wn({apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:n,beforeRequest:s,mcpServerUrl:i,resolveConfig:m,debug:l,webSearch:Nn(u)}),I=Gn({mcpServerUrl:i,resolveConfig:m,debug:l}),L=zn({mcpServerUrl:i,resolveConfig:m,debug:l}),S=jn({mcpServerUrl:i,resolveConfig:m,debug:l,source:o}),C=process.env.WANIWANI_EVAL==="1";async function g(P){c("\u2192 GET",P.url);try{let M=new URL(P.url),D=M.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",M.pathname,"subRoute:",D),C&&D==="scenarios"){c("dispatching to scenarios handler (proxy to app API)");try{let T=await(await fetch(`${a}/api/mcp/scenarios`,{headers:{...t?{Authorization:`Bearer ${t}`}:{}}})).json();return p(T.data??T,200)}catch{return p([],200)}}if(D==="resource"){c("dispatching to resource handler");let _=await I(M);return c("\u2190 resource handler returned",_.status),d(_)}if(D==="config")return c("dispatching to config handler"),p({debug:l,eval:C},200);if(D==="tools"){c("dispatching to tools-list handler");let _=await L();return c("\u2190 tools-list handler returned",_.status),d(_)}return c("\u2190 404 no matching sub-route for",D),p({error:"Not found"},404)}catch(M){console.error("[waniwani:router] GET handler error:",M);let N=M instanceof Error?M.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:N},500)}}async function y(P){c("\u2192 POST",P.url);try{let M=new URL(P.url),D=M.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",M.pathname,"subRoute:",D),C&&D==="scenarios"){c("dispatching to save-scenario handler (proxy to app API)");try{let T=await P.json(),B=await fetch(`${a}/api/mcp/scenarios`,{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(T)}),k=await B.json();return B.ok?p({ok:!0,scenario:k.data},200):p({error:k.message??"Failed to save scenario"},B.status)}catch(T){let B=T instanceof Error?T.message:"Failed to save scenario";return p({error:B},400)}}if(D==="tool"){c("dispatching to tool handler");let T=await S(P);return c("\u2190 tool handler returned",T.status),d(T)}c("dispatching to chat handler");let _=await h(P);return d(_)}catch(M){console.error("[waniwani:router] POST handler error:",M);let N=M instanceof Error?M.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:N},500)}}async function A(P){c("\u2192 PATCH",P.url);try{let M=new URL(P.url),N=M.pathname.replace(/\/$/,"").split("/").filter(Boolean),D=N.at(-1),_=N.at(-2);if(c("pathname:",M.pathname,"subRoute:",_,"id:",D),C&&_==="scenarios"&&D){c("dispatching to update-scenario handler (proxy to app API)");try{let T=await P.json(),B=await fetch(`${a}/api/mcp/scenarios/${D}`,{method:"PATCH",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(T)}),k=await B.json();return B.ok?p({ok:!0,scenario:k.data},200):p({error:k.message??"Failed to update scenario"},B.status)}catch(T){let B=T instanceof Error?T.message:"Failed to update scenario";return p({error:B},400)}}return c("\u2190 404 no matching sub-route for PATCH",_),p({error:"Not found"},404)}catch(M){console.error("[waniwani:router] PATCH handler error:",M);let N=M instanceof Error?M.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:N},500)}}function R(){return d(new Response(null,{status:204}))}return{handleChat:h,handleResource:I,handleTool:S,routeGet:g,routePost:y,routePatch:A,handleOptions:R}}var Xn=!1;function ML(e,t){!Xn&&process.env.NODE_ENV!=="test"&&(console.warn("[waniwani-sdk] toNextJsHandler is deprecated; switch to toExpressJsHandler from @waniwani/sdk/express-js. It will be removed in a follow-up release."),Xn=!0);let{apiKey:a,apiUrl:o}=e._config,r=t?.debug??process.env.WANIWANI_DEBUG==="1",n=$n({...t?.chat,apiKey:a,apiUrl:o,source:t?.source,debug:r});return{POST:n.routePost,GET:n.routeGet,PATCH:n.routePatch,OPTIONS:()=>n.handleOptions()}}f();import{forwardRef as fg,useCallback as Wr,useEffect as pg,useImperativeHandle as mg,useRef as pu,useState as mu}from"react";f();f();f();import{forwardRef as Ld,createElement as Cd}from"react";f();var Aa=(...e)=>e.filter((t,a,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===a).join(" ").trim();f();var Kn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();f();f();var Qn=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,o)=>o?o.toUpperCase():a.toLowerCase());var Ao=e=>{let t=Qn(e);return t.charAt(0).toUpperCase()+t.slice(1)};f();import{forwardRef as xd,createElement as Yn}from"react";f();var Jn={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};f();var Zn=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var es=xd(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:o,className:r="",children:n,iconNode:s,...i},l)=>Yn("svg",{ref:l,...Jn,width:t,height:t,stroke:e,strokeWidth:o?Number(a)*24/Number(t):a,className:Aa("lucide",r),...!n&&!Zn(i)&&{"aria-hidden":"true"},...i},[...s.map(([u,c])=>Yn(u,c)),...Array.isArray(n)?n:[n]]));var W=(e,t)=>{let a=Ld(({className:o,...r},n)=>Cd(es,{ref:n,iconNode:t,className:Aa(`lucide-${Kn(Ao(e))}`,`lucide-${e}`,o),...r}));return a.displayName=Ao(e),a};f();var Id=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ht=W("arrow-down",Id);f();var Sd=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],qt=W("arrow-up",Sd);f();var yd=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Wt=W("check",yd);f();var bd=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Je=W("chevron-down",bd);f();var kd=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Gt=W("chevron-right",kd);f();var Td=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],jt=W("clipboard-copy",Td);f();var vd=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],st=W("clock",vd);f();var Pd=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],zt=W("file",Pd);f();var Ad=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Vt=W("globe",Ad);f();var Rd=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],$t=W("loader",Rd);f();var Md=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Xt=W("paperclip",Md);f();var Fd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Kt=W("square",Fd);f();var Dd=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],$e=W("wrench",Dd);f();var Bd=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],it=W("x",Bd);f();var Ed=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Qt=W("zap",Ed);import{useCallback as Zd}from"react";f();import{useCallback as Ze,useMemo as _d,useRef as Nd,useState as Ro}from"react";var Od={damping:.7,stiffness:.05,mass:1.25},Ud=70,Hd=1e3/60,qd=350,Ra=!1;globalThis.document?.addEventListener("mousedown",()=>{Ra=!0});globalThis.document?.addEventListener("mouseup",()=>{Ra=!1});globalThis.document?.addEventListener("click",()=>{Ra=!1});var as=(e={})=>{let[t,a]=Ro(!1),[o,r]=Ro(e.initial!==!1),[n,s]=Ro(!1),i=Nd(null);i.current=e;let l=Ze(()=>{if(!Ra)return!1;let C=window.getSelection();if(!C||!C.rangeCount)return!1;let g=C.getRangeAt(0);return g.commonAncestorContainer.contains(L.current)||L.current?.contains(g.commonAncestorContainer)},[]),u=Ze(C=>{d.isAtBottom=C,r(C)},[]),c=Ze(C=>{d.escapedFromLock=C,a(C)},[]),d=_d(()=>{let C;return{escapedFromLock:t,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return L.current?.scrollTop??0},set scrollTop(g){L.current&&(L.current.scrollTop=g,d.ignoreScrollToTop=L.current.scrollTop)},get targetScrollTop(){return!L.current||!S.current?0:L.current.scrollHeight-1-L.current.clientHeight},get calculatedTargetScrollTop(){if(!L.current||!S.current)return 0;let{targetScrollTop:g}=this;if(!e.targetScrollTop)return g;if(C?.targetScrollTop===g)return C.calculatedScrollTop;let y=Math.max(Math.min(e.targetScrollTop(g,{scrollElement:L.current,contentElement:S.current}),g),0);return C={targetScrollTop:g,calculatedScrollTop:y},requestAnimationFrame(()=>{C=void 0}),y},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Ud}}},[]),p=Ze((C={})=>{typeof C=="string"&&(C={animation:C}),C.preserveScrollPosition||u(!0);let g=Date.now()+(Number(C.wait)||0),y=Fo(i.current,C.animation),{ignoreEscapes:A=!1}=C,R,P=d.calculatedTargetScrollTop;C.duration instanceof Promise?C.duration.finally(()=>{R=Date.now()}):R=g+(C.duration??0);let M=async()=>{let N=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:D}=d,_=performance.now(),T=(_-(d.lastTick??_))/Hd;if(d.animation||(d.animation={behavior:y,promise:N,ignoreEscapes:A}),d.animation.behavior===y&&(d.lastTick=_),l()||g>Date.now())return M();if(D<Math.min(P,d.calculatedTargetScrollTop)){if(d.animation?.behavior===y){if(y==="instant")return d.scrollTop=d.calculatedTargetScrollTop,M();d.velocity=(y.damping*d.velocity+y.stiffness*d.scrollDifference)/y.mass,d.accumulated+=d.velocity*T,d.scrollTop+=d.accumulated,d.scrollTop!==D&&(d.accumulated=0)}return M()}return R>Date.now()?(P=d.calculatedTargetScrollTop,M()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?p({animation:Fo(i.current,i.current.resize),ignoreEscapes:A,duration:Math.max(0,R-Date.now())||void 0}):d.isAtBottom)});return N.then(D=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),D))};return C.wait!==!0&&(d.animation=void 0),d.animation?.behavior===y?d.animation.promise:M()},[u,l,d]),m=Ze(()=>{c(!0),u(!1)},[c,u]),h=Ze(({target:C})=>{if(C!==L.current)return;let{scrollTop:g,ignoreScrollToTop:y}=d,{lastScrollTop:A=g}=d;d.lastScrollTop=g,d.ignoreScrollToTop=void 0,y&&y>g&&(A=y),s(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||g===y)return;if(l()){c(!0),u(!1);return}let R=g>A,P=g<A;if(d.animation?.ignoreEscapes){d.scrollTop=A;return}P&&(c(!0),u(!1)),R&&c(!1),!d.escapedFromLock&&d.isNearBottom&&u(!0)},1)},[c,u,l,d]),I=Ze(({target:C,deltaY:g})=>{let y=C;for(;!["scroll","auto"].includes(getComputedStyle(y).overflow);){if(!y.parentElement)return;y=y.parentElement}y===L.current&&g<0&&L.current.scrollHeight>L.current.clientHeight&&!d.animation?.ignoreEscapes&&(c(!0),u(!1))},[c,u,d]),L=ts(C=>{L.current?.removeEventListener("scroll",h),L.current?.removeEventListener("wheel",I),C?.addEventListener("scroll",h,{passive:!0}),C?.addEventListener("wheel",I,{passive:!0})},[]),S=ts(C=>{if(d.resizeObserver?.disconnect(),!C)return;let g;d.resizeObserver=new ResizeObserver(([y])=>{let{height:A}=y.contentRect,R=A-(g??A);if(d.resizeDifference=R,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),s(d.isNearBottom),R>=0){let P=Fo(i.current,g?i.current.resize:i.current.initial);p({animation:P,wait:!0,preserveScrollPosition:!0,duration:P==="instant"?void 0:qd})}else d.isNearBottom&&(c(!1),u(!0));g=A,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===R&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(C)},[]);return{contentRef:S,scrollRef:L,scrollToBottom:p,stopScroll:m,isAtBottom:o||n,isNearBottom:n,escapedFromLock:t,state:d}};function ts(e,t){let a=Ze(o=>(a.current=o,e(o)),t);return a}var Mo=new Map;function Fo(...e){let t={...Od},a=!1;for(let r of e){if(r==="instant"){a=!0;continue}typeof r=="object"&&(a=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let o=JSON.stringify(t);return Mo.has(o)||Mo.set(o,Object.freeze(t)),a?"instant":Mo.get(o)}f();import*as lt from"react";import{createContext as Wd,useContext as Gd,useEffect as jd,useImperativeHandle as zd,useLayoutEffect as Vd,useMemo as $d,useRef as Xd}from"react";var os=Wd(null),Kd=typeof window<"u"?Vd:jd;function Jt({instance:e,children:t,resize:a,initial:o,mass:r,damping:n,stiffness:s,targetScrollTop:i,contextRef:l,...u}){let c=Xd(null),d=lt.useCallback((A,R)=>(y?.targetScrollTop??i)?.(A,R)??A,[i]),p=as({mass:r,damping:n,stiffness:s,resize:a,initial:o,targetScrollTop:d}),{scrollRef:m,contentRef:h,scrollToBottom:I,stopScroll:L,isAtBottom:S,escapedFromLock:C,state:g}=e??p,y=$d(()=>({scrollToBottom:I,stopScroll:L,scrollRef:m,isAtBottom:S,escapedFromLock:C,contentRef:h,state:g,get targetScrollTop(){return c.current},set targetScrollTop(A){c.current=A}}),[I,S,h,m,L,C,g]);return zd(l,()=>y,[y]),Kd(()=>{m.current&&getComputedStyle(m.current).overflow==="visible"&&(m.current.style.overflow="auto")},[]),lt.createElement(os.Provider,{value:y},lt.createElement("div",{...u},typeof t=="function"?t(y):t))}(function(e){function t({children:a,scrollClassName:o,...r}){let n=Do();return lt.createElement("div",{ref:n.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:o},lt.createElement("div",{...r,ref:n.contentRef},typeof a=="function"?a(n):a))}e.Content=t})(Jt||(Jt={}));function Do(){let e=Gd(os);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}f();var Qd=Kr({prefix:"ww"});function F(...e){return Qd(Xr(e))}f();import{jsx as Jd}from"react/jsx-runtime";var qe=({className:e,variant:t="default",size:a="default",type:o="button",...r})=>Jd("button",{type:o,className:F("ww:inline-flex ww:cursor-pointer ww:items-center ww:justify-center ww:rounded-md ww:font-medium ww:transition-colors ww:disabled:pointer-events-none ww:disabled:opacity-50",t==="default"&&"ww:bg-primary ww:text-primary-foreground ww:hover:bg-primary/90",t==="outline"&&"ww:border ww:border-border ww:bg-background ww:hover:bg-accent ww:hover:text-accent-foreground",t==="ghost"&&"ww:hover:bg-accent ww:hover:text-accent-foreground",a==="default"&&"ww:h-9 ww:px-4 ww:py-2 ww:text-sm",a==="sm"&&"ww:h-8 ww:px-3 ww:text-xs",a==="icon"&&"ww:size-9 ww:!rounded-full",a==="icon-sm"&&"ww:size-7 ww:!rounded-full",e),...r});import{jsx as Ma}from"react/jsx-runtime";var rs=({className:e,...t})=>Ma(Jt,{className:F("ww:relative ww:flex-1 ww:overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),ns=({className:e,...t})=>Ma(Jt.Content,{className:F("ww:flex ww:flex-col ww:gap-6 ww:px-4 ww:py-6 ww:mx-auto ww:w-full ww:max-w-3xl",e),...t}),ss=({className:e,...t})=>{let{isAtBottom:a,scrollToBottom:o}=Do(),r=Zd(()=>{o()},[o]);return!a&&Ma(qe,{className:F("ww:absolute ww:bottom-4 ww:left-[50%] ww:translate-x-[-50%] ww:rounded-full",e),onClick:r,size:"icon",variant:"outline",...t,children:Ma(Ht,{className:"ww:size-4"})})};f();f();import ls from"crypto";f();var is="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Yd=128,ut,kt,ec=e=>{!ut||ut.length<e?(ut=Buffer.allocUnsafe(e*Yd),ls.randomFillSync(ut),kt=0):kt+e>ut.length&&(ls.randomFillSync(ut),kt=0),kt+=e};var Zt=(e=21)=>{ec(e|=0);let t="";for(let a=kt-e;a<kt;a++)t+=is[ut[a]&63];return t};import{createContext as sc,useCallback as Xe,useContext as ic,useEffect as No,useMemo as lc,useRef as Oo,useState as us}from"react";f();f();import{createContext as oc,useContext as rc,useEffect as uS,useMemo as dS,useState as cS}from"react";f();f();f();f();var Eo={promptInput:{placeholder:"What would you like to know?",uploadFiles:"Upload files",stop:"Stop",submit:"Submit",removeAttachments:"Remove all attachments"},workingIndicator:{default:"On it\u2026"},reasoning:{thinking:"Thinking\u2026",thoughtBrief:"Thought for a few seconds",thoughtForSeconds:e=>`Thought for ${e} second${e===1?"":"s"}`},tool:{copy:"Copy",copied:"Copied",request:"Request",response:"Response",error:"Error"},attachments:{attachmentFallback:"attachment",fileFallback:"file"},threadMenu:{newChat:"New chat",threadHistory:"Thread history",deleteThread:"Delete thread",noPreviousChats:"No previous chats yet.",hiddenThreads:e=>`${e} older thread${e===1?"":"s"} hidden`},chatQueue:{attachmentFallback:"(attachment)",removeFromQueue:"Remove from queue",queued:e=>`${e} queued`},poweredBy:{label:"AI agent powered by"},aiDisclaimer:{default:"can make mistakes"},exportSession:{saving:"saving...",saved:"saved",error:"error",export:"export",tooltip:"Save scenario to Waniwani"},widgetErrorBoundary:{failedToLoad:"Widget failed to load",retry:"Retry"},launcher:{prompt:"Ask anything\u2026",open:"Open chat",close:"Close chat",minimize:"Minimize"}};f();f();import{jsx as xS}from"react/jsx-runtime";var nc=oc(null);function V(){let e=rc(nc);return e||{locale:"en",t:Eo,ready:!0}}f();function _o(e,t){let a=Date.now()-e;if(a<6e4)try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"narrow"}).format(0,"second")}catch{return"just now"}let o,r;a<60*6e4?(o=-Math.floor(a/6e4),r="minute"):a<1440*6e4?(o=-Math.floor(a/(60*6e4)),r="hour"):(o=-Math.floor(a/(1440*6e4)),r="day");try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"short"}).format(o,r)}catch{return`${Math.abs(o)}${r==="minute"?"m":r==="hour"?"h":"d"} ago`}}import{jsx as _e,jsxs as gs}from"react/jsx-runtime";var uc=async e=>{try{let a=await(await fetch(e)).blob();return new Promise(o=>{let r=new FileReader;r.onloadend=()=>o(r.result),r.onerror=()=>o(null),r.readAsDataURL(a)})}catch{return null}},ds=sc(null),cs=()=>{let e=ic(ds);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},fs=({className:e,accept:t,multiple:a,globalDrop:o,maxFiles:r,maxFileSize:n,onSubmit:s,children:i,...l})=>{let{t:u}=V(),c=Oo(null),d=Oo(null),[p,m]=us([]),h=Oo(p);No(()=>{h.current=p},[p]);let I=Xe(()=>{c.current?.click()},[]),L=Xe(R=>{let P=[...R];if(P.length===0)return;let M=D=>n?D.size<=n:!0,N=P.filter(M);m(D=>{let _=typeof r=="number"?Math.max(0,r-D.length):void 0,T=typeof _=="number"?N.slice(0,_):N;return[...D,...T.map(B=>({filename:B.name,id:Zt(),mediaType:B.type,type:"file",url:URL.createObjectURL(B)}))]})},[r,n]),S=Xe(R=>{m(P=>{let M=P.find(N=>N.id===R);return M?.url&&URL.revokeObjectURL(M.url),P.filter(N=>N.id!==R)})},[]),C=Xe(()=>{m(R=>{for(let P of R)P.url&&URL.revokeObjectURL(P.url);return[]})},[]);No(()=>()=>{for(let R of h.current)R.url&&URL.revokeObjectURL(R.url)},[]);let g=Xe(R=>{R.currentTarget.files&&L(R.currentTarget.files),R.currentTarget.value=""},[L]);No(()=>{if(!o)return;let R=M=>{M.dataTransfer?.types?.includes("Files")&&M.preventDefault()},P=M=>{M.dataTransfer?.types?.includes("Files")&&M.preventDefault(),M.dataTransfer?.files&&M.dataTransfer.files.length>0&&L(M.dataTransfer.files)};return document.addEventListener("dragover",R),document.addEventListener("drop",P),()=>{document.removeEventListener("dragover",R),document.removeEventListener("drop",P)}},[L,o]);let y=Xe(async R=>{R.preventDefault();let P=R.currentTarget,N=new FormData(P).get("message")||"";P.reset();let D=await Promise.all(p.map(async({id:_,...T})=>{if(T.url?.startsWith("blob:")){let B=await uc(T.url);return{...T,url:B??T.url}}return T}));try{let _=s({files:D,text:N},R);_ instanceof Promise&&await _,C()}catch{}},[p,s,C]),A=lc(()=>({add:L,clear:C,files:p,openFileDialog:I,remove:S}),[p,L,S,C,I]);return gs(ds.Provider,{value:A,children:[_e("input",{accept:t,"aria-label":u.promptInput.uploadFiles,className:"ww:hidden",multiple:a,onChange:g,ref:c,title:u.promptInput.uploadFiles,type:"file"}),_e("form",{className:F("ww:flex ww:w-full ww:flex-col ww:rounded-lg ww:border ww:border-border ww:bg-background",e),onSubmit:y,ref:d,...l,children:i})]})};var ps=({onChange:e,onKeyDown:t,className:a,placeholder:o,...r})=>{let{t:n}=V(),s=cs(),[i,l]=us(!1),u=o??n.promptInput.placeholder,c=Xe(p=>{if(t?.(p),!p.defaultPrevented){if(p.key==="Enter"){if(i||p.nativeEvent.isComposing||p.shiftKey)return;p.preventDefault();let{form:m}=p.currentTarget;if(m?.querySelector('button[type="submit"]')?.disabled)return;m?.requestSubmit()}if(p.key==="Backspace"&&p.currentTarget.value===""&&s.files.length>0){p.preventDefault();let m=s.files.at(-1);m&&s.remove(m.id)}}},[t,i,s]),d=Xe(p=>{let m=p.clipboardData?.items;if(!m)return;let h=[];for(let I of m)if(I.kind==="file"){let L=I.getAsFile();L&&h.push(L)}h.length>0&&(p.preventDefault(),s.add(h))},[s]);return _e("textarea",{className:F("ww:field-sizing-content ww:max-h-48 ww:min-h-0 ww:w-full ww:resize-none ww:border-0 ww:bg-transparent ww:px-3 ww:py-2 ww:text-base ww:sm:text-sm ww:outline-none ww:placeholder:text-muted-foreground",a),name:"message",onCompositionEnd:()=>l(!1),onCompositionStart:()=>l(!0),onKeyDown:c,onPaste:d,placeholder:u,onChange:e,...r})},ms=({className:e,status:t,onStop:a,onClick:o,children:r,...n})=>{let{t:s}=V(),i=t==="submitted"||t==="streaming",l=_e(qt,{className:"ww:size-4"});t==="submitted"?l=_e($t,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(l=_e(Kt,{className:"ww:size-4"}));let u=Xe(c=>{if(i&&a){c.preventDefault(),a();return}o?.(c)},[i,a,o]);return _e(qe,{"aria-label":i?s.promptInput.stop:s.promptInput.submit,className:F("ww:bg-foreground ww:text-background ww:hover:bg-foreground ww:rounded-full",e),onClick:u,size:"icon-sm",type:i&&a?"button":"submit",variant:"ghost",...n,children:r??l})},hs=({className:e,children:t,...a})=>{let{t:o}=V(),r=cs();return r.files.length>0?gs(qe,{className:F("ww:group ww:relative",e),onClick:()=>r.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":o.promptInput.removeAttachments,...a,children:[_e("span",{className:"ww:flex ww:size-5 ww:items-center ww:justify-center ww:rounded-full ww:bg-primary ww:text-[10px] ww:font-medium ww:text-primary-foreground ww:transition-opacity ww:group-hover:opacity-0",children:r.files.length}),_e(it,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]}):_e(qe,{className:F(e),onClick:()=>r.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??_e(Xt,{className:"ww:size-4"})})};f();import{memo as dc,useCallback as cc}from"react";f();import{jsx as Tt}from"react/jsx-runtime";var ws=({className:e,...t})=>Tt("div",{className:F("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),xs=({className:e,...t})=>Tt("li",{className:F("ww:group ww:flex ww:items-center ww:gap-2 ww:rounded-md ww:px-2 ww:py-1 ww:text-sm ww:transition-colors ww:hover:bg-muted",e),...t}),Ls=({className:e,...t})=>Tt("span",{className:F("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),Cs=({className:e,...t})=>Tt("span",{className:F("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),Is=({className:e,...t})=>Tt("div",{className:F("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),Ss=({className:e,...t})=>Tt(qe,{className:F("ww:size-auto ww:rounded ww:p-1 ww:text-muted-foreground ww:hover:bg-muted-foreground/10 ww:hover:text-foreground",e),size:"icon",type:"button",variant:"ghost",...t});import{jsx as Ye,jsxs as ks}from"react/jsx-runtime";var ys=dc(({message:e,onRemove:t})=>{let{t:a}=V(),o=cc(()=>t(e.id),[t,e.id]);return ks(xs,{children:[Ye(Ls,{}),Ye(Cs,{children:e.text||a.chatQueue.attachmentFallback}),Ye(Is,{children:Ye(Ss,{"aria-label":a.chatQueue.removeFromQueue,onClick:o,children:Ye(it,{className:"ww:size-3"})})})]})});ys.displayName="ChatQueueItem";function bs({queuedMessages:e,onRemove:t,className:a}){let{t:o}=V();return e.length===0?null:ks(ws,{className:F("ww:border-t ww:border-border",a),children:[Ye("div",{className:"ww:text-[11px] ww:font-medium ww:text-muted-foreground ww:px-2",children:o.chatQueue.queued(e.length)}),Ye("ul",{children:e.map(r=>Ye(ys,{message:r,onRemove:t},r.id))})]})}f();import{useState as Ts}from"react";import{jsx as fc}from"react/jsx-runtime";function vs({messages:e,evalEnabled:t,api:a="/api/waniwani"}){let{t:o}=V(),[r,n]=Ts(!1),[s,i]=Ts(null),l=async()=>{let c={name:`session-${new Date().toISOString().slice(0,19)}`,type:"functional",messages:e,mode:"manual"};n(!0),i(null);try{let d=await fetch(`${a}/scenarios`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok)throw new Error(`${d.status}`);i("saved")}catch{i("error")}finally{n(!1),setTimeout(()=>i(null),2e3)}};if(!t||e.length===0)return null;let u=r?o.exportSession.saving:s==="saved"?o.exportSession.saved:s==="error"?o.exportSession.error:o.exportSession.export;return fc("button",{type:"button",onClick:l,disabled:r,title:o.exportSession.tooltip,className:"ww:ml-auto ww:text-[10px] ww:font-mono ww:uppercase ww:tracking-wider ww:text-muted-foreground hover:ww:text-foreground ww:cursor-pointer ww:transition-colors ww:disabled:opacity-40",children:u})}f();f();import{jsx as Yt,jsxs as mc}from"react/jsx-runtime";var Ps=({files:e,className:t,...a})=>e.length===0?null:Yt("div",{className:F("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((o,r)=>Yt(pc,{file:o},r))});function pc({file:e}){let{t}=V();return e.mediaType?.startsWith("image/")&&e.url?Yt("img",{src:e.url,alt:e.filename??t.attachments.attachmentFallback,className:"ww:h-16 ww:max-w-32 ww:rounded ww:object-cover"}):mc("span",{className:"ww:inline-flex ww:items-center ww:gap-1.5 ww:rounded ww:bg-background/20 ww:px-2 ww:py-1 ww:text-xs",children:[Yt(zt,{className:"ww:size-3 ww:shrink-0"}),Yt("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??t.attachments.fileFallback})]})}f();import{createContext as Tc,useCallback as vc,useContext as Pc,useEffect as Fs,useMemo as Ac,useRef as Rc,useState as Wo}from"react";f();import{createContext as xc,memo as qo,useCallback as Lc,useContext as Cc,useEffect as Uo,useMemo as Ic,useRef as As,useState as Ho}from"react";f();f();import{memo as hc}from"react";import{jsx as wc}from"react/jsx-runtime";var gc=({as:e="span",className:t,duration:a=2,style:o,children:r,...n})=>{let s={backgroundImage:"linear-gradient(90deg, var(--ww-color-muted-foreground) 0%, var(--ww-color-muted-foreground) 40%, var(--ww-color-foreground) 50%, var(--ww-color-muted-foreground) 60%, var(--ww-color-muted-foreground) 100%)",backgroundSize:"250% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",animation:`ww-shimmer ${a}s linear infinite`,...o};return wc(e,{"data-waniwani-shimmer":"",className:F("ww:inline-block",t),style:s,...n,children:r})},Ne=hc(gc);Ne.displayName="Shimmer";import{Fragment as bc,jsx as Oe,jsxs as kc}from"react/jsx-runtime";var Rs=xc(null);function Ms(){let e=Cc(Rs);if(!e)throw new Error("Reasoning components must be used within <Reasoning>");return e}var Sc=1e3,yc=1e3,ea=qo(({className:e,isStreaming:t=!1,open:a,defaultOpen:o,onOpenChange:r,duration:n,children:s,...i})=>{let l=o??t,u=o===!1,c=a!==void 0,[d,p]=Ho(l),m=c?a:d,h=Lc(P=>{c||p(P),r?.(P)},[c,r]),[I,L]=Ho(void 0),S=n??I,C=As(t),[g,y]=Ho(!1),A=As(null);Uo(()=>{t?(C.current=!0,A.current===null&&(A.current=Date.now())):A.current!==null&&(L(Math.ceil((Date.now()-A.current)/yc)),A.current=null)},[t]),Uo(()=>{t&&!m&&!u&&h(!0)},[t,m,u,h]),Uo(()=>{if(C.current&&!t&&m&&!g){let P=setTimeout(()=>{h(!1),y(!0)},Sc);return()=>clearTimeout(P)}},[t,m,g,h]);let R=Ic(()=>({isStreaming:t,isOpen:m,setIsOpen:h,duration:S}),[t,m,h,S]);return Oe(Rs.Provider,{value:R,children:Oe("div",{className:F("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":m?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...i,children:s})})});ea.displayName="Reasoning";var ta=qo(({className:e,children:t,getThinkingMessage:a,hideIcon:o=!1,onClick:r,...n})=>{let{t:s}=V(),{isStreaming:i,isOpen:l,duration:u,setIsOpen:c}=Ms(),p=a??((m,h)=>m||h===0?Oe(Ne,{duration:1.6,children:s.reasoning.thinking}):h===void 0?Oe("span",{children:s.reasoning.thoughtBrief}):Oe("span",{children:s.reasoning.thoughtForSeconds(h)}));return Oe("button",{type:"button","aria-expanded":l,onClick:m=>{c(!l),r?.(m)},className:F("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),...n,children:t??kc(bc,{children:[!o&&Oe(st,{className:"ww:size-4 ww:shrink-0"}),p(i,u)]})})});ta.displayName="ReasoningTrigger";var aa=qo(({className:e,children:t,...a})=>{let{isOpen:o}=Ms();return Oe("div",{className:F("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:Oe("div",{className:"ww:min-h-0 ww:overflow-hidden",children:Oe("div",{className:F("ww:text-sm ww:text-muted-foreground",e),...a,children:Oe(Mt,{children:t})})})})});aa.displayName="ReasoningContent";import{jsx as ee,jsxs as dt}from"react/jsx-runtime";var Mc=1e3,Ds=Tc(null);function Bs(){let e=Pc(Ds);if(!e)throw new Error("ChainOfThought components must be used within <ChainOfThought>");return e}function Es({className:e,isWorking:t=!1,open:a,defaultOpen:o,onOpenChange:r,children:n,...s}){let i=o??t,l=a!==void 0,[u,c]=Wo(i),d=l?a:u,p=vc(S=>{l||c(S),r?.(S)},[l,r]),m=Rc(t),[h,I]=Wo(!1);Fs(()=>{t&&(m.current=!0,I(!1),l||c(!0))},[t,l]),Fs(()=>{if(m.current&&!t&&d&&!h){let S=setTimeout(()=>{p(!1),I(!0)},Mc);return()=>clearTimeout(S)}},[t,d,h,p]);let L=Ac(()=>({open:d,setOpen:p,isWorking:t}),[d,p,t]);return ee(Ds.Provider,{value:L,children:ee("div",{className:F("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":d?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...s,children:n})})}function _s({className:e,label:t,children:a,...o}){let{open:r,setOpen:n,isWorking:s}=Bs(),i=a??(s?ee(Ne,{duration:1.6,children:t??""}):t);return dt("button",{type:"button",onClick:()=>n(!r),"aria-expanded":r,className:F("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),...o,children:[ee($e,{className:"ww:size-4 ww:shrink-0"}),ee("span",{className:"ww:truncate",children:i}),ee(Je,{className:F("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function Ns({className:e,children:t,...a}){let{open:o}=Bs();return ee("div",{className:F("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:ee("div",{className:"ww:min-h-0 ww:overflow-hidden",children:ee("div",{className:F("ww:flex ww:flex-col",e),...a,children:t})})})}function Os({icon:e,isLast:t,running:a,error:o}){return dt("div",{className:"ww:flex ww:flex-col ww:items-center ww:self-stretch",children:[ee("span",{className:"ww:flex ww:h-5 ww:items-center",children:ee(e,{className:F("ww:size-4 ww:shrink-0",o?"ww:text-destructive":a?"ww:animate-pulse ww:text-foreground":"ww:text-muted-foreground")})}),!t&&ee("span",{className:"ww:w-px ww:flex-1 ww:bg-border"})]})}function Go({className:e,icon:t,title:a,state:o,isLast:r=!1,children:n,...s}){let i=o==="input-available"||o==="input-streaming",l=o==="output-error",u=n!=null,[c,d]=Wo(!1),p=a??"",m=i?ee(Ne,{duration:1.6,children:p}):ee("span",{className:"ww:truncate",children:p});return dt("div",{className:F("ww:flex ww:gap-2",e),...s,children:[ee(Os,{icon:t,isLast:r,running:i,error:l}),dt("div",{className:F("ww:min-w-0 ww:flex-1",!r&&"ww:pb-3"),children:[u?dt("button",{type:"button",onClick:()=>d(h=>!h),"aria-expanded":c,className:"ww:flex ww:w-full ww:items-center ww:gap-1.5 ww:text-left ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",children:[m,ee(Je,{className:F("ww:size-3.5 ww:shrink-0 ww:transition-transform ww:duration-200",c&&"ww:rotate-180")})]}):ee("div",{className:"ww:flex ww:items-center ww:text-sm ww:text-muted-foreground",children:m}),u&&ee("div",{className:F("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",c?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:ee("div",{className:"ww:min-h-0 ww:overflow-hidden",children:ee("div",{className:"ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",children:n})})})]})]})}function Us({isStreaming:e=!1,isLast:t=!1,children:a}){return dt("div",{className:"ww:flex ww:gap-2",children:[ee(Os,{icon:st,isLast:t,running:e}),ee("div",{className:F("ww:min-w-0 ww:flex-1",!t&&"ww:pb-3"),children:dt(ea,{isStreaming:e,className:"ww:mb-0",children:[ee(ta,{hideIcon:!0}),ee(aa,{children:a})]})})]})}f();f();f();f();f();f();var he={carriageReturn:-5,lineFeed:-4,carriageReturnLineFeed:-3,horizontalTab:-2,virtualSpace:-1,eof:null,nul:0,soh:1,stx:2,etx:3,eot:4,enq:5,ack:6,bel:7,bs:8,ht:9,lf:10,vt:11,ff:12,cr:13,so:14,si:15,dle:16,dc1:17,dc2:18,dc3:19,dc4:20,nak:21,syn:22,etb:23,can:24,em:25,sub:26,esc:27,fs:28,gs:29,rs:30,us:31,space:32,exclamationMark:33,quotationMark:34,numberSign:35,dollarSign:36,percentSign:37,ampersand:38,apostrophe:39,leftParenthesis:40,rightParenthesis:41,asterisk:42,plusSign:43,comma:44,dash:45,dot:46,slash:47,digit0:48,digit1:49,digit2:50,digit3:51,digit4:52,digit5:53,digit6:54,digit7:55,digit8:56,digit9:57,colon:58,semicolon:59,lessThan:60,equalsTo:61,greaterThan:62,questionMark:63,atSign:64,uppercaseA:65,uppercaseB:66,uppercaseC:67,uppercaseD:68,uppercaseE:69,uppercaseF:70,uppercaseG:71,uppercaseH:72,uppercaseI:73,uppercaseJ:74,uppercaseK:75,uppercaseL:76,uppercaseM:77,uppercaseN:78,uppercaseO:79,uppercaseP:80,uppercaseQ:81,uppercaseR:82,uppercaseS:83,uppercaseT:84,uppercaseU:85,uppercaseV:86,uppercaseW:87,uppercaseX:88,uppercaseY:89,uppercaseZ:90,leftSquareBracket:91,backslash:92,rightSquareBracket:93,caret:94,underscore:95,graveAccent:96,lowercaseA:97,lowercaseB:98,lowercaseC:99,lowercaseD:100,lowercaseE:101,lowercaseF:102,lowercaseG:103,lowercaseH:104,lowercaseI:105,lowercaseJ:106,lowercaseK:107,lowercaseL:108,lowercaseM:109,lowercaseN:110,lowercaseO:111,lowercaseP:112,lowercaseQ:113,lowercaseR:114,lowercaseS:115,lowercaseT:116,lowercaseU:117,lowercaseV:118,lowercaseW:119,lowercaseX:120,lowercaseY:121,lowercaseZ:122,leftCurlyBrace:123,verticalBar:124,rightCurlyBrace:125,tilde:126,del:127,byteOrderMarker:65279,replacementCharacter:65533};f();var We={attentionSideAfter:2,attentionSideBefore:1,atxHeadingOpeningFenceSizeMax:6,autolinkDomainSizeMax:63,autolinkSchemeSizeMax:32,cdataOpeningString:"CDATA[",characterGroupPunctuation:2,characterGroupWhitespace:1,characterReferenceDecimalSizeMax:7,characterReferenceHexadecimalSizeMax:6,characterReferenceNamedSizeMax:31,codeFencedSequenceSizeMin:3,contentTypeContent:"content",contentTypeDocument:"document",contentTypeFlow:"flow",contentTypeString:"string",contentTypeText:"text",hardBreakPrefixSizeMin:2,htmlBasic:6,htmlCdata:5,htmlComment:2,htmlComplete:7,htmlDeclaration:4,htmlInstruction:3,htmlRawSizeMax:8,htmlRaw:1,linkResourceDestinationBalanceMax:32,linkReferenceSizeMax:999,listItemValueSizeMax:10,numericBaseDecimal:10,numericBaseHexadecimal:16,tabSize:4,thematicBreakMarkerCountMin:3,v8MaxSafeChunkSize:1e4};f();var Ae={data:"data",whitespace:"whitespace",lineEnding:"lineEnding",lineEndingBlank:"lineEndingBlank",linePrefix:"linePrefix",lineSuffix:"lineSuffix",atxHeading:"atxHeading",atxHeadingSequence:"atxHeadingSequence",atxHeadingText:"atxHeadingText",autolink:"autolink",autolinkEmail:"autolinkEmail",autolinkMarker:"autolinkMarker",autolinkProtocol:"autolinkProtocol",characterEscape:"characterEscape",characterEscapeValue:"characterEscapeValue",characterReference:"characterReference",characterReferenceMarker:"characterReferenceMarker",characterReferenceMarkerNumeric:"characterReferenceMarkerNumeric",characterReferenceMarkerHexadecimal:"characterReferenceMarkerHexadecimal",characterReferenceValue:"characterReferenceValue",codeFenced:"codeFenced",codeFencedFence:"codeFencedFence",codeFencedFenceSequence:"codeFencedFenceSequence",codeFencedFenceInfo:"codeFencedFenceInfo",codeFencedFenceMeta:"codeFencedFenceMeta",codeFlowValue:"codeFlowValue",codeIndented:"codeIndented",codeText:"codeText",codeTextData:"codeTextData",codeTextPadding:"codeTextPadding",codeTextSequence:"codeTextSequence",content:"content",definition:"definition",definitionDestination:"definitionDestination",definitionDestinationLiteral:"definitionDestinationLiteral",definitionDestinationLiteralMarker:"definitionDestinationLiteralMarker",definitionDestinationRaw:"definitionDestinationRaw",definitionDestinationString:"definitionDestinationString",definitionLabel:"definitionLabel",definitionLabelMarker:"definitionLabelMarker",definitionLabelString:"definitionLabelString",definitionMarker:"definitionMarker",definitionTitle:"definitionTitle",definitionTitleMarker:"definitionTitleMarker",definitionTitleString:"definitionTitleString",emphasis:"emphasis",emphasisSequence:"emphasisSequence",emphasisText:"emphasisText",escapeMarker:"escapeMarker",hardBreakEscape:"hardBreakEscape",hardBreakTrailing:"hardBreakTrailing",htmlFlow:"htmlFlow",htmlFlowData:"htmlFlowData",htmlText:"htmlText",htmlTextData:"htmlTextData",image:"image",label:"label",labelText:"labelText",labelLink:"labelLink",labelImage:"labelImage",labelMarker:"labelMarker",labelImageMarker:"labelImageMarker",labelEnd:"labelEnd",link:"link",paragraph:"paragraph",reference:"reference",referenceMarker:"referenceMarker",referenceString:"referenceString",resource:"resource",resourceDestination:"resourceDestination",resourceDestinationLiteral:"resourceDestinationLiteral",resourceDestinationLiteralMarker:"resourceDestinationLiteralMarker",resourceDestinationRaw:"resourceDestinationRaw",resourceDestinationString:"resourceDestinationString",resourceMarker:"resourceMarker",resourceTitle:"resourceTitle",resourceTitleMarker:"resourceTitleMarker",resourceTitleString:"resourceTitleString",setextHeading:"setextHeading",setextHeadingText:"setextHeadingText",setextHeadingLine:"setextHeadingLine",setextHeadingLineSequence:"setextHeadingLineSequence",strong:"strong",strongSequence:"strongSequence",strongText:"strongText",thematicBreak:"thematicBreak",thematicBreakSequence:"thematicBreakSequence",blockQuote:"blockQuote",blockQuotePrefix:"blockQuotePrefix",blockQuoteMarker:"blockQuoteMarker",blockQuotePrefixWhitespace:"blockQuotePrefixWhitespace",listOrdered:"listOrdered",listUnordered:"listUnordered",listItemIndent:"listItemIndent",listItemMarker:"listItemMarker",listItemPrefix:"listItemPrefix",listItemPrefixWhitespace:"listItemPrefixWhitespace",listItemValue:"listItemValue",chunkDocument:"chunkDocument",chunkContent:"chunkContent",chunkFlow:"chunkFlow",chunkText:"chunkText",chunkString:"chunkString"};f();f();f();function Hs(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}function qs(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function Ws(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e>=94192&&e<=94198||e>=94208&&e<=101589||e>=101631&&e<=101662||e>=101760&&e<=101874||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128728||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129674||e>=129678&&e<=129734||e===129736||e>=129741&&e<=129756||e>=129759&&e<=129770||e>=129775&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}function Gs(e){return Hs(e)?"ambiguous":qs(e)?"fullwidth":e===8361||e>=65377&&e<=65470||e>=65474&&e<=65479||e>=65482&&e<=65487||e>=65490&&e<=65495||e>=65498&&e<=65500||e>=65512&&e<=65518?"halfwidth":e>=32&&e<=126||e===162||e===163||e===165||e===166||e===172||e===175||e>=10214&&e<=10221||e===10629||e===10630?"narrow":Ws(e)?"wide":"neutral"}function Fc(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function js(e){return Fc(e),Gs(e)}var Dc=Object.defineProperty,Bc=(e,t,a)=>t in e?Dc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,Ec=(e,t,a)=>Bc(e,typeof t!="symbol"?t+"":t,a);function _c(e){return new RegExp("^\\p{Emoji_Presentation}","u").test(String.fromCodePoint(e))}function Nc(e){if(!e||e<4352)return!1;switch(js(e)){case"fullwidth":case"halfwidth":return!0;case"wide":return!_c(e);case"narrow":return!1;case"ambiguous":return 917760<=e&&e<=917999?null:!1;case"neutral":return new RegExp("^\\p{sc=Hangul}","u").test(String.fromCodePoint(e))}}function Oc(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function Uc(e){return e!==null&&e>=65024&&e<=65038}var Hc=zs(new RegExp("\\p{P}|\\p{S}","u")),qc=zs(/\s/);function zs(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCodePoint(a))}}var Re;(e=>{e.spaceOrPunctuation=3,e.cjk=4096,e.cjkPunctuation=4098,e.ivs=8192,e.cjkOrIvs=12288,e.nonEmojiGeneralUseVS=16384,e.variationSelector=24576,e.ivsToCjkRightShift=1})(Re||(Re={}));function et(e){if(e===he.eof||on(e)||qc(e))return We.characterGroupWhitespace;let t=0;if(e>=4352){if(Uc(e))return Re.nonEmojiGeneralUseVS;switch(Nc(e)){case null:return Re.ivs;case!0:t|=Re.cjk;break}}return Hc(e)&&(t|=We.characterGroupPunctuation),t}function Fa(e,t,a){if(!Gc(e))return e;let o=t(),r=et(o);return!o||ct(r)?e:Oc(o,a)?Re.cjkPunctuation:Wc(r)}function Wc(e){return e&~Re.ivs}function ct(e){return!!(e&We.characterGroupWhitespace)}function vt(e){return(e&Re.cjkPunctuation)===We.characterGroupPunctuation}function oa(e){return!!(e&Re.cjk)}function Vs(e){return e===Re.ivs}function $s(e){return!!(e&Re.cjkOrIvs)}function Gc(e){return e===Re.nonEmojiGeneralUseVS}function jo(e){return!!(e&Re.spaceOrPunctuation)}function Da(e){return!!(e&&e>=55296&&e<=56319)}function Ba(e){return!!(e&&e>=56320&&e<=57343)}function Ea(e,t,a){if(t._bufferIndex<2)return e;let r=a({start:{...t,_bufferIndex:t._bufferIndex-2},end:t}).codePointAt(0);return r&&r>=65536?r:e}function jc(e,t,a){let o=e>=65536?2:1;if(t._bufferIndex<1+o)return null;let r=t._bufferIndex-o-2,n=a({start:{...t,_bufferIndex:r>=0?r:0},end:{...t,_bufferIndex:t._bufferIndex-o}}),s=n.charCodeAt(n.length-1);if(Number.isNaN(s))return null;if(n.length<2||s<56320||57343<s)return s;let i=n.codePointAt(0);return i&&i>=65536?i:s}var _a=class{constructor(e,t,a){this.previousCode=e,this.nowPoint=t,this.sliceSerialize=a,Ec(this,"cachedValue")}value(){return this.cachedValue===void 0&&(this.cachedValue=jc(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function Na(e,t,a){let o=a({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return o&&o>=65536?o:e}var zo={name:"attention",resolveAll:zc,tokenize:Vc};function zc(e,t){let a=-1,o,r,n,s,i,l,u,c;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(o=a;o--;)if(e[o][0]==="exit"&&e[o][1].type==="attentionSequence"&&e[o][1]._open&&t.sliceSerialize(e[o][1]).charCodeAt(0)===t.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[o][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[o][1].end.offset-e[o][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;l=e[o][1].end.offset-e[o][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;let d={...e[o][1].end},p={...e[a][1].start};Xs(d,-l),Xs(p,l),s={type:l>1?Ae.strongSequence:Ae.emphasisSequence,start:d,end:{...e[o][1].end}},i={type:l>1?Ae.strongSequence:Ae.emphasisSequence,start:{...e[a][1].start},end:p},n={type:l>1?Ae.strongText:Ae.emphasisText,start:{...e[o][1].end},end:{...e[a][1].start}},r={type:l>1?Ae.strong:Ae.emphasis,start:{...s.start},end:{...i.end}},e[o][1].end={...s.start},e[a][1].start={...i.end},u=[],e[o][1].end.offset-e[o][1].start.offset&&(u=St(u,[["enter",e[o][1],t],["exit",e[o][1],t]])),u=St(u,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",n,t]]),t.parser.constructs.insideSpan.null,u=St(u,ya(t.parser.constructs.insideSpan.null,e.slice(o+1,a),t)),u=St(u,[["exit",n,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[a][1].end.offset-e[a][1].start.offset?(c=2,u=St(u,[["enter",e[a][1],t],["exit",e[a][1],t]])):c=0,It(e,o-1,a-o+3,u),a=o+u.length-c-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function Vc(e,t){let a=this.parser.constructs.attentionMarkers.null,{now:o,sliceSerialize:r,previous:n}=this,s=Ba(n)?Ea(n,o(),r):n,i=et(s),l=new _a(s,o(),r),u=Fa(i,l.value.bind(l),s),c;return d;function d(m){return m===he.asterisk||he.underscore,c=m,e.enter("attentionSequence"),p(m)}function p(m){if(m===c)return e.consume(m),p;let h=e.exit("attentionSequence"),I=Da(m)?Na(m,o(),r):m,L=et(I);let S=vt(u),C=S||ct(u),g=vt(L),y=g||ct(L),A=$s(u),R=!y||g&&(C||A)||a.includes(m),P=!C||S&&(y||oa(L))||a.includes(s);return h._open=!!(c===he.asterisk?R:R&&(jo(u)||!P)),h._close=!!(c===he.asterisk?P:P&&(jo(L)||!R)),t(m)}}function Xs(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function Ks(){return{text:{[he.asterisk]:zo,[he.underscore]:zo},insideSpan:{null:[zo]}}}function Qs(){let e=this.data();(e.micromarkExtensions||(e.micromarkExtensions=[])).push(Ks())}f();f();function Js(e){let a=(e||{}).singleTilde,o={name:"strikethrough",tokenize:n,resolveAll:r};return a==null&&(a=!0),{text:{[he.tilde]:o},insideSpan:{null:[o]},attentionMarkers:{null:[he.tilde]}};function r(s,i){let l=-1;for(;++l<s.length;)if(s[l][0]==="enter"&&s[l][1].type==="strikethroughSequenceTemporary"&&s[l][1]._close){let u=l;for(;u--;)if(s[u][0]==="exit"&&s[u][1].type==="strikethroughSequenceTemporary"&&s[u][1]._open&&s[l][1].end.offset-s[l][1].start.offset===s[u][1].end.offset-s[u][1].start.offset){s[l][1].type="strikethroughSequence",s[u][1].type="strikethroughSequence";let c={type:"strikethrough",start:Object.assign({},s[u][1].start),end:Object.assign({},s[l][1].end)},d={type:"strikethroughText",start:Object.assign({},s[u][1].end),end:Object.assign({},s[l][1].start)},p=[["enter",c,i],["enter",s[u][1],i],["exit",s[u][1],i],["enter",d,i]],m=i.parser.constructs.insideSpan.null;m&&It(p,p.length,0,ya(m,s.slice(u+1,l),i)),It(p,p.length,0,[["exit",d,i],["enter",s[l][1],i],["exit",s[l][1],i],["exit",c,i]]),It(s,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<s.length;)s[l][1].type==="strikethroughSequenceTemporary"&&(s[l][1].type=Ae.data);return s}function n(s,i,l){let{now:u,sliceSerialize:c,previous:d}=this,p=Ba(d)?Ea(d,u(),c):d,m=et(p),h=new _a(p,u(),c),I=Fa(m,h.value.bind(h),p),L=this.events,S=0;return C;function C(y){return he.tilde,p===he.tilde&&L[L.length-1][1].type!==Ae.characterEscape?l(y):(s.enter("strikethroughSequenceTemporary"),g(y))}function g(y){let A=et(p);if(y===he.tilde)return S>1?l(y):(s.consume(y),S++,g);if(S<2&&!a)return l(y);let R=s.exit("strikethroughSequenceTemporary"),P=Da(y)?Na(y,u(),c):y,M=et(P),D=vt(I)||ct(I),T=vt(M)||ct(M),B=oa(I)||Vs(A);return R._open=!T||M===We.attentionSideAfter&&(D||B),R._close=!D||A===We.attentionSideAfter&&(T||oa(M)),i(y)}}}function Zs(e){let t=this.data();(t.micromarkExtensions||(t.micromarkExtensions=[])).push(Js(e))}var $c=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),Xc=/^(https?:\/\/|mailto:|www\.)/i,Kc=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type==="text"&&t.value===e.url},Qc=e=>{let t=0;for(let a of e){if($c.has(a))return t;t+=a.length}return null},Jc=(e,t)=>({...t,url:e,children:[{type:"text",value:e}]}),Zc=e=>({type:"text",value:e}),Yc=()=>e=>{Qr(e,"link",(t,a,o)=>{if(!o||typeof a!="number"||!Kc(t)||!Xc.test(t.url))return;let r=Qc(t.url);if(r===null||r===0)return;let n=t.url.slice(0,r),s=t.url.slice(r),i=Jc(n,t),l=Zc(s);return o.children.splice(a,1,i,l),a+1})};function ef(){let e=[Qs],t=[Yc,Zs],a=[...e,...t];return{name:"cjk",type:"cjk",remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:a}}var Vo=ef();f();f();f();f();f();var ae=class extends Error{constructor(t){super(t),this.name="ShikiError"}};f();function tf(e){return ar(e)}function ar(e){return Array.isArray(e)?af(e):e instanceof RegExp?e:typeof e=="object"?of(e):e}function af(e){let t=[];for(let a=0,o=e.length;a<o;a++)t[a]=ar(e[a]);return t}function of(e){let t={};for(let a in e)t[a]=ar(e[a]);return t}function ii(e,...t){return t.forEach(a=>{for(let o in a)e[o]=a[o]}),e}function li(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?li(e.substring(0,e.length-1)):e.substr(~t+1)}var $o=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Oa=class{static hasCaptures(e){return e===null?!1:($o.lastIndex=0,$o.test(e))}static replaceCaptures(e,t,a){return e.replace($o,(o,r,n,s)=>{let i=a[parseInt(r||n,10)];if(i){let l=t.substring(i.start,i.end);for(;l[0]===".";)l=l.substring(1);switch(s){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return o})}};function ui(e,t){return e<t?-1:e>t?1:0}function di(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let a=e.length,o=t.length;if(a===o){for(let r=0;r<a;r++){let n=ui(e[r],t[r]);if(n!==0)return n}return 0}return a-o}function Ys(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function ci(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var fi=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},sa=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(sf(e),t)}static createFromParsedTheme(e,t){return uf(e,t)}_cachedMatchRoot=new fi(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,o=this._cachedMatchRoot.get(t).find(r=>rf(e.parent,r.parentScopes));return o?new pi(o.fontStyle,o.foreground,o.background):null}},Xo=class Ua{constructor(t,a){this.parent=t,this.scopeName=a}static push(t,a){for(let o of a)t=new Ua(t,o);return t}static from(...t){let a=null;for(let o=0;o<t.length;o++)a=new Ua(a,t[o]);return a}push(t){return new Ua(this,t)}getSegments(){let t=this,a=[];for(;t;)a.push(t.scopeName),t=t.parent;return a.reverse(),a}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){let a=[],o=this;for(;o&&o!==t;)a.push(o.scopeName),o=o.parent;return o===t?a.reverse():void 0}};function rf(e,t){if(t.length===0)return!0;for(let a=0;a<t.length;a++){let o=t[a],r=!1;if(o===">"){if(a===t.length-1)return!1;o=t[++a],r=!0}for(;e&&!nf(e.scopeName,o);){if(r)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function nf(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var pi=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function sf(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,a=[],o=0;for(let r=0,n=t.length;r<n;r++){let s=t[r];if(!s.settings)continue;let i;if(typeof s.scope=="string"){let d=s.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),i=d.split(",")}else Array.isArray(s.scope)?i=s.scope:i=[""];let l=-1;if(typeof s.settings.fontStyle=="string"){l=0;let d=s.settings.fontStyle.split(" ");for(let p=0,m=d.length;p<m;p++)switch(d[p]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let u=null;typeof s.settings.foreground=="string"&&Ys(s.settings.foreground)&&(u=s.settings.foreground);let c=null;typeof s.settings.background=="string"&&Ys(s.settings.background)&&(c=s.settings.background);for(let d=0,p=i.length;d<p;d++){let h=i[d].trim().split(" "),I=h[h.length-1],L=null;h.length>1&&(L=h.slice(0,h.length-1),L.reverse()),a[o++]=new lf(I,L,r,l,u,c)}}return a}var lf=class{constructor(e,t,a,o,r,n){this.scope=e,this.parentScopes=t,this.index=a,this.fontStyle=o,this.foreground=r,this.background=n}},ge=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(ge||{});function uf(e,t){e.sort((l,u)=>{let c=ui(l.scope,u.scope);return c!==0||(c=di(l.parentScopes,u.parentScopes),c!==0)?c:l.index-u.index});let a=0,o="#000000",r="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(a=l.fontStyle),l.foreground!==null&&(o=l.foreground),l.background!==null&&(r=l.background)}let n=new df(t),s=new pi(a,n.getId(o),n.getId(r)),i=new ff(new Qo(0,null,-1,0,0),[]);for(let l=0,u=e.length;l<u;l++){let c=e[l];i.insert(0,c.scope,c.parentScopes,c.fontStyle,n.getId(c.foreground),n.getId(c.background))}return new sa(n,s,i)}var df=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,a=e.length;t<a;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},cf=Object.freeze([]),Qo=class mi{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,o,r,n){this.scopeDepth=t,this.parentScopes=a||cf,this.fontStyle=o,this.foreground=r,this.background=n}clone(){return new mi(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let a=[];for(let o=0,r=t.length;o<r;o++)a[o]=t[o].clone();return a}acceptOverwrite(t,a,o,r){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,a!==-1&&(this.fontStyle=a),o!==0&&(this.foreground=o),r!==0&&(this.background=r)}},ff=class Jo{constructor(t,a=[],o={}){this._mainRule=t,this._children=o,this._rulesWithParentScopes=a}_rulesWithParentScopes;static _cmpBySpecificity(t,a){if(t.scopeDepth!==a.scopeDepth)return a.scopeDepth-t.scopeDepth;let o=0,r=0;for(;t.parentScopes[o]===">"&&o++,a.parentScopes[r]===">"&&r++,!(o>=t.parentScopes.length||r>=a.parentScopes.length);){let n=a.parentScopes[r].length-t.parentScopes[o].length;if(n!==0)return n;o++,r++}return a.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let o=t.indexOf("."),r,n;if(o===-1?(r=t,n=""):(r=t.substring(0,o),n=t.substring(o+1)),this._children.hasOwnProperty(r))return this._children[r].match(n)}let a=this._rulesWithParentScopes.concat(this._mainRule);return a.sort(Jo._cmpBySpecificity),a}insert(t,a,o,r,n,s){if(a===""){this._doInsertHere(t,o,r,n,s);return}let i=a.indexOf("."),l,u;i===-1?(l=a,u=""):(l=a.substring(0,i),u=a.substring(i+1));let c;this._children.hasOwnProperty(l)?c=this._children[l]:(c=new Jo(this._mainRule.clone(),Qo.cloneArr(this._rulesWithParentScopes)),this._children[l]=c),c.insert(t+1,u,o,r,n,s)}_doInsertHere(t,a,o,r,n){if(a===null){this._mainRule.acceptOverwrite(t,o,r,n);return}for(let s=0,i=this._rulesWithParentScopes.length;s<i;s++){let l=this._rulesWithParentScopes[s];if(di(l.parentScopes,a)===0){l.acceptOverwrite(t,o,r,n);return}}o===-1&&(o=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),n===0&&(n=this._mainRule.background),this._rulesWithParentScopes.push(new Qo(t,a,o,r,n))}},pt=class De{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=De.getLanguageId(t),o=De.getTokenType(t),r=De.getFontStyle(t),n=De.getForeground(t),s=De.getBackground(t);console.log({languageId:a,tokenType:o,fontStyle:r,foreground:n,background:s})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,a,o,r,n,s,i){let l=De.getLanguageId(t),u=De.getTokenType(t),c=De.containsBalancedBrackets(t)?1:0,d=De.getFontStyle(t),p=De.getForeground(t),m=De.getBackground(t);return a!==0&&(l=a),o!==8&&(u=o),r!==null&&(c=r?1:0),n!==-1&&(d=n),s!==0&&(p=s),i!==0&&(m=i),(l<<0|u<<8|c<<10|d<<11|p<<15|m<<24)>>>0}};function qa(e,t){let a=[],o=pf(e),r=o.next();for(;r!==null;){let l=0;if(r.length===2&&r.charAt(1)===":"){switch(r.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${r} in scope selector`)}r=o.next()}let u=s();if(a.push({matcher:u,priority:l}),r!==",")break;r=o.next()}return a;function n(){if(r==="-"){r=o.next();let l=n();return u=>!!l&&!l(u)}if(r==="("){r=o.next();let l=i();return r===")"&&(r=o.next()),l}if(ei(r)){let l=[];do l.push(r),r=o.next();while(ei(r));return u=>t(l,u)}return null}function s(){let l=[],u=n();for(;u;)l.push(u),u=n();return c=>l.every(d=>d(c))}function i(){let l=[],u=s();for(;u&&(l.push(u),r==="|"||r===",");){do r=o.next();while(r==="|"||r===",");u=s()}return c=>l.some(d=>d(c))}}function ei(e){return!!e&&!!e.match(/[\w\.:]+/)}function pf(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,a=t.exec(e);return{next:()=>{if(!a)return null;let o=a[0];return a=t.exec(e),o}}}function hi(e){typeof e.dispose=="function"&&e.dispose()}var ia=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},mf=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},hf=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},gf=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new ia(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new hf;for(let a of e)wf(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof ia){if(this.seenFullScopeRequests.has(a.scopeName))continue;this.seenFullScopeRequests.add(a.scopeName),this.Q.push(a)}else{if(this.seenFullScopeRequests.has(a.scopeName)||this.seenPartialScopeRequests.has(a.toKey()))continue;this.seenPartialScopeRequests.add(a.toKey()),this.Q.push(a)}}};function wf(e,t,a,o){let r=a.lookup(e.scopeName);if(!r){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let n=a.lookup(t);e instanceof ia?Ha({baseGrammar:n,selfGrammar:r},o):Zo(e.ruleName,{baseGrammar:n,selfGrammar:r,repository:r.repository},o);let s=a.injections(e.scopeName);if(s)for(let i of s)o.add(new ia(i))}function Zo(e,t,a){if(t.repository&&t.repository[e]){let o=t.repository[e];Wa([o],t,a)}}function Ha(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Wa(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Wa(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Wa(e,t,a){for(let o of e){if(a.visitedRule.has(o))continue;a.visitedRule.add(o);let r=o.repository?ii({},t.repository,o.repository):t.repository;Array.isArray(o.patterns)&&Wa(o.patterns,{...t,repository:r},a);let n=o.include;if(!n)continue;let s=gi(n);switch(s.kind){case 0:Ha({...t,selfGrammar:t.baseGrammar},a);break;case 1:Ha(t,a);break;case 2:Zo(s.ruleName,{...t,repository:r},a);break;case 3:case 4:let i=s.scopeName===t.selfGrammar.scopeName?t.selfGrammar:s.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(i){let l={baseGrammar:t.baseGrammar,selfGrammar:i,repository:r};s.kind===4?Zo(s.ruleName,l,a):Ha(l,a)}else s.kind===4?a.add(new mf(s.scopeName,s.ruleName)):a.add(new ia(s.scopeName));break}}}var xf=class{kind=0},Lf=class{kind=1},Cf=class{constructor(e){this.ruleName=e}kind=2},If=class{constructor(e){this.scopeName=e}kind=3},Sf=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function gi(e){if(e==="$base")return new xf;if(e==="$self")return new Lf;let t=e.indexOf("#");if(t===-1)return new If(e);if(t===0)return new Cf(e.substring(1));{let a=e.substring(0,t),o=e.substring(t+1);return new Sf(a,o)}}var yf=/\\(\d+)/,ti=/\\(\d+)/g;var bf=-1,wi=-2;var da=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,a,o){this.$location=e,this.id=t,this._name=a||null,this._nameIsCapturing=Oa.hasCaptures(this._name),this._contentName=o||null,this._contentNameIsCapturing=Oa.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${li(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Oa.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Oa.replaceCaptures(this._contentName,e,t)}},kf=class extends da{retokenizeCapturedWithRuleId;constructor(e,t,a,o,r){super(e,t,a,o),this.retokenizeCapturedWithRuleId=r}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,a,o){throw new Error("Not supported!")}},Tf=class extends da{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,null),this._match=new la(o,this.id),this.captures=r,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new ua,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},ai=class extends da{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,o),this.patterns=r.patterns,this.hasMissingPatterns=r.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let a of this.patterns)e.getRule(a).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new ua,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Yo=class extends da{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r,n,s,i,l,u){super(e,t,a,o),this._begin=new la(r,this.id),this.beginCaptures=n,this._end=new la(s||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=l||!1,this.patterns=u.patterns,this.hasMissingPatterns=u.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e,t).compileAG(e,a,o)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new ua;for(let a of this.patterns)e.getRule(a).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Ga=class extends da{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,a,o,r,n,s,i,l){super(e,t,a,o),this._begin=new la(r,this.id),this.beginCaptures=n,this.whileCaptures=i,this._while=new la(s,wi),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new ua;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,a,o){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,a,o)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new ua,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},xi=class Se{static createCaptureRule(t,a,o,r,n){return t.registerRule(s=>new kf(a,s,o,r,n))}static getCompiledRuleId(t,a,o){return t.id||a.registerRule(r=>{if(t.id=r,t.match)return new Tf(t.$vscodeTextmateLocation,t.id,t.name,t.match,Se._compileCaptures(t.captures,a,o));if(typeof t.begin>"u"){t.repository&&(o=ii({},o,t.repository));let n=t.patterns;return typeof n>"u"&&t.include&&(n=[{include:t.include}]),new ai(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Se._compilePatterns(n,a,o))}return t.while?new Ga(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Se._compileCaptures(t.beginCaptures||t.captures,a,o),t.while,Se._compileCaptures(t.whileCaptures||t.captures,a,o),Se._compilePatterns(t.patterns,a,o)):new Yo(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Se._compileCaptures(t.beginCaptures||t.captures,a,o),t.end,Se._compileCaptures(t.endCaptures||t.captures,a,o),t.applyEndPatternLast,Se._compilePatterns(t.patterns,a,o))}),t.id}static _compileCaptures(t,a,o){let r=[];if(t){let n=0;for(let s in t){if(s==="$vscodeTextmateLocation")continue;let i=parseInt(s,10);i>n&&(n=i)}for(let s=0;s<=n;s++)r[s]=null;for(let s in t){if(s==="$vscodeTextmateLocation")continue;let i=parseInt(s,10),l=0;t[s].patterns&&(l=Se.getCompiledRuleId(t[s],a,o)),r[i]=Se.createCaptureRule(a,t[s].$vscodeTextmateLocation,t[s].name,t[s].contentName,l)}}return r}static _compilePatterns(t,a,o){let r=[];if(t)for(let n=0,s=t.length;n<s;n++){let i=t[n],l=-1;if(i.include){let u=gi(i.include);switch(u.kind){case 0:case 1:l=Se.getCompiledRuleId(o[i.include],a,o);break;case 2:let c=o[u.ruleName];c&&(l=Se.getCompiledRuleId(c,a,o));break;case 3:case 4:let d=u.scopeName,p=u.kind===4?u.ruleName:null,m=a.getExternalGrammar(d,o);if(m)if(p){let h=m.repository[p];h&&(l=Se.getCompiledRuleId(h,a,m.repository))}else l=Se.getCompiledRuleId(m.repository.$self,a,m.repository);break}}else l=Se.getCompiledRuleId(i,a,o);if(l!==-1){let u=a.getRule(l),c=!1;if((u instanceof ai||u instanceof Yo||u instanceof Ga)&&u.hasMissingPatterns&&u.patterns.length===0&&(c=!0),c)continue;r.push(l)}}return{patterns:r,hasMissingPatterns:(t?t.length:0)!==r.length}}},la=class Li{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,a){if(t&&typeof t=="string"){let o=t.length,r=0,n=[],s=!1;for(let i=0;i<o;i++)if(t.charAt(i)==="\\"&&i+1<o){let u=t.charAt(i+1);u==="z"?(n.push(t.substring(r,i)),n.push("$(?!\\n)(?<!\\n)"),r=i+2):(u==="A"||u==="G")&&(s=!0),i++}this.hasAnchor=s,r===0?this.source=t:(n.push(t.substring(r,o)),this.source=n.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=a,typeof this.source=="string"?this.hasBackReferences=yf.test(this.source):this.hasBackReferences=!1}clone(){return new Li(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,a){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let o=a.map(r=>t.substring(r.start,r.end));return ti.lastIndex=0,this.source.replace(ti,(r,n)=>ci(o[parseInt(n,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],a=[],o=[],r=[],n,s,i,l;for(n=0,s=this.source.length;n<s;n++)i=this.source.charAt(n),t[n]=i,a[n]=i,o[n]=i,r[n]=i,i==="\\"&&n+1<s&&(l=this.source.charAt(n+1),l==="A"?(t[n+1]="\uFFFF",a[n+1]="\uFFFF",o[n+1]="A",r[n+1]="A"):l==="G"?(t[n+1]="\uFFFF",a[n+1]="G",o[n+1]="\uFFFF",r[n+1]="G"):(t[n+1]=l,a[n+1]=l,o[n+1]=l,r[n+1]=l),n++);return{A0_G0:t.join(""),A0_G1:a.join(""),A1_G0:o.join(""),A1_G1:r.join("")}}resolveAnchors(t,a){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?a?this._anchorCache.A1_G1:this._anchorCache.A1_G0:a?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},ua=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(a=>a.source);this._cached=new oi(e,t,this._items.map(a=>a.ruleId))}return this._cached}compileAG(e,t,a){return this._hasAnchors?t?a?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G0):a?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,a){let o=this._items.map(r=>r.resolveAnchors(t,a));return new oi(e,o,this._items.map(r=>r.ruleId))}},oi=class{constructor(e,t,a){this.regExps=t,this.rules=a,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){let e=[];for(let t=0,a=this.rules.length;t<a;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
69
+ `)}findNextMatchSync(e,t,a){let o=this.scanner.findNextMatchSync(e,t,a);return o?{ruleId:this.rules[o.index],captureIndices:o.captureIndices}:null}},Ko=class{constructor(e,t){this.languageId=e,this.tokenType=t}},vf=class er{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,a){this._defaultAttributes=new Ko(t,8),this._embeddedLanguagesMatcher=new Pf(Object.entries(a||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?er._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Ko(0,0);_getBasicScopeAttributes=new fi(t=>{let a=this._scopeToLanguage(t),o=this._toStandardTokenType(t);return new Ko(a,o)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let a=t.match(er.STANDARD_TOKEN_TYPE_REGEXP);if(!a)return 8;switch(a[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Pf=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([a,o])=>ci(a));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},Bb={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},Ci=!1,ri=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Ii(e,t,a,o,r,n,s,i){let l=t.content.length,u=!1,c=-1;if(s){let m=Af(e,t,a,o,r,n);r=m.stack,o=m.linePos,a=m.isFirstLine,c=m.anchorPosition}let d=Date.now();for(;!u;){if(i!==0&&Date.now()-d>i)return new ri(r,!0);p()}return new ri(r,!1);function p(){let m=Rf(e,t,a,o,r,c);if(!m){n.produce(r,l),u=!0;return}let h=m.captureIndices,I=m.matchedRuleId,L=h&&h.length>0?h[0].end>o:!1;if(I===bf){let S=r.getRule(e);n.produce(r,h[0].start),r=r.withContentNameScopesList(r.nameScopesList),ra(e,t,a,r,n,S.endCaptures,h),n.produce(r,h[0].end);let C=r;if(r=r.parent,c=C.getAnchorPos(),!L&&C.getEnterPos()===o){r=C,n.produce(r,l),u=!0;return}}else{let S=e.getRule(I);n.produce(r,h[0].start);let C=r,g=S.getName(t.content,h),y=r.contentNameScopesList.pushAttributed(g,e);if(r=r.push(I,o,c,h[0].end===l,null,y,y),S instanceof Yo){let A=S;ra(e,t,a,r,n,A.beginCaptures,h),n.produce(r,h[0].end),c=h[0].end;let R=A.getContentName(t.content,h),P=y.pushAttributed(R,e);if(r=r.withContentNameScopesList(P),A.endHasBackReferences&&(r=r.withEndRule(A.getEndWithResolvedBackReferences(t.content,h))),!L&&C.hasSameRuleAs(r)){r=r.pop(),n.produce(r,l),u=!0;return}}else if(S instanceof Ga){let A=S;ra(e,t,a,r,n,A.beginCaptures,h),n.produce(r,h[0].end),c=h[0].end;let R=A.getContentName(t.content,h),P=y.pushAttributed(R,e);if(r=r.withContentNameScopesList(P),A.whileHasBackReferences&&(r=r.withEndRule(A.getWhileWithResolvedBackReferences(t.content,h))),!L&&C.hasSameRuleAs(r)){r=r.pop(),n.produce(r,l),u=!0;return}}else if(ra(e,t,a,r,n,S.captures,h),n.produce(r,h[0].end),r=r.pop(),!L){r=r.safePop(),n.produce(r,l),u=!0;return}}h[0].end>o&&(o=h[0].end,a=!1)}}function Af(e,t,a,o,r,n){let s=r.beginRuleCapturedEOL?0:-1,i=[];for(let l=r;l;l=l.pop()){let u=l.getRule(e);u instanceof Ga&&i.push({rule:u,stack:l})}for(let l=i.pop();l;l=i.pop()){let{ruleScanner:u,findOptions:c}=Df(l.rule,e,l.stack.endRule,a,o===s),d=u.findNextMatchSync(t,o,c);if(d){if(d.ruleId!==wi){r=l.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(n.produce(l.stack,d.captureIndices[0].start),ra(e,t,a,l.stack,n,l.rule.whileCaptures,d.captureIndices),n.produce(l.stack,d.captureIndices[0].end),s=d.captureIndices[0].end,d.captureIndices[0].end>o&&(o=d.captureIndices[0].end,a=!1))}else{r=l.stack.pop();break}}return{stack:r,linePos:o,anchorPosition:s,isFirstLine:a}}function Rf(e,t,a,o,r,n){let s=Mf(e,t,a,o,r,n),i=e.getInjections();if(i.length===0)return s;let l=Ff(i,e,t,a,o,r,n);if(!l)return s;if(!s)return l;let u=s.captureIndices[0].start,c=l.captureIndices[0].start;return c<u||l.priorityMatch&&c===u?l:s}function Mf(e,t,a,o,r,n){let s=r.getRule(e),{ruleScanner:i,findOptions:l}=Si(s,e,r.endRule,a,o===n),u=i.findNextMatchSync(t,o,l);return u?{captureIndices:u.captureIndices,matchedRuleId:u.ruleId}:null}function Ff(e,t,a,o,r,n,s){let i=Number.MAX_VALUE,l=null,u,c=0,d=n.contentNameScopesList.getScopeNames();for(let p=0,m=e.length;p<m;p++){let h=e[p];if(!h.matcher(d))continue;let I=t.getRule(h.ruleId),{ruleScanner:L,findOptions:S}=Si(I,t,null,o,r===s),C=L.findNextMatchSync(a,r,S);if(!C)continue;let g=C.captureIndices[0].start;if(!(g>=i)&&(i=g,l=C.captureIndices,u=C.ruleId,c=h.priority,i===r))break}return l?{priorityMatch:c===-1,captureIndices:l,matchedRuleId:u}:null}function Si(e,t,a,o,r){if(Ci){let s=e.compile(t,a),i=yi(o,r);return{ruleScanner:s,findOptions:i}}return{ruleScanner:e.compileAG(t,a,o,r),findOptions:0}}function Df(e,t,a,o,r){if(Ci){let s=e.compileWhile(t,a),i=yi(o,r);return{ruleScanner:s,findOptions:i}}return{ruleScanner:e.compileWhileAG(t,a,o,r),findOptions:0}}function yi(e,t){let a=0;return e||(a|=1),t||(a|=4),a}function ra(e,t,a,o,r,n,s){if(n.length===0)return;let i=t.content,l=Math.min(n.length,s.length),u=[],c=s[0].end;for(let d=0;d<l;d++){let p=n[d];if(p===null)continue;let m=s[d];if(m.length===0)continue;if(m.start>c)break;for(;u.length>0&&u[u.length-1].endPos<=m.start;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop();if(u.length>0?r.produceFromScopes(u[u.length-1].scopes,m.start):r.produce(o,m.start),p.retokenizeCapturedWithRuleId){let I=p.getName(i,s),L=o.contentNameScopesList.pushAttributed(I,e),S=p.getContentName(i,s),C=L.pushAttributed(S,e),g=o.push(p.retokenizeCapturedWithRuleId,m.start,-1,!1,null,L,C),y=e.createOnigString(i.substring(0,m.end));Ii(e,y,a&&m.start===0,m.start,g,r,!1,0),hi(y);continue}let h=p.getName(i,s);if(h!==null){let L=(u.length>0?u[u.length-1].scopes:o.contentNameScopesList).pushAttributed(h,e);u.push(new Bf(L,m.end))}}for(;u.length>0;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var Bf=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function Ef(e,t,a,o,r,n,s,i){return new Nf(e,t,a,o,r,n,s,i)}function ni(e,t,a,o,r){let n=qa(t,ja),s=xi.getCompiledRuleId(a,o,r.repository);for(let i of n)e.push({debugSelector:t,matcher:i.matcher,ruleId:s,grammar:r,priority:i.priority})}function ja(e,t){if(t.length<e.length)return!1;let a=0;return e.every(o=>{for(let r=a;r<t.length;r++)if(_f(t[r],o))return a=r+1,!0;return!1})}function _f(e,t){if(!e)return!1;if(e===t)return!0;let a=t.length;return e.length>a&&e.substr(0,a)===t&&e[a]==="."}var Nf=class{constructor(e,t,a,o,r,n,s,i){if(this._rootScopeName=e,this.balancedBracketSelectors=n,this._onigLib=i,this._basicScopeAttributesProvider=new vf(a,o),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=s,this._grammar=si(t,null),this._injections=null,this._tokenTypeMatchers=[],r)for(let l of Object.keys(r)){let u=qa(l,ja);for(let c of u)this._tokenTypeMatchers.push({matcher:c.matcher,type:r[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:r=>r===this._rootScopeName?this._grammar:this.getExternalGrammar(r),injections:r=>this._grammarRepository.injections(r)},t=[],a=this._rootScopeName,o=e.lookup(a);if(o){let r=o.injections;if(r)for(let s in r)ni(t,s,r[s],this,o);let n=this._grammarRepository.injections(a);n&&n.forEach(s=>{let i=this.getExternalGrammar(s);if(i){let l=i.injectionSelector;l&&ni(t,l,i,this,i)}})}return t.sort((r,n)=>r.priority-n.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,a=e(t);return this._ruleId2desc[t]=a,a}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let a=this._grammarRepository.lookup(e);if(a)return this._includedGrammars[e]=si(a,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,a=0){let o=this._tokenize(e,t,!1,a);return{tokens:o.lineTokens.getResult(o.ruleStack,o.lineLength),ruleStack:o.ruleStack,stoppedEarly:o.stoppedEarly}}tokenizeLine2(e,t,a=0){let o=this._tokenize(e,t,!0,a);return{tokens:o.lineTokens.getBinaryResult(o.ruleStack,o.lineLength),ruleStack:o.ruleStack,stoppedEarly:o.stoppedEarly}}_tokenize(e,t,a,o){this._rootId===-1&&(this._rootId=xi.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let r;if(!t||t===tr.NULL){r=!0;let u=this._basicScopeAttributesProvider.getDefaultAttributes(),c=this.themeProvider.getDefaults(),d=pt.set(0,u.languageId,u.tokenType,null,c.fontStyle,c.foregroundId,c.backgroundId),p=this.getRule(this._rootId).getName(null,null),m;p?m=na.createRootAndLookUpScopeName(p,d,this):m=na.createRoot("unknown",d),t=new tr(null,this._rootId,-1,-1,!1,null,m,m)}else r=!1,t.reset();e=e+`
70
+ `;let n=this.createOnigString(e),s=n.content.length,i=new Uf(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Ii(this,n,r,0,t,i,!0,o);return hi(n),{lineLength:s,lineTokens:i,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function si(e,t){return e=tf(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var na=class Ge{constructor(t,a,o){this.parent=t,this.scopePath=a,this.tokenAttributes=o}static fromExtension(t,a){let o=t,r=t?.scopePath??null;for(let n of a)r=Xo.push(r,n.scopeNames),o=new Ge(o,r,n.encodedTokenAttributes);return o}static createRoot(t,a){return new Ge(null,new Xo(null,t),a)}static createRootAndLookUpScopeName(t,a,o){let r=o.getMetadataForScope(t),n=new Xo(null,t),s=o.themeProvider.themeMatch(n),i=Ge.mergeAttributes(a,r,s);return new Ge(null,n,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Ge.equals(this,t)}static equals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.scopeName!==a.scopeName||t.tokenAttributes!==a.tokenAttributes)return!1;t=t.parent,a=a.parent}while(!0)}static mergeAttributes(t,a,o){let r=-1,n=0,s=0;return o!==null&&(r=o.fontStyle,n=o.foregroundId,s=o.backgroundId),pt.set(t,a.languageId,a.tokenType,null,r,n,s)}pushAttributed(t,a){if(t===null)return this;if(t.indexOf(" ")===-1)return Ge._pushAttributed(this,t,a);let o=t.split(/ /g),r=this;for(let n of o)r=Ge._pushAttributed(r,n,a);return r}static _pushAttributed(t,a,o){let r=o.getMetadataForScope(a),n=t.scopePath.push(a),s=o.themeProvider.themeMatch(n),i=Ge.mergeAttributes(t.tokenAttributes,r,s);return new Ge(t,n,i)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let a=[],o=this;for(;o&&o!==t;)a.push({encodedTokenAttributes:o.tokenAttributes,scopeNames:o.scopePath.getExtensionIfDefined(o.parent?.scopePath??null)}),o=o.parent;return o===t?a.reverse():void 0}},tr=class ft{constructor(t,a,o,r,n,s,i,l){this.parent=t,this.ruleId=a,this.beginRuleCapturedEOL=n,this.endRule=s,this.nameScopesList=i,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=o,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new ft(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:ft._equals(this,t)}static _equals(t,a){return t===a?!0:this._structuralEquals(t,a)?na.equals(t.contentNameScopesList,a.contentNameScopesList):!1}static _structuralEquals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.depth!==a.depth||t.ruleId!==a.ruleId||t.endRule!==a.endRule)return!1;t=t.parent,a=a.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){ft._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,a,o,r,n,s,i){return new ft(this,t,a,o,r,n,s,i)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,a){return this.parent&&(a=this.parent._writeString(t,a)),t[a++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,a}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new ft(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let a=this;for(;a&&a._enterPos===t._enterPos;){if(a.ruleId===t.ruleId)return!0;a=a.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,a){let o=na.fromExtension(t?.nameScopesList??null,a.nameScopesList);return new ft(t,a.ruleId,a.enterPos??-1,a.anchorPos??-1,a.beginRuleCapturedEOL,a.endRule,o,na.fromExtension(o,a.contentNameScopesList))}},Of=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(a=>a==="*"?(this.allowAny=!0,[]):qa(a,ja).map(o=>o.matcher)),this.unbalancedBracketScopes=t.flatMap(a=>qa(a,ja).map(o=>o.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},Uf=class{constructor(e,t,a,o){this.balancedBracketSelectors=o,this._emitBinaryTokens=e,this._tokenTypeOverrides=a,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let o=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let n=e?.getScopeNames()??[];for(let s of this._tokenTypeOverrides)s.matcher(n)&&(o=pt.set(o,0,s.type,null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(n))}if(r&&(o=pt.set(o,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===o){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(o),this._lastTokenEndIndex=t;return}let a=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:a}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let a=new Uint32Array(this._binaryTokens.length);for(let o=0,r=this._binaryTokens.length;o<r;o++)a[o]=this._binaryTokens[o];return a}},Hf=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,a,o,r){if(!this._grammars.has(e)){let n=this._rawGrammars.get(e);if(!n)return null;this._grammars.set(e,Ef(e,n,t,a,o,r,this,this._onigLib))}return this._grammars.get(e)}},bi=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Hf(sa.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(sa.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,a){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:a})}loadGrammarWithConfiguration(e,t,a){return this._loadGrammar(e,t,a.embeddedLanguages,a.tokenTypes,new Of(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,o,r){let n=new gf(this._syncRegistry,e);for(;n.Q.length>0;)n.Q.map(s=>this._loadSingleGrammar(s.scopeName)),n.processQueue();return this._grammarForScopeName(e,t,a,o,r)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let a=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,a)}}addGrammar(e,t=[],a=0,o=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,a,o)}_grammarForScopeName(e,t=0,a=null,o=null,r=null){return this._syncRegistry.grammarForScopeName(e,t,a,o,r)}},za=tr.NULL;f();f();f();f();f();f();var qf=/["&'<>`]/g,Wf=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Gf=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,jf=/[|\\{}()[\]^$+*?.]/g,ki=new WeakMap;function Ti(e,t){if(e=e.replace(t.subset?zf(t.subset):qf,o),t.subset||t.escapeOnly)return e;return e.replace(Wf,a).replace(Gf,o);function a(r,n,s){return t.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,s.charCodeAt(n+2),t)}function o(r,n,s){return t.format(r.charCodeAt(0),s.charCodeAt(n+1),t)}}function zf(e){let t=ki.get(e);return t||(t=Vf(e),ki.set(e,t)),t}function Vf(e){let t=[],a=-1;for(;++a<e.length;)t.push(e[a].replace(jf,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}f();f();var $f=/[\dA-Fa-f]/;function vi(e,t,a){let o="&#x"+e.toString(16).toUpperCase();return a&&t&&!$f.test(String.fromCharCode(t))?o:o+";"}f();var Xf=/\d/;function Pi(e,t,a){let o="&#"+String(e);return a&&t&&!Xf.test(String.fromCharCode(t))?o:o+";"}f();f();var Ai=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];f();var Va={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};f();var Ri=["cent","copy","divide","gt","lt","not","para","times"];var Mi={}.hasOwnProperty,or={},$a;for($a in Va)Mi.call(Va,$a)&&(or[Va[$a]]=$a);var Kf=/[^\dA-Za-z]/;function Fi(e,t,a,o){let r=String.fromCharCode(e);if(Mi.call(or,r)){let n=or[r],s="&"+n;return a&&Ai.includes(n)&&!Ri.includes(n)&&(!o||t&&t!==61&&Kf.test(String.fromCharCode(t)))?s:s+";"}return""}function Di(e,t,a){let o=vi(e,t,a.omitOptionalSemicolons),r;if((a.useNamedReferences||a.useShortestReferences)&&(r=Fi(e,t,a.omitOptionalSemicolons,a.attribute)),(a.useShortestReferences||!r)&&a.useShortestReferences){let n=Pi(e,t,a.omitOptionalSemicolons);n.length<o.length&&(o=n)}return r&&(!a.useShortestReferences||r.length<o.length)?r:o}function Ke(e,t){return Ti(e,Object.assign({format:Di},t))}var Qf=/^>|^->|<!--|-->|--!>|<!-$/g,Jf=[">"],Zf=["<",">"];function Bi(e,t,a,o){return o.settings.bogusComments?"<?"+Ke(e.value,Object.assign({},o.settings.characterReferences,{subset:Jf}))+">":"<!--"+e.value.replace(Qf,r)+"-->";function r(n){return Ke(n,Object.assign({},o.settings.characterReferences,{subset:Zf}))}}f();function Ei(e,t,a,o){return"<!"+(o.settings.upperDoctype?"DOCTYPE":"doctype")+(o.settings.tightDoctype?"":" ")+"html>"}f();f();f();var se=_i(1),rr=_i(-1),Yf=[];function _i(e){return t;function t(a,o,r){let n=a?a.children:Yf,s=(o||0)+e,i=n[s];if(!r)for(;i&&yt(i);)s+=e,i=n[s];return i}}f();var ep={}.hasOwnProperty;function Xa(e){return t;function t(a,o,r){return ep.call(e,a.tagName)&&e[a.tagName](a,o,r)}}var ca=Xa({body:ap,caption:nr,colgroup:nr,dd:sp,dt:np,head:nr,html:tp,li:rp,optgroup:ip,option:lp,p:op,rp:Ni,rt:Ni,tbody:dp,td:Oi,tfoot:cp,th:Oi,thead:up,tr:fp});function nr(e,t,a){let o=se(a,t,!0);return!o||o.type!=="comment"&&!(o.type==="text"&&yt(o.value.charAt(0)))}function tp(e,t,a){let o=se(a,t);return!o||o.type!=="comment"}function ap(e,t,a){let o=se(a,t);return!o||o.type!=="comment"}function op(e,t,a){let o=se(a,t);return o?o.type==="element"&&(o.tagName==="address"||o.tagName==="article"||o.tagName==="aside"||o.tagName==="blockquote"||o.tagName==="details"||o.tagName==="div"||o.tagName==="dl"||o.tagName==="fieldset"||o.tagName==="figcaption"||o.tagName==="figure"||o.tagName==="footer"||o.tagName==="form"||o.tagName==="h1"||o.tagName==="h2"||o.tagName==="h3"||o.tagName==="h4"||o.tagName==="h5"||o.tagName==="h6"||o.tagName==="header"||o.tagName==="hgroup"||o.tagName==="hr"||o.tagName==="main"||o.tagName==="menu"||o.tagName==="nav"||o.tagName==="ol"||o.tagName==="p"||o.tagName==="pre"||o.tagName==="section"||o.tagName==="table"||o.tagName==="ul"):!a||!(a.type==="element"&&(a.tagName==="a"||a.tagName==="audio"||a.tagName==="del"||a.tagName==="ins"||a.tagName==="map"||a.tagName==="noscript"||a.tagName==="video"))}function rp(e,t,a){let o=se(a,t);return!o||o.type==="element"&&o.tagName==="li"}function np(e,t,a){let o=se(a,t);return!!(o&&o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd"))}function sp(e,t,a){let o=se(a,t);return!o||o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd")}function Ni(e,t,a){let o=se(a,t);return!o||o.type==="element"&&(o.tagName==="rp"||o.tagName==="rt")}function ip(e,t,a){let o=se(a,t);return!o||o.type==="element"&&o.tagName==="optgroup"}function lp(e,t,a){let o=se(a,t);return!o||o.type==="element"&&(o.tagName==="option"||o.tagName==="optgroup")}function up(e,t,a){let o=se(a,t);return!!(o&&o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot"))}function dp(e,t,a){let o=se(a,t);return!o||o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot")}function cp(e,t,a){return!se(a,t)}function fp(e,t,a){let o=se(a,t);return!o||o.type==="element"&&o.tagName==="tr"}function Oi(e,t,a){let o=se(a,t);return!o||o.type==="element"&&(o.tagName==="td"||o.tagName==="th")}f();var Ui=Xa({body:hp,colgroup:gp,head:mp,html:pp,tbody:wp});function pp(e){let t=se(e,-1);return!t||t.type!=="comment"}function mp(e){let t=new Set;for(let o of e.children)if(o.type==="element"&&(o.tagName==="base"||o.tagName==="title")){if(t.has(o.tagName))return!1;t.add(o.tagName)}let a=e.children[0];return!a||a.type==="element"}function hp(e){let t=se(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&yt(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function gp(e,t,a){let o=rr(a,t),r=se(e,-1,!0);return a&&o&&o.type==="element"&&o.tagName==="colgroup"&&ca(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function wp(e,t,a){let o=rr(a,t),r=se(e,-1);return a&&o&&o.type==="element"&&(o.tagName==="thead"||o.tagName==="tbody")&&ca(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}var Ka={name:[[`
71
71
  \f\r &/=>`.split(""),`
72
72
  \f\r "&'/=>\``.split("")],[`\0
73
73
  \f\r "&'/<=>`.split(""),`\0
@@ -75,11 +75,11 @@ import{a as Wr,b as Gr,c as jr,d as wt,e as xt,f as xa,g as zr,h as Vr,i as $r,j
75
75
  \f\r &>`.split(""),`\0
76
76
  \f\r "&'<=>\``.split("")],[`\0
77
77
  \f\r "&'<=>\``.split(""),`\0
78
- \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Ai(e,t,a,o){let r=o.schema,s=r.space==="svg"?!1:o.settings.omitOptionalTags,n=r.space==="svg"?o.settings.closeEmptyElements:o.settings.voids.includes(e.tagName.toLowerCase()),i=[],l;r.space==="html"&&e.tagName==="svg"&&(o.schema=La);let u=ep(o,e.properties),c=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,c&&(n=!1),(u||!s||!Pi(e,t,a))&&(i.push("<",e.tagName,u?" "+u:""),n&&(r.space==="svg"||o.settings.closeSelfClosing)&&(l=u.charAt(u.length-1),(!o.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(c),!n&&(!s||!ia(e,t,a))&&i.push("</"+e.tagName+">"),i.join("")}function ep(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let s=tp(e,r,t[r]);s&&a.push(s)}}for(;++o<a.length;){let s=e.settings.tightAttributes?a[o].charAt(a[o].length-1):void 0;o!==a.length-1&&s!=='"'&&s!=="'"&&(a[o]+=" ")}return a.join("")}function tp(e,t,a){let o=$r(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1,n=e.quote,i;if(o.overloadedBoolean&&(a===o.attribute||a==="")?a=!0:(o.boolean||o.overloadedBoolean)&&(typeof a!="string"||a===o.attribute||a==="")&&(a=!!a),a==null||a===!1||typeof a=="number"&&Number.isNaN(a))return"";let l=Ke(o.attribute,Object.assign({},e.settings.characterReferences,{subset:za.name[r][s]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?Qr:Jr)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a)?l:(e.settings.preferUnquoted&&(i=Ke(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:za.unquoted[r][s]}))),i!==a&&(e.settings.quoteSmart&&xo(a,n)>xo(a,e.alternative)&&(n=e.alternative),i=n+Ke(a,Object.assign({},e.settings.characterReferences,{subset:(n==="'"?za.single:za.double)[r][s],attribute:!0}))+n),l+(i&&"="+i))}f();f();var ap=["<","&"];function Va(e,t,a,o){return a&&a.type==="element"&&(a.tagName==="script"||a.tagName==="style")?e.value:Ke(e.value,Object.assign({},o.settings.characterReferences,{subset:ap}))}function Ri(e,t,a,o){return o.settings.allowDangerousHtml?e.value:Va(e,t,a,o)}f();function Mi(e,t,a,o){return o.all(e)}var Fi=Kr("type",{invalid:op,unknown:rp,handlers:{comment:yi,doctype:bi,element:Ai,raw:Ri,root:Mi,text:Va}});function op(e){throw new Error("Expected node, not `"+e+"`")}function rp(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var sp={},np={},ip=[];function Yo(e,t){let a=t||sp,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:lp,all:up,settings:{omitOptionalTags:a.omitOptionalTags||!1,allowParseErrors:a.allowParseErrors||!1,allowDangerousCharacters:a.allowDangerousCharacters||!1,quoteSmart:a.quoteSmart||!1,preferUnquoted:a.preferUnquoted||!1,tightAttributes:a.tightAttributes||!1,upperDoctype:a.upperDoctype||!1,tightDoctype:a.tightDoctype||!1,bogusComments:a.bogusComments||!1,tightCommaSeparatedLists:a.tightCommaSeparatedLists||!1,tightSelfClosing:a.tightSelfClosing||!1,collapseEmptyAttributes:a.collapseEmptyAttributes||!1,allowDangerousHtml:a.allowDangerousHtml||!1,voids:a.voids||Vr,characterReferences:a.characterReferences||np,closeSelfClosing:a.closeSelfClosing||!1,closeEmptyElements:a.closeEmptyElements||!1},schema:a.space==="svg"?La:Xr,quote:o,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function lp(e,t,a){return Fi(e,t,a,this)}function up(e){let t=[],a=e&&e.children||ip,o=-1;for(;++o<a.length;)t[o]=this.one(a[o],o,e);return t.join("")}function $a(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},o=typeof e=="string"?e:e.name;for(let[r,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?a[r]=s:r===o&&Object.assign(a,s);return a}function tt(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function dp(e){return Array.isArray(e)?e:[e]}async function Ui(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function sr(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Hi(e){return e==="ansi"||sr(e)}function nr(e){return e==="none"}function qi(e){return nr(e)}function Wi(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);let a=Array.isArray(t)?t:t.split(/\s+/g);for(let o of a)o&&!e.properties.class.includes(o)&&e.properties.class.push(o);return e}function Za(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(/(\r?\n)/g),o=0,r=[];for(let s=0;s<a.length;s+=2){let n=t?a[s]+(a[s+1]||""):a[s];r.push([n,o]),o+=a[s].length,o+=a[s+1]?.length||0}return r}function cp(e){let t=Za(e,!0).map(([r])=>r);function a(r){if(r===e.length)return{line:t.length-1,character:t[t.length-1].length};let s=r,n=0;for(let i of t){if(s<i.length)break;s-=i.length,n++}return{line:n,character:s}}function o(r,s){let n=0;for(let i=0;i<r;i++)n+=t[i].length;return n+=s,n}return{lines:t,indexToPos:a,posToIndex:o}}function Gi(e,t,a){let o=new Set;for(let s of e.matchAll(/:?lang=["']([^"']+)["']/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/\\begin\{([\w-]+)\}/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let n=s[1].toLowerCase().trim(),i=n.includes("/")?n.split("/").pop():n;i&&o.add(i)}if(!a)return Array.from(o);let r=a.getBundledLanguages();return Array.from(o).filter(s=>s&&r[s])}var ir="light-dark()",fp=["color","background-color"];function pp(e,t){let a=0,o=[];for(let r of t)r>a&&o.push({...e,content:e.content.slice(a,r),offset:e.offset+a}),a=r;return a<e.content.length&&o.push({...e,content:e.content.slice(a),offset:e.offset+a}),o}function mp(e,t){let a=Array.from(t instanceof Set?t:new Set(t)).sort((o,r)=>o-r);return a.length?e.map(o=>o.flatMap(r=>{let s=a.filter(n=>r.offset<n&&n<r.offset+r.content.length).map(n=>n-r.offset).sort((n,i)=>n-i);return s.length?pp(r,s):r})):e}function hp(e,t,a,o,r="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},n=t.map(c=>Xa(e.variants[c])),i=new Set(n.flatMap(c=>Object.keys(c))),l={},u=(c,d)=>{let p=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return a+t[c]+(d==="color"?"":p)};return n.forEach((c,d)=>{for(let p of i){let m=c[p]||"inherit";if(d===0&&o&&fp.includes(p))if(o===ir&&n.length>1){let h=t.findIndex(C=>C==="light"),I=t.findIndex(C=>C==="dark");if(h===-1||I===-1)throw new Z('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let L=n[h][p]||"inherit",S=n[I][p]||"inherit";l[p]=`light-dark(${L}, ${S})`,r==="css-vars"&&(l[u(d,p)]=m)}else l[p]=m;else r==="css-vars"&&(l[u(d,p)]=m)}}),s.htmlStyle=l,s}function Xa(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&me.Italic&&(t["font-style"]="italic"),e.fontStyle&me.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&me.Underline&&a.push("underline"),e.fontStyle&me.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function ar(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var ji=new WeakMap;function Ya(e,t){ji.set(e,t)}function ua(e){return ji.get(e)}var bt=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,a){return new e(Object.fromEntries(dp(a).map(o=>[o,qa])),t)}constructor(...t){if(t.length===2){let[a,o]=t;this.lang=o,this._stacks=a}else{let[a,o,r]=t;this.lang=o,this._stacks={[r]:a}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return gp(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function gp(e){let t=[],a=new Set;function o(r){if(a.has(r))return;a.add(r);let s=r?.nameScopesList?.scopeName;s&&t.push(s),r.parent&&o(r.parent)}return o(e),t}function wp(e,t){if(!(e instanceof bt))throw new Z("Invalid grammar state");return e.getInternalStack(t)}function xp(){let e=new WeakMap;function t(a){if(!e.has(a.meta)){let o=function(n){if(typeof n=="number"){if(n<0||n>a.source.length)throw new Z(`Invalid decoration offset: ${n}. Code length: ${a.source.length}`);return{...r.indexToPos(n),offset:n}}else{let i=r.lines[n.line];if(i===void 0)throw new Z(`Invalid decoration position ${JSON.stringify(n)}. Lines length: ${r.lines.length}`);let l=n.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new Z(`Invalid decoration position ${JSON.stringify(n)}. Line ${n.line} length: ${i.length}`);return{...n,character:l,offset:r.posToIndex(n.line,l)}}},r=cp(a.source),s=(a.options.decorations||[]).map(n=>({...n,start:o(n.start),end:o(n.end)}));Lp(s),e.set(a.meta,{decorations:s,converter:r,source:a.source})}return e.get(a.meta)}return{name:"shiki:decorations",tokens(a){if(!this.options.decorations?.length)return;let r=t(this).decorations.flatMap(n=>[n.start.offset,n.end.offset]);return mp(a,r)},code(a){if(!this.options.decorations?.length)return;let o=t(this),r=Array.from(a.children).filter(c=>c.type==="element"&&c.tagName==="span");if(r.length!==o.converter.lines.length)throw new Z(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${o.converter.lines.length}). Failed to apply decorations.`);function s(c,d,p,m){let h=r[c],I="",L=-1,S=-1;if(d===0&&(L=0),p===0&&(S=0),p===Number.POSITIVE_INFINITY&&(S=h.children.length),L===-1||S===-1)for(let g=0;g<h.children.length;g++)I+=zi(h.children[g]),L===-1&&I.length===d&&(L=g+1),S===-1&&I.length===p&&(S=g+1);if(L===-1)throw new Z(`Failed to find start index for decoration ${JSON.stringify(m.start)}`);if(S===-1)throw new Z(`Failed to find end index for decoration ${JSON.stringify(m.end)}`);let C=h.children.slice(L,S);if(!m.alwaysWrap&&C.length===h.children.length)i(h,m,"line");else if(!m.alwaysWrap&&C.length===1&&C[0].type==="element")i(C[0],m,"token");else{let g={type:"element",tagName:"span",properties:{},children:C};i(g,m,"wrapper"),h.children.splice(L,C.length,g)}}function n(c,d){r[c]=i(r[c],d,"line")}function i(c,d,p){let m=d.properties||{},h=d.transform||(I=>I);return c.tagName=d.tagName||"span",c.properties={...c.properties,...m,class:c.properties.class},d.properties?.class&&Wi(c,d.properties.class),c=h(c,p)||c,c}let l=[],u=o.decorations.sort((c,d)=>d.start.offset-c.start.offset||c.end.offset-d.end.offset);for(let c of u){let{start:d,end:p}=c;if(d.line===p.line)s(d.line,d.character,p.character,c);else if(d.line<p.line){s(d.line,d.character,Number.POSITIVE_INFINITY,c);for(let m=d.line+1;m<p.line;m++)l.unshift(()=>n(m,c));s(p.line,0,p.character,c)}}l.forEach(c=>c())}}}function Lp(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new Z(`Invalid decoration range: ${JSON.stringify(a.start)} - ${JSON.stringify(a.end)}`);for(let o=t+1;o<e.length;o++){let r=e[o],s=a.start.offset<=r.start.offset&&r.start.offset<a.end.offset,n=a.start.offset<r.end.offset&&r.end.offset<=a.end.offset,i=r.start.offset<=a.start.offset&&a.start.offset<r.end.offset,l=r.start.offset<a.end.offset&&a.end.offset<=r.end.offset;if(s||n||i||l){if(s&&n||i&&l||i&&a.start.offset===a.end.offset||n&&r.start.offset===r.end.offset)continue;throw new Z(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function zi(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(zi).join(""):""}var Cp=[xp()];function Ka(e){let t=Ip(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Cp]}function Ip(e){let t=[],a=[],o=[];for(let r of e)switch(r.enforce){case"pre":t.push(r);break;case"post":a.push(r);break;default:o.push(r)}return{pre:t,post:a,normal:o}}var ct=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],er={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Sp(e,t){let a=e.indexOf("\x1B",t);if(a!==-1&&e[a+1]==="["){let o=e.indexOf("m",a);if(o!==-1)return{sequence:e.substring(a+2,o).split(";"),startPosition:a,position:o+1}}return{position:e.length}}function Di(e){let t=e.shift();if(t==="2"){let a=e.splice(0,3).map(o=>Number.parseInt(o));return a.length!==3||a.some(o=>Number.isNaN(o))?void 0:{type:"rgb",rgb:a}}else if(t==="5"){let a=e.shift();if(a)return{type:"table",index:Number(a)}}}function yp(e){let t=[];for(;e.length>0;){let a=e.shift();if(!a)continue;let o=Number.parseInt(a);if(!Number.isNaN(o))if(o===0)t.push({type:"resetAll"});else if(o<=9)er[o]&&t.push({type:"setDecoration",value:er[o]});else if(o<=29){let r=er[o-20];r&&(t.push({type:"resetDecoration",value:r}),r==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(o<=37)t.push({type:"setForegroundColor",value:{type:"named",name:ct[o-30]}});else if(o===38){let r=Di(e);r&&t.push({type:"setForegroundColor",value:r})}else if(o===39)t.push({type:"resetForegroundColor"});else if(o<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:ct[o-40]}});else if(o===48){let r=Di(e);r&&t.push({type:"setBackgroundColor",value:r})}else o===49?t.push({type:"resetBackgroundColor"}):o===53?t.push({type:"setDecoration",value:"overline"}):o===55?t.push({type:"resetDecoration",value:"overline"}):o>=90&&o<=97?t.push({type:"setForegroundColor",value:{type:"named",name:ct[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:ct[o-100+8]}})}return t}function bp(){let e=null,t=null,a=new Set;return{parse(o){let r=[],s=0;do{let n=Sp(o,s),i=n.sequence?o.substring(s,n.startPosition):o.substring(s);if(i.length>0&&r.push({value:i,foreground:e,background:t,decorations:new Set(a)}),n.sequence){let l=yp(n.sequence);for(let u of l)u.type==="resetAll"?(e=null,t=null,a.clear()):u.type==="resetForegroundColor"?e=null:u.type==="resetBackgroundColor"?t=null:u.type==="resetDecoration"&&a.delete(u.value);for(let u of l)u.type==="setForegroundColor"?e=u.value:u.type==="setBackgroundColor"?t=u.value:u.type==="setDecoration"&&a.add(u.value)}s=n.position}while(s<o.length);return r}}}var kp={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function Tp(e=kp){function t(i){return e[i]}function a(i){return`#${i.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let o;function r(){if(o)return o;o=[];for(let u=0;u<ct.length;u++)o.push(t(ct[u]));let i=[0,95,135,175,215,255];for(let u=0;u<6;u++)for(let c=0;c<6;c++)for(let d=0;d<6;d++)o.push(a([i[u],i[c],i[d]]));let l=8;for(let u=0;u<24;u++,l+=10)o.push(a([l,l,l]));return o}function s(i){return r()[i]}function n(i){switch(i.type){case"named":return t(i.name);case"rgb":return a(i.rgb);case"table":return s(i.index)}}return{value:n}}var vp={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function Pp(e,t,a){let o=$a(e,a),r=Za(t),s=Object.fromEntries(ct.map(l=>{let u=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,c=e.colors?.[u];return[l,c||vp[l]]})),n=Tp(s),i=bp();return r.map(l=>i.parse(l[0]).map(u=>{let c,d;u.decorations.has("reverse")?(c=u.background?n.value(u.background):e.bg,d=u.foreground?n.value(u.foreground):e.fg):(c=u.foreground?n.value(u.foreground):e.fg,d=u.background?n.value(u.background):void 0),c=tt(c,o),d=tt(d,o),u.decorations.has("dim")&&(c=Ap(c));let p=me.None;return u.decorations.has("bold")&&(p|=me.Bold),u.decorations.has("italic")&&(p|=me.Italic),u.decorations.has("underline")&&(p|=me.Underline),u.decorations.has("strikethrough")&&(p|=me.Strikethrough),{content:u.value,offset:l[1],color:c,bgColor:d,fontStyle:p}}))}function Ap(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let o=t[1];if(o.length===8){let r=Math.round(Number.parseInt(o.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${o.slice(0,6)}${r}`}else{if(o.length===6)return`#${o}80`;if(o.length===4){let r=o[0],s=o[1],n=o[2],i=o[3],l=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${s}${s}${n}${n}${l}`}else if(o.length===3){let r=o[0],s=o[1],n=o[2];return`#${r}${r}${s}${s}${n}${n}80`}}}let a=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return a?`var(${a[1]}-dim)`:e}function lr(e,t,a={}){let{theme:o=e.getLoadedThemes()[0]}=a,r=e.resolveLangAlias(a.lang||"text");if(sr(r)||nr(o))return Za(t).map(l=>[{content:l[0],offset:l[1]}]);let{theme:s,colorMap:n}=e.setTheme(o);if(r==="ansi")return Pp(s,t,a);let i=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==i.name)throw new Z(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${i.name}"`);if(!a.grammarState.themes.includes(s.name))throw new Z(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return Mp(t,i,s,n,a)}function Rp(...e){if(e.length===2)return ua(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:s=t.getLoadedThemes()[0]}=o;if(sr(r)||nr(s))throw new Z("Plain language does not have grammar state");if(r==="ansi")throw new Z("ANSI language does not have grammar state");let{theme:n,colorMap:i}=t.setTheme(s),l=t.getLanguage(r);return new bt(ur(a,l,n,i,o).stateStack,l.name,n.name)}function Mp(e,t,a,o,r){let s=ur(e,t,a,o,r),n=new bt(s.stateStack,t.name,a.name);return Ya(s.tokens,n),s.tokens}function ur(e,t,a,o,r){let s=$a(a,r),{tokenizeMaxLineLength:n=0,tokenizeTimeLimit:i=500}=r,l=Za(e),u=r.grammarState?wp(r.grammarState,a.name)??qa:r.grammarContextCode!=null?ur(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:qa,c=[],d=[];for(let p=0,m=l.length;p<m;p++){let[h,I]=l[p];if(h===""){c=[],d.push([]);continue}if(n>0&&h.length>=n){c=[],d.push([{content:h,offset:I,color:"",fontStyle:0}]);continue}let L,S,C;r.includeExplanation&&(L=t.tokenizeLine(h,u,i),S=L.tokens,C=0);let g=t.tokenizeLine2(h,u,i),b=g.tokens.length/2;for(let P=0;P<b;P++){let A=g.tokens[2*P],v=P+1<b?g.tokens[2*P+2]:h.length;if(A===v)continue;let R=g.tokens[2*P+1],_=tt(o[dt.getForeground(R)],s),M=dt.getFontStyle(R),T={content:h.substring(A,v),offset:I+A,color:_,fontStyle:M};if(r.includeExplanation){let y=[];if(r.includeExplanation!=="scopeName")for(let U of a.settings){let F;switch(typeof U.scope){case"string":F=U.scope.split(/,/).map(Q=>Q.trim());break;case"object":F=U.scope;break;default:continue}y.push({settings:U,selectors:F.map(Q=>Q.split(/ /))})}T.explanation=[];let B=0;for(;A+B<v;){let U=S[C],F=h.substring(U.startIndex,U.endIndex);B+=F.length,T.explanation.push({content:F,scopes:r.includeExplanation==="scopeName"?Fp(U.scopes):Dp(y,U.scopes)}),C+=1}}c.push(T)}d.push(c),c=[],u=g.ruleStack}return{tokens:d,stateStack:u}}function Fp(e){return e.map(t=>({scopeName:t}))}function Dp(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let s=t[o];a[o]={scopeName:s,themeMatches:Ep(e,s,t.slice(0,o))}}return a}function Bi(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Bp(e,t,a){if(!Bi(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)Bi(e[o],a[r])&&(o-=1),r-=1;return o===-1}function Ep(e,t,a){let o=[];for(let{selectors:r,settings:s}of e)for(let n of r)if(Bp(n,t,a)){o.push(s);break}return o}function Vi(e,t,a){let o=Object.entries(a.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),r=o.map(l=>{let u=lr(e,t,{...a,theme:l.theme}),c=ua(u),d=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:u,state:c,theme:d}}),s=_p(...r.map(l=>l.tokens)),n=s[0].map((l,u)=>l.map((c,d)=>{let p={content:c.content,variants:{},offset:c.offset};return"includeExplanation"in a&&a.includeExplanation&&(p.explanation=c.explanation),s.forEach((m,h)=>{let{content:I,explanation:L,offset:S,...C}=m[u][d];p.variants[o[h].color]=C}),p})),i=r[0].state?new bt(Object.fromEntries(r.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),r[0].state.lang):void 0;return i&&Ya(n,i),n}function _p(...e){let t=e.map(()=>[]),a=e.length;for(let o=0;o<e[0].length;o++){let r=e.map(l=>l[o]),s=t.map(()=>[]);t.forEach((l,u)=>l.push(s[u]));let n=r.map(()=>0),i=r.map(l=>l[0]);for(;i.every(l=>l);){let l=Math.min(...i.map(u=>u.content.length));for(let u=0;u<a;u++){let c=i[u];c.content.length===l?(s[u].push(c),n[u]+=1,i[u]=r[u][n[u]]):(s[u].push({...c,content:c.content.slice(0,l)}),i[u]={...c,content:c.content.slice(l),offset:c.offset+l})}}}return t}function Qa(e,t,a){let o,r,s,n,i,l;if("themes"in a){let{defaultColor:u="light",cssVariablePrefix:c="--shiki-",colorsRendering:d="css-vars"}=a,p=Object.entries(a.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,C)=>S.color===u?-1:C.color===u?1:0);if(p.length===0)throw new Z("`themes` option must not be empty");let m=Vi(e,t,a);if(l=ua(m),u&&ir!==u&&!p.find(S=>S.color===u))throw new Z(`\`themes\` option must contain the defaultColor key \`${u}\``);let h=p.map(S=>e.getTheme(S.theme)),I=p.map(S=>S.color);s=m.map(S=>S.map(C=>hp(C,I,c,u,d))),l&&Ya(s,l);let L=p.map(S=>$a(S.theme,a));r=Ei(p,h,L,c,u,"fg",d),o=Ei(p,h,L,c,u,"bg",d),n=`shiki-themes ${h.map(S=>S.name).join(" ")}`,i=u?void 0:[r,o].join(";")}else if("theme"in a){let u=$a(a.theme,a);s=lr(e,t,a);let c=e.getTheme(a.theme);o=tt(c.bg,u),r=tt(c.fg,u),n=c.name,l=ua(s)}else throw new Z("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:r,bg:o,themeName:n,rootStyle:i,grammarState:l}}function Ei(e,t,a,o,r,s,n){return e.map((i,l)=>{let u=tt(t[l][s],a[l])||"inherit",c=`${o+i.color}${s==="bg"?"-bg":""}:${u}`;if(l===0&&r){if(r===ir&&e.length>1){let d=e.findIndex(I=>I.color==="light"),p=e.findIndex(I=>I.color==="dark");if(d===-1||p===-1)throw new Z('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let m=tt(t[d][s],a[d])||"inherit",h=tt(t[p][s],a[p])||"inherit";return`light-dark(${m}, ${h});${c}`}return u}return n==="css-vars"?c:null}).filter(i=>!!i).join(";")}function Ja(e,t,a,o={meta:{},options:a,codeToHast:(r,s)=>Ja(e,r,s),codeToTokens:(r,s)=>Qa(e,r,s)}){let r=t;for(let h of Ka(a))r=h.preprocess?.call(o,r,a)||r;let{tokens:s,fg:n,bg:i,themeName:l,rootStyle:u,grammarState:c}=Qa(e,r,a),{mergeWhitespaces:d=!0,mergeSameStyleTokens:p=!1}=a;d===!0?s=Op(s):d==="never"&&(s=Up(s)),p&&(s=Hp(s));let m={...o,get source(){return r}};for(let h of Ka(a))s=h.tokens?.call(m,s)||s;return Np(s,{...a,fg:n,bg:i,themeName:l,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},m,c)}function Np(e,t,a,o=ua(e)){let r=Ka(t),s=[],n={type:"root",children:[]},{structure:i="classic",tabindex:l="0"}=t,u={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?u.style=t.rootStyle:u.style=`background-color:${t.bg};color:${t.fg}`),l!==!1&&l!=null&&(u.tabindex=l.toString());for(let[I,L]of Object.entries(t.meta||{}))I.startsWith("_")||(u[I]=L);let c={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},p=[],m={...a,structure:i,addClassToHast:Wi,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return n},get pre(){return c},get code(){return d},get lines(){return p}};if(e.forEach((I,L)=>{L&&(i==="inline"?n.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&s.push({type:"text",value:`
79
- `}));let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},C=0;for(let g of I){let b={type:"element",tagName:"span",properties:{...g.htmlAttrs},children:[{type:"text",value:g.content}]},P=ar(g.htmlStyle||Xa(g));P&&(b.properties.style=P);for(let A of r)b=A?.span?.call(m,b,L+1,C,S,g)||b;i==="inline"?n.children.push(b):i==="classic"&&S.children.push(b),C+=g.content.length}if(i==="classic"){for(let g of r)S=g?.line?.call(m,S,L+1)||S;p.push(S),s.push(S)}else i==="inline"&&p.push(S)}),i==="classic"){for(let I of r)d=I?.code?.call(m,d)||d;c.children.push(d);for(let I of r)c=I?.pre?.call(m,c)||c;n.children.push(c)}else if(i==="inline"){let I=[],L={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let g of n.children)g.type==="element"&&g.tagName==="br"?(I.push(L),L={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(g.type==="element"||g.type==="text")&&L.children.push(g);I.push(L);let C={type:"element",tagName:"code",properties:{},children:I};for(let g of r)C=g?.code?.call(m,C)||C;n.children=[];for(let g=0;g<C.children.length;g++){g>0&&n.children.push({type:"element",tagName:"br",properties:{},children:[]});let b=C.children[g];b.type==="element"&&n.children.push(...b.children)}}let h=n;for(let I of r)h=I?.root?.call(m,h)||h;return o&&Ya(h,o),h}function Op(e){return e.map(t=>{let a=[],o="",r;return t.forEach((s,n)=>{let l=!(s.fontStyle&&(s.fontStyle&me.Underline||s.fontStyle&me.Strikethrough));l&&s.content.match(/^\s+$/)&&t[n+1]?(r===void 0&&(r=s.offset),o+=s.content):o?(l?a.push({...s,offset:r,content:o+s.content}):a.push({content:o,offset:r},s),r=void 0,o=""):a.push(s)}),a})}function Up(e){return e.map(t=>t.flatMap(a=>{if(a.content.match(/^\s+$/))return a;let o=a.content.match(/^(\s*)(.*?)(\s*)$/);if(!o)return a;let[,r,s,n]=o;if(!r&&!n)return a;let i=[{...a,offset:a.offset+r.length,content:s}];return r&&i.unshift({content:r,offset:a.offset}),n&&i.push({content:n,offset:a.offset+r.length+s.length}),i}))}function Hp(e){return e.map(t=>{let a=[];for(let o of t){if(a.length===0){a.push({...o});continue}let r=a[a.length-1],s=ar(r.htmlStyle||Xa(r)),n=ar(o.htmlStyle||Xa(o)),i=r.fontStyle&&(r.fontStyle&me.Underline||r.fontStyle&me.Strikethrough),l=o.fontStyle&&(o.fontStyle&me.Underline||o.fontStyle&me.Strikethrough);!i&&!l&&s===n?r.content+=o.content:a.push({...o})}return a})}var qp=Yo;function Wp(e,t,a){let o={meta:{},options:a,codeToHast:(s,n)=>Ja(e,s,n),codeToTokens:(s,n)=>Qa(e,s,n)},r=qp(Ja(e,t,a,o));for(let s of Ka(a))r=s.postprocess?.call(o,r,a)||r;return r}var _i={light:"#333333",dark:"#bbbbbb"},Ni={light:"#fffffe",dark:"#1e1e1e"},Oi="__shiki_resolved";function dr(e){if(e?.[Oi])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:a,fg:o}=t;if(!a||!o){let i=t.settings?t.settings.find(l=>!l.name&&!l.scope):void 0;i?.settings?.foreground&&(o=i.settings.foreground),i?.settings?.background&&(a=i.settings.background),!o&&t?.colors?.["editor.foreground"]&&(o=t.colors["editor.foreground"]),!a&&t?.colors?.["editor.background"]&&(a=t.colors["editor.background"]),o||(o=t.type==="light"?_i.light:_i.dark),a||(a=t.type==="light"?Ni.light:Ni.dark),t.fg=o,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let r=0,s=new Map;function n(i){if(s.has(i))return s.get(i);r+=1;let l=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?n(i):(s.set(i,l),l)}t.settings=t.settings.map(i=>{let l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),u=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!u)return i;let c={...i,settings:{...i.settings}};if(l){let d=n(i.settings.foreground);t.colorReplacements[d]=i.settings.foreground,c.settings.foreground=d}if(u){let d=n(i.settings.background);t.colorReplacements[d]=i.settings.background,c.settings.background=d}return c});for(let i of Object.keys(t.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!t.colors[i]?.startsWith("#")){let l=n(t.colors[i]);t.colorReplacements[l]=t.colors[i],t.colors[i]=l}return Object.defineProperty(t,Oi,{enumerable:!1,writable:!1,value:!0}),t}async function $i(e){return Array.from(new Set((await Promise.all(e.filter(t=>!Hi(t)).map(async t=>await Ui(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function Xi(e){return(await Promise.all(e.map(async a=>qi(a)?null:dr(await Ui(a))))).filter(a=>!!a)}var tr=3,Gp=!1;function jp(e,t=3){if(tr&&!(typeof tr=="number"&&t>tr)){if(Gp)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var et=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Ki(e,t){if(!t)return e;if(t[e]){let a=new Set([e]);for(;t[e];){if(e=t[e],a.has(e))throw new et(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var or=class extends pi{constructor(t,a,o,r={}){super(t),this._resolver=t,this._themes=a,this._langs=o,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){let a=dr(t);return a.name&&(this._resolvedThemes.set(a.name,a),this._loadedThemesCache=null),a}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let a=this._textmateThemeCache.get(t);a||(a=aa.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=Ki(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let a=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);let o={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);let r=this.loadGrammarWithConfiguration(t.scopeName,1,o);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases&&t.aliases.forEach(s=>{this._alias[s]=t.name}),this._loadedLanguagesCache=null,a.size)for(let s of a)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(let r of t)this.resolveEmbeddedLanguages(r);let a=Array.from(this._langGraph.entries()),o=a.filter(([r,s])=>!s);if(o.length){let r=a.filter(([s,n])=>n?(n.embeddedLanguages||n.embeddedLangs)?.some(l=>o.map(([u])=>u).includes(l)):!1).filter(s=>!o.includes(s));throw new et(`Missing languages ${o.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(let[r,s]of a)this._resolver.addLanguage(s);for(let[r,s]of a)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);let a=t.embeddedLanguages??t.embeddedLangs;if(a)for(let o of a)this._langGraph.set(o,this._langMap.get(o))}},rr=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,a){this._onigLib={createOnigScanner:o=>t.createScanner(o),createOnigString:o=>t.createString(o)},a.forEach(o=>this.addLanguage(o))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(a=>{this._langs.set(a,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(a=>{this._injections.get(a)||this._injections.set(a,[]),this._injections.get(a).push(t.scopeName)})}getInjections(t){let a=t.split("."),o=[];for(let r=1;r<=a.length;r++){let s=a.slice(0,r).join(".");o=[...o,...this._injections.get(s)||[]]}return o}},la=0;function zp(e){la+=1,e.warnings!==!1&&la>=10&&la%10===0&&console.warn(`[Shiki] ${la} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new et("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(dr),r=new rr(e.engine,a),s=new or(r,o,a,e.langAlias),n;function i(g){return Ki(g,e.langAlias)}function l(g){S();let b=s.getGrammar(typeof g=="string"?g:g.name);if(!b)throw new et(`Language \`${g}\` not found, you may need to load it first`);return b}function u(g){if(g==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};S();let b=s.getTheme(g);if(!b)throw new et(`Theme \`${g}\` not found, you may need to load it first`);return b}function c(g){S();let b=u(g);n!==g&&(s.setTheme(b),n=g);let P=s.getColorMap();return{theme:b,colorMap:P}}function d(){return S(),s.getLoadedThemes()}function p(){return S(),s.getLoadedLanguages()}function m(...g){S(),s.loadLanguages(g.flat(1))}async function h(...g){return m(await $i(g))}function I(...g){S();for(let b of g.flat(1))s.loadTheme(b)}async function L(...g){return S(),I(await Xi(g))}function S(){if(t)throw new et("Shiki instance has been disposed")}function C(){t||(t=!0,s.dispose(),la-=1)}return{setTheme:c,getTheme:u,getLanguage:l,getLoadedThemes:d,getLoadedLanguages:p,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:m,loadTheme:L,loadThemeSync:I,dispose:C,[Symbol.dispose]:C}}async function Vp(e){e.engine||jp("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([Xi(e.themes||[]),$i(e.langs||[]),e.engine]);return zp({...e,themes:t,langs:a,engine:o})}async function $p(e){let t=await Vp(e);return{getLastGrammarState:(...a)=>Rp(t,...a),codeToTokensBase:(a,o)=>lr(t,a,o),codeToTokensWithThemes:(a,o)=>Vi(t,a,o),codeToTokens:(a,o)=>Qa(t,a,o),codeToHast:(a,o)=>Ja(t,a,o),codeToHtml:(a,o)=>Wp(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Qi(e){let t=e.langs,a=e.themes,o=e.engine;async function r(s){function n(d){if(typeof d=="string"){if(d=s.langAlias?.[d]||d,Hi(d))return[];let p=t[d];if(!p)throw new Z(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}function i(d){if(qi(d))return"none";if(typeof d=="string"){let p=a[d];if(!p)throw new Z(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}let l=(s.themes??[]).map(d=>i(d)),u=(s.langs??[]).map(d=>n(d)),c=await $p({engine:s.engine??o(),...s,themes:l,langs:u});return{...c,loadLanguage(...d){return c.loadLanguage(...d.map(n))},loadTheme(...d){return c.loadTheme(...d.map(i))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function Xp(e){let t;async function a(o={}){if(t){let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}else{t=e({...o,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}}return a}function Ji(e,t){let a=Xp(e);async function o(r,s){let n=await a({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),i=await t?.guessEmbeddedLanguages?.(r,s.lang,n);return i&&await n.loadLanguage(...i),n}return{getSingletonHighlighter(r){return a(r)},async codeToHtml(r,s){return(await o(r,s)).codeToHtml(r,s)},async codeToHast(r,s){return(await o(r,s)).codeToHast(r,s)},async codeToTokens(r,s){return(await o(r,s)).codeToTokens(r,s)},async codeToTokensBase(r,s){return(await o(r,s)).codeToTokensBase(r,s)},async codeToTokensWithThemes(r,s){return(await o(r,s)).codeToTokensWithThemes(r,s)},async getLastGrammarState(r,s){return(await a({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(r,s)}}}f();var cr=[{id:"abap",name:"ABAP",import:(()=>import("../abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-VZSV3CDH.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-UPMUIYI3.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-OU63AG2P.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-ZTMAKUPW.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-WADBFJPS.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-ZC25ZSBI.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-EOACOM4G.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-BVUO2H7O.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("../c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-CDQIRWGP.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-SKJIT3WM.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-4EW5XLOK.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-YFCJLEES.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-6EXQ7B24.js"))},{id:"css",name:"CSS",import:(()=>import("../css-MH4LSMNV.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("../d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-CSERBUPM.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-3LWPZYS7.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-3H7W7YJZ.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-YHLQYGNI.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-AXCKAI43.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-ZXI6Y36F.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-BJKMFBLF.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("../go-CPCZAAWX.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-KHEFECOG.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-KV5GHBVV.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-6R7X7F2Q.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-U44VLSEQ.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("../html-MYZBE4UD.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-OWRPAN3G.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-JSPDAWSO.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-OT2SM4S7.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("../java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-CCI3FGLW.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("../json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-BWWONBRS.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-LT46F7AO.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-R4PJ7JDY.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("../less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-OSRU4KOW.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-WBQ7MHV7.js"))},{id:"log",name:"Log file",import:(()=>import("../log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-D432BEB5.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-WVASNOGB.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-PDOFYVVO.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-KRRNBH7O.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-LQ7JL5LZ.js"))},{id:"move",name:"Move",import:(()=>import("../move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-DPCEWQNZ.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-WGQAUAVA.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-26KZW4VL.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-Y3ALUOFJ.js"))},{id:"php",name:"PHP",import:(()=>import("../php-QERWOQJG.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-7XNGVJEC.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("../r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-C2NV2YNT.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-WD6BJFDY.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-W5S2XFF7.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-EYYAUQUG.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-A4JCTK6H.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-4QR2BXFS.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-G2LDZSDN.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-SBP7VV3V.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-MNI5YOQU.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-EYZDXUS2.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-JEBLU4EM.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-KXQ2KV7D.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-L55DZDKV.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-TCQ23O6Y.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-JAL4753Y.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-6JSRRA42.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("../v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-D6SXQNWM.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-T6MFB2MU.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-6LJUAPBA.js"))}],Zi=Object.fromEntries(cr.map(e=>[e.id,e.import])),Yi=Object.fromEntries(cr.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),da={...Zi,...Yi};f();var Kp=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("../andromeeda-XSK3JERF.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("../aurora-x-CGSVHL4H.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("../ayu-dark-XYI57HMC.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("../ayu-light-4PSGMDIC.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("../ayu-mirage-DU5SNMZX.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("../catppuccin-frappe-UZ4N3Z4I.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("../catppuccin-latte-GCOWYLZG.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("../catppuccin-macchiato-PJD7W5WJ.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("../catppuccin-mocha-RRH4FOBS.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("../dark-plus-PSM5XP2I.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("../dracula-2VHT5LK5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("../dracula-soft-MSCUO73T.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("../everforest-dark-AGVJEQ35.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("../everforest-light-62GPFKVJ.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("../github-dark-5OJVMBCE.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("../github-dark-default-4WERFSZW.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("../github-dark-dimmed-7VD3SZKC.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("../github-dark-high-contrast-FVMMS656.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("../github-light-SE4LEKO7.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("../github-light-default-TV7BYQGI.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("../github-light-high-contrast-WKO4I3G7.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("../gruvbox-dark-hard-LOYZQIGI.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("../gruvbox-dark-medium-UIMSJJ6K.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("../gruvbox-dark-soft-PU6RNTTO.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("../gruvbox-light-hard-ZQJ7XSZF.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("../gruvbox-light-medium-CD3ZGYV6.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("../gruvbox-light-soft-S74MAGOM.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("../horizon-EAAZ4KVN.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("../houston-UNRWGR67.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("../kanagawa-dragon-BOSCCB42.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("../kanagawa-lotus-NXMB2IVI.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("../kanagawa-wave-YOHS63UF.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("../laserwave-TS4AG4VO.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("../light-plus-2HYW3NJ6.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("../material-theme-KPDVFAGV.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("../material-theme-darker-GVSTMSNT.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("../material-theme-lighter-JWZNUXUH.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("../material-theme-ocean-MU4N3XNQ.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("../material-theme-palenight-VMWD73WM.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("../min-dark-ASEVSA24.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("../min-light-3H54BB3D.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("../monokai-5QWQOFN6.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("../night-owl-4QQBS2UX.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("../night-owl-light-HR6A2OQO.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("../nord-XK3AUNCF.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("../one-dark-pro-ZV7CEA5M.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("../one-light-FKZJCKM6.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("../plastic-SXCQPKYC.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("../poimandres-S3UYVG4O.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("../red-A6OC2HVL.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("../rose-pine-GLWOWPBK.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("../rose-pine-dawn-HYE6T7LV.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("../rose-pine-moon-VHVTDDVO.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("../slack-dark-OPW5CYSY.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("../slack-ochin-WTVMYBFH.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("../snazzy-light-5UQ56PC5.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("../solarized-dark-DSMP6D7D.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("../solarized-light-3IZTZCIV.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("../synthwave-84-JWI6CVJZ.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("../tokyo-night-SRK4SADJ.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("../vesper-WIZFPFI7.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("../vitesse-black-PEGI4HJX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("../vitesse-dark-M2ZAGPXG.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("../vitesse-light-RICZI4IG.js"))}],el=Object.fromEntries(Kp.map(e=>[e.id,e.import]));f();var ca=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Qp(){return 2147483648}function Jp(){return typeof performance<"u"?performance.now():Date.now()}var Zp=(e,t)=>e+(t-e%t)%t;async function Yp(e){let t,a,o={};function r(m){a=m,o.HEAPU8=new Uint8Array(m),o.HEAPU32=new Uint32Array(m)}function s(m,h,I){o.HEAPU8.copyWithin(m,h,h+I)}function n(m){try{return t.grow(m-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function i(m){let h=o.HEAPU8.length;m=m>>>0;let I=Qp();if(m>I)return!1;for(let L=1;L<=4;L*=2){let S=h*(1+.2/L);S=Math.min(S,m+100663296);let C=Math.min(I,Zp(Math.max(m,S),65536));if(n(C))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(m,h,I=1024){let L=h+I,S=h;for(;m[S]&&!(S>=L);)++S;if(S-h>16&&m.buffer&&l)return l.decode(m.subarray(h,S));let C="";for(;h<S;){let g=m[h++];if(!(g&128)){C+=String.fromCharCode(g);continue}let b=m[h++]&63;if((g&224)===192){C+=String.fromCharCode((g&31)<<6|b);continue}let P=m[h++]&63;if((g&240)===224?g=(g&15)<<12|b<<6|P:g=(g&7)<<18|b<<12|P<<6|m[h++]&63,g<65536)C+=String.fromCharCode(g);else{let A=g-65536;C+=String.fromCharCode(55296|A>>10,56320|A&1023)}}return C}function c(m,h){return m?u(o.HEAPU8,m,h):""}let d={emscripten_get_now:Jp,emscripten_memcpy_big:s,emscripten_resize_heap:i,fd_write:()=>0};async function p(){let h=await e({env:d,wasi_snapshot_preview1:d});t=h.memory,r(t.buffer),Object.assign(o,h),o.UTF8ToString=c}return await p(),o}var em=Object.defineProperty,tm=(e,t,a)=>t in e?em(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,ie=(e,t,a)=>tm(e,typeof t!="symbol"?t+"":t,a),fe=null;function am(e){throw new ca(e.UTF8ToString(e.getLastOnigError()))}var to=class e{constructor(t){ie(this,"utf16Length"),ie(this,"utf8Length"),ie(this,"utf16Value"),ie(this,"utf8Value"),ie(this,"utf16OffsetToUtf8"),ie(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,s=r?new Uint32Array(a+1):null;r&&(s[a]=o);let n=r?new Uint32Array(o+1):null;r&&(n[o]=a);let i=new Uint8Array(o),l=0;for(let u=0;u<a;u++){let c=t.charCodeAt(u),d=c,p=!1;if(c>=55296&&c<=56319&&u+1<a){let m=t.charCodeAt(u+1);m>=56320&&m<=57343&&(d=(c-55296<<10)+65536|m-56320,p=!0)}r&&(s[u]=l,p&&(s[u+1]=l),d<=127?n[l+0]=u:d<=2047?(n[l+0]=u,n[l+1]=u):d<=65535?(n[l+0]=u,n[l+1]=u,n[l+2]=u):(n[l+0]=u,n[l+1]=u,n[l+2]=u,n[l+3]=u)),d<=127?i[l++]=d:d<=2047?(i[l++]=192|(d&1984)>>>6,i[l++]=128|(d&63)>>>0):d<=65535?(i[l++]=224|(d&61440)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0):(i[l++]=240|(d&1835008)>>>18,i[l++]=128|(d&258048)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0),p&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=i,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=n}static _utf8ByteLength(t){let a=0;for(let o=0,r=t.length;o<r;o++){let s=t.charCodeAt(o),n=s,i=!1;if(s>=55296&&s<=56319&&o+1<r){let l=t.charCodeAt(o+1);l>=56320&&l<=57343&&(n=(s-55296<<10)+65536|l-56320,i=!0)}n<=127?a+=1:n<=2047?a+=2:n<=65535?a+=3:a+=4,i&&o++}return a}createString(t){let a=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,a),a}},ao=class Ge{constructor(t){if(ie(this,"id",++Ge.LAST_ID),ie(this,"_onigBinding"),ie(this,"content"),ie(this,"utf16Length"),ie(this,"utf8Length"),ie(this,"utf16OffsetToUtf8"),ie(this,"utf8OffsetToUtf16"),ie(this,"ptr"),!fe)throw new ca("Must invoke loadWasm first.");this._onigBinding=fe,this.content=t;let a=new to(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!Ge._sharedPtrInUse?(Ge._sharedPtr||(Ge._sharedPtr=fe.omalloc(1e4)),Ge._sharedPtrInUse=!0,fe.HEAPU8.set(a.utf8Value,Ge._sharedPtr),this.ptr=Ge._sharedPtr):this.ptr=a.createString(fe)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===Ge._sharedPtr?Ge._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};ie(ao,"LAST_ID",0);ie(ao,"_sharedPtr",0);ie(ao,"_sharedPtrInUse",!1);var tl=ao,pr=class{constructor(t){if(ie(this,"_onigBinding"),ie(this,"_ptr"),!fe)throw new ca("Must invoke loadWasm first.");let a=[],o=[];for(let i=0,l=t.length;i<l;i++){let u=new to(t[i]);a[i]=u.createString(fe),o[i]=u.utf8Length}let r=fe.omalloc(4*t.length);fe.HEAPU32.set(a,r/4);let s=fe.omalloc(4*t.length);fe.HEAPU32.set(o,s/4);let n=fe.createOnigScanner(r,s,t.length);for(let i=0,l=t.length;i<l;i++)fe.ofree(a[i]);fe.ofree(s),fe.ofree(r),n===0&&am(fe),this._onigBinding=fe,this._ptr=n}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,a,o){let r=0;if(typeof o=="number"&&(r=o),typeof t=="string"){t=new tl(t);let s=this._findNextMatchSync(t,a,!1,r);return t.dispose(),s}return this._findNextMatchSync(t,a,!1,r)}_findNextMatchSync(t,a,o,r){let s=this._onigBinding,n=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(a),r);if(n===0)return null;let i=s.HEAPU32,l=n/4,u=i[l++],c=i[l++],d=[];for(let p=0;p<c;p++){let m=t.convertUtf8OffsetToUtf16(i[l++]),h=t.convertUtf8OffsetToUtf16(i[l++]);d[p]={start:m,end:h,length:h-m}}return{index:u,captureIndices:d}}};function om(e){return typeof e.instantiator=="function"}function rm(e){return typeof e.default=="function"}function sm(e){return typeof e.data<"u"}function nm(e){return typeof Response<"u"&&e instanceof Response}function im(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var eo;function lm(e){if(eo)return eo;async function t(){fe=await Yp(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),om(o)?o=await o.instantiator(a):rm(o)?o=await o.default(a):(sm(o)&&(o=o.data),nm(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await um(o)(a):o=await dm(o)(a):im(o)?o=await fr(o)(a):o instanceof WebAssembly.Module?o=await fr(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await fr(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return eo=t(),eo}function fr(e){return t=>WebAssembly.instantiate(e,t)}function um(e){return t=>WebAssembly.instantiateStreaming(e,t)}function dm(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function al(e){return e&&await lm(e),{createScanner(t){return new pr(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new tl(t)}}}var oo=Qi({langs:da,themes:el,engine:()=>al(import("../wasm-ISCPKFD2.js"))}),{codeToHtml:cm,codeToHast:fm,codeToTokens:pm,codeToTokensBase:mm,codeToTokensWithThemes:hm,getSingletonHighlighter:gm,getLastGrammarState:wm}=Ji(oo,{guessEmbeddedLanguages:Gi});var ol=new Set(Object.keys(da)),mr=new Map,hr=new Map,kt=new Map,xm=(e,t)=>`${e}-${t[0]}-${t[1]}`,Lm=(e,t,a)=>{let o=e.slice(0,100),r=e.length>100?e.slice(-100):"";return`${t}:${a[0]}:${a[1]}:${e.length}:${o}:${r}`},Cm=(e,t)=>{let a=xm(e,t);if(mr.has(a))return mr.get(a);let o=oo({themes:t,langs:[e]});return mr.set(a,o),o};function Im(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return ol.has(o)},getSupportedLanguages(){return Array.from(ol)},getThemes(){return a},highlight({code:o,language:r,themes:s},n){let i=Lm(o,r,s);return hr.has(i)?hr.get(i):(n&&(kt.has(i)||kt.set(i,new Set),kt.get(i).add(n)),Cm(r,s).then(l=>{let u=l.getLoadedLanguages().includes(r)?r:"text",c=l.codeToTokens(o,{lang:u,themes:{light:s[0],dark:s[1]}});hr.set(i,c);let d=kt.get(i);if(d){for(let p of d)p(c);kt.delete(i)}}).catch(l=>{console.error("[Streamdown Code] Failed to highlight code:",l),kt.delete(i)}),null)}}}var rl=Im();import{memo as km}from"react";f();f();import{useEffect as Sm,useRef as ro,useState as ym}from"react";var bm=5,sl=400;function nl(e,t,a={}){let{msPerChar:o=bm}=a,[r,s]=ym(t?"":e),n=ro(e),i=ro(t?0:e.length),l=ro(0),u=ro(null);return(e.length<i.current||!e.startsWith(r.slice(0,i.current)))&&(i.current=t?0:e.length),n.current=e,Sm(()=>{if(!t){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),i.current=e.length,s(e);return}if(n.current.length-i.current>sl&&(i.current=n.current.length-sl),u.current!==null)return;let d=p=>{let m=n.current;if(i.current>=m.length){u.current=null;return}l.current===0&&(l.current=p);let h=p-l.current;if(h>=o){let I=Math.min(Math.floor(h/o),m.length-i.current);i.current+=I,s(m.slice(0,i.current)),l.current=p}u.current=requestAnimationFrame(d)};return u.current=requestAnimationFrame(d),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,o]),r}import{jsx as so}from"react/jsx-runtime";var gr=({className:e,from:t,children:a,...o})=>so("div",{className:D("ww:group ww:flex ww:w-full",t==="user"?"is-user ww:ml-auto ww:max-w-[80%] ww:flex-col ww:items-end":"is-assistant ww:flex-col",e),...o,children:so("div",{className:D("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),wr=({children:e,className:t,...a})=>so("div",{className:D("ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden ww:text-base","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:rounded-lg ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:px-4 ww:group-[.is-user]:py-3 ww:group-[.is-user]:text-primary-foreground","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),Tm={cjk:Uo,code:rl},vm={cjk:Uo},Pm={enabled:!1};function Am({className:e,linkSafety:t,isStreaming:a,children:o,...r}){let n=nl(typeof o=="string"?o:"",!!a),i=typeof o=="string"?n:o;return so(At,{className:D("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??Pm,plugins:a?vm:Tm,...r,children:i})}var no=km(Am,(e,t)=>e.children===t.children&&e.isStreaming===t.isStreaming);no.displayName="MessageResponse";f();import{createContext as Rm,memo as Cr,useCallback as Mm,useContext as Fm,useEffect as xr,useMemo as Dm,useRef as il,useState as Lr}from"react";import{Fragment as _m,jsx as _e,jsxs as Nm}from"react/jsx-runtime";var ll=Rm(null);function ul(){let e=Fm(ll);if(!e)throw new Error("Reasoning components must be used within <Reasoning>");return e}var Bm=1e3,Em=1e3,Ir=Cr(({className:e,isStreaming:t=!1,open:a,defaultOpen:o,onOpenChange:r,duration:s,children:n,...i})=>{let l=o??t,u=o===!1,c=a!==void 0,[d,p]=Lr(l),m=c?a:d,h=Mm(v=>{c||p(v),r?.(v)},[c,r]),[I,L]=Lr(void 0),S=s??I,C=il(t),[g,b]=Lr(!1),P=il(null);xr(()=>{t?(C.current=!0,P.current===null&&(P.current=Date.now())):P.current!==null&&(L(Math.ceil((Date.now()-P.current)/Em)),P.current=null)},[t]),xr(()=>{t&&!m&&!u&&h(!0)},[t,m,u,h]),xr(()=>{if(C.current&&!t&&m&&!g){let v=setTimeout(()=>{h(!1),b(!0)},Bm);return()=>clearTimeout(v)}},[t,m,g,h]);let A=Dm(()=>({isStreaming:t,isOpen:m,setIsOpen:h,duration:S}),[t,m,h,S]);return _e(ll.Provider,{value:A,children:_e("div",{className:D("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":m?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...i,children:n})})});Ir.displayName="Reasoning";var Sr=Cr(({className:e,children:t,getThinkingMessage:a,onClick:o,...r})=>{let{t:s}=z(),{isStreaming:n,isOpen:i,duration:l,setIsOpen:u}=ul(),d=a??((p,m)=>p||m===0?_e(Xe,{duration:1.6,children:s.reasoning.thinking}):m===void 0?_e("span",{children:s.reasoning.thoughtBrief}):_e("span",{children:s.reasoning.thoughtForSeconds(m)}));return _e("button",{type:"button","aria-expanded":i,onClick:p=>{u(!i),o?.(p)},className:D("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),...r,children:t??Nm(_m,{children:[_e(Ht,{className:"ww:size-4 ww:shrink-0"}),d(n,l)]})})});Sr.displayName="ReasoningTrigger";var yr=Cr(({className:e,children:t,...a})=>{let{isOpen:o}=ul();return _e("div",{className:D("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:_e("div",{className:"ww:min-h-0 ww:overflow-hidden",children:_e("div",{className:D("ww:text-sm ww:text-muted-foreground",e),...a,children:_e(At,{children:t})})})})});yr.displayName="ReasoningContent";f();import{createContext as Om,useCallback as Um,useContext as mT,useEffect as Hm,useMemo as kr,useRef as qm,useState as pl}from"react";import{Fragment as fl,jsx as Ie,jsxs as Tt}from"react/jsx-runtime";function Wm(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let o=Object.entries(e),r=[],s=t-2;for(let[n,i]of o){if(s<=8)break;let l=n.length>4?`${n.slice(0,4)}\u2026`:n,u;typeof i=="string"?u=i.length>2?`'${i.slice(0,1)}\u2026`:`'${i}'`:Array.isArray(i)?u=`Array(${i.length})`:typeof i=="object"&&i!==null?u="{\u2026}":u=String(i);let c=`${l}\u2009${u}`;r.push(c),s-=c.length+3}return`{${r.join(", ")}}`}function Gm({text:e,className:t}){let{t:a}=z(),[o,r]=pl(!1),s=qm(null);Hm(()=>()=>{s.current&&clearTimeout(s.current)},[]);let n=Um(async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>r(!1),2e3)}catch{}},[e]);return Ie(He,{variant:"ghost",size:"sm",onClick:n,className:D("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:o?Tt(fl,{children:[Ie(qt,{className:"ww:size-3.5"}),Ie("span",{children:a.tool.copied})]}):Tt(fl,{children:[Ie(Gt,{className:"ww:size-3.5"}),Ie("span",{children:a.tool.copy})]})})}function ml({data:e,label:t,className:a,...o}){let[r,s]=pl(!1),n=kr(()=>JSON.stringify(e,null,2),[e]),i=Wm(e);return Tt("div",{className:D("ww:rounded-lg ww:bg-tool-card",a),...o,children:[Tt("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[Ie("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),Ie(Gm,{text:n})]}),Tt("button",{type:"button",onClick:()=>s(l=>!l),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[Ie(Wt,{className:D("ww:mt-0.5 ww:size-3.5 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-150",r&&"ww:rotate-90")}),r?Ie("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:Ie("code",{children:n})}):Ie("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:i})]})]})}var LT=Om({open:!1,toggle:()=>{}});function hl({className:e,input:t,debug:a,...o}){let{t:r}=z(),s=kr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:n,...i}=t;return i}return t},[t,a]);return Ie(ml,{data:s,label:r.tool.request,className:e,...o})}function br(e){if(!(typeof e!="object"||e===null))return e}function gl(e){return br(e?.ui)}function wl(e){return br(br(e)?._meta)}function dl(e){if(!e)return;let t=gl(e)?.resourceUri;if(typeof t=="string"&&t.length>0)return t;let a=e["ui/resourceUri"];if(typeof a=="string"&&a.length>0)return a;let o=e["openai/outputTemplate"];if(typeof o=="string"&&o.length>0)return o}function cl(e){return gl(e)?.autoHeight===!0}function fa(e,t,a){if(e){let o=dl(a?.[e]?._meta);if(o)return o}return dl(wl(t))}function xl(e,t,a){return e&&cl(a?.[e]?._meta)?!0:cl(wl(t))}function Ll({className:e,output:t,errorText:a,debug:o,...r}){let{t:s}=z(),n=kr(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:i,...l}=t;return l}return t},[t,o]);return t||a?a?Tt("div",{className:D("ww:space-y-2",e),...r,children:[Ie("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:s.tool.error}),Ie("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):Ie(ml,{data:n,label:s.tool.response,className:e,...r}):null}f();import{jsx as Cl,jsxs as jm}from"react/jsx-runtime";function Il(e){return e.type==="text"||e.type==="reasoning"||e.type==="file"||"toolCallId"in e}function Sl(e){return e.parts.some(Il)}function yl(e,t,a){if(t!=="submitted"&&t!=="streaming")return!1;let o=e[e.length-1];return!o||o.role!=="assistant"?!0:!o.parts.some(s=>!(!Il(s)||a?.ignoreToolParts&&"toolCallId"in s||a?.ignoreReasoningParts&&s.type==="reasoning"))}function bl({className:e,...t}){let{t:a}=z();return jm("div",{"aria-live":"polite",className:D("ww:mb-4 ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...t,children:[Cl(Xt,{className:"ww:size-4 ww:shrink-0"}),Cl(Xe,{duration:1.6,children:a.workingIndicator.default})]})}f();import{useCallback as zm,useEffect as kl,useMemo as Vm,useRef as Se,useState as Tl}from"react";import{jsx as oh}from"react/jsx-runtime";var $m="/api/mcp/resource",Xm=500,Km=0,Qm=16,Jm="2026-01-26",Zm=300,Ym=3e3,eh=3;function th(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function ah(e,t,a){return fa(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function vl({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=$m,chatSessionId:r,isDark:s=!1,className:n,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:c,onDisplayModeChange:d,isFullscreen:p=!1,toolDefinitions:m}){let h=Se(null),I=Se(t),L=Se(a),S=Se({width:0,height:0}),C=Se(null),g=Se(!1),b=Se(0),P=Se("inline"),[A,v]=Tl(Km),[R,_]=Tl(void 0),M=Se(l),T=Se(u),y=Se(c),B=Se(d),U=Se(r),F=Se(m);I.current=t,L.current=a,M.current=l,T.current=u,y.current=c,B.current=d,U.current=r,F.current=m;let Q=zm(te=>i?Math.max(te+Qm,0):Math.min(Math.max(te,50),Xm),[i]),Ne=Vm(()=>{let te=o.includes("?")?"&":"?";return`${o}${te}uri=${encodeURIComponent(e)}`},[o,e]),ye=Se(s);return ye.current=s,kl(()=>{if(!g.current)return;let te=h.current;te?.contentWindow&&te.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:s?"dark":"light"}},"*")},[s]),kl(()=>{let te=h.current;if(!te)return;let we=!1,ve=!1,Ce=null,be=null,Qe=setTimeout(()=>{if(we||ve||b.current>=eh)return;b.current+=1;let ee=new URL(te.src);ee.searchParams.set("_retry",String(b.current)),te.src=ee.toString()},Ym),O=ee=>{te.contentWindow?.postMessage(ee,"*")},ue=ee=>{if(we||ee.source!==te.contentWindow)return;let X=ee.data;if(!X||typeof X!="object"||X.jsonrpc!=="2.0")return;let ae=X.method,q=X.id;if(ae==="ui/initialize"&&q!=null){ve=!0,clearTimeout(Qe),O({jsonrpc:"2.0",id:q,result:{protocolVersion:X.params?.protocolVersion??Jm,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:ye.current?"dark":"light",displayMode:P.current}}});return}if(ae==="ui/notifications/initialized"){g.current=!0;let j=I.current,V=L.current,J=V._meta&&typeof V._meta=="object"?V._meta:null,K=th(U.current),se=J&&typeof J.waniwani=="object"&&J.waniwani!==null?J.waniwani:null,ke=se||K?{...se??{},...K?{sessionId:K}:{}}:void 0,Me=J||ke?{...J??{},...ke?{waniwani:ke}:{}}:void 0;O({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:j}});let mt=V.content??[{type:"text",text:JSON.stringify(V)}];O({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:mt,structuredContent:V.structuredContent,_meta:Me,meta:Me}});return}if(ae==="ui/notifications/size-changed"){let j=X.params,V=typeof j?.height=="number"?j.height:void 0,J=typeof j?.width=="number"?j.width:void 0,K=S.current,se=V!==void 0&&V!==K.height,ke=J!==void 0&&J!==K.width;if(!se&&!ke)return;if(se&&V!==void 0){K.height=V;let Me=Q(V),mt=te.getBoundingClientRect().height;if(C.current&&(C.current.cancel(),C.current=null),v(Me),te.animate&&Math.abs(mt-Me)>2){let ht=te.animate([{height:`${mt}px`},{height:`${Me}px`}],{duration:Zm,easing:"ease-out",fill:"forwards"});C.current=ht,ht.onfinish=()=>{C.current===ht&&(ht.cancel(),C.current=null)}}}ke&&i&&J!==void 0&&(K.width=J,_(J));return}if(ae==="ui/open-link"&&q!=null){let j=X.params?.url;typeof j=="string"&&(M.current?M.current(j):window.open(j,"_blank","noopener,noreferrer")),O({jsonrpc:"2.0",id:q,result:{}});return}if(ae==="ui/message"&&q!=null){if(T.current&&X.params){let j=X.params,V=Ce;if(Ce=null,be){clearTimeout(be.timer);let J=be.text;be=null;let K=(j.content??[]).map(se=>se.text??"").join("").trim();j={...j,content:[{type:"text",text:`${K}
78
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Hi(e,t,a,o){let r=o.schema,n=r.space==="svg"?!1:o.settings.omitOptionalTags,s=r.space==="svg"?o.settings.closeEmptyElements:o.settings.voids.includes(e.tagName.toLowerCase()),i=[],l;r.space==="html"&&e.tagName==="svg"&&(o.schema=Sa);let u=xp(o,e.properties),c=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,c&&(s=!1),(u||!n||!Ui(e,t,a))&&(i.push("<",e.tagName,u?" "+u:""),s&&(r.space==="svg"||o.settings.closeSelfClosing)&&(l=u.charAt(u.length-1),(!o.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(c),!s&&(!n||!ca(e,t,a))&&i.push("</"+e.tagName+">"),i.join("")}function xp(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let n=Lp(e,r,t[r]);n&&a.push(n)}}for(;++o<a.length;){let n=e.settings.tightAttributes?a[o].charAt(a[o].length-1):void 0;o!==a.length-1&&n!=='"'&&n!=="'"&&(a[o]+=" ")}return a.join("")}function Lp(e,t,a){let o=Jr(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,n=e.settings.allowDangerousCharacters?0:1,s=e.quote,i;if(o.overloadedBoolean&&(a===o.attribute||a==="")?a=!0:(o.boolean||o.overloadedBoolean)&&(typeof a!="string"||a===o.attribute||a==="")&&(a=!!a),a==null||a===!1||typeof a=="number"&&Number.isNaN(a))return"";let l=Ke(o.attribute,Object.assign({},e.settings.characterReferences,{subset:Ka.name[r][n]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?Yr:en)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a)?l:(e.settings.preferUnquoted&&(i=Ke(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Ka.unquoted[r][n]}))),i!==a&&(e.settings.quoteSmart&&So(a,s)>So(a,e.alternative)&&(s=e.alternative),i=s+Ke(a,Object.assign({},e.settings.characterReferences,{subset:(s==="'"?Ka.single:Ka.double)[r][n],attribute:!0}))+s),l+(i&&"="+i))}f();f();var Cp=["<","&"];function Qa(e,t,a,o){return a&&a.type==="element"&&(a.tagName==="script"||a.tagName==="style")?e.value:Ke(e.value,Object.assign({},o.settings.characterReferences,{subset:Cp}))}function qi(e,t,a,o){return o.settings.allowDangerousHtml?e.value:Qa(e,t,a,o)}f();function Wi(e,t,a,o){return o.all(e)}var Gi=tn("type",{invalid:Ip,unknown:Sp,handlers:{comment:Bi,doctype:Ei,element:Hi,raw:qi,root:Wi,text:Qa}});function Ip(e){throw new Error("Expected node, not `"+e+"`")}function Sp(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var yp={},bp={},kp=[];function sr(e,t){let a=t||yp,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:Tp,all:vp,settings:{omitOptionalTags:a.omitOptionalTags||!1,allowParseErrors:a.allowParseErrors||!1,allowDangerousCharacters:a.allowDangerousCharacters||!1,quoteSmart:a.quoteSmart||!1,preferUnquoted:a.preferUnquoted||!1,tightAttributes:a.tightAttributes||!1,upperDoctype:a.upperDoctype||!1,tightDoctype:a.tightDoctype||!1,bogusComments:a.bogusComments||!1,tightCommaSeparatedLists:a.tightCommaSeparatedLists||!1,tightSelfClosing:a.tightSelfClosing||!1,collapseEmptyAttributes:a.collapseEmptyAttributes||!1,allowDangerousHtml:a.allowDangerousHtml||!1,voids:a.voids||an,characterReferences:a.characterReferences||bp,closeSelfClosing:a.closeSelfClosing||!1,closeEmptyElements:a.closeEmptyElements||!1},schema:a.space==="svg"?Sa:Zr,quote:o,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function Tp(e,t,a){return Gi(e,t,a,this)}function vp(e){let t=[],a=e&&e.children||kp,o=-1;for(;++o<a.length;)t[o]=this.one(a[o],o,e);return t.join("")}function Ja(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},o=typeof e=="string"?e:e.name;for(let[r,n]of Object.entries(t?.colorReplacements||{}))typeof n=="string"?a[r]=n:r===o&&Object.assign(a,n);return a}function at(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Pp(e){return Array.isArray(e)?e:[e]}async function Qi(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function fr(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Ji(e){return e==="ansi"||fr(e)}function pr(e){return e==="none"}function Zi(e){return pr(e)}function Yi(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);let a=Array.isArray(t)?t:t.split(/\s+/g);for(let o of a)o&&!e.properties.class.includes(o)&&e.properties.class.push(o);return e}function ao(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(/(\r?\n)/g),o=0,r=[];for(let n=0;n<a.length;n+=2){let s=t?a[n]+(a[n+1]||""):a[n];r.push([s,o]),o+=a[n].length,o+=a[n+1]?.length||0}return r}function Ap(e){let t=ao(e,!0).map(([r])=>r);function a(r){if(r===e.length)return{line:t.length-1,character:t[t.length-1].length};let n=r,s=0;for(let i of t){if(n<i.length)break;n-=i.length,s++}return{line:s,character:n}}function o(r,n){let s=0;for(let i=0;i<r;i++)s+=t[i].length;return s+=n,s}return{lines:t,indexToPos:a,posToIndex:o}}function el(e,t,a){let o=new Set;for(let n of e.matchAll(/:?lang=["']([^"']+)["']/g)){let s=n[1].toLowerCase().trim();s&&o.add(s)}for(let n of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let s=n[1].toLowerCase().trim();s&&o.add(s)}for(let n of e.matchAll(/\\begin\{([\w-]+)\}/g)){let s=n[1].toLowerCase().trim();s&&o.add(s)}for(let n of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let s=n[1].toLowerCase().trim(),i=s.includes("/")?s.split("/").pop():s;i&&o.add(i)}if(!a)return Array.from(o);let r=a.getBundledLanguages();return Array.from(o).filter(n=>n&&r[n])}var mr="light-dark()",Rp=["color","background-color"];function Mp(e,t){let a=0,o=[];for(let r of t)r>a&&o.push({...e,content:e.content.slice(a,r),offset:e.offset+a}),a=r;return a<e.content.length&&o.push({...e,content:e.content.slice(a),offset:e.offset+a}),o}function Fp(e,t){let a=Array.from(t instanceof Set?t:new Set(t)).sort((o,r)=>o-r);return a.length?e.map(o=>o.flatMap(r=>{let n=a.filter(s=>r.offset<s&&s<r.offset+r.content.length).map(s=>s-r.offset).sort((s,i)=>s-i);return n.length?Mp(r,n):r})):e}function Dp(e,t,a,o,r="css-vars"){let n={content:e.content,explanation:e.explanation,offset:e.offset},s=t.map(c=>Za(e.variants[c])),i=new Set(s.flatMap(c=>Object.keys(c))),l={},u=(c,d)=>{let p=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return a+t[c]+(d==="color"?"":p)};return s.forEach((c,d)=>{for(let p of i){let m=c[p]||"inherit";if(d===0&&o&&Rp.includes(p))if(o===mr&&s.length>1){let h=t.findIndex(C=>C==="light"),I=t.findIndex(C=>C==="dark");if(h===-1||I===-1)throw new ae('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let L=s[h][p]||"inherit",S=s[I][p]||"inherit";l[p]=`light-dark(${L}, ${S})`,r==="css-vars"&&(l[u(d,p)]=m)}else l[p]=m;else r==="css-vars"&&(l[u(d,p)]=m)}}),n.htmlStyle=l,n}function Za(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&ge.Italic&&(t["font-style"]="italic"),e.fontStyle&ge.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&ge.Underline&&a.push("underline"),e.fontStyle&ge.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function ur(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var tl=new WeakMap;function oo(e,t){tl.set(e,t)}function pa(e){return tl.get(e)}var Pt=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,a){return new e(Object.fromEntries(Pp(a).map(o=>[o,za])),t)}constructor(...t){if(t.length===2){let[a,o]=t;this.lang=o,this._stacks=a}else{let[a,o,r]=t;this.lang=o,this._stacks={[r]:a}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return Bp(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Bp(e){let t=[],a=new Set;function o(r){if(a.has(r))return;a.add(r);let n=r?.nameScopesList?.scopeName;n&&t.push(n),r.parent&&o(r.parent)}return o(e),t}function Ep(e,t){if(!(e instanceof Pt))throw new ae("Invalid grammar state");return e.getInternalStack(t)}function _p(){let e=new WeakMap;function t(a){if(!e.has(a.meta)){let o=function(s){if(typeof s=="number"){if(s<0||s>a.source.length)throw new ae(`Invalid decoration offset: ${s}. Code length: ${a.source.length}`);return{...r.indexToPos(s),offset:s}}else{let i=r.lines[s.line];if(i===void 0)throw new ae(`Invalid decoration position ${JSON.stringify(s)}. Lines length: ${r.lines.length}`);let l=s.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new ae(`Invalid decoration position ${JSON.stringify(s)}. Line ${s.line} length: ${i.length}`);return{...s,character:l,offset:r.posToIndex(s.line,l)}}},r=Ap(a.source),n=(a.options.decorations||[]).map(s=>({...s,start:o(s.start),end:o(s.end)}));Np(n),e.set(a.meta,{decorations:n,converter:r,source:a.source})}return e.get(a.meta)}return{name:"shiki:decorations",tokens(a){if(!this.options.decorations?.length)return;let r=t(this).decorations.flatMap(s=>[s.start.offset,s.end.offset]);return Fp(a,r)},code(a){if(!this.options.decorations?.length)return;let o=t(this),r=Array.from(a.children).filter(c=>c.type==="element"&&c.tagName==="span");if(r.length!==o.converter.lines.length)throw new ae(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${o.converter.lines.length}). Failed to apply decorations.`);function n(c,d,p,m){let h=r[c],I="",L=-1,S=-1;if(d===0&&(L=0),p===0&&(S=0),p===Number.POSITIVE_INFINITY&&(S=h.children.length),L===-1||S===-1)for(let g=0;g<h.children.length;g++)I+=al(h.children[g]),L===-1&&I.length===d&&(L=g+1),S===-1&&I.length===p&&(S=g+1);if(L===-1)throw new ae(`Failed to find start index for decoration ${JSON.stringify(m.start)}`);if(S===-1)throw new ae(`Failed to find end index for decoration ${JSON.stringify(m.end)}`);let C=h.children.slice(L,S);if(!m.alwaysWrap&&C.length===h.children.length)i(h,m,"line");else if(!m.alwaysWrap&&C.length===1&&C[0].type==="element")i(C[0],m,"token");else{let g={type:"element",tagName:"span",properties:{},children:C};i(g,m,"wrapper"),h.children.splice(L,C.length,g)}}function s(c,d){r[c]=i(r[c],d,"line")}function i(c,d,p){let m=d.properties||{},h=d.transform||(I=>I);return c.tagName=d.tagName||"span",c.properties={...c.properties,...m,class:c.properties.class},d.properties?.class&&Yi(c,d.properties.class),c=h(c,p)||c,c}let l=[],u=o.decorations.sort((c,d)=>d.start.offset-c.start.offset||c.end.offset-d.end.offset);for(let c of u){let{start:d,end:p}=c;if(d.line===p.line)n(d.line,d.character,p.character,c);else if(d.line<p.line){n(d.line,d.character,Number.POSITIVE_INFINITY,c);for(let m=d.line+1;m<p.line;m++)l.unshift(()=>s(m,c));n(p.line,0,p.character,c)}}l.forEach(c=>c())}}}function Np(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new ae(`Invalid decoration range: ${JSON.stringify(a.start)} - ${JSON.stringify(a.end)}`);for(let o=t+1;o<e.length;o++){let r=e[o],n=a.start.offset<=r.start.offset&&r.start.offset<a.end.offset,s=a.start.offset<r.end.offset&&r.end.offset<=a.end.offset,i=r.start.offset<=a.start.offset&&a.start.offset<r.end.offset,l=r.start.offset<a.end.offset&&a.end.offset<=r.end.offset;if(n||s||i||l){if(n&&s||i&&l||i&&a.start.offset===a.end.offset||s&&r.start.offset===r.end.offset)continue;throw new ae(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function al(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(al).join(""):""}var Op=[_p()];function Ya(e){let t=Up(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Op]}function Up(e){let t=[],a=[],o=[];for(let r of e)switch(r.enforce){case"pre":t.push(r);break;case"post":a.push(r);break;default:o.push(r)}return{pre:t,post:a,normal:o}}var mt=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],ir={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Hp(e,t){let a=e.indexOf("\x1B",t);if(a!==-1&&e[a+1]==="["){let o=e.indexOf("m",a);if(o!==-1)return{sequence:e.substring(a+2,o).split(";"),startPosition:a,position:o+1}}return{position:e.length}}function ji(e){let t=e.shift();if(t==="2"){let a=e.splice(0,3).map(o=>Number.parseInt(o));return a.length!==3||a.some(o=>Number.isNaN(o))?void 0:{type:"rgb",rgb:a}}else if(t==="5"){let a=e.shift();if(a)return{type:"table",index:Number(a)}}}function qp(e){let t=[];for(;e.length>0;){let a=e.shift();if(!a)continue;let o=Number.parseInt(a);if(!Number.isNaN(o))if(o===0)t.push({type:"resetAll"});else if(o<=9)ir[o]&&t.push({type:"setDecoration",value:ir[o]});else if(o<=29){let r=ir[o-20];r&&(t.push({type:"resetDecoration",value:r}),r==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(o<=37)t.push({type:"setForegroundColor",value:{type:"named",name:mt[o-30]}});else if(o===38){let r=ji(e);r&&t.push({type:"setForegroundColor",value:r})}else if(o===39)t.push({type:"resetForegroundColor"});else if(o<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:mt[o-40]}});else if(o===48){let r=ji(e);r&&t.push({type:"setBackgroundColor",value:r})}else o===49?t.push({type:"resetBackgroundColor"}):o===53?t.push({type:"setDecoration",value:"overline"}):o===55?t.push({type:"resetDecoration",value:"overline"}):o>=90&&o<=97?t.push({type:"setForegroundColor",value:{type:"named",name:mt[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:mt[o-100+8]}})}return t}function Wp(){let e=null,t=null,a=new Set;return{parse(o){let r=[],n=0;do{let s=Hp(o,n),i=s.sequence?o.substring(n,s.startPosition):o.substring(n);if(i.length>0&&r.push({value:i,foreground:e,background:t,decorations:new Set(a)}),s.sequence){let l=qp(s.sequence);for(let u of l)u.type==="resetAll"?(e=null,t=null,a.clear()):u.type==="resetForegroundColor"?e=null:u.type==="resetBackgroundColor"?t=null:u.type==="resetDecoration"&&a.delete(u.value);for(let u of l)u.type==="setForegroundColor"?e=u.value:u.type==="setBackgroundColor"?t=u.value:u.type==="setDecoration"&&a.add(u.value)}n=s.position}while(n<o.length);return r}}}var Gp={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function jp(e=Gp){function t(i){return e[i]}function a(i){return`#${i.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let o;function r(){if(o)return o;o=[];for(let u=0;u<mt.length;u++)o.push(t(mt[u]));let i=[0,95,135,175,215,255];for(let u=0;u<6;u++)for(let c=0;c<6;c++)for(let d=0;d<6;d++)o.push(a([i[u],i[c],i[d]]));let l=8;for(let u=0;u<24;u++,l+=10)o.push(a([l,l,l]));return o}function n(i){return r()[i]}function s(i){switch(i.type){case"named":return t(i.name);case"rgb":return a(i.rgb);case"table":return n(i.index)}}return{value:s}}var zp={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function Vp(e,t,a){let o=Ja(e,a),r=ao(t),n=Object.fromEntries(mt.map(l=>{let u=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,c=e.colors?.[u];return[l,c||zp[l]]})),s=jp(n),i=Wp();return r.map(l=>i.parse(l[0]).map(u=>{let c,d;u.decorations.has("reverse")?(c=u.background?s.value(u.background):e.bg,d=u.foreground?s.value(u.foreground):e.fg):(c=u.foreground?s.value(u.foreground):e.fg,d=u.background?s.value(u.background):void 0),c=at(c,o),d=at(d,o),u.decorations.has("dim")&&(c=$p(c));let p=ge.None;return u.decorations.has("bold")&&(p|=ge.Bold),u.decorations.has("italic")&&(p|=ge.Italic),u.decorations.has("underline")&&(p|=ge.Underline),u.decorations.has("strikethrough")&&(p|=ge.Strikethrough),{content:u.value,offset:l[1],color:c,bgColor:d,fontStyle:p}}))}function $p(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let o=t[1];if(o.length===8){let r=Math.round(Number.parseInt(o.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${o.slice(0,6)}${r}`}else{if(o.length===6)return`#${o}80`;if(o.length===4){let r=o[0],n=o[1],s=o[2],i=o[3],l=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${n}${n}${s}${s}${l}`}else if(o.length===3){let r=o[0],n=o[1],s=o[2];return`#${r}${r}${n}${n}${s}${s}80`}}}let a=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return a?`var(${a[1]}-dim)`:e}function hr(e,t,a={}){let{theme:o=e.getLoadedThemes()[0]}=a,r=e.resolveLangAlias(a.lang||"text");if(fr(r)||pr(o))return ao(t).map(l=>[{content:l[0],offset:l[1]}]);let{theme:n,colorMap:s}=e.setTheme(o);if(r==="ansi")return Vp(n,t,a);let i=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==i.name)throw new ae(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${i.name}"`);if(!a.grammarState.themes.includes(n.name))throw new ae(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${n.name}"`)}return Kp(t,i,n,s,a)}function Xp(...e){if(e.length===2)return pa(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:n=t.getLoadedThemes()[0]}=o;if(fr(r)||pr(n))throw new ae("Plain language does not have grammar state");if(r==="ansi")throw new ae("ANSI language does not have grammar state");let{theme:s,colorMap:i}=t.setTheme(n),l=t.getLanguage(r);return new Pt(gr(a,l,s,i,o).stateStack,l.name,s.name)}function Kp(e,t,a,o,r){let n=gr(e,t,a,o,r),s=new Pt(n.stateStack,t.name,a.name);return oo(n.tokens,s),n.tokens}function gr(e,t,a,o,r){let n=Ja(a,r),{tokenizeMaxLineLength:s=0,tokenizeTimeLimit:i=500}=r,l=ao(e),u=r.grammarState?Ep(r.grammarState,a.name)??za:r.grammarContextCode!=null?gr(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:za,c=[],d=[];for(let p=0,m=l.length;p<m;p++){let[h,I]=l[p];if(h===""){c=[],d.push([]);continue}if(s>0&&h.length>=s){c=[],d.push([{content:h,offset:I,color:"",fontStyle:0}]);continue}let L,S,C;r.includeExplanation&&(L=t.tokenizeLine(h,u,i),S=L.tokens,C=0);let g=t.tokenizeLine2(h,u,i),y=g.tokens.length/2;for(let A=0;A<y;A++){let R=g.tokens[2*A],P=A+1<y?g.tokens[2*A+2]:h.length;if(R===P)continue;let M=g.tokens[2*A+1],N=at(o[pt.getForeground(M)],n),D=pt.getFontStyle(M),_={content:h.substring(R,P),offset:I+R,color:N,fontStyle:D};if(r.includeExplanation){let T=[];if(r.includeExplanation!=="scopeName")for(let k of a.settings){let v;switch(typeof k.scope){case"string":v=k.scope.split(/,/).map(q=>q.trim());break;case"object":v=k.scope;break;default:continue}T.push({settings:k,selectors:v.map(q=>q.split(/ /))})}_.explanation=[];let B=0;for(;R+B<P;){let k=S[C],v=h.substring(k.startIndex,k.endIndex);B+=v.length,_.explanation.push({content:v,scopes:r.includeExplanation==="scopeName"?Qp(k.scopes):Jp(T,k.scopes)}),C+=1}}c.push(_)}d.push(c),c=[],u=g.ruleStack}return{tokens:d,stateStack:u}}function Qp(e){return e.map(t=>({scopeName:t}))}function Jp(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let n=t[o];a[o]={scopeName:n,themeMatches:Yp(e,n,t.slice(0,o))}}return a}function zi(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Zp(e,t,a){if(!zi(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)zi(e[o],a[r])&&(o-=1),r-=1;return o===-1}function Yp(e,t,a){let o=[];for(let{selectors:r,settings:n}of e)for(let s of r)if(Zp(s,t,a)){o.push(n);break}return o}function ol(e,t,a){let o=Object.entries(a.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),r=o.map(l=>{let u=hr(e,t,{...a,theme:l.theme}),c=pa(u),d=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:u,state:c,theme:d}}),n=em(...r.map(l=>l.tokens)),s=n[0].map((l,u)=>l.map((c,d)=>{let p={content:c.content,variants:{},offset:c.offset};return"includeExplanation"in a&&a.includeExplanation&&(p.explanation=c.explanation),n.forEach((m,h)=>{let{content:I,explanation:L,offset:S,...C}=m[u][d];p.variants[o[h].color]=C}),p})),i=r[0].state?new Pt(Object.fromEntries(r.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),r[0].state.lang):void 0;return i&&oo(s,i),s}function em(...e){let t=e.map(()=>[]),a=e.length;for(let o=0;o<e[0].length;o++){let r=e.map(l=>l[o]),n=t.map(()=>[]);t.forEach((l,u)=>l.push(n[u]));let s=r.map(()=>0),i=r.map(l=>l[0]);for(;i.every(l=>l);){let l=Math.min(...i.map(u=>u.content.length));for(let u=0;u<a;u++){let c=i[u];c.content.length===l?(n[u].push(c),s[u]+=1,i[u]=r[u][s[u]]):(n[u].push({...c,content:c.content.slice(0,l)}),i[u]={...c,content:c.content.slice(l),offset:c.offset+l})}}}return t}function eo(e,t,a){let o,r,n,s,i,l;if("themes"in a){let{defaultColor:u="light",cssVariablePrefix:c="--shiki-",colorsRendering:d="css-vars"}=a,p=Object.entries(a.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,C)=>S.color===u?-1:C.color===u?1:0);if(p.length===0)throw new ae("`themes` option must not be empty");let m=ol(e,t,a);if(l=pa(m),u&&mr!==u&&!p.find(S=>S.color===u))throw new ae(`\`themes\` option must contain the defaultColor key \`${u}\``);let h=p.map(S=>e.getTheme(S.theme)),I=p.map(S=>S.color);n=m.map(S=>S.map(C=>Dp(C,I,c,u,d))),l&&oo(n,l);let L=p.map(S=>Ja(S.theme,a));r=Vi(p,h,L,c,u,"fg",d),o=Vi(p,h,L,c,u,"bg",d),s=`shiki-themes ${h.map(S=>S.name).join(" ")}`,i=u?void 0:[r,o].join(";")}else if("theme"in a){let u=Ja(a.theme,a);n=hr(e,t,a);let c=e.getTheme(a.theme);o=at(c.bg,u),r=at(c.fg,u),s=c.name,l=pa(n)}else throw new ae("Invalid options, either `theme` or `themes` must be provided");return{tokens:n,fg:r,bg:o,themeName:s,rootStyle:i,grammarState:l}}function Vi(e,t,a,o,r,n,s){return e.map((i,l)=>{let u=at(t[l][n],a[l])||"inherit",c=`${o+i.color}${n==="bg"?"-bg":""}:${u}`;if(l===0&&r){if(r===mr&&e.length>1){let d=e.findIndex(I=>I.color==="light"),p=e.findIndex(I=>I.color==="dark");if(d===-1||p===-1)throw new ae('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let m=at(t[d][n],a[d])||"inherit",h=at(t[p][n],a[p])||"inherit";return`light-dark(${m}, ${h});${c}`}return u}return s==="css-vars"?c:null}).filter(i=>!!i).join(";")}function to(e,t,a,o={meta:{},options:a,codeToHast:(r,n)=>to(e,r,n),codeToTokens:(r,n)=>eo(e,r,n)}){let r=t;for(let h of Ya(a))r=h.preprocess?.call(o,r,a)||r;let{tokens:n,fg:s,bg:i,themeName:l,rootStyle:u,grammarState:c}=eo(e,r,a),{mergeWhitespaces:d=!0,mergeSameStyleTokens:p=!1}=a;d===!0?n=am(n):d==="never"&&(n=om(n)),p&&(n=rm(n));let m={...o,get source(){return r}};for(let h of Ya(a))n=h.tokens?.call(m,n)||n;return tm(n,{...a,fg:s,bg:i,themeName:l,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},m,c)}function tm(e,t,a,o=pa(e)){let r=Ya(t),n=[],s={type:"root",children:[]},{structure:i="classic",tabindex:l="0"}=t,u={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?u.style=t.rootStyle:u.style=`background-color:${t.bg};color:${t.fg}`),l!==!1&&l!=null&&(u.tabindex=l.toString());for(let[I,L]of Object.entries(t.meta||{}))I.startsWith("_")||(u[I]=L);let c={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:n},p=[],m={...a,structure:i,addClassToHast:Yi,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return s},get pre(){return c},get code(){return d},get lines(){return p}};if(e.forEach((I,L)=>{L&&(i==="inline"?s.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&n.push({type:"text",value:`
79
+ `}));let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},C=0;for(let g of I){let y={type:"element",tagName:"span",properties:{...g.htmlAttrs},children:[{type:"text",value:g.content}]},A=ur(g.htmlStyle||Za(g));A&&(y.properties.style=A);for(let R of r)y=R?.span?.call(m,y,L+1,C,S,g)||y;i==="inline"?s.children.push(y):i==="classic"&&S.children.push(y),C+=g.content.length}if(i==="classic"){for(let g of r)S=g?.line?.call(m,S,L+1)||S;p.push(S),n.push(S)}else i==="inline"&&p.push(S)}),i==="classic"){for(let I of r)d=I?.code?.call(m,d)||d;c.children.push(d);for(let I of r)c=I?.pre?.call(m,c)||c;s.children.push(c)}else if(i==="inline"){let I=[],L={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let g of s.children)g.type==="element"&&g.tagName==="br"?(I.push(L),L={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(g.type==="element"||g.type==="text")&&L.children.push(g);I.push(L);let C={type:"element",tagName:"code",properties:{},children:I};for(let g of r)C=g?.code?.call(m,C)||C;s.children=[];for(let g=0;g<C.children.length;g++){g>0&&s.children.push({type:"element",tagName:"br",properties:{},children:[]});let y=C.children[g];y.type==="element"&&s.children.push(...y.children)}}let h=s;for(let I of r)h=I?.root?.call(m,h)||h;return o&&oo(h,o),h}function am(e){return e.map(t=>{let a=[],o="",r;return t.forEach((n,s)=>{let l=!(n.fontStyle&&(n.fontStyle&ge.Underline||n.fontStyle&ge.Strikethrough));l&&n.content.match(/^\s+$/)&&t[s+1]?(r===void 0&&(r=n.offset),o+=n.content):o?(l?a.push({...n,offset:r,content:o+n.content}):a.push({content:o,offset:r},n),r=void 0,o=""):a.push(n)}),a})}function om(e){return e.map(t=>t.flatMap(a=>{if(a.content.match(/^\s+$/))return a;let o=a.content.match(/^(\s*)(.*?)(\s*)$/);if(!o)return a;let[,r,n,s]=o;if(!r&&!s)return a;let i=[{...a,offset:a.offset+r.length,content:n}];return r&&i.unshift({content:r,offset:a.offset}),s&&i.push({content:s,offset:a.offset+r.length+n.length}),i}))}function rm(e){return e.map(t=>{let a=[];for(let o of t){if(a.length===0){a.push({...o});continue}let r=a[a.length-1],n=ur(r.htmlStyle||Za(r)),s=ur(o.htmlStyle||Za(o)),i=r.fontStyle&&(r.fontStyle&ge.Underline||r.fontStyle&ge.Strikethrough),l=o.fontStyle&&(o.fontStyle&ge.Underline||o.fontStyle&ge.Strikethrough);!i&&!l&&n===s?r.content+=o.content:a.push({...o})}return a})}var nm=sr;function sm(e,t,a){let o={meta:{},options:a,codeToHast:(n,s)=>to(e,n,s),codeToTokens:(n,s)=>eo(e,n,s)},r=nm(to(e,t,a,o));for(let n of Ya(a))r=n.postprocess?.call(o,r,a)||r;return r}var $i={light:"#333333",dark:"#bbbbbb"},Xi={light:"#fffffe",dark:"#1e1e1e"},Ki="__shiki_resolved";function wr(e){if(e?.[Ki])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:a,fg:o}=t;if(!a||!o){let i=t.settings?t.settings.find(l=>!l.name&&!l.scope):void 0;i?.settings?.foreground&&(o=i.settings.foreground),i?.settings?.background&&(a=i.settings.background),!o&&t?.colors?.["editor.foreground"]&&(o=t.colors["editor.foreground"]),!a&&t?.colors?.["editor.background"]&&(a=t.colors["editor.background"]),o||(o=t.type==="light"?$i.light:$i.dark),a||(a=t.type==="light"?Xi.light:Xi.dark),t.fg=o,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let r=0,n=new Map;function s(i){if(n.has(i))return n.get(i);r+=1;let l=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?s(i):(n.set(i,l),l)}t.settings=t.settings.map(i=>{let l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),u=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!u)return i;let c={...i,settings:{...i.settings}};if(l){let d=s(i.settings.foreground);t.colorReplacements[d]=i.settings.foreground,c.settings.foreground=d}if(u){let d=s(i.settings.background);t.colorReplacements[d]=i.settings.background,c.settings.background=d}return c});for(let i of Object.keys(t.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!t.colors[i]?.startsWith("#")){let l=s(t.colors[i]);t.colorReplacements[l]=t.colors[i],t.colors[i]=l}return Object.defineProperty(t,Ki,{enumerable:!1,writable:!1,value:!0}),t}async function rl(e){return Array.from(new Set((await Promise.all(e.filter(t=>!Ji(t)).map(async t=>await Qi(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function nl(e){return(await Promise.all(e.map(async a=>Zi(a)?null:wr(await Qi(a))))).filter(a=>!!a)}var lr=3,im=!1;function lm(e,t=3){if(lr&&!(typeof lr=="number"&&t>lr)){if(im)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var tt=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function sl(e,t){if(!t)return e;if(t[e]){let a=new Set([e]);for(;t[e];){if(e=t[e],a.has(e))throw new tt(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var dr=class extends bi{constructor(t,a,o,r={}){super(t),this._resolver=t,this._themes=a,this._langs=o,this._alias=r,this._themes.map(n=>this.loadTheme(n)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){let a=wr(t);return a.name&&(this._resolvedThemes.set(a.name,a),this._loadedThemesCache=null),a}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let a=this._textmateThemeCache.get(t);a||(a=sa.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=sl(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let a=new Set([...this._langMap.values()].filter(n=>n.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);let o={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);let r=this.loadGrammarWithConfiguration(t.scopeName,1,o);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases&&t.aliases.forEach(n=>{this._alias[n]=t.name}),this._loadedLanguagesCache=null,a.size)for(let n of a)this._resolvedGrammars.delete(n.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(n.scopeName),this._syncRegistry?._grammars?.delete(n.scopeName),this.loadLanguage(this._langMap.get(n.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(let r of t)this.resolveEmbeddedLanguages(r);let a=Array.from(this._langGraph.entries()),o=a.filter(([r,n])=>!n);if(o.length){let r=a.filter(([n,s])=>s?(s.embeddedLanguages||s.embeddedLangs)?.some(l=>o.map(([u])=>u).includes(l)):!1).filter(n=>!o.includes(n));throw new tt(`Missing languages ${o.map(([n])=>`\`${n}\``).join(", ")}, required by ${r.map(([n])=>`\`${n}\``).join(", ")}`)}for(let[r,n]of a)this._resolver.addLanguage(n);for(let[r,n]of a)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);let a=t.embeddedLanguages??t.embeddedLangs;if(a)for(let o of a)this._langGraph.set(o,this._langMap.get(o))}},cr=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,a){this._onigLib={createOnigScanner:o=>t.createScanner(o),createOnigString:o=>t.createString(o)},a.forEach(o=>this.addLanguage(o))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(a=>{this._langs.set(a,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(a=>{this._injections.get(a)||this._injections.set(a,[]),this._injections.get(a).push(t.scopeName)})}getInjections(t){let a=t.split("."),o=[];for(let r=1;r<=a.length;r++){let n=a.slice(0,r).join(".");o=[...o,...this._injections.get(n)||[]]}return o}},fa=0;function um(e){fa+=1,e.warnings!==!1&&fa>=10&&fa%10===0&&console.warn(`[Shiki] ${fa} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new tt("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(wr),r=new cr(e.engine,a),n=new dr(r,o,a,e.langAlias),s;function i(g){return sl(g,e.langAlias)}function l(g){S();let y=n.getGrammar(typeof g=="string"?g:g.name);if(!y)throw new tt(`Language \`${g}\` not found, you may need to load it first`);return y}function u(g){if(g==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};S();let y=n.getTheme(g);if(!y)throw new tt(`Theme \`${g}\` not found, you may need to load it first`);return y}function c(g){S();let y=u(g);s!==g&&(n.setTheme(y),s=g);let A=n.getColorMap();return{theme:y,colorMap:A}}function d(){return S(),n.getLoadedThemes()}function p(){return S(),n.getLoadedLanguages()}function m(...g){S(),n.loadLanguages(g.flat(1))}async function h(...g){return m(await rl(g))}function I(...g){S();for(let y of g.flat(1))n.loadTheme(y)}async function L(...g){return S(),I(await nl(g))}function S(){if(t)throw new tt("Shiki instance has been disposed")}function C(){t||(t=!0,n.dispose(),fa-=1)}return{setTheme:c,getTheme:u,getLanguage:l,getLoadedThemes:d,getLoadedLanguages:p,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:m,loadTheme:L,loadThemeSync:I,dispose:C,[Symbol.dispose]:C}}async function dm(e){e.engine||lm("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([nl(e.themes||[]),rl(e.langs||[]),e.engine]);return um({...e,themes:t,langs:a,engine:o})}async function cm(e){let t=await dm(e);return{getLastGrammarState:(...a)=>Xp(t,...a),codeToTokensBase:(a,o)=>hr(t,a,o),codeToTokensWithThemes:(a,o)=>ol(t,a,o),codeToTokens:(a,o)=>eo(t,a,o),codeToHast:(a,o)=>to(t,a,o),codeToHtml:(a,o)=>sm(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function il(e){let t=e.langs,a=e.themes,o=e.engine;async function r(n){function s(d){if(typeof d=="string"){if(d=n.langAlias?.[d]||d,Ji(d))return[];let p=t[d];if(!p)throw new ae(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}function i(d){if(Zi(d))return"none";if(typeof d=="string"){let p=a[d];if(!p)throw new ae(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}let l=(n.themes??[]).map(d=>i(d)),u=(n.langs??[]).map(d=>s(d)),c=await cm({engine:n.engine??o(),...n,themes:l,langs:u});return{...c,loadLanguage(...d){return c.loadLanguage(...d.map(s))},loadTheme(...d){return c.loadTheme(...d.map(i))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function fm(e){let t;async function a(o={}){if(t){let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}else{t=e({...o,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}}return a}function ll(e,t){let a=fm(e);async function o(r,n){let s=await a({langs:[n.lang],themes:"theme"in n?[n.theme]:Object.values(n.themes)}),i=await t?.guessEmbeddedLanguages?.(r,n.lang,s);return i&&await s.loadLanguage(...i),s}return{getSingletonHighlighter(r){return a(r)},async codeToHtml(r,n){return(await o(r,n)).codeToHtml(r,n)},async codeToHast(r,n){return(await o(r,n)).codeToHast(r,n)},async codeToTokens(r,n){return(await o(r,n)).codeToTokens(r,n)},async codeToTokensBase(r,n){return(await o(r,n)).codeToTokensBase(r,n)},async codeToTokensWithThemes(r,n){return(await o(r,n)).codeToTokensWithThemes(r,n)},async getLastGrammarState(r,n){return(await a({langs:[n.lang],themes:[n.theme]})).getLastGrammarState(r,n)}}}f();var xr=[{id:"abap",name:"ABAP",import:(()=>import("../abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-GK625GFM.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-BBPQXDS2.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-OU63AG2P.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-JGB4KP74.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-WADBFJPS.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-K7JGTCPV.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-EOACOM4G.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-RWJJQSLU.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("../c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-CDQIRWGP.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-ZFZ6ZP6X.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-HLYUQ6RF.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-UPNOBGN4.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-6EXQ7B24.js"))},{id:"css",name:"CSS",import:(()=>import("../css-MH4LSMNV.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("../d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-CSERBUPM.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-XE5XFLFP.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-EXRA4QJX.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-YHLQYGNI.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-LRUOJBTB.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-JA25I4AE.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-CKELYRRF.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("../go-CPCZAAWX.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-UN5O7U5U.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-QIUJFE3G.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-JQIESO7E.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-UBV5AWUH.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("../html-AWDHWPK7.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-QY3ZIV7G.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-KIGXJYY6.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-BZB5LDD5.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("../java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-AEVQQKWS.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("../json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-75QR2XDN.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-LT46F7AO.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-R4PJ7JDY.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("../less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-S4LVU77Y.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-WBQ7MHV7.js"))},{id:"log",name:"Log file",import:(()=>import("../log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-D432BEB5.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-WVASNOGB.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-NDTDGSIG.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-KRRNBH7O.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-LQ7JL5LZ.js"))},{id:"move",name:"Move",import:(()=>import("../move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-DPCEWQNZ.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-Z6EEJ7SX.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-26KZW4VL.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-5IQEFQG3.js"))},{id:"php",name:"PHP",import:(()=>import("../php-UQGWKJAF.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-XHTBJJNO.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("../r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-UMC4HKIF.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-WD6BJFDY.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-HCGHBPBZ.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-ML25RVXY.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-A4JCTK6H.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-4QR2BXFS.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-ALTWCQTO.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-SBP7VV3V.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-MNI5YOQU.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-6TT7H4YP.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-JEBLU4EM.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-WN3SJLUV.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-L55DZDKV.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-NAJDOQCO.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-GIY7NVAA.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-6JSRRA42.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("../v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-V6GLJNYA.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-KB45C76H.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-6LJUAPBA.js"))}],ul=Object.fromEntries(xr.map(e=>[e.id,e.import])),dl=Object.fromEntries(xr.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),ma={...ul,...dl};f();var pm=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("../andromeeda-XSK3JERF.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("../aurora-x-CGSVHL4H.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("../ayu-dark-XYI57HMC.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("../ayu-light-4PSGMDIC.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("../ayu-mirage-DU5SNMZX.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("../catppuccin-frappe-UZ4N3Z4I.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("../catppuccin-latte-GCOWYLZG.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("../catppuccin-macchiato-PJD7W5WJ.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("../catppuccin-mocha-RRH4FOBS.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("../dark-plus-PSM5XP2I.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("../dracula-2VHT5LK5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("../dracula-soft-MSCUO73T.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("../everforest-dark-AGVJEQ35.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("../everforest-light-62GPFKVJ.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("../github-dark-5OJVMBCE.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("../github-dark-default-4WERFSZW.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("../github-dark-dimmed-7VD3SZKC.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("../github-dark-high-contrast-FVMMS656.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("../github-light-SE4LEKO7.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("../github-light-default-TV7BYQGI.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("../github-light-high-contrast-WKO4I3G7.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("../gruvbox-dark-hard-LOYZQIGI.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("../gruvbox-dark-medium-UIMSJJ6K.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("../gruvbox-dark-soft-PU6RNTTO.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("../gruvbox-light-hard-ZQJ7XSZF.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("../gruvbox-light-medium-CD3ZGYV6.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("../gruvbox-light-soft-S74MAGOM.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("../horizon-EAAZ4KVN.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("../houston-UNRWGR67.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("../kanagawa-dragon-BOSCCB42.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("../kanagawa-lotus-NXMB2IVI.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("../kanagawa-wave-YOHS63UF.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("../laserwave-TS4AG4VO.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("../light-plus-2HYW3NJ6.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("../material-theme-KPDVFAGV.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("../material-theme-darker-GVSTMSNT.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("../material-theme-lighter-JWZNUXUH.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("../material-theme-ocean-MU4N3XNQ.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("../material-theme-palenight-VMWD73WM.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("../min-dark-ASEVSA24.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("../min-light-3H54BB3D.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("../monokai-5QWQOFN6.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("../night-owl-4QQBS2UX.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("../night-owl-light-HR6A2OQO.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("../nord-XK3AUNCF.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("../one-dark-pro-ZV7CEA5M.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("../one-light-FKZJCKM6.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("../plastic-SXCQPKYC.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("../poimandres-S3UYVG4O.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("../red-A6OC2HVL.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("../rose-pine-GLWOWPBK.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("../rose-pine-dawn-HYE6T7LV.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("../rose-pine-moon-VHVTDDVO.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("../slack-dark-OPW5CYSY.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("../slack-ochin-WTVMYBFH.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("../snazzy-light-5UQ56PC5.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("../solarized-dark-DSMP6D7D.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("../solarized-light-3IZTZCIV.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("../synthwave-84-JWI6CVJZ.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("../tokyo-night-SRK4SADJ.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("../vesper-WIZFPFI7.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("../vitesse-black-PEGI4HJX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("../vitesse-dark-M2ZAGPXG.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("../vitesse-light-RICZI4IG.js"))}],cl=Object.fromEntries(pm.map(e=>[e.id,e.import]));f();var ha=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function mm(){return 2147483648}function hm(){return typeof performance<"u"?performance.now():Date.now()}var gm=(e,t)=>e+(t-e%t)%t;async function wm(e){let t,a,o={};function r(m){a=m,o.HEAPU8=new Uint8Array(m),o.HEAPU32=new Uint32Array(m)}function n(m,h,I){o.HEAPU8.copyWithin(m,h,h+I)}function s(m){try{return t.grow(m-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function i(m){let h=o.HEAPU8.length;m=m>>>0;let I=mm();if(m>I)return!1;for(let L=1;L<=4;L*=2){let S=h*(1+.2/L);S=Math.min(S,m+100663296);let C=Math.min(I,gm(Math.max(m,S),65536));if(s(C))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(m,h,I=1024){let L=h+I,S=h;for(;m[S]&&!(S>=L);)++S;if(S-h>16&&m.buffer&&l)return l.decode(m.subarray(h,S));let C="";for(;h<S;){let g=m[h++];if(!(g&128)){C+=String.fromCharCode(g);continue}let y=m[h++]&63;if((g&224)===192){C+=String.fromCharCode((g&31)<<6|y);continue}let A=m[h++]&63;if((g&240)===224?g=(g&15)<<12|y<<6|A:g=(g&7)<<18|y<<12|A<<6|m[h++]&63,g<65536)C+=String.fromCharCode(g);else{let R=g-65536;C+=String.fromCharCode(55296|R>>10,56320|R&1023)}}return C}function c(m,h){return m?u(o.HEAPU8,m,h):""}let d={emscripten_get_now:hm,emscripten_memcpy_big:n,emscripten_resize_heap:i,fd_write:()=>0};async function p(){let h=await e({env:d,wasi_snapshot_preview1:d});t=h.memory,r(t.buffer),Object.assign(o,h),o.UTF8ToString=c}return await p(),o}var xm=Object.defineProperty,Lm=(e,t,a)=>t in e?xm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,de=(e,t,a)=>Lm(e,typeof t!="symbol"?t+"":t,a),me=null;function Cm(e){throw new ha(e.UTF8ToString(e.getLastOnigError()))}var no=class e{constructor(t){de(this,"utf16Length"),de(this,"utf8Length"),de(this,"utf16Value"),de(this,"utf8Value"),de(this,"utf16OffsetToUtf8"),de(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,n=r?new Uint32Array(a+1):null;r&&(n[a]=o);let s=r?new Uint32Array(o+1):null;r&&(s[o]=a);let i=new Uint8Array(o),l=0;for(let u=0;u<a;u++){let c=t.charCodeAt(u),d=c,p=!1;if(c>=55296&&c<=56319&&u+1<a){let m=t.charCodeAt(u+1);m>=56320&&m<=57343&&(d=(c-55296<<10)+65536|m-56320,p=!0)}r&&(n[u]=l,p&&(n[u+1]=l),d<=127?s[l+0]=u:d<=2047?(s[l+0]=u,s[l+1]=u):d<=65535?(s[l+0]=u,s[l+1]=u,s[l+2]=u):(s[l+0]=u,s[l+1]=u,s[l+2]=u,s[l+3]=u)),d<=127?i[l++]=d:d<=2047?(i[l++]=192|(d&1984)>>>6,i[l++]=128|(d&63)>>>0):d<=65535?(i[l++]=224|(d&61440)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0):(i[l++]=240|(d&1835008)>>>18,i[l++]=128|(d&258048)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0),p&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=i,this.utf16OffsetToUtf8=n,this.utf8OffsetToUtf16=s}static _utf8ByteLength(t){let a=0;for(let o=0,r=t.length;o<r;o++){let n=t.charCodeAt(o),s=n,i=!1;if(n>=55296&&n<=56319&&o+1<r){let l=t.charCodeAt(o+1);l>=56320&&l<=57343&&(s=(n-55296<<10)+65536|l-56320,i=!0)}s<=127?a+=1:s<=2047?a+=2:s<=65535?a+=3:a+=4,i&&o++}return a}createString(t){let a=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,a),a}},so=class je{constructor(t){if(de(this,"id",++je.LAST_ID),de(this,"_onigBinding"),de(this,"content"),de(this,"utf16Length"),de(this,"utf8Length"),de(this,"utf16OffsetToUtf8"),de(this,"utf8OffsetToUtf16"),de(this,"ptr"),!me)throw new ha("Must invoke loadWasm first.");this._onigBinding=me,this.content=t;let a=new no(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!je._sharedPtrInUse?(je._sharedPtr||(je._sharedPtr=me.omalloc(1e4)),je._sharedPtrInUse=!0,me.HEAPU8.set(a.utf8Value,je._sharedPtr),this.ptr=je._sharedPtr):this.ptr=a.createString(me)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===je._sharedPtr?je._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};de(so,"LAST_ID",0);de(so,"_sharedPtr",0);de(so,"_sharedPtrInUse",!1);var fl=so,Cr=class{constructor(t){if(de(this,"_onigBinding"),de(this,"_ptr"),!me)throw new ha("Must invoke loadWasm first.");let a=[],o=[];for(let i=0,l=t.length;i<l;i++){let u=new no(t[i]);a[i]=u.createString(me),o[i]=u.utf8Length}let r=me.omalloc(4*t.length);me.HEAPU32.set(a,r/4);let n=me.omalloc(4*t.length);me.HEAPU32.set(o,n/4);let s=me.createOnigScanner(r,n,t.length);for(let i=0,l=t.length;i<l;i++)me.ofree(a[i]);me.ofree(n),me.ofree(r),s===0&&Cm(me),this._onigBinding=me,this._ptr=s}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,a,o){let r=0;if(typeof o=="number"&&(r=o),typeof t=="string"){t=new fl(t);let n=this._findNextMatchSync(t,a,!1,r);return t.dispose(),n}return this._findNextMatchSync(t,a,!1,r)}_findNextMatchSync(t,a,o,r){let n=this._onigBinding,s=n.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(a),r);if(s===0)return null;let i=n.HEAPU32,l=s/4,u=i[l++],c=i[l++],d=[];for(let p=0;p<c;p++){let m=t.convertUtf8OffsetToUtf16(i[l++]),h=t.convertUtf8OffsetToUtf16(i[l++]);d[p]={start:m,end:h,length:h-m}}return{index:u,captureIndices:d}}};function Im(e){return typeof e.instantiator=="function"}function Sm(e){return typeof e.default=="function"}function ym(e){return typeof e.data<"u"}function bm(e){return typeof Response<"u"&&e instanceof Response}function km(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var ro;function Tm(e){if(ro)return ro;async function t(){me=await wm(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),Im(o)?o=await o.instantiator(a):Sm(o)?o=await o.default(a):(ym(o)&&(o=o.data),bm(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await vm(o)(a):o=await Pm(o)(a):km(o)?o=await Lr(o)(a):o instanceof WebAssembly.Module?o=await Lr(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await Lr(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return ro=t(),ro}function Lr(e){return t=>WebAssembly.instantiate(e,t)}function vm(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Pm(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function pl(e){return e&&await Tm(e),{createScanner(t){return new Cr(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new fl(t)}}}var io=il({langs:ma,themes:cl,engine:()=>pl(import("../wasm-ISCPKFD2.js"))}),{codeToHtml:Am,codeToHast:Rm,codeToTokens:Mm,codeToTokensBase:Fm,codeToTokensWithThemes:Dm,getSingletonHighlighter:Bm,getLastGrammarState:Em}=ll(io,{guessEmbeddedLanguages:el});var ml=new Set(Object.keys(ma)),Ir=new Map,Sr=new Map,At=new Map,_m=(e,t)=>`${e}-${t[0]}-${t[1]}`,Nm=(e,t,a)=>{let o=e.slice(0,100),r=e.length>100?e.slice(-100):"";return`${t}:${a[0]}:${a[1]}:${e.length}:${o}:${r}`},Om=(e,t)=>{let a=_m(e,t);if(Ir.has(a))return Ir.get(a);let o=io({themes:t,langs:[e]});return Ir.set(a,o),o};function Um(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return ml.has(o)},getSupportedLanguages(){return Array.from(ml)},getThemes(){return a},highlight({code:o,language:r,themes:n},s){let i=Nm(o,r,n);return Sr.has(i)?Sr.get(i):(s&&(At.has(i)||At.set(i,new Set),At.get(i).add(s)),Om(r,n).then(l=>{let u=l.getLoadedLanguages().includes(r)?r:"text",c=l.codeToTokens(o,{lang:u,themes:{light:n[0],dark:n[1]}});Sr.set(i,c);let d=At.get(i);if(d){for(let p of d)p(c);At.delete(i)}}).catch(l=>{console.error("[Streamdown Code] Failed to highlight code:",l),At.delete(i)}),null)}}}var hl=Um();import{memo as Gm}from"react";f();import{useEffect as Hm,useRef as lo,useState as qm}from"react";var Wm=5,gl=400;function wl(e,t,a={}){let{msPerChar:o=Wm}=a,[r,n]=qm(t?"":e),s=lo(e),i=lo(t?0:e.length),l=lo(0),u=lo(null);return(e.length<i.current||!e.startsWith(r.slice(0,i.current)))&&(i.current=t?0:e.length),s.current=e,Hm(()=>{if(!t){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),i.current=e.length,n(e);return}if(s.current.length-i.current>gl&&(i.current=s.current.length-gl),u.current!==null)return;let d=p=>{let m=s.current;if(i.current>=m.length){u.current=null;return}l.current===0&&(l.current=p);let h=p-l.current;if(h>=o){let I=Math.min(Math.floor(h/o),m.length-i.current);i.current+=I,n(m.slice(0,i.current)),l.current=p}u.current=requestAnimationFrame(d)};return u.current=requestAnimationFrame(d),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,o]),r}import{jsx as uo}from"react/jsx-runtime";var yr=({className:e,from:t,children:a,...o})=>uo("div",{className:F("ww:group ww:flex ww:w-full",t==="user"?"is-user ww:ml-auto ww:max-w-[80%] ww:flex-col ww:items-end":"is-assistant ww:flex-col",e),...o,children:uo("div",{className:F("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),br=({children:e,className:t,...a})=>uo("div",{className:F("ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden ww:text-base","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:rounded-lg ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:px-4 ww:group-[.is-user]:py-3 ww:group-[.is-user]:text-primary-foreground","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),jm={cjk:Vo,code:hl},zm={cjk:Vo},Vm={enabled:!1};function $m({className:e,linkSafety:t,isStreaming:a,children:o,...r}){let s=wl(typeof o=="string"?o:"",!!a),i=typeof o=="string"?s:o;return uo(Mt,{className:F("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??Vm,plugins:a?zm:jm,...r,children:i})}var co=Gm($m,(e,t)=>e.children===t.children&&e.isStreaming===t.isStreaming);co.displayName="MessageResponse";f();import{createContext as Xm,useCallback as Km,useContext as Il,useEffect as Qm,useMemo as Tr,useRef as Jm,useState as vr}from"react";import{Fragment as Cl,jsx as $,jsxs as ht}from"react/jsx-runtime";function Zm(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let o=Object.entries(e),r=[],n=t-2;for(let[s,i]of o){if(n<=8)break;let l=s.length>4?`${s.slice(0,4)}\u2026`:s,u;typeof i=="string"?u=i.length>2?`'${i.slice(0,1)}\u2026`:`'${i}'`:Array.isArray(i)?u=`Array(${i.length})`:typeof i=="object"&&i!==null?u="{\u2026}":u=String(i);let c=`${l}\u2009${u}`;r.push(c),n-=c.length+3}return`{${r.join(", ")}}`}function Ym({text:e,className:t}){let{t:a}=V(),[o,r]=vr(!1),n=Jm(null);Qm(()=>()=>{n.current&&clearTimeout(n.current)},[]);let s=Km(async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(!1),2e3)}catch{}},[e]);return $(qe,{variant:"ghost",size:"sm",onClick:s,className:F("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:o?ht(Cl,{children:[$(Wt,{className:"ww:size-3.5"}),$("span",{children:a.tool.copied})]}):ht(Cl,{children:[$(jt,{className:"ww:size-3.5"}),$("span",{children:a.tool.copy})]})})}function Sl({data:e,label:t,className:a,...o}){let[r,n]=vr(!1),s=Tr(()=>JSON.stringify(e,null,2),[e]),i=Zm(e);return ht("div",{className:F("ww:rounded-lg ww:bg-tool-card",a),...o,children:[ht("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[$("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),$(Ym,{text:s})]}),ht("button",{type:"button",onClick:()=>n(l=>!l),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[$(Gt,{className:F("ww:mt-0.5 ww:size-3.5 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-150",r&&"ww:rotate-90")}),r?$("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:$("code",{children:s})}):$("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:i})]})]})}var Pr=Xm({open:!1,toggle:()=>{}});function yl({className:e,defaultOpen:t=!1,children:a,...o}){let[r,n]=vr(t);return $(Pr.Provider,{value:{open:r,toggle:()=>n(s=>!s)},children:$("div",{className:F("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...o,children:a})})}function bl({className:e,title:t,state:a,...o}){let{open:r,toggle:n}=Il(Pr),s=a==="input-available"||a==="input-streaming",i=t??"";return ht("button",{type:"button",onClick:n,className:F("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),"aria-expanded":r,...o,children:[$($e,{className:"ww:size-4 ww:shrink-0"}),$("span",{className:"ww:truncate",children:s?$(Ne,{duration:1.6,children:i}):i}),$(Je,{className:F("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function kl({className:e,title:t,state:a,...o}){let r=a==="input-available"||a==="input-streaming",n=t??"";return $("div",{className:F("ww:mb-4 ww:flex ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...o,children:$("span",{className:"ww:truncate",children:r?$(Ne,{duration:1.6,children:n}):n})})}function Tl({className:e,children:t,...a}){let{open:o}=Il(Pr);return $("div",{className:F("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:$("div",{className:"ww:min-h-0 ww:overflow-hidden",children:$("div",{className:F("ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",e),...a,children:t})})})}function Ar({className:e,input:t,debug:a,...o}){let{t:r}=V(),n=Tr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...i}=t;return i}return t},[t,a]);return $(Sl,{data:n,label:r.tool.request,className:e,...o})}function kr(e){if(!(typeof e!="object"||e===null))return e}function vl(e){return kr(e?.ui)}function Pl(e){return kr(kr(e)?._meta)}function xl(e){if(!e)return;let t=vl(e)?.resourceUri;if(typeof t=="string"&&t.length>0)return t;let a=e["ui/resourceUri"];if(typeof a=="string"&&a.length>0)return a;let o=e["openai/outputTemplate"];if(typeof o=="string"&&o.length>0)return o}function Ll(e){return vl(e)?.autoHeight===!0}function ga(e,t,a){if(e){let o=xl(a?.[e]?._meta);if(o)return o}return xl(Pl(t))}function Al(e,t,a){return e&&Ll(a?.[e]?._meta)?!0:Ll(Pl(t))}function Rr({className:e,output:t,errorText:a,debug:o,...r}){let{t:n}=V(),s=Tr(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:i,...l}=t;return l}return t},[t,o]);return t||a?a?ht("div",{className:F("ww:space-y-2",e),...r,children:[$("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:n.tool.error}),$("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):$(Sl,{data:s,label:n.tool.response,className:e,...r}):null}f();import{jsx as Rl,jsxs as eh}from"react/jsx-runtime";function Ml(e){return e.type==="text"||e.type==="reasoning"||e.type==="file"||"toolCallId"in e}function Fl(e){return e.parts.some(Ml)}function Dl(e,t,a){if(t!=="submitted"&&t!=="streaming")return!1;let o=e[e.length-1];return!o||o.role!=="assistant"?!0:!o.parts.some(n=>!(!Ml(n)||a?.ignoreToolParts&&"toolCallId"in n||a?.ignoreReasoningParts&&n.type==="reasoning"))}function Bl({className:e,...t}){let{t:a}=V();return eh("div",{"aria-live":"polite",className:F("ww:mb-4 ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...t,children:[Rl(Qt,{className:"ww:size-4 ww:shrink-0"}),Rl(Ne,{duration:1.6,children:a.workingIndicator.default})]})}f();import{useCallback as th,useEffect as El,useMemo as ah,useRef as be,useState as _l}from"react";import{jsx as ph}from"react/jsx-runtime";var oh="/api/mcp/resource",rh=500,nh=0,sh=16,ih="2026-01-26",lh=300,uh=3e3,dh=3;function ch(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function fh(e,t,a){return ga(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function Nl({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=oh,chatSessionId:r,isDark:n=!1,className:s,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:c,onDisplayModeChange:d,isFullscreen:p=!1,toolDefinitions:m}){let h=be(null),I=be(t),L=be(a),S=be({width:0,height:0}),C=be(null),g=be(!1),y=be(0),A=be("inline"),[R,P]=_l(nh),[M,N]=_l(void 0),D=be(l),_=be(u),T=be(c),B=be(d),k=be(r),v=be(m);I.current=t,L.current=a,D.current=l,_.current=u,T.current=c,B.current=d,k.current=r,v.current=m;let q=th(X=>i?Math.max(X+sh,0):Math.min(Math.max(X,50),rh),[i]),Le=ah(()=>{let X=o.includes("?")?"&":"?";return`${o}${X}uri=${encodeURIComponent(e)}`},[o,e]),ie=be(n);return ie.current=n,El(()=>{if(!g.current)return;let X=h.current;X?.contentWindow&&X.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:n?"dark":"light"}},"*")},[n]),El(()=>{let X=h.current;if(!X)return;let Ce=!1,Pe=!1,ye=null,ke=null,Qe=setTimeout(()=>{if(Ce||Pe||y.current>=dh)return;y.current+=1;let re=new URL(X.src);re.searchParams.set("_retry",String(y.current)),X.src=re.toString()},uh),U=re=>{X.contentWindow?.postMessage(re,"*")},fe=re=>{if(Ce||re.source!==X.contentWindow)return;let Z=re.data;if(!Z||typeof Z!="object"||Z.jsonrpc!=="2.0")return;let ne=Z.method,G=Z.id;if(ne==="ui/initialize"&&G!=null){Pe=!0,clearTimeout(Qe),U({jsonrpc:"2.0",id:G,result:{protocolVersion:Z.params?.protocolVersion??ih,hostInfo:{name:"Waniwani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:ie.current?"dark":"light",displayMode:A.current}}});return}if(ne==="ui/notifications/initialized"){g.current=!0;let z=I.current,K=L.current,te=K._meta&&typeof K._meta=="object"?K._meta:null,Y=ch(k.current),le=te&&typeof te.waniwani=="object"&&te.waniwani!==null?te.waniwani:null,Te=le||Y?{...le??{},...Y?{sessionId:Y}:{}}:void 0,Fe=te||Te?{...te??{},...Te?{waniwani:Te}:{}}:void 0;U({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:z}});let xt=K.content??[{type:"text",text:JSON.stringify(K)}];U({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:xt,structuredContent:K.structuredContent,_meta:Fe,meta:Fe}});return}if(ne==="ui/notifications/size-changed"){let z=Z.params,K=typeof z?.height=="number"?z.height:void 0,te=typeof z?.width=="number"?z.width:void 0,Y=S.current,le=K!==void 0&&K!==Y.height,Te=te!==void 0&&te!==Y.width;if(!le&&!Te)return;if(le&&K!==void 0){Y.height=K;let Fe=q(K),xt=X.getBoundingClientRect().height;if(C.current&&(C.current.cancel(),C.current=null),P(Fe),X.animate&&Math.abs(xt-Fe)>2){let Lt=X.animate([{height:`${xt}px`},{height:`${Fe}px`}],{duration:lh,easing:"ease-out",fill:"forwards"});C.current=Lt,Lt.onfinish=()=>{C.current===Lt&&(Lt.cancel(),C.current=null)}}}Te&&i&&te!==void 0&&(Y.width=te,N(te));return}if(ne==="ui/open-link"&&G!=null){let z=Z.params?.url;typeof z=="string"&&(D.current?D.current(z):window.open(z,"_blank","noopener,noreferrer")),U({jsonrpc:"2.0",id:G,result:{}});return}if(ne==="ui/message"&&G!=null){if(_.current&&Z.params){let z=Z.params,K=ye;if(ye=null,ke){clearTimeout(ke.timer);let te=ke.text;ke=null;let Y=(z.content??[]).map(le=>le.text??"").join("").trim();z={...z,content:[{type:"text",text:`${Y}
80
80
 
81
- ${J}`}]}}T.current({...j,...V?{modelContext:V}:{}})}O({jsonrpc:"2.0",id:q,result:{}});return}if(ae==="ui/update-model-context"&&q!=null){Ce=Hr(Ce,X.params),O({jsonrpc:"2.0",id:q,result:{}});return}if(ae==="tools/call"&&q!=null){let j=y.current;if(!j){O({jsonrpc:"2.0",id:q,error:{code:-32601,message:"tools/call not supported"}});return}let V=X.params?.name;j({name:V,arguments:X.params?.arguments??{}}).then(J=>{O({jsonrpc:"2.0",id:q,result:J});let K=J.content?.map(se=>se.text??"").join("").trim();K&&ah(V,J,F.current)&&(be&&clearTimeout(be.timer),be={text:K,timer:setTimeout(()=>{if(we)return;let se=Ce;Ce=null,be=null,T.current?.({role:"user",content:[{type:"text",text:K}],...se?{modelContext:se}:{}})},500)})}).catch(J=>{let K=J instanceof Error?J.message:"Tool call failed";O({jsonrpc:"2.0",id:q,error:{code:-32e3,message:K}})});return}if(ae==="ui/request-display-mode"&&q!=null){let j=X.params?.mode,V=j==="fullscreen"||j==="inline"||j==="pip"?j:"inline";P.current=V,O({jsonrpc:"2.0",id:q,result:{mode:V}}),O({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:V}}),B.current?.(V);return}if(ae==="ui/resource-teardown"&&q!=null){O({jsonrpc:"2.0",id:q,result:{}});return}ae==="ping"&&q!=null&&O({jsonrpc:"2.0",id:q,result:{}})};return window.addEventListener("message",ue),()=>{we=!0,clearTimeout(Qe),be&&clearTimeout(be.timer),window.removeEventListener("message",ue)}},[i,Q]),oh("iframe",{ref:h,src:Ne,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:D(!p&&"ww:rounded-md ww:border ww:border-border",n),style:{height:p?"100%":A,minWidth:p||!R?void 0:`min(${R}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}f();import{jsx as pa,jsxs as rh}from"react/jsx-runtime";function Pl({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return rh("div",{className:"ww:flex ww:flex-col ww:items-center ww:justify-center ww:py-12 ww:px-6 ww:text-center ww:min-h-full",children:[e&&pa("div",{className:"ww:mb-4 ww:flex ww:items-center ww:justify-center ww:size-12 ww:rounded-xl ww:bg-foreground ww:text-background",children:e}),pa("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&pa("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&pa("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((s,n)=>pa("button",{type:"button",onClick:()=>r?.(s),className:D("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})]})}f();import{Component as sh}from"react";import{jsx as Tr,jsxs as ih}from"react/jsx-runtime";function nh({onRetry:e}){let{t}=z();return ih("div",{className:"ww:flex ww:items-center ww:justify-between ww:rounded-md ww:border ww:border-border ww:bg-muted/50 ww:px-4 ww:py-3 ww:text-sm ww:text-muted-foreground",children:[Tr("span",{children:t.widgetErrorBoundary.failedToLoad}),Tr("button",{type:"button",onClick:e,className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:t.widgetErrorBoundary.retry})]})}var io=class extends sh{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[WaniWani] Widget failed to render:",t.message)}render(){return this.state.hasError?Tr(nh,{onRetry:()=>this.setState({hasError:!1})}):this.props.children}};import{Fragment as lh,jsx as re,jsxs as vt}from"react/jsx-runtime";function Al(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function Rl({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:p,showToolCalls:m=!0,toolDefinitions:h}){let I=e[e.length-1],L=e.length>0,S=d!=null,C=!S&&yl(e,t,{ignoreToolParts:m===!1,ignoreReasoningParts:m===!1});return vt(lh,{children:[!S&&(!L&&o?re(Pl,{...o,onSuggestionSelect:r}):a&&re(gr,{from:"assistant",children:re(wr,{children:re(no,{children:a})})})),e.map(g=>{let b=g.parts.filter(T=>T.type==="text"),P=g.parts.filter(T=>T.type==="reasoning"),A=g.parts.filter(T=>T.type==="file"),v=g.parts.filter(T=>"toolCallId"in T),R=g===I&&g.role==="assistant",_=b.length>0,M=S?v.some(T=>T.toolCallId===d):!1;return S&&!M?re("div",{style:{display:"none"}},g.id):g.role==="assistant"&&!Sl(g)?re("div",{style:{display:"none"}},g.id):m===!1&&g.role==="assistant"&&!_&&A.length===0&&v.every(T=>{let y="output"in T?T.output:void 0;return y===void 0||!s||!fa(T.toolName,y,h)})?re("div",{style:{display:"none"}},g.id):vt(gr,{from:g.role,children:[m!==!1&&!M&&P.map((T,y)=>vt(Ir,{isStreaming:T.state==="streaming",children:[re(Sr,{}),re(yr,{children:T.text})]},`reasoning-${g.id}-${y}`)),m!==!1&&!M&&v.length>0&&vt(Tn,{isWorking:v.some(T=>T.state==="input-available"||T.state==="input-streaming"),children:[re(vn,{label:(()=>{let T=v[v.length-1];return T.title??Al(T.toolName)})()}),re(Pn,{children:v.map((T,y)=>{let B=T.title??Al(T.toolName),U=y===v.length-1;if(m==="titles-only")return re(_o,{title:B,state:T.state,isLast:U},T.toolCallId);let F="output"in T?T.output:void 0;return vt(_o,{title:B,state:T.state,isLast:U,children:[re(hl,{input:T.input,debug:p}),F!==void 0&&re(Ll,{output:F,errorText:"errorText"in T?T.errorText:void 0,debug:p})]},T.toolCallId)})})]}),v.map(T=>{let y="output"in T?T.output:void 0,B=fa(T.toolName,y,h),U=xl(T.toolName,y,h),F=T.toolCallId===d;return B&&s&&y!==void 0?re("div",{style:F?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:B&&s&&y!==void 0&&re(io,{children:re(vl,{isFullscreen:F,resourceUri:B,toolInput:T.input??{},toolResult:{content:y.content,structuredContent:y.structuredContent,_meta:y._meta},resourceEndpoint:s,chatSessionId:n,isDark:i,autoHeight:U,toolDefinitions:h,onFollowUp:l,onCallTool:u,onDisplayModeChange:c?Q=>c(Q,{toolCallId:T.toolCallId,resourceUri:B,toolInput:T.input??{},toolResult:{content:y.content,structuredContent:y.structuredContent,_meta:y._meta},autoHeight:U}):void 0})})},T.toolCallId):null}),!M&&re("div",{children:vt(wr,{children:[A.length>0&&re(Sn,{files:A}),_?b.map((T,y)=>{let B=R&&t==="streaming"&&y===b.length-1;return re(no,{isStreaming:B,children:T.type==="text"?T.text:""},`${g.id}-${y}`)}):null]})})]},g.id)}),C&&re(bl,{})]})}f();import{jsx as Ml,jsxs as ch}from"react/jsx-runtime";var uh="https://app.waniwani.ai/assets/waniwani-logo.svg",dh="https://waniwani.ai";function Fl(){let{t:e}=z();return ch("a",{href:dh,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[Ml("span",{children:e.poweredBy.label}),Ml("img",{src:uh,alt:"WaniWani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}f();import{jsx as lo}from"react/jsx-runtime";function Dl({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:lo("div",{className:D("ww:px-4 ww:py-2",o),...r,children:lo("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(s=>lo("div",{className:"ww:h-7 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+s*20}px`}},s)):e.map((s,n)=>lo("button",{type:"button",onClick:()=>a(s),className:D("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3 ww:py-1 ww:text-xs","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})})}f();import{useEffect as fh,useRef as ph,useState as mh}from"react";import{jsx as Y,jsxs as ft}from"react/jsx-runtime";var Bl=20;function hh({label:e}){return ft("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[Y("title",{children:e}),Y("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),Y("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function gh({label:e}){return ft("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[Y("title",{children:e}),Y("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),Y("polyline",{points:"3 4 3 9 8 9"}),Y("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),Y("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function wh({label:e}){return ft("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[Y("title",{children:e}),Y("polyline",{points:"3 6 5 6 21 6"}),Y("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),Y("path",{d:"M10 11v6"}),Y("path",{d:"M14 11v6"})]})}function El({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let{locale:s,t:n}=z(),[i,l]=mh(!1),u=ph(null);fh(()=>{if(!i)return;let p=m=>{let h=u.current;h&&(m.composedPath().includes(h)||l(!1))};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[i]);let c=e.slice(0,Bl),d=Math.max(0,e.length-Bl);return ft("div",{ref:u,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[Y("button",{type:"button",onClick:a,title:n.threadMenu.newChat,"aria-label":n.threadMenu.newChat,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:Y(hh,{label:n.threadMenu.newChat})}),Y("button",{type:"button",onClick:()=>l(p=>!p),title:n.threadMenu.threadHistory,"aria-label":n.threadMenu.threadHistory,"aria-expanded":i,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:Y(gh,{label:n.threadMenu.threadHistory})}),i&&ft("div",{role:"menu",className:"ww:absolute ww:right-0 ww:top-full ww:mt-1 ww:w-72 ww:max-h-80 ww:overflow-y-auto ww:rounded-lg ww:border ww:border-border ww:bg-background ww:shadow-lg ww:z-50",children:[c.length===0&&Y("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:n.threadMenu.noPreviousChats}),c.map(p=>{let m=p.threadId===t,h=Date.parse(p.updatedAt);return ft("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${m?"ww:bg-foreground/5":""}`,children:[ft("button",{type:"button",onClick:()=>{o(p.threadId),l(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[Y("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:p.title}),Y("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Number.isNaN(h)?"":Fo(h,s)})]}),Y("button",{type:"button",onClick:I=>{I.stopPropagation(),r(p.threadId)},title:n.threadMenu.deleteThread,"aria-label":n.threadMenu.deleteThread,className:"ww:p-1 ww:rounded ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/10 ww:transition-colors ww:cursor-pointer",children:Y(wh,{label:n.threadMenu.deleteThread})})]},p.threadId)}),d>0&&Y("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:n.threadMenu.hiddenThreads(d)})]})]})}f();import{useCallback as xh,useRef as Lh}from"react";function _l(e){let t=Lh(e);return t.current=e,xh(async a=>{let{api:o,headers:r,onCallTool:s,sessionId:n}=t.current;if(s)return s(a);let i=`${o??"/api/waniwani"}/tool`,l=typeof n=="string"&&n.trim().length>0?n.trim():void 0,u=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...l?{"X-Session-Id":l}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}f();import{useChat as _h}from"@ai-sdk/react";import{useCallback as he,useEffect as De,useRef as le,useState as pt}from"react";f();import{DefaultChatTransport as Ch,uiMessageChunkSchema as Ih}from"ai";function Sh(e){let t=e?.cause,a=t?.issues??t?.errors;if(!Array.isArray(a))return null;let o=a.find(r=>r.code==="invalid_union");if(!o?.errors)return null;for(let r of o.errors){if(!Array.isArray(r)||r.some(i=>(i.code==="invalid_value"||i.code==="invalid_literal")&&i.path?.[0]==="type"))continue;let n=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(n.length>0)return n}return null}var uo=class extends Ch{processResponseStream(t){let a="",o=Ih(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let i=a.split(`
82
- `);a=i.pop()??"";for(let l of i){let u=l.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){n.enqueue(d);continue}let p=await r(d);if(p.success){n.enqueue(p.value);continue}let m=Sh(p.error);if(m?.length){let h={...d};for(let L of m)delete h[L];let I=await r(h);I.success&&n.enqueue(I.value)}}catch{}}}}))}};f();f();var yh="waniwani-memory";var Re="threads",co="by_memoryUserId",bh="by_updatedAt";var Ol="memoryUserId",Nl="waniwani-memory-user-id",vr=null;function Pr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function kh(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Re)){let a=e.createObjectStore(Re,{keyPath:"threadId"});a.createIndex(co,"memoryUserId",{unique:!1}),a.createIndex(bh,"updatedAt",{unique:!1})}}async function Ar(){return new Promise((e,t)=>{let a=indexedDB.open(yh,2);a.onupgradeneeded=o=>{kh(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function Th(){return Ar()}async function vh(e){return new Promise((t,a)=>{let s=e.transaction("ids","readonly").objectStore("ids").get(Ol);s.onsuccess=()=>t(typeof s.result=="string"?s.result:null),s.onerror=()=>a(s.error)})}async function Ph(e,t){return new Promise((a,o)=>{let n=e.transaction("ids","readwrite").objectStore("ids").put(t,Ol);n.onsuccess=()=>a(),n.onerror=()=>o(n.error)})}async function Ah(){if(typeof indexedDB>"u")return null;try{let e=await Th();try{let t=await vh(e);if(t)return t;let a=Pr();return await Ph(e,a),a}finally{e.close()}}catch{return null}}function Rh(){try{let e=localStorage.getItem(Nl);if(e)return e;let t=Pr();return localStorage.setItem(Nl,t),t}catch{return null}}async function Ul(){let e=await Ah();if(e)return e;let t=Rh();return t||(vr||(vr=Pr()),vr)}var Hl=50,ql=1e3;function fo(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.threadId=="string"&&typeof t.memoryUserId=="string"&&typeof t.title=="string"&&Array.isArray(t.messages)&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"}async function po(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await Ar(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function Rr(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function Mr(e){return await po(async a=>{let s=a.transaction(Re,"readonly").objectStore(Re).index(co),i=(await Rr(s.getAll(e))??[]).filter(fo);return i.sort((l,u)=>l.updatedAt<u.updatedAt?1:-1),i})??[]}async function mo(e){return await po(async a=>{let r=a.transaction(Re,"readonly").objectStore(Re),s=await Rr(r.get(e));return fo(s)?s:null})??null}async function Fr(e){if(!fo(e))return;let t=e.messages.length>ql?{...e,messages:e.messages.slice(e.messages.length-ql)}:e;await po(async a=>{await new Promise((l,u)=>{let c=a.transaction(Re,"readwrite");c.oncomplete=()=>l(),c.onerror=()=>u(c.error),c.onabort=()=>u(c.error),c.objectStore(Re).put(t)});let o=a.transaction(Re,"readwrite"),r=o.objectStore(Re),s=r.index(co),i=(await Rr(s.getAll(t.memoryUserId))??[]).filter(fo);if(i.length>Hl){i.sort((u,c)=>u.updatedAt<c.updatedAt?-1:1);let l=i.slice(0,i.length-Hl);for(let u of l)r.delete(u.threadId)}return await new Promise((l,u)=>{o.oncomplete=()=>l(),o.onerror=()=>u(o.error),o.onabort=()=>u(o.error)}),null})}async function Wl(e){await po(async t=>(await new Promise((a,o)=>{let r=t.transaction(Re,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(Re).delete(e)}),null))}async function Dr(e){return(await Mr(e))[0]?.threadId??null}function Gl(e){let t=e.trim();if(!t)return`Conversation on ${new Date().toISOString().slice(0,10)}`;let a=t.split(/\r?\n/,1)[0]??t;return a.length<=60?a:`${a.slice(0,60).trimEnd()}\u2026`}f();var jl="waniwani-visitor-id";function zl(e,t){return e.match(t)?.[1]??null}function Mh(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,o]of t){let r=zl(e,o);if(r)return{name:a,version:r}}return null}function Fh(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,o]of t){let r=zl(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function Dh(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function Bh(e){let t=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}async function Eh(){try{let a=localStorage.getItem(jl);if(a)return a}catch{}let e=[navigator.userAgent,screen.width,screen.height,screen.colorDepth,Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.language,navigator.hardwareConcurrency??"",navigator.platform??""].join("|"),t=await Bh(e);try{localStorage.setItem(jl,t)}catch{}return t}async function Br(){let e=navigator.userAgent,[t,a]=await Promise.all([Eh(),Ul()]);return{userAgent:e,browser:Mh(e),os:Fh(e),deviceType:Dh(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t,memoryUserId:a}}var Nh="x-session-id",Oh=250;function Vl(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Qt()}function ho(){return new Date().toISOString()}function $l(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function Uh(e,t){let a=`${e.replace(/\/$/,"")}/tools`,o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let s={};for(let n of r.tools)n&&typeof n.name=="string"&&(s[n.name]=n);return s}function Xl(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s,enableThreadHistory:n=!1,activeThreadId:i,onThreadChange:l}=e,u=le(a),c=le(o),d=le(n);De(()=>{d.current=n},[n]);let p=le(void 0),m=le(null),[h,I]=pt(void 0),L=le(h),[S,C]=pt(i),g=le(S),[b,P]=pt([]),[A,v]=pt(!n),R=le(void 0),_=le(void 0),M=le(void 0),T=le(void 0),y=le(0),B=le(l);De(()=>{B.current=l},[l]);let U=he(k=>{g.current=k,C(k),k&&B.current?.(k)},[]),F=he(async()=>{if(!n)return;let k=m.current?.memoryUserId;if(!k)return;let N=await Mr(k);P(N)},[n]),Q=he(()=>L.current,[]),Ne=he(k=>{let N=$l(k);N&&L.current!==N&&(L.current=N,I(N))},[]),ye=he(()=>{L.current=void 0,I(void 0)},[]);De(()=>{u.current=a},[a]),De(()=>{c.current=o},[o]),De(()=>{let k=!1,N=y.current;return(async()=>{try{let xe=await Br();if(k)return;m.current=xe}catch{}if(!n)return;let H=m.current?.memoryUserId;if(!H){v(!0);return}try{let xe=i??await Dr(H);if(k||N!==y.current)return;if(xe){let de=await mo(xe);if(k||N!==y.current)return;de&&de.memoryUserId===H&&(g.current=de.threadId,C(de.threadId),R.current=de.createdAt,_.current=de.title,de.sessionId&&(L.current=de.sessionId,I(de.sessionId)),ae(de.messages))}await F()}finally{k||v(!0)}})(),()=>{k=!0}},[]);let te=le(new uo({api:t,headers:()=>({...u.current}),body:()=>{let k={...c.current??{}},N=Object.hasOwn(k,"sessionId"),H=$l(k.sessionId);if(H)Ne(H),k.sessionId=H;else if(N)ye(),delete k.sessionId;else{let Be=Q();Be&&(k.sessionId=Be)}if(gt(p.current)&&(k.modelContext=p.current),m.current){let Be=m.current;k.visitorContext={timezone:Be.timezone,language:Be.language,languages:Be.languages,deviceType:Be.deviceType,referrer:Be.referrer,visitorId:Be.visitorId};let je=typeof k.visitor=="object"&&k.visitor!==null?k.visitor:{},mu=typeof je.client=="object"&&je.client!==null?je.client:{};k.visitor={...je,client:{...mu,memoryUserId:Be.memoryUserId}}}let xe=typeof k.extra=="object"&&k.extra!==null&&!Array.isArray(k.extra)?k.extra:void 0,de=m.current?.memoryUserId,ne=m.current?.language,wa={};if(de&&(wa.memoryUserId=de),ne&&(wa.locale=ne),(Object.keys(wa).length>0||xe)&&(k.extra={...wa,...xe??{}}),d.current)if(Object.hasOwn(k,"threadId"))typeof k.threadId=="string"&&(g.current=k.threadId);else{let je=g.current;je||(je=Vl(),R.current=ho(),_.current=void 0,U(je)),k.threadId=je}return k},fetch:(async(k,N)=>{let H=await fetch(k,N);return p.current=void 0,Ne(H.headers.get(Nh)),H})})),we=le(null),ve=le(null),Ce=le({}),[be,Qe]=pt(0),O=e.skipRemoteConfig===!0,ue=he(async()=>{if(!O)try{let k=await Uh(t,u.current);Ce.current=k,Qe(N=>N+1)}catch(k){console.warn("[WaniWani] Failed to fetch tool definitions:",k instanceof Error?k.message:k)}},[t,O]);De(()=>{ue()},[ue]);let{messages:ee,sendMessage:X,setMessages:ae,status:q}=_h({messages:e.initialMessages,transport:te.current,onFinish({message:k}){s?.(),we.current&&(ve.current=k)},onError(k){console.warn("[WaniWani] Chat error:",k.message),we.current&&(we.current.reject(k),we.current=null)}}),j=le(ee);De(()=>{j.current=ee},[ee]);let V=le(n);De(()=>{if(!n||V.current||(V.current=!0,j.current.length>0))return;let k=!1,N=y.current;return v(!1),(async()=>{try{let H=m.current;if(!H)try{H=await Br(),m.current=H}catch{}let xe=H?.memoryUserId;if(!xe||k||N!==y.current){k||v(!0);return}let de=i??await Dr(xe);if(k||N!==y.current)return;if(de){let ne=await mo(de);if(k||N!==y.current)return;ne&&ne.memoryUserId===xe&&(g.current=ne.threadId,C(ne.threadId),R.current=ne.createdAt,_.current=ne.title,ne.sessionId&&(L.current=ne.sessionId,I(ne.sessionId)),ae(ne.messages))}await F()}finally{k||v(!0)}})(),()=>{k=!0}},[n]),De(()=>{if(q==="ready"&&we.current&&ve.current){let k=we.current,N=ve.current;we.current=null,ve.current=null,k.resolve(N)}},[q]);let[J,K]=pt(""),[se,ke]=pt([]),Me=q==="submitted"||q==="streaming",mt=he(k=>{ke(N=>N.filter(H=>H.id!==k))},[]),ht=Me&&se.length>0,nu=he(k=>{let N=!!k.text?.trim(),H=!!k.files?.length;if(N||H){if(Me){if(se.length>0)return;ke(xe=>[...xe,{id:Qt(),text:k.text||"",files:k.files??[],modelContext:k.modelContext}]),K("");return}p.current=k.modelContext,X({text:k.text||"",files:k.files}),r?.(k.text||""),K("")}},[X,r,Me,se.length]),iu=he(k=>new Promise((N,H)=>{we.current={resolve:N,reject:H},X({text:k}),r?.(k)}),[X,r]);De(()=>{if(q!=="ready"||se.length===0)return;let[k,...N]=se;ke(N),p.current=k.modelContext,X({text:k.text,files:k.files.length>0?k.files:void 0}),r?.(k.text)},[q,X,r,se]);let lu=he(()=>{ae([]),ke([]),ye(),K(""),Ce.current={},Qe(k=>k+1),ue()},[ae,ye,ue]),ha=he(()=>{if(!d.current)return;let k=m.current?.memoryUserId,N=g.current,H=j.current;if(!(!k||!N||H.length===0)){if(R.current||(R.current=ho()),!_.current){let xe=H.find(ne=>ne.role==="user"),de=xe?xe.parts.map(ne=>"text"in ne&&typeof ne.text=="string"?ne.text:"").join(" "):"";_.current=Gl(de)}return{threadId:N,memoryUserId:k,title:_.current,messages:H,sessionId:L.current,createdAt:R.current,updatedAt:ho()}}},[]),Nr=he(async()=>{let k=ha();k&&(await Fr(k),await F())},[ha,F]);De(()=>{if(n&&A&&!(q==="submitted"||q==="streaming")&&ee.length!==0)return M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{M.current=void 0;let k=Nr().finally(()=>{T.current===k&&(T.current=void 0)});T.current=k},Oh),()=>{M.current&&clearTimeout(M.current)}},[n,A,ee,q,Nr]);let ga=he(()=>{let k=T.current,N=M.current,H=N?ha():void 0;return N&&(clearTimeout(N),M.current=void 0),(async()=>{k&&await k,H&&(await Fr(H),await F())})()},[ha,F]),uu=he(()=>{y.current+=1,ga(),ae([]),ke([]),ye(),K("");let k=Vl();return R.current=ho(),_.current=void 0,U(k),F(),k},[ae,ye,U,F,ga]),go=he(async k=>{y.current+=1;let N=y.current;if(await ga(),N!==y.current)return;let H=await mo(k);N===y.current&&H&&(U(H.threadId),R.current=H.createdAt,_.current=H.title,H.sessionId?(L.current=H.sessionId,I(H.sessionId)):ye(),ae(H.messages),ke([]),K(""))},[ae,ye,U,ga]),du=he(async k=>{if(g.current===k){y.current+=1,M.current&&(clearTimeout(M.current),M.current=void 0);let N=T.current;N&&await N}await Wl(k),await F(),g.current===k&&(ae([]),ke([]),ye(),K(""),g.current=void 0,C(void 0),R.current=void 0,_.current=void 0)},[ae,ye,F]);De(()=>{n&&A&&i!==void 0&&i!==g.current&&go(i)},[i,n,A,go]);let cu=he(k=>{K(k.target.value)},[]),Or=ee[ee.length-1],Ur=ee.length>0,fu=Me&&(!Ur||Or.role==="user"),pu=Ce.current;return{messages:ee,status:q,text:J,setText:K,handleSubmit:nu,handleTextChange:cu,isLoading:Me,showLoaderBubble:fu,lastMessage:Or,hasMessages:Ur,sendMessage:X,sendMessageAndWait:iu,reset:lu,queuedMessages:se,queueFull:ht,removeQueuedMessage:mt,sessionId:h,toolDefinitions:pu,refreshToolDefinitions:ue,threads:b,activeThreadId:S,isThreadHistoryReady:A,startNewThread:uu,switchThread:go,deleteThread:du}}f();import{useEffect as Kl,useRef as Hh,useState as qh}from"react";var Wh={debug:!1,eval:!1};function Ql(e="/api/waniwani",t,a=!1){let[o,r]=qh(Wh),s=Hh(t);return Kl(()=>{s.current=t},[t]),Kl(()=>{a||(async()=>{try{let n=s.current,l=await(await fetch(`${e}/config`,{headers:n?{...n}:void 0})).json();r({debug:l.debug===!0,eval:l.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as Gh,useEffect as Er,useRef as jh,useState as zh}from"react";function Vh(e){for(let t of e.parts){let a=t;if(a.type==="data"||a.type==="data-suggestions"){let o=a.data;if(o&&Array.isArray(o.suggestions))return o.suggestions}}return null}function Jl(e){return typeof e=="object"&&e!==null&&"initial"in e}function Zl(e){let{messages:t,status:a,config:o}=e,r=Jl(o)&&o.initial?o.initial:void 0,[s,n]=zh(r??[]),i=jh(a),l=o===!0||Jl(o)&&o.dynamic!==!1,u=Gh(()=>{n([])},[]),c=t.length>0;Er(()=>{!c&&r&&r.length>0&&n(r)},[r,c]);let d=t[t.length-1];return Er(()=>{d?.role==="user"&&u()},[d,u]),Er(()=>{let p=i.current;if(i.current=a,p==="streaming"&&a==="ready"&&l){let m=[...t].reverse().find(I=>I.role==="assistant");if(!m)return;let h=Vh(m);h&&n(h)}},[a,l,t]),{suggestions:s,isLoading:!1,clear:u}}f();import{useEffect as $h,useRef as Xh,useState as Kh}from"react";var Qh=50,Jh=30,Zh=2e3,Yl=500;function eu(e,t=!0){let[a,o]=Kh(""),r=Xh(void 0);return $h(()=>{if(!t){o("");return}let s=0,n=!1,i=!1,l=()=>{i||(n?(s--,o(e.slice(0,s)),s<=0?(n=!1,r.current=setTimeout(l,Yl)):r.current=setTimeout(l,Jh)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(l,Zh)):r.current=setTimeout(l,Qh)))};return r.current=setTimeout(l,Yl),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}f();function tu(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return o?`${e}/resource?token=${encodeURIComponent(o)}`:`${e}/resource`}f();var Yh={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",borderWidth:0,boxShadow:"none",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:12,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5"};var eg={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],borderWidth:["--ww-border-width"],boxShadow:["--ww-shadow"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"]};function au(e){return{...Yh,...e}}function ou(e){let t={};for(let[a,o]of Object.entries(eg)){let r=e[a];if(r===void 0)continue;let s=typeof r=="number"?`${r}px`:String(r);for(let n of o)t[n]=s}return t}import{jsx as ge,jsxs as ma}from"react/jsx-runtime";var rg=tg(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:h,enableThreadHistory:I=!1,showToolCalls:L=!0}=t,S=m??"/api/waniwani",C=tu(S,t.headers),g=au(o),b=ou(g),P=g.backgroundColor.replace("#",""),A=parseInt(P.substring(0,2),16),v=parseInt(P.substring(2,4),16),R=parseInt(P.substring(4,6),16),_=(A*299+v*587+R*114)/1e3<128,M=Ql(S,t.headers,t.skipRemoteConfig),T=h??M.debug,y=Xl({...t,api:S}),B=_l({...t,api:S,sessionId:y.sessionId}),U=eu(d,!y.text),[F,Q]=su(!1),[Ne,ye]=su(null),te=ru(null),we=ru(void 0),ve=_r(()=>{let O=te.current;if(!O)return;O.scrollIntoView({behavior:"smooth",block:"center"});let ue=O.querySelector("textarea");ue&&setTimeout(()=>ue.focus(),300),Q(!0),clearTimeout(we.current),we.current=setTimeout(()=>Q(!1),2e3)},[]),Ce=Zl({messages:y.messages,status:y.status,config:t.suggestions}),be=_r(O=>{let ue=O.content.map(ee=>ee.text??"").join("").trim();ue&&y.handleSubmit({text:ue,files:[],modelContext:O.modelContext})},[y.handleSubmit]),Qe=_r(O=>{Ce.clear(),y.handleSubmit({text:O,files:[]})},[Ce.clear,y.handleSubmit]);return og(a,()=>({sendMessage:O=>{y.handleSubmit({text:O,files:[]}),ve()},sendMessageAndWait:O=>y.sendMessageAndWait(O),reset:y.reset,focus:ve,get messages(){return y.messages},get sessionId(){return y.sessionId}}),[y.handleSubmit,y.sendMessageAndWait,y.reset,y.messages,y.sessionId,ve]),ag(()=>{if(!p)return;let O=ue=>{let ee=ue.detail,X=typeof ee?.message=="string"?ee.message:void 0;X&&y.handleSubmit({text:X,files:[]}),ve()};return window.addEventListener(p,O),()=>window.removeEventListener(p,O)},[p,y.handleSubmit,ve]),ma("div",{ref:te,style:{...b,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",..._?{"data-waniwani-dark":""}:{},className:D("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",F&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[ma("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[ge("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),ge(In,{messages:y.messages,evalEnabled:M.eval,api:S}),I&&ge(El,{threads:y.threads,activeThreadId:y.activeThreadId,onNewThread:y.startNewThread,onSelectThread:O=>{y.switchThread(O)},onDeleteThread:O=>{y.deleteThread(O)}})]}),ma(Js,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[ge(Zs,{scrollClassName:Ne?"ww:!relative ww:!overflow-hidden":void 0,children:ge(Rl,{messages:y.messages,status:y.status,welcomeMessage:u,welcome:c,onSuggestionSelect:Qe,resourceEndpoint:C,chatSessionId:y.sessionId,isDark:_,onFollowUp:be,onCallTool:B,fullscreenToolCallId:Ne,debug:T,showToolCalls:L,toolDefinitions:y.toolDefinitions,onWidgetDisplayModeChange:(O,ue)=>{ye(O==="fullscreen"?ue.toolCallId:null)}})}),ge(Ys,{})]}),ge("div",{style:Ne?{display:"none"}:void 0,children:ge(Dl,{suggestions:Ce.suggestions,isLoading:Ce.isLoading,onSelect:Qe})}),ge("div",{style:Ne?{display:"none"}:void 0,children:ge(xn,{queuedMessages:y.queuedMessages,onRemove:y.removeQueuedMessage})}),ge("div",{style:Ne?{display:"none"}:void 0,children:ge("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:ma("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[ge(sn,{onSubmit:y.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:ma("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&ge(un,{}),ge(nn,{onChange:y.handleTextChange,value:y.text,placeholder:U,className:"ww:min-h-0 ww:py-1 ww:px-0"}),ge(ln,{status:y.status,disabled:y.queueFull})]})}),ge(Fl,{})]})})})]})});export{rg as ChatCard,ns as DevModeProvider,Su as InitializeNextJsInIframe,od as LoadingWidget,ms as WidgetProvider,ts as createResource,xu as createTool,wo as detectPlatform,Sa as getMockState,Ft as initializeMockOpenAI,gu as isMCPApps,hu as isOpenAI,Lu as registerTools,CL as toNextJsHandler,ds as unstable_useSendFollowUpWithGhostGuard,Bt as updateMockDisplayMode,at as updateMockGlobal,Et as updateMockTheme,Dt as updateMockToolOutput,hs as useCallTool,gs as useDisplayMode,ws as useFlowAction,xs as useIsChatGptApp,Ls as useLocale,Cs as useMaxHeight,Is as useOpenExternal,Ss as useRequestDisplayMode,ys as useSafeArea,bs as useSendFollowUp,ks as useTheme,ba as useToolOutput,Ts as useToolResponseMetadata,vs as useUpdateModelContext,W as useWidgetClient,Ps as useWidgetState};
81
+ ${te}`}]}}_.current({...z,...K?{modelContext:K}:{}})}U({jsonrpc:"2.0",id:G,result:{}});return}if(ne==="ui/update-model-context"&&G!=null){ye=Vr(ye,Z.params),U({jsonrpc:"2.0",id:G,result:{}});return}if(ne==="tools/call"&&G!=null){let z=T.current;if(!z){U({jsonrpc:"2.0",id:G,error:{code:-32601,message:"tools/call not supported"}});return}let K=Z.params?.name;z({name:K,arguments:Z.params?.arguments??{}}).then(te=>{U({jsonrpc:"2.0",id:G,result:te});let Y=te.content?.map(le=>le.text??"").join("").trim();Y&&fh(K,te,v.current)&&(ke&&clearTimeout(ke.timer),ke={text:Y,timer:setTimeout(()=>{if(Ce)return;let le=ye;ye=null,ke=null,_.current?.({role:"user",content:[{type:"text",text:Y}],...le?{modelContext:le}:{}})},500)})}).catch(te=>{let Y=te instanceof Error?te.message:"Tool call failed";U({jsonrpc:"2.0",id:G,error:{code:-32e3,message:Y}})});return}if(ne==="ui/request-display-mode"&&G!=null){let z=Z.params?.mode,K=z==="fullscreen"||z==="inline"||z==="pip"?z:"inline";A.current=K,U({jsonrpc:"2.0",id:G,result:{mode:K}}),U({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:K}}),B.current?.(K);return}if(ne==="ui/resource-teardown"&&G!=null){U({jsonrpc:"2.0",id:G,result:{}});return}ne==="ping"&&G!=null&&U({jsonrpc:"2.0",id:G,result:{}})};return window.addEventListener("message",fe),()=>{Ce=!0,clearTimeout(Qe),ke&&clearTimeout(ke.timer),window.removeEventListener("message",fe)}},[i,q]),ph("iframe",{ref:h,src:Le,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:F(!p&&"ww:rounded-md ww:border ww:border-border",s),style:{height:p?"100%":R,minWidth:p||!M?void 0:`min(${M}px, 100%)`,width:"100%",border:"none",colorScheme:n?"dark":"auto"},title:"MCP App"})}f();import{jsx as wa,jsxs as mh}from"react/jsx-runtime";function Ol({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return mh("div",{className:"ww:flex ww:flex-col ww:items-center ww:justify-center ww:py-12 ww:px-6 ww:text-center ww:min-h-full",children:[e&&wa("div",{className:"ww:mb-4 ww:flex ww:items-center ww:justify-center ww:size-12 ww:rounded-xl ww:bg-foreground ww:text-background",children:e}),wa("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&wa("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&wa("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((n,s)=>wa("button",{type:"button",onClick:()=>r?.(n),className:F("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${s*50}ms`},children:n},n))})]})}f();import{Component as hh}from"react";import{jsx as Mr,jsxs as wh}from"react/jsx-runtime";function gh({onRetry:e}){let{t}=V();return wh("div",{className:"ww:flex ww:items-center ww:justify-between ww:rounded-md ww:border ww:border-border ww:bg-muted/50 ww:px-4 ww:py-3 ww:text-sm ww:text-muted-foreground",children:[Mr("span",{children:t.widgetErrorBoundary.failedToLoad}),Mr("button",{type:"button",onClick:e,className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:t.widgetErrorBoundary.retry})]})}var fo=class extends hh{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[Waniwani] Widget failed to render:",t.message)}render(){return this.state.hasError?Mr(gh,{onRetry:()=>this.setState({hasError:!1})}):this.props.children}};import{Fragment as Lh,jsx as J,jsxs as ot}from"react/jsx-runtime";function Fr(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function xh(e){return e&&/search|find|lookup|query|web|browse|google/i.test(e)?Vt:$e}function Ul({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:n,chatSessionId:s,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:p,showToolCalls:m=!0,toolDefinitions:h}){let I=e[e.length-1],L=e.length>0,S=d!=null,C=!S&&Dl(e,t,{ignoreToolParts:m===!1,ignoreReasoningParts:m===!1});return ot(Lh,{children:[!S&&(!L&&o?J(Ol,{...o,onSuggestionSelect:r}):a&&J(yr,{from:"assistant",children:J(br,{children:J(co,{children:a})})})),e.map(g=>{let y=g.parts.filter(k=>k.type==="text"),A=g.parts.filter(k=>k.type==="reasoning"),R=g.parts.filter(k=>k.type==="file"),P=g.parts.filter(k=>"toolCallId"in k),M=g.parts.filter(k=>k.type==="reasoning"||"toolCallId"in k),N=g===I&&g.role==="assistant",D=y.length>0,_=S?P.some(k=>k.toolCallId===d):!1,T=P.some(k=>k.state==="input-available"||k.state==="input-streaming"),B=m!==!1&&!_&&P.length>=1&&M.length>=2;return S&&!_?J("div",{style:{display:"none"}},g.id):g.role==="assistant"&&!Fl(g)?J("div",{style:{display:"none"}},g.id):m===!1&&g.role==="assistant"&&!D&&R.length===0&&P.every(k=>{let v="output"in k?k.output:void 0;return v===void 0||!n||!ga(k.toolName,v,h)})?J("div",{style:{display:"none"}},g.id):ot(yr,{from:g.role,children:[m!==!1&&!_&&!B&&A.map((k,v)=>ot(ea,{isStreaming:k.state==="streaming",children:[J(ta,{}),J(aa,{children:k.text})]},`reasoning-${g.id}-${v}`)),B&&ot(Es,{isWorking:T||A.some(k=>k.state==="streaming"),children:[J(_s,{label:P[P.length-1].title??Fr(P[P.length-1].toolName)}),J(Ns,{children:M.map((k,v)=>{let q=v===M.length-1;if(k.type==="reasoning")return J(Us,{isStreaming:k.state==="streaming",isLast:q,children:k.text},`reasoning-${g.id}-${v}`);let Le=k.title??Fr(k.toolName),ie=xh(k.toolName);if(m==="titles-only")return J(Go,{icon:ie,title:Le,state:k.state,isLast:q},k.toolCallId);let X="output"in k?k.output:void 0;return ot(Go,{icon:ie,title:Le,state:k.state,isLast:q,children:[J(Ar,{input:k.input,debug:p}),X!==void 0&&J(Rr,{output:X,errorText:"errorText"in k?k.errorText:void 0,debug:p})]},k.toolCallId)})})]}),m!==!1&&!_&&!B&&P.length===1&&(()=>{let k=P[0],v=k.title??Fr(k.toolName);if(m==="titles-only")return J(kl,{title:v,state:k.state});let q="output"in k?k.output:void 0;return ot(yl,{children:[J(bl,{title:v,state:k.state}),ot(Tl,{children:[J(Ar,{input:k.input,debug:p}),q!==void 0&&J(Rr,{output:q,errorText:"errorText"in k?k.errorText:void 0,debug:p})]})]})})(),P.map(k=>{let v="output"in k?k.output:void 0,q=ga(k.toolName,v,h),Le=Al(k.toolName,v,h),ie=k.toolCallId===d;return q&&n&&v!==void 0?J("div",{style:ie?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:q&&n&&v!==void 0&&J(fo,{children:J(Nl,{isFullscreen:ie,resourceUri:q,toolInput:k.input??{},toolResult:{content:v.content,structuredContent:v.structuredContent,_meta:v._meta},resourceEndpoint:n,chatSessionId:s,isDark:i,autoHeight:Le,toolDefinitions:h,onFollowUp:l,onCallTool:u,onDisplayModeChange:c?X=>c(X,{toolCallId:k.toolCallId,resourceUri:q,toolInput:k.input??{},toolResult:{content:v.content,structuredContent:v.structuredContent,_meta:v._meta},autoHeight:Le}):void 0})})},k.toolCallId):null}),!_&&J("div",{children:ot(br,{children:[R.length>0&&J(Ps,{files:R}),D?y.map((k,v)=>{let q=N&&t==="streaming"&&v===y.length-1;return J(co,{isStreaming:q,children:k.type==="text"?k.text:""},`${g.id}-${v}`)}):null]})})]},g.id)}),C&&J(Bl,{})]})}f();import{jsx as Hl,jsxs as Sh}from"react/jsx-runtime";var Ch="https://app.waniwani.ai/assets/waniwani-logo.svg",Ih="https://waniwani.ai";function ql(){let{t:e}=V();return Sh("a",{href:Ih,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[Hl("span",{children:e.poweredBy.label}),Hl("img",{src:Ch,alt:"Waniwani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}f();import{jsx as po}from"react/jsx-runtime";function Wl({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:po("div",{className:F("ww:px-4 ww:py-2",o),...r,children:po("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(n=>po("div",{className:"ww:h-7 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+n*20}px`}},n)):e.map((n,s)=>po("button",{type:"button",onClick:()=>a(n),className:F("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3 ww:py-1 ww:text-xs","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${s*50}ms`},children:n},n))})})}f();import{useEffect as yh,useRef as bh,useState as kh}from"react";import{jsx as oe,jsxs as gt}from"react/jsx-runtime";var Gl=20;function Th({label:e}){return gt("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[oe("title",{children:e}),oe("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),oe("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function vh({label:e}){return gt("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[oe("title",{children:e}),oe("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),oe("polyline",{points:"3 4 3 9 8 9"}),oe("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),oe("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function Ph({label:e}){return gt("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[oe("title",{children:e}),oe("polyline",{points:"3 6 5 6 21 6"}),oe("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),oe("path",{d:"M10 11v6"}),oe("path",{d:"M14 11v6"})]})}function jl({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let{locale:n,t:s}=V(),[i,l]=kh(!1),u=bh(null);yh(()=>{if(!i)return;let p=m=>{let h=u.current;h&&(m.composedPath().includes(h)||l(!1))};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[i]);let c=e.slice(0,Gl),d=Math.max(0,e.length-Gl);return gt("div",{ref:u,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[oe("button",{type:"button",onClick:a,title:s.threadMenu.newChat,"aria-label":s.threadMenu.newChat,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:oe(Th,{label:s.threadMenu.newChat})}),oe("button",{type:"button",onClick:()=>l(p=>!p),title:s.threadMenu.threadHistory,"aria-label":s.threadMenu.threadHistory,"aria-expanded":i,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:oe(vh,{label:s.threadMenu.threadHistory})}),i&&gt("div",{role:"menu",className:"ww:absolute ww:right-0 ww:top-full ww:mt-1 ww:w-72 ww:max-h-80 ww:overflow-y-auto ww:rounded-lg ww:border ww:border-border ww:bg-background ww:shadow-lg ww:z-50",children:[c.length===0&&oe("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:s.threadMenu.noPreviousChats}),c.map(p=>{let m=p.threadId===t,h=Date.parse(p.updatedAt);return gt("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${m?"ww:bg-foreground/5":""}`,children:[gt("button",{type:"button",onClick:()=>{o(p.threadId),l(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[oe("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:p.title}),oe("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Number.isNaN(h)?"":_o(h,n)})]}),oe("button",{type:"button",onClick:I=>{I.stopPropagation(),r(p.threadId)},title:s.threadMenu.deleteThread,"aria-label":s.threadMenu.deleteThread,className:"ww:p-1 ww:rounded ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/10 ww:transition-colors ww:cursor-pointer",children:oe(Ph,{label:s.threadMenu.deleteThread})})]},p.threadId)}),d>0&&oe("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:s.threadMenu.hiddenThreads(d)})]})]})}f();import{useCallback as Ah,useRef as Rh}from"react";function zl(e){let t=Rh(e);return t.current=e,Ah(async a=>{let{api:o,headers:r,onCallTool:n,sessionId:s}=t.current;if(n)return n(a);let i=`${o??"/api/waniwani"}/tool`,l=typeof s=="string"&&s.trim().length>0?s.trim():void 0,u=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...l?{"X-Session-Id":l}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}f();import{useChat as $h}from"@ai-sdk/react";import{useCallback as we,useEffect as Be,useRef as ce,useState as wt}from"react";f();import{DefaultChatTransport as Mh,uiMessageChunkSchema as Fh}from"ai";function Dh(e){let t=e?.cause,a=t?.issues??t?.errors;if(!Array.isArray(a))return null;let o=a.find(r=>r.code==="invalid_union");if(!o?.errors)return null;for(let r of o.errors){if(!Array.isArray(r)||r.some(i=>(i.code==="invalid_value"||i.code==="invalid_literal")&&i.path?.[0]==="type"))continue;let s=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(s.length>0)return s}return null}var mo=class extends Mh{processResponseStream(t){let a="",o=Fh(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(n,s){a+=n;let i=a.split(`
82
+ `);a=i.pop()??"";for(let l of i){let u=l.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){s.enqueue(d);continue}let p=await r(d);if(p.success){s.enqueue(p.value);continue}let m=Dh(p.error);if(m?.length){let h={...d};for(let L of m)delete h[L];let I=await r(h);I.success&&s.enqueue(I.value)}}catch{}}}}))}};f();f();var Bh="waniwani-memory";var Me="threads",ho="by_memoryUserId",Eh="by_updatedAt";var $l="memoryUserId",Vl="waniwani-memory-user-id",Dr=null;function Br(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function _h(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Me)){let a=e.createObjectStore(Me,{keyPath:"threadId"});a.createIndex(ho,"memoryUserId",{unique:!1}),a.createIndex(Eh,"updatedAt",{unique:!1})}}async function Er(){return new Promise((e,t)=>{let a=indexedDB.open(Bh,2);a.onupgradeneeded=o=>{_h(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function Nh(){return Er()}async function Oh(e){return new Promise((t,a)=>{let n=e.transaction("ids","readonly").objectStore("ids").get($l);n.onsuccess=()=>t(typeof n.result=="string"?n.result:null),n.onerror=()=>a(n.error)})}async function Uh(e,t){return new Promise((a,o)=>{let s=e.transaction("ids","readwrite").objectStore("ids").put(t,$l);s.onsuccess=()=>a(),s.onerror=()=>o(s.error)})}async function Hh(){if(typeof indexedDB>"u")return null;try{let e=await Nh();try{let t=await Oh(e);if(t)return t;let a=Br();return await Uh(e,a),a}finally{e.close()}}catch{return null}}function qh(){try{let e=localStorage.getItem(Vl);if(e)return e;let t=Br();return localStorage.setItem(Vl,t),t}catch{return null}}async function Xl(){let e=await Hh();if(e)return e;let t=qh();return t||(Dr||(Dr=Br()),Dr)}var Kl=50,Ql=1e3;function go(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.threadId=="string"&&typeof t.memoryUserId=="string"&&typeof t.title=="string"&&Array.isArray(t.messages)&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"}async function wo(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await Er(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function _r(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function Nr(e){return await wo(async a=>{let n=a.transaction(Me,"readonly").objectStore(Me).index(ho),i=(await _r(n.getAll(e))??[]).filter(go);return i.sort((l,u)=>l.updatedAt<u.updatedAt?1:-1),i})??[]}async function xo(e){return await wo(async a=>{let r=a.transaction(Me,"readonly").objectStore(Me),n=await _r(r.get(e));return go(n)?n:null})??null}async function Or(e){if(!go(e))return;let t=e.messages.length>Ql?{...e,messages:e.messages.slice(e.messages.length-Ql)}:e;await wo(async a=>{await new Promise((l,u)=>{let c=a.transaction(Me,"readwrite");c.oncomplete=()=>l(),c.onerror=()=>u(c.error),c.onabort=()=>u(c.error),c.objectStore(Me).put(t)});let o=a.transaction(Me,"readwrite"),r=o.objectStore(Me),n=r.index(ho),i=(await _r(n.getAll(t.memoryUserId))??[]).filter(go);if(i.length>Kl){i.sort((u,c)=>u.updatedAt<c.updatedAt?-1:1);let l=i.slice(0,i.length-Kl);for(let u of l)r.delete(u.threadId)}return await new Promise((l,u)=>{o.oncomplete=()=>l(),o.onerror=()=>u(o.error),o.onabort=()=>u(o.error)}),null})}async function Jl(e){await wo(async t=>(await new Promise((a,o)=>{let r=t.transaction(Me,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(Me).delete(e)}),null))}async function Ur(e){return(await Nr(e))[0]?.threadId??null}function Zl(e){let t=e.trim();if(!t)return`Conversation on ${new Date().toISOString().slice(0,10)}`;let a=t.split(/\r?\n/,1)[0]??t;return a.length<=60?a:`${a.slice(0,60).trimEnd()}\u2026`}f();var Yl="waniwani-visitor-id";function eu(e,t){return e.match(t)?.[1]??null}function Wh(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,o]of t){let r=eu(e,o);if(r)return{name:a,version:r}}return null}function Gh(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,o]of t){let r=eu(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function jh(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function zh(e){let t=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}async function Vh(){try{let a=localStorage.getItem(Yl);if(a)return a}catch{}let e=[navigator.userAgent,screen.width,screen.height,screen.colorDepth,Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.language,navigator.hardwareConcurrency??"",navigator.platform??""].join("|"),t=await zh(e);try{localStorage.setItem(Yl,t)}catch{}return t}async function Hr(){let e=navigator.userAgent,[t,a]=await Promise.all([Vh(),Xl()]);return{userAgent:e,browser:Wh(e),os:Gh(e),deviceType:jh(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t,memoryUserId:a}}var Xh="x-session-id",Kh=250;function tu(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Zt()}function Lo(){return new Date().toISOString()}function au(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function Qh(e,t){let a=`${e.replace(/\/$/,"")}/tools`,o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[Waniwani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let n={};for(let s of r.tools)s&&typeof s.name=="string"&&(n[s.name]=s);return n}function ou(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:n,enableThreadHistory:s=!1,activeThreadId:i,onThreadChange:l}=e,u=ce(a),c=ce(o),d=ce(s);Be(()=>{d.current=s},[s]);let p=ce(void 0),m=ce(null),[h,I]=wt(void 0),L=ce(h),[S,C]=wt(i),g=ce(S),[y,A]=wt([]),[R,P]=wt(!s),M=ce(void 0),N=ce(void 0),D=ce(void 0),_=ce(void 0),T=ce(0),B=ce(l);Be(()=>{B.current=l},[l]);let k=we(b=>{g.current=b,C(b),b&&B.current?.(b)},[]),v=we(async()=>{if(!s)return;let b=m.current?.memoryUserId;if(!b)return;let O=await Nr(b);A(O)},[s]),q=we(()=>L.current,[]),Le=we(b=>{let O=au(b);O&&L.current!==O&&(L.current=O,I(O))},[]),ie=we(()=>{L.current=void 0,I(void 0)},[]);Be(()=>{u.current=a},[a]),Be(()=>{c.current=o},[o]),Be(()=>{let b=!1,O=T.current;return(async()=>{try{let Ie=await Hr();if(b)return;m.current=Ie}catch{}if(!s)return;let H=m.current?.memoryUserId;if(!H){P(!0);return}try{let Ie=i??await Ur(H);if(b||O!==T.current)return;if(Ie){let pe=await xo(Ie);if(b||O!==T.current)return;pe&&pe.memoryUserId===H&&(g.current=pe.threadId,C(pe.threadId),M.current=pe.createdAt,N.current=pe.title,pe.sessionId&&(L.current=pe.sessionId,I(pe.sessionId)),ne(pe.messages))}await v()}finally{b||P(!0)}})(),()=>{b=!0}},[]);let X=ce(new mo({api:t,headers:()=>({...u.current}),body:()=>{let b={...c.current??{}},O=Object.hasOwn(b,"sessionId"),H=au(b.sessionId);if(H)Le(H),b.sessionId=H;else if(O)ie(),delete b.sessionId;else{let Ee=q();Ee&&(b.sessionId=Ee)}if(Ct(p.current)&&(b.modelContext=p.current),m.current){let Ee=m.current;b.visitorContext={timezone:Ee.timezone,language:Ee.language,languages:Ee.languages,deviceType:Ee.deviceType,referrer:Ee.referrer,visitorId:Ee.visitorId};let ze=typeof b.visitor=="object"&&b.visitor!==null?b.visitor:{},yu=typeof ze.client=="object"&&ze.client!==null?ze.client:{};b.visitor={...ze,client:{...yu,memoryUserId:Ee.memoryUserId}}}let Ie=typeof b.extra=="object"&&b.extra!==null&&!Array.isArray(b.extra)?b.extra:void 0,pe=m.current?.memoryUserId,ue=m.current?.language,Ia={};if(pe&&(Ia.memoryUserId=pe),ue&&(Ia.locale=ue),(Object.keys(Ia).length>0||Ie)&&(b.extra={...Ia,...Ie??{}}),d.current)if(Object.hasOwn(b,"threadId"))typeof b.threadId=="string"&&(g.current=b.threadId);else{let ze=g.current;ze||(ze=tu(),M.current=Lo(),N.current=void 0,k(ze)),b.threadId=ze}return b},fetch:(async(b,O)=>{let H=await fetch(b,O);return p.current=void 0,Le(H.headers.get(Xh)),H})})),Ce=ce(null),Pe=ce(null),ye=ce({}),[ke,Qe]=wt(0),U=e.skipRemoteConfig===!0,fe=we(async()=>{if(!U)try{let b=await Qh(t,u.current);ye.current=b,Qe(O=>O+1)}catch(b){console.warn("[Waniwani] Failed to fetch tool definitions:",b instanceof Error?b.message:b)}},[t,U]);Be(()=>{fe()},[fe]);let{messages:re,sendMessage:Z,setMessages:ne,status:G}=$h({messages:e.initialMessages,transport:X.current,onFinish({message:b}){n?.(),Ce.current&&(Pe.current=b)},onError(b){console.warn("[Waniwani] Chat error:",b.message),Ce.current&&(Ce.current.reject(b),Ce.current=null)}}),z=ce(re);Be(()=>{z.current=re},[re]);let K=ce(s);Be(()=>{if(!s||K.current||(K.current=!0,z.current.length>0))return;let b=!1,O=T.current;return P(!1),(async()=>{try{let H=m.current;if(!H)try{H=await Hr(),m.current=H}catch{}let Ie=H?.memoryUserId;if(!Ie||b||O!==T.current){b||P(!0);return}let pe=i??await Ur(Ie);if(b||O!==T.current)return;if(pe){let ue=await xo(pe);if(b||O!==T.current)return;ue&&ue.memoryUserId===Ie&&(g.current=ue.threadId,C(ue.threadId),M.current=ue.createdAt,N.current=ue.title,ue.sessionId&&(L.current=ue.sessionId,I(ue.sessionId)),ne(ue.messages))}await v()}finally{b||P(!0)}})(),()=>{b=!0}},[s]),Be(()=>{if(G==="ready"&&Ce.current&&Pe.current){let b=Ce.current,O=Pe.current;Ce.current=null,Pe.current=null,b.resolve(O)}},[G]);let[te,Y]=wt(""),[le,Te]=wt([]),Fe=G==="submitted"||G==="streaming",xt=we(b=>{Te(O=>O.filter(H=>H.id!==b))},[]),Lt=Fe&&le.length>0,hu=we(b=>{let O=!!b.text?.trim(),H=!!b.files?.length;if(O||H){if(Fe){if(le.length>0)return;Te(Ie=>[...Ie,{id:Zt(),text:b.text||"",files:b.files??[],modelContext:b.modelContext}]),Y("");return}p.current=b.modelContext,Z({text:b.text||"",files:b.files}),r?.(b.text||""),Y("")}},[Z,r,Fe,le.length]),gu=we(b=>new Promise((O,H)=>{Ce.current={resolve:O,reject:H},Z({text:b}),r?.(b)}),[Z,r]);Be(()=>{if(G!=="ready"||le.length===0)return;let[b,...O]=le;Te(O),p.current=b.modelContext,Z({text:b.text,files:b.files.length>0?b.files:void 0}),r?.(b.text)},[G,Z,r,le]);let wu=we(()=>{ne([]),Te([]),ie(),Y(""),ye.current={},Qe(b=>b+1),fe()},[ne,ie,fe]),La=we(()=>{if(!d.current)return;let b=m.current?.memoryUserId,O=g.current,H=z.current;if(!(!b||!O||H.length===0)){if(M.current||(M.current=Lo()),!N.current){let Ie=H.find(ue=>ue.role==="user"),pe=Ie?Ie.parts.map(ue=>"text"in ue&&typeof ue.text=="string"?ue.text:"").join(" "):"";N.current=Zl(pe)}return{threadId:O,memoryUserId:b,title:N.current,messages:H,sessionId:L.current,createdAt:M.current,updatedAt:Lo()}}},[]),Gr=we(async()=>{let b=La();b&&(await Or(b),await v())},[La,v]);Be(()=>{if(s&&R&&!(G==="submitted"||G==="streaming")&&re.length!==0)return D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{D.current=void 0;let b=Gr().finally(()=>{_.current===b&&(_.current=void 0)});_.current=b},Kh),()=>{D.current&&clearTimeout(D.current)}},[s,R,re,G,Gr]);let Ca=we(()=>{let b=_.current,O=D.current,H=O?La():void 0;return O&&(clearTimeout(O),D.current=void 0),(async()=>{b&&await b,H&&(await Or(H),await v())})()},[La,v]),xu=we(()=>{T.current+=1,Ca(),ne([]),Te([]),ie(),Y("");let b=tu();return M.current=Lo(),N.current=void 0,k(b),v(),b},[ne,ie,k,v,Ca]),Co=we(async b=>{T.current+=1;let O=T.current;if(await Ca(),O!==T.current)return;let H=await xo(b);O===T.current&&H&&(k(H.threadId),M.current=H.createdAt,N.current=H.title,H.sessionId?(L.current=H.sessionId,I(H.sessionId)):ie(),ne(H.messages),Te([]),Y(""))},[ne,ie,k,Ca]),Lu=we(async b=>{if(g.current===b){T.current+=1,D.current&&(clearTimeout(D.current),D.current=void 0);let O=_.current;O&&await O}await Jl(b),await v(),g.current===b&&(ne([]),Te([]),ie(),Y(""),g.current=void 0,C(void 0),M.current=void 0,N.current=void 0)},[ne,ie,v]);Be(()=>{s&&R&&i!==void 0&&i!==g.current&&Co(i)},[i,s,R,Co]);let Cu=we(b=>{Y(b.target.value)},[]),jr=re[re.length-1],zr=re.length>0,Iu=Fe&&(!zr||jr.role==="user"),Su=ye.current;return{messages:re,status:G,text:te,setText:Y,handleSubmit:hu,handleTextChange:Cu,isLoading:Fe,showLoaderBubble:Iu,lastMessage:jr,hasMessages:zr,sendMessage:Z,sendMessageAndWait:gu,reset:wu,queuedMessages:le,queueFull:Lt,removeQueuedMessage:xt,sessionId:h,toolDefinitions:Su,refreshToolDefinitions:fe,threads:y,activeThreadId:S,isThreadHistoryReady:R,startNewThread:xu,switchThread:Co,deleteThread:Lu}}f();import{useEffect as ru,useRef as Jh,useState as Zh}from"react";var Yh={debug:!1,eval:!1};function nu(e="/api/waniwani",t,a=!1){let[o,r]=Zh(Yh),n=Jh(t);return ru(()=>{n.current=t},[t]),ru(()=>{a||(async()=>{try{let s=n.current,l=await(await fetch(`${e}/config`,{headers:s?{...s}:void 0})).json();r({debug:l.debug===!0,eval:l.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as eg,useEffect as qr,useRef as tg,useState as ag}from"react";function og(e){for(let t of e.parts){let a=t;if(a.type==="data"||a.type==="data-suggestions"){let o=a.data;if(o&&Array.isArray(o.suggestions))return o.suggestions}}return null}function su(e){return typeof e=="object"&&e!==null&&"initial"in e}function iu(e){let{messages:t,status:a,config:o}=e,r=su(o)&&o.initial?o.initial:void 0,[n,s]=ag(r??[]),i=tg(a),l=o===!0||su(o)&&o.dynamic!==!1,u=eg(()=>{s([])},[]),c=t.length>0;qr(()=>{!c&&r&&r.length>0&&s(r)},[r,c]);let d=t[t.length-1];return qr(()=>{d?.role==="user"&&u()},[d,u]),qr(()=>{let p=i.current;if(i.current=a,p==="streaming"&&a==="ready"&&l){let m=[...t].reverse().find(I=>I.role==="assistant");if(!m)return;let h=og(m);h&&s(h)}},[a,l,t]),{suggestions:n,isLoading:!1,clear:u}}f();import{useEffect as rg,useRef as ng,useState as sg}from"react";var ig=50,lg=30,ug=2e3,lu=500;function uu(e,t=!0){let[a,o]=sg(""),r=ng(void 0);return rg(()=>{if(!t){o("");return}let n=0,s=!1,i=!1,l=()=>{i||(s?(n--,o(e.slice(0,n)),n<=0?(s=!1,r.current=setTimeout(l,lu)):r.current=setTimeout(l,lg)):(n++,o(e.slice(0,n)),n>=e.length?(s=!0,r.current=setTimeout(l,ug)):r.current=setTimeout(l,ig)))};return r.current=setTimeout(l,lu),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}f();function du(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return o?`${e}/resource?token=${encodeURIComponent(o)}`:`${e}/resource`}f();var dg={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",borderWidth:0,boxShadow:"none",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:12,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5"};var cg={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],borderWidth:["--ww-border-width"],boxShadow:["--ww-shadow"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"]};function cu(e){return{...dg,...e}}function fu(e){let t={};for(let[a,o]of Object.entries(cg)){let r=e[a];if(r===void 0)continue;let n=typeof r=="number"?`${r}px`:String(r);for(let s of o)t[s]=n}return t}import{jsx as xe,jsxs as xa}from"react/jsx-runtime";var hg=fg(function(t,a){let{theme:o,title:r="Assistant",width:n,height:s,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:h,enableThreadHistory:I=!1,showToolCalls:L=!0}=t,S=m??"/api/waniwani",C=du(S,t.headers),g=cu(o),y=fu(g),A=g.backgroundColor.replace("#",""),R=parseInt(A.substring(0,2),16),P=parseInt(A.substring(2,4),16),M=parseInt(A.substring(4,6),16),N=(R*299+P*587+M*114)/1e3<128,D=nu(S,t.headers,t.skipRemoteConfig),_=h??D.debug,T=ou({...t,api:S}),B=zl({...t,api:S,sessionId:T.sessionId}),k=uu(d,!T.text),[v,q]=mu(!1),[Le,ie]=mu(null),X=pu(null),Ce=pu(void 0),Pe=Wr(()=>{let U=X.current;if(!U)return;U.scrollIntoView({behavior:"smooth",block:"center"});let fe=U.querySelector("textarea");fe&&setTimeout(()=>fe.focus(),300),q(!0),clearTimeout(Ce.current),Ce.current=setTimeout(()=>q(!1),2e3)},[]),ye=iu({messages:T.messages,status:T.status,config:t.suggestions}),ke=Wr(U=>{let fe=U.content.map(re=>re.text??"").join("").trim();fe&&T.handleSubmit({text:fe,files:[],modelContext:U.modelContext})},[T.handleSubmit]),Qe=Wr(U=>{ye.clear(),T.handleSubmit({text:U,files:[]})},[ye.clear,T.handleSubmit]);return mg(a,()=>({sendMessage:U=>{T.handleSubmit({text:U,files:[]}),Pe()},sendMessageAndWait:U=>T.sendMessageAndWait(U),reset:T.reset,focus:Pe,get messages(){return T.messages},get sessionId(){return T.sessionId}}),[T.handleSubmit,T.sendMessageAndWait,T.reset,T.messages,T.sessionId,Pe]),pg(()=>{if(!p)return;let U=fe=>{let re=fe.detail,Z=typeof re?.message=="string"?re.message:void 0;Z&&T.handleSubmit({text:Z,files:[]}),Pe()};return window.addEventListener(p,U),()=>window.removeEventListener(p,U)},[p,T.handleSubmit,Pe]),xa("div",{ref:X,style:{...y,width:n,height:s},"data-waniwani-chat":"","data-waniwani-layout":"card",...N?{"data-waniwani-dark":""}:{},className:F("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",v&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[xa("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[xe("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),xe(vs,{messages:T.messages,evalEnabled:D.eval,api:S}),I&&xe(jl,{threads:T.threads,activeThreadId:T.activeThreadId,onNewThread:T.startNewThread,onSelectThread:U=>{T.switchThread(U)},onDeleteThread:U=>{T.deleteThread(U)}})]}),xa(rs,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[xe(ns,{scrollClassName:Le?"ww:!relative ww:!overflow-hidden":void 0,children:xe(Ul,{messages:T.messages,status:T.status,welcomeMessage:u,welcome:c,onSuggestionSelect:Qe,resourceEndpoint:C,chatSessionId:T.sessionId,isDark:N,onFollowUp:ke,onCallTool:B,fullscreenToolCallId:Le,debug:_,showToolCalls:L,toolDefinitions:T.toolDefinitions,onWidgetDisplayModeChange:(U,fe)=>{ie(U==="fullscreen"?fe.toolCallId:null)}})}),xe(ss,{})]}),xe("div",{style:Le?{display:"none"}:void 0,children:xe(Wl,{suggestions:ye.suggestions,isLoading:ye.isLoading,onSelect:Qe})}),xe("div",{style:Le?{display:"none"}:void 0,children:xe(bs,{queuedMessages:T.queuedMessages,onRemove:T.removeQueuedMessage})}),xe("div",{style:Le?{display:"none"}:void 0,children:xe("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:xa("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[xe(fs,{onSubmit:T.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:xa("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&xe(hs,{}),xe(ps,{onChange:T.handleTextChange,value:T.text,placeholder:k,className:"ww:min-h-0 ww:py-1 ww:px-0"}),xe(ms,{status:T.status,disabled:T.queueFull})]})}),xe(ql,{})]})})})]})});export{hg as ChatCard,pn as DevModeProvider,Mu as InitializeNextJsInIframe,fd as LoadingWidget,In as WidgetProvider,ln as createResource,vu as createTool,Io as detectPlatform,Ta as getMockState,Bt as initializeMockOpenAI,ku as isMCPApps,bu as isOpenAI,Pu as registerTools,ML as toNextJsHandler,wn as unstable_useSendFollowUpWithGhostGuard,_t as updateMockDisplayMode,rt as updateMockGlobal,Nt as updateMockTheme,Et as updateMockToolOutput,Sn as useCallTool,yn as useDisplayMode,bn as useFlowAction,kn as useIsChatGptApp,Tn as useLocale,vn as useMaxHeight,Pn as useOpenExternal,An as useRequestDisplayMode,Rn as useSafeArea,Mn as useSendFollowUp,Fn as useTheme,Pa as useToolOutput,Dn as useToolResponseMetadata,Bn as useUpdateModelContext,j as useWidgetClient,En as useWidgetState};
83
83
  /*! Bundled license information:
84
84
 
85
85
  lucide-react/dist/esm/shared/src/utils/mergeClasses.js:
@@ -92,16 +92,17 @@ lucide-react/dist/esm/Icon.js:
92
92
  lucide-react/dist/esm/createLucideIcon.js:
93
93
  lucide-react/dist/esm/icons/arrow-down.js:
94
94
  lucide-react/dist/esm/icons/arrow-up.js:
95
- lucide-react/dist/esm/icons/braces.js:
96
- lucide-react/dist/esm/icons/brain.js:
97
95
  lucide-react/dist/esm/icons/check.js:
98
96
  lucide-react/dist/esm/icons/chevron-down.js:
99
97
  lucide-react/dist/esm/icons/chevron-right.js:
100
98
  lucide-react/dist/esm/icons/clipboard-copy.js:
99
+ lucide-react/dist/esm/icons/clock.js:
101
100
  lucide-react/dist/esm/icons/file.js:
101
+ lucide-react/dist/esm/icons/globe.js:
102
102
  lucide-react/dist/esm/icons/loader.js:
103
103
  lucide-react/dist/esm/icons/paperclip.js:
104
104
  lucide-react/dist/esm/icons/square.js:
105
+ lucide-react/dist/esm/icons/wrench.js:
105
106
  lucide-react/dist/esm/icons/x.js:
106
107
  lucide-react/dist/esm/icons/zap.js:
107
108
  lucide-react/dist/esm/lucide-react.js: