opencami 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +111 -0
- package/bin/opencami.js +155 -0
- package/dist/client/apple-touch-icon-180x180.png +0 -0
- package/dist/client/assets/_sessionKey-B-MBYHgD.js +95 -0
- package/dist/client/assets/abap-BdImnpbu.js +1 -0
- package/dist/client/assets/actionscript-3-CfeIJUat.js +1 -0
- package/dist/client/assets/ada-bCR0ucgS.js +1 -0
- package/dist/client/assets/andromeeda-C-Jbm3Hp.js +1 -0
- package/dist/client/assets/angular-html-CU67Zn6k.js +1 -0
- package/dist/client/assets/angular-ts-BwZT4LLn.js +1 -0
- package/dist/client/assets/apache-Pmp26Uib.js +1 -0
- package/dist/client/assets/apex-D8_7TLub.js +1 -0
- package/dist/client/assets/apl-dKokRX4l.js +1 -0
- package/dist/client/assets/applescript-Co6uUVPk.js +1 -0
- package/dist/client/assets/ara-BRHolxvo.js +1 -0
- package/dist/client/assets/asciidoc-Dv7Oe6Be.js +1 -0
- package/dist/client/assets/asm-D_Q5rh1f.js +1 -0
- package/dist/client/assets/astro-CbQHKStN.js +1 -0
- package/dist/client/assets/aurora-x-D-2ljcwZ.js +1 -0
- package/dist/client/assets/awk-DMzUqQB5.js +1 -0
- package/dist/client/assets/ayu-dark-CmMr59Fi.js +1 -0
- package/dist/client/assets/ballerina-BFfxhgS-.js +1 -0
- package/dist/client/assets/bat-BkioyH1T.js +1 -0
- package/dist/client/assets/beancount-k_qm7-4y.js +1 -0
- package/dist/client/assets/berry-uYugtg8r.js +1 -0
- package/dist/client/assets/bibtex-CHM0blh-.js +1 -0
- package/dist/client/assets/bicep-Bmn6On1c.js +1 -0
- package/dist/client/assets/blade-D4QpJJKB.js +1 -0
- package/dist/client/assets/bsl-BO_Y6i37.js +1 -0
- package/dist/client/assets/button-D_9OBT_f.js +1 -0
- package/dist/client/assets/c-BIGW1oBm.js +1 -0
- package/dist/client/assets/c3-VCDPK7BO.js +1 -0
- package/dist/client/assets/cadence-Bv_4Rxtq.js +1 -0
- package/dist/client/assets/cairo-KRGpt6FW.js +1 -0
- package/dist/client/assets/catppuccin-frappe-DFWUc33u.js +1 -0
- package/dist/client/assets/catppuccin-latte-C9dUb6Cb.js +1 -0
- package/dist/client/assets/catppuccin-macchiato-DQyhUUbL.js +1 -0
- package/dist/client/assets/catppuccin-mocha-D87Tk5Gz.js +1 -0
- package/dist/client/assets/clarity-D53aC0YG.js +1 -0
- package/dist/client/assets/clojure-P80f7IUj.js +1 -0
- package/dist/client/assets/cmake-D1j8_8rp.js +1 -0
- package/dist/client/assets/cobol-nwyudZeR.js +1 -0
- package/dist/client/assets/codeowners-Bp6g37R7.js +1 -0
- package/dist/client/assets/codeql-DsOJ9woJ.js +1 -0
- package/dist/client/assets/coffee-Ch7k5sss.js +1 -0
- package/dist/client/assets/common-lisp-Cg-RD9OK.js +1 -0
- package/dist/client/assets/connect-BRasuRbB.js +2 -0
- package/dist/client/assets/coq-DkFqJrB1.js +1 -0
- package/dist/client/assets/cpp-CofmeUqb.js +1 -0
- package/dist/client/assets/crystal-tKQVLTB8.js +1 -0
- package/dist/client/assets/csharp-K5feNrxe.js +1 -0
- package/dist/client/assets/css-DPfMkruS.js +1 -0
- package/dist/client/assets/csv-fuZLfV_i.js +1 -0
- package/dist/client/assets/cue-D82EKSYY.js +1 -0
- package/dist/client/assets/cypher-COkxafJQ.js +1 -0
- package/dist/client/assets/d-85-TOEBH.js +1 -0
- package/dist/client/assets/dark-plus-C3mMm8J8.js +1 -0
- package/dist/client/assets/dart-CF10PKvl.js +1 -0
- package/dist/client/assets/dax-CEL-wOlO.js +1 -0
- package/dist/client/assets/desktop-BmXAJ9_W.js +1 -0
- package/dist/client/assets/diff-D97Zzqfu.js +1 -0
- package/dist/client/assets/docker-BcOcwvcX.js +1 -0
- package/dist/client/assets/dotenv-Da5cRb03.js +1 -0
- package/dist/client/assets/dracula-BzJJZx-M.js +1 -0
- package/dist/client/assets/dracula-soft-BXkSAIEj.js +1 -0
- package/dist/client/assets/dream-maker-BtqSS_iP.js +1 -0
- package/dist/client/assets/edge-BkV0erSs.js +1 -0
- package/dist/client/assets/elixir-CDX3lj18.js +1 -0
- package/dist/client/assets/elm-DbKCFpqz.js +1 -0
- package/dist/client/assets/emacs-lisp-C9XAeP06.js +1 -0
- package/dist/client/assets/erb-BOJIQeun.js +1 -0
- package/dist/client/assets/erlang-DsQrWhSR.js +1 -0
- package/dist/client/assets/everforest-dark-BgDCqdQA.js +1 -0
- package/dist/client/assets/everforest-light-C8M2exoo.js +1 -0
- package/dist/client/assets/fennel-BYunw83y.js +1 -0
- package/dist/client/assets/file-explorer-screen-Daf4rIq9.js +1 -0
- package/dist/client/assets/files-ByeIMLfw.js +2 -0
- package/dist/client/assets/fish-BvzEVeQv.js +1 -0
- package/dist/client/assets/fluent-C4IJs8-o.js +1 -0
- package/dist/client/assets/fortran-fixed-form-CkoXwp7k.js +1 -0
- package/dist/client/assets/fortran-free-form-BxgE0vQu.js +1 -0
- package/dist/client/assets/fsharp-CXgrBDvD.js +1 -0
- package/dist/client/assets/gdresource-B7Tvp0Sc.js +1 -0
- package/dist/client/assets/gdscript-DTMYz4Jt.js +1 -0
- package/dist/client/assets/gdshader-DkwncUOv.js +1 -0
- package/dist/client/assets/genie-D0YGMca9.js +1 -0
- package/dist/client/assets/gherkin-DyxjwDmM.js +1 -0
- package/dist/client/assets/git-commit-F4YmCXRG.js +1 -0
- package/dist/client/assets/git-rebase-r7XF79zn.js +1 -0
- package/dist/client/assets/github-dark-DHJKELXO.js +1 -0
- package/dist/client/assets/github-dark-default-Cuk6v7N8.js +1 -0
- package/dist/client/assets/github-dark-dimmed-DH5Ifo-i.js +1 -0
- package/dist/client/assets/github-dark-high-contrast-E3gJ1_iC.js +1 -0
- package/dist/client/assets/github-light-DAi9KRSo.js +1 -0
- package/dist/client/assets/github-light-default-D7oLnXFd.js +1 -0
- package/dist/client/assets/github-light-high-contrast-BfjtVDDH.js +1 -0
- package/dist/client/assets/gleam-BspZqrRM.js +1 -0
- package/dist/client/assets/glimmer-js-Rg0-pVw9.js +1 -0
- package/dist/client/assets/glimmer-ts-U6CK756n.js +1 -0
- package/dist/client/assets/glsl-DplSGwfg.js +1 -0
- package/dist/client/assets/gn-n2N0HUVH.js +1 -0
- package/dist/client/assets/gnuplot-DdkO51Og.js +1 -0
- package/dist/client/assets/go-Dn2_MT6a.js +1 -0
- package/dist/client/assets/graphql-ChdNCCLP.js +1 -0
- package/dist/client/assets/groovy-gcz8RCvz.js +1 -0
- package/dist/client/assets/gruvbox-dark-hard-CFHQjOhq.js +1 -0
- package/dist/client/assets/gruvbox-dark-medium-GsRaNv29.js +1 -0
- package/dist/client/assets/gruvbox-dark-soft-CVdnzihN.js +1 -0
- package/dist/client/assets/gruvbox-light-hard-CH1njM8p.js +1 -0
- package/dist/client/assets/gruvbox-light-medium-DRw_LuNl.js +1 -0
- package/dist/client/assets/gruvbox-light-soft-hJgmCMqR.js +1 -0
- package/dist/client/assets/hack-CaT9iCJl.js +1 -0
- package/dist/client/assets/haml-B8DHNrY2.js +1 -0
- package/dist/client/assets/handlebars-BL8al0AC.js +1 -0
- package/dist/client/assets/haskell-Df6bDoY_.js +1 -0
- package/dist/client/assets/haxe-CzTSHFRz.js +1 -0
- package/dist/client/assets/hcl-BWvSN4gD.js +1 -0
- package/dist/client/assets/hjson-D5-asLiD.js +1 -0
- package/dist/client/assets/hlsl-D3lLCCz7.js +1 -0
- package/dist/client/assets/houston-DnULxvSX.js +1 -0
- package/dist/client/assets/html-GMplVEZG.js +1 -0
- package/dist/client/assets/html-derivative-BFtXZ54Q.js +1 -0
- package/dist/client/assets/http-jrhK8wxY.js +1 -0
- package/dist/client/assets/hurl-irOxFIW8.js +1 -0
- package/dist/client/assets/hxml-Bvhsp5Yf.js +1 -0
- package/dist/client/assets/hy-DFXneXwc.js +1 -0
- package/dist/client/assets/imba-DGztddWO.js +1 -0
- package/dist/client/assets/index-ByUDBI-n.js +14 -0
- package/dist/client/assets/index-DHGnKfAU.js +1 -0
- package/dist/client/assets/ini-BEwlwnbL.js +1 -0
- package/dist/client/assets/java-CylS5w8V.js +1 -0
- package/dist/client/assets/javascript-wDzz0qaB.js +1 -0
- package/dist/client/assets/jinja-4LBKfQ-Z.js +1 -0
- package/dist/client/assets/jison-wvAkD_A8.js +1 -0
- package/dist/client/assets/json-Cp-IABpG.js +1 -0
- package/dist/client/assets/json5-C9tS-k6U.js +1 -0
- package/dist/client/assets/jsonc-Des-eS-w.js +1 -0
- package/dist/client/assets/jsonl-DcaNXYhu.js +1 -0
- package/dist/client/assets/jsonnet-DFQXde-d.js +1 -0
- package/dist/client/assets/jssm-C2t-YnRu.js +1 -0
- package/dist/client/assets/jsx-g9-lgVsj.js +1 -0
- package/dist/client/assets/julia-CxzCAyBv.js +1 -0
- package/dist/client/assets/kanagawa-dragon-CkXjmgJE.js +1 -0
- package/dist/client/assets/kanagawa-lotus-CfQXZHmo.js +1 -0
- package/dist/client/assets/kanagawa-wave-DWedfzmr.js +1 -0
- package/dist/client/assets/kdl-DV7GczEv.js +1 -0
- package/dist/client/assets/keyboard-shortcuts-dialog-agsWJ36q.js +1 -0
- package/dist/client/assets/kotlin-BdnUsdx6.js +1 -0
- package/dist/client/assets/kusto-DZf3V79B.js +1 -0
- package/dist/client/assets/laserwave-DUszq2jm.js +1 -0
- package/dist/client/assets/latex-B4uzh10-.js +1 -0
- package/dist/client/assets/lean-BZvkOJ9d.js +1 -0
- package/dist/client/assets/less-B1dDrJ26.js +1 -0
- package/dist/client/assets/light-plus-B7mTdjB0.js +1 -0
- package/dist/client/assets/liquid-DYVedYrR.js +1 -0
- package/dist/client/assets/llvm-BtvRca6l.js +1 -0
- package/dist/client/assets/log-2UxHyX5q.js +1 -0
- package/dist/client/assets/logo-BtOb2qkB.js +1 -0
- package/dist/client/assets/lua-BbnMAYS6.js +1 -0
- package/dist/client/assets/luau-C-HG3fhB.js +1 -0
- package/dist/client/assets/main-BAHT5yqU.js +81 -0
- package/dist/client/assets/make-CHLpvVh8.js +1 -0
- package/dist/client/assets/markdown-Cvjx9yec.js +1 -0
- package/dist/client/assets/marko-DZsq8hO1.js +1 -0
- package/dist/client/assets/material-theme-D5KoaKCx.js +1 -0
- package/dist/client/assets/material-theme-darker-BfHTSMKl.js +1 -0
- package/dist/client/assets/material-theme-lighter-B0m2ddpp.js +1 -0
- package/dist/client/assets/material-theme-ocean-CyktbL80.js +1 -0
- package/dist/client/assets/material-theme-palenight-Csfq5Kiy.js +1 -0
- package/dist/client/assets/matlab-D7o27uSR.js +1 -0
- package/dist/client/assets/mdc-DUICxH0z.js +1 -0
- package/dist/client/assets/mdx-Cmh6b_Ma.js +1 -0
- package/dist/client/assets/menu-BhVaz8Ly.js +20 -0
- package/dist/client/assets/mermaid-mWjccvbQ.js +1 -0
- package/dist/client/assets/min-dark-CafNBF8u.js +1 -0
- package/dist/client/assets/min-light-CTRr51gU.js +1 -0
- package/dist/client/assets/mipsasm-CKIfxQSi.js +1 -0
- package/dist/client/assets/mojo-B93PlW-d.js +1 -0
- package/dist/client/assets/monokai-D4h5O-jR.js +1 -0
- package/dist/client/assets/moonbit-Ba13S78F.js +1 -0
- package/dist/client/assets/move-Bu9oaDYs.js +1 -0
- package/dist/client/assets/narrat-DRg8JJMk.js +1 -0
- package/dist/client/assets/new-DLlBm66g.js +1 -0
- package/dist/client/assets/nextflow-BrzmwbiE.js +1 -0
- package/dist/client/assets/nginx-DknmC5AR.js +1 -0
- package/dist/client/assets/night-owl-C39BiMTA.js +1 -0
- package/dist/client/assets/nim-CVrawwO9.js +1 -0
- package/dist/client/assets/nix-CwoSXNpI.js +1 -0
- package/dist/client/assets/nord-Ddv68eIx.js +1 -0
- package/dist/client/assets/nushell-C-sUppwS.js +1 -0
- package/dist/client/assets/objective-c-DXmwc3jG.js +1 -0
- package/dist/client/assets/objective-cpp-CLxacb5B.js +1 -0
- package/dist/client/assets/ocaml-C0hk2d4L.js +1 -0
- package/dist/client/assets/one-dark-pro-DVMEJ2y_.js +1 -0
- package/dist/client/assets/one-light-PoHY5YXO.js +1 -0
- package/dist/client/assets/openscad-C4EeE6gA.js +1 -0
- package/dist/client/assets/pascal-D93ZcfNL.js +1 -0
- package/dist/client/assets/perl-C0TMdlhV.js +1 -0
- package/dist/client/assets/php-CDn_0X-4.js +1 -0
- package/dist/client/assets/pkl-u5AG7uiY.js +1 -0
- package/dist/client/assets/plastic-3e1v2bzS.js +1 -0
- package/dist/client/assets/plsql-ChMvpjG-.js +1 -0
- package/dist/client/assets/po-BTJTHyun.js +1 -0
- package/dist/client/assets/poimandres-CS3Unz2-.js +1 -0
- package/dist/client/assets/polar-C0HS_06l.js +1 -0
- package/dist/client/assets/postcss-CXtECtnM.js +1 -0
- package/dist/client/assets/powerquery-CEu0bR-o.js +1 -0
- package/dist/client/assets/powershell-Dpen1YoG.js +1 -0
- package/dist/client/assets/prisma-Dd19v3D-.js +1 -0
- package/dist/client/assets/prolog-CbFg5uaA.js +1 -0
- package/dist/client/assets/proto-C7zT0LnQ.js +1 -0
- package/dist/client/assets/pug-CGlum2m_.js +1 -0
- package/dist/client/assets/puppet-BMWR74SV.js +1 -0
- package/dist/client/assets/purescript-CklMAg4u.js +1 -0
- package/dist/client/assets/python-B6aJPvgy.js +1 -0
- package/dist/client/assets/qml-3beO22l8.js +1 -0
- package/dist/client/assets/qmldir-C8lEn-DE.js +1 -0
- package/dist/client/assets/qss-IeuSbFQv.js +1 -0
- package/dist/client/assets/r-Dspwwk_N.js +1 -0
- package/dist/client/assets/racket-BqYA7rlc.js +1 -0
- package/dist/client/assets/raku-DXvB9xmW.js +1 -0
- package/dist/client/assets/razor-C1TweQQi.js +1 -0
- package/dist/client/assets/red-bN70gL4F.js +1 -0
- package/dist/client/assets/reg-C-SQnVFl.js +1 -0
- package/dist/client/assets/regexp-CDVJQ6XC.js +1 -0
- package/dist/client/assets/rel-C3B-1QV4.js +1 -0
- package/dist/client/assets/riscv-BM1_JUlF.js +1 -0
- package/dist/client/assets/rose-pine-dawn-DHQR4-dF.js +1 -0
- package/dist/client/assets/rose-pine-moon-D4_iv3hh.js +1 -0
- package/dist/client/assets/rose-pine-qdsjHGoJ.js +1 -0
- package/dist/client/assets/rosmsg-BJDFO7_C.js +1 -0
- package/dist/client/assets/rst-B0xPkSld.js +1 -0
- package/dist/client/assets/ruby-BvKwtOVI.js +1 -0
- package/dist/client/assets/rust-B1yitclQ.js +1 -0
- package/dist/client/assets/sas-cz2c8ADy.js +1 -0
- package/dist/client/assets/sass-Cj5Yp3dK.js +1 -0
- package/dist/client/assets/scala-C151Ov-r.js +1 -0
- package/dist/client/assets/scheme-C98Dy4si.js +1 -0
- package/dist/client/assets/scss-OYdSNvt2.js +1 -0
- package/dist/client/assets/sdbl-DVxCFoDh.js +1 -0
- package/dist/client/assets/search-dialog-CHwnOyPS.js +1 -0
- package/dist/client/assets/session-export-dialog-uOlDUzgX.js +1 -0
- package/dist/client/assets/settings-dialog-D0aYDkAM.js +1 -0
- package/dist/client/assets/shaderlab-Dg9Lc6iA.js +1 -0
- package/dist/client/assets/shellscript-Yzrsuije.js +1 -0
- package/dist/client/assets/shellsession-BADoaaVG.js +1 -0
- package/dist/client/assets/slack-dark-BthQWCQV.js +1 -0
- package/dist/client/assets/slack-ochin-DqwNpetd.js +1 -0
- package/dist/client/assets/smalltalk-BERRCDM3.js +1 -0
- package/dist/client/assets/snazzy-light-Bw305WKR.js +1 -0
- package/dist/client/assets/solarized-dark-DXbdFlpD.js +1 -0
- package/dist/client/assets/solarized-light-L9t79GZl.js +1 -0
- package/dist/client/assets/solidity-rGO070M0.js +1 -0
- package/dist/client/assets/soy-Brmx7dQM.js +1 -0
- package/dist/client/assets/sparql-rVzFXLq3.js +1 -0
- package/dist/client/assets/splunk-BtCnVYZw.js +1 -0
- package/dist/client/assets/sql-BLtJtn59.js +1 -0
- package/dist/client/assets/ssh-config-_ykCGR6B.js +1 -0
- package/dist/client/assets/stata-BH5u7GGu.js +1 -0
- package/dist/client/assets/styles-7aVSlb6l.css +1 -0
- package/dist/client/assets/stylus-BEDo0Tqx.js +1 -0
- package/dist/client/assets/svelte-zxCyuUbr.js +1 -0
- package/dist/client/assets/swift-Dg5xB15N.js +1 -0
- package/dist/client/assets/synthwave-84-CbfX1IO0.js +1 -0
- package/dist/client/assets/system-verilog-CnnmHF94.js +1 -0
- package/dist/client/assets/systemd-4A_iFExJ.js +1 -0
- package/dist/client/assets/talonscript-CkByrt1z.js +1 -0
- package/dist/client/assets/tasl-QIJgUcNo.js +1 -0
- package/dist/client/assets/tcl-dwOrl1Do.js +1 -0
- package/dist/client/assets/templ-W15q3VgB.js +1 -0
- package/dist/client/assets/terraform-BETggiCN.js +1 -0
- package/dist/client/assets/tex-CvyZ59Mk.js +1 -0
- package/dist/client/assets/tokyo-night-hegEt444.js +1 -0
- package/dist/client/assets/toml-vGWfd6FD.js +1 -0
- package/dist/client/assets/ts-tags-zn1MmPIZ.js +1 -0
- package/dist/client/assets/tsv-B_m7g4N7.js +1 -0
- package/dist/client/assets/tsx-COt5Ahok.js +1 -0
- package/dist/client/assets/turtle-BsS91CYL.js +1 -0
- package/dist/client/assets/twig-CO9l9SDP.js +1 -0
- package/dist/client/assets/typescript-BPQ3VLAy.js +1 -0
- package/dist/client/assets/typespec-BGHnOYBU.js +1 -0
- package/dist/client/assets/typst-DHCkPAjA.js +1 -0
- package/dist/client/assets/v-BcVCzyr7.js +1 -0
- package/dist/client/assets/vala-CsfeWuGM.js +1 -0
- package/dist/client/assets/vb-D17OF-Vu.js +1 -0
- package/dist/client/assets/verilog-BQ8w6xss.js +1 -0
- package/dist/client/assets/vesper-DU1UobuO.js +1 -0
- package/dist/client/assets/vhdl-CeAyd5Ju.js +1 -0
- package/dist/client/assets/viml-CJc9bBzg.js +1 -0
- package/dist/client/assets/vitesse-black-Bkuqu6BP.js +1 -0
- package/dist/client/assets/vitesse-dark-D0r3Knsf.js +1 -0
- package/dist/client/assets/vitesse-light-CVO1_9PV.js +1 -0
- package/dist/client/assets/vue-DN_0RTcg.js +1 -0
- package/dist/client/assets/vue-html-AaS7Mt5G.js +1 -0
- package/dist/client/assets/vue-vine-CQOfvN7w.js +1 -0
- package/dist/client/assets/vyper-CDx5xZoG.js +1 -0
- package/dist/client/assets/wasm-CG6Dc4jp.js +1 -0
- package/dist/client/assets/wasm-MzD3tlZU.js +1 -0
- package/dist/client/assets/wenyan-BV7otONQ.js +1 -0
- package/dist/client/assets/wgsl-Dx-B1_4e.js +1 -0
- package/dist/client/assets/wikitext-BhOHFoWU.js +1 -0
- package/dist/client/assets/wit-5i3qLPDT.js +1 -0
- package/dist/client/assets/wolfram-lXgVvXCa.js +1 -0
- package/dist/client/assets/xml-sdJ4AIDG.js +1 -0
- package/dist/client/assets/xsl-CtQFsRM5.js +1 -0
- package/dist/client/assets/yaml-Buea-lGh.js +1 -0
- package/dist/client/assets/zenscript-DVFEvuxE.js +1 -0
- package/dist/client/assets/zig-VOosw3JB.js +1 -0
- package/dist/client/cover.jpg +0 -0
- package/dist/client/cover.webp +0 -0
- package/dist/client/favicon.svg +4 -0
- package/dist/client/manifest.json +40 -0
- package/dist/client/pwa-192x192.png +0 -0
- package/dist/client/pwa-512x512.png +0 -0
- package/dist/client/pwa-maskable-512x512.png +0 -0
- package/dist/client/robots.txt +3 -0
- package/dist/client/screenshot-file-explorer.png +0 -0
- package/dist/client/sw.js +165 -0
- package/dist/server/assets/_sessionKey-qlAPF_Ft.js +6130 -0
- package/dist/server/assets/_tanstack-start-manifest_v-El8F-kd-.js +4 -0
- package/dist/server/assets/button-DtQ3rV1m.js +53 -0
- package/dist/server/assets/connect-BWI_6rCm.js +80 -0
- package/dist/server/assets/file-explorer-screen-DJXPEG_J.js +2450 -0
- package/dist/server/assets/files-CONoVTGD.js +11 -0
- package/dist/server/assets/index-Bp8QskbI.js +28 -0
- package/dist/server/assets/index-COu2idHm.js +226 -0
- package/dist/server/assets/keyboard-shortcuts-dialog-D5hqVX2v.js +69 -0
- package/dist/server/assets/menu-D6n4DB0U.js +156 -0
- package/dist/server/assets/new-Dzk5YxE9.js +6 -0
- package/dist/server/assets/router-DbxyvprK.js +2749 -0
- package/dist/server/assets/search-dialog-JY8C3mqa.js +443 -0
- package/dist/server/assets/session-export-dialog-D87uafPD.js +80 -0
- package/dist/server/assets/settings-dialog-CBj7njLM.js +568 -0
- package/dist/server/assets/start-HYkvq4Ni.js +4 -0
- package/dist/server/server.js +1013 -0
- package/package.json +93 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/settings-dialog-D0aYDkAM.js","assets/main-BAHT5yqU.js","assets/button-D_9OBT_f.js","assets/menu-BhVaz8Ly.js","assets/index-ByUDBI-n.js","assets/session-export-dialog-uOlDUzgX.js","assets/keyboard-shortcuts-dialog-agsWJ36q.js","assets/search-dialog-CHwnOyPS.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as h,r as m,L as gr,u as qt,_ as zn,g as Ms,a as _a,b as Oa,c as Ps,d as Fa}from"./main-BAHT5yqU.js";import{D as $a,a as Ba,b as Ha,c as qa,d as Ua,u as Ka,e as Wa,f as Va,g as Xa,h as Ya,i as Ga,j as Qa,k as Ja,l as Za,m as zs,n as el,o as _s,p as tl,q as mt,r as Os,t as nl,s as Xe,T as ki,v as Fs,w as rl,x as il,A as Oe,y as sl,z as ol,B as al,C as wn,E as ll,F as $s,G as ul,M as Mr,H as Pr,I as zr,J as vt,K as Bs,L as Ke,N as At,O as Ot,P as Ft,Q as $t,R as Bt,S as Sn,U as dt,V as cl,W as wi}from"./menu-BhVaz8Ly.js";import{B as ye,u as fl,c as H,f as _r,a as xt,b as hl,H as ae,d as pl,e as dl,g as ml,h as Hs,l as qs,i as Si,I as gl,q as xl,P as yl,A as bl,j as kl,n as wl,X as Us,x as Sl,k as Cl,D as vl,T as El,m as Or,o as Tl,p as jl,Q as Wn,W as Ci,V as Ks,r as Il,S as Al,w as Rl}from"./button-D_9OBT_f.js";import{s as Fr,h as Nl,w as Dl,f as Ll,a as Ml,b as Pl,c as vi,C as zl,u as _l,p as Ol}from"./index-ByUDBI-n.js";const Fl={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};function xr(e){if(!e)return"main";const t=e.trim();if(t.length===0)return"main";const n=t.split(":"),i=(n[n.length-1]??"").trim();return i.length>0?i:t}function Ye(e){return(Array.isArray(e.content)?e.content:[]).map(n=>n.type==="text"?String(n.text??""):"").join("").trim()}function Pt(e){return(Array.isArray(e.content)?e.content:[]).filter(n=>n.type==="toolCall")}function $l(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e12?e*1e3:e;if(typeof e=="string"){const t=Date.parse(e);if(!Number.isNaN(t))return t}return null}function yr(e){const t=[e.createdAt,e.created_at,e.timestamp,e.time,e.ts];for(const n of t){const r=$l(n);if(r)return r}return Date.now()}const Bl=["agent:main:main","main"];function br(e){return Bl.includes(e)}const Hl=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ql(e){if(e.includes(":subagent:")||e.startsWith("agent:codex:")||e.includes(":openai:"))return"subagent";if(e.startsWith("isolated:")||e.includes(":cron:"))return"cron";if(e.startsWith("agent:")&&!e.startsWith("agent:main:"))return"other";if(e.startsWith("agent:main:")){const t=e.slice(11);return Hl.test(t)?"webchat":"chat"}return"other"}function Ul(e){return Array.isArray(e)?e.map(t=>{const n=typeof t.key=="string"&&t.key.trim().length>0?t.key.trim():xr(t.friendlyId??t.key),r=typeof t.friendlyId=="string"&&t.friendlyId.trim().length>0?t.friendlyId.trim():xr(n),i=ql(n),s=t,o=typeof s.totalTokens=="number"?s.totalTokens:void 0,a=typeof s.contextTokens=="number"?s.contextTokens:void 0;return{key:n,friendlyId:r,title:typeof t.title=="string"?t.title:void 0,derivedTitle:typeof t.derivedTitle=="string"?t.derivedTitle:void 0,label:typeof t.label=="string"?t.label:void 0,updatedAt:typeof t.updatedAt=="number"?t.updatedAt:void 0,lastMessage:t.lastMessage??null,kind:i,totalTokens:o,contextTokens:a}}):[]}async function nt(e){try{const t=await e.json();return t?.error?String(t.error):t?.message?String(t.message):JSON.stringify(t)}catch{try{return await e.text()}catch{return e.statusText||"Request failed"}}}const Kl="Missing gateway auth. Set CLAWDBOT_GATEWAY_TOKEN (recommended) or CLAWDBOT_GATEWAY_PASSWORD in the server environment.";function Ei(e){return e.includes(Kl)}function Ti(e,t){const n=crypto.randomUUID(),r=`opt-${n}`,i=Date.now(),s=[];if(t&&t.length>0)for(const a of t)a.type==="image"&&a.base64&&s.push({type:"image",source:{type:"base64",media_type:a.file.type,data:a.base64}});return e.trim()?s.push({type:"text",text:e}):t&&t.length>0&&s.push({type:"text",text:""}),{clientId:n,optimisticId:r,optimisticMessage:{role:"user",content:s,__optimisticId:r,clientId:n,status:"sending",timestamp:i}}}const pe={sessions:["chat","sessions"],history:function(t,n){return["chat","history",t,n]}};async function Wl(){const e=await fetch("/api/sessions");if(!e.ok)throw new Error(await nt(e));const t=await e.json();return Ul(t.sessions)}async function Vl(e){const t=new URLSearchParams({limit:"200"});e.sessionKey&&t.set("sessionKey",e.sessionKey),e.friendlyId&&t.set("friendlyId",e.friendlyId);const n=await fetch(`/api/history?${t.toString()}`);if(!n.ok)throw new Error(await nt(n));return await n.json()}async function Xl(){const e=new AbortController,t=window.setTimeout(()=>e.abort(),2500);try{const n=await fetch("/api/ping",{signal:e.signal});if(!n.ok)throw new Error(await nt(n));return await n.json()}catch(n){throw n instanceof DOMException&&n.name==="AbortError"?new Error("Gateway check timed out"):n}finally{window.clearTimeout(t)}}function $r(e,t,n,r){const i=pe.history(t,n);e.setQueryData(i,function(o){const a=o,l=Array.isArray(a?.messages)?a.messages:[],u=r(l);return{sessionKey:a?.sessionKey??n,sessionId:a?.sessionId,messages:u}})}function Vn(e,t,n,r){$r(e,t,n,function(s){return[...s,r]})}function Yl(e,t,n,r,i){const s=`opt-${r}`;$r(e,t,n,function(a){return a.map(l=>l.clientId===r||l.__optimisticId===r||l.__optimisticId===s?i(l):l)})}function Gl(e,t,n,r,i){$r(e,t,n,function(o){return o.filter(a=>!(a.clientId===r||a.__optimisticId===r||i&&a.__optimisticId===i))})}function kr(e,t,n){const r=pe.history(t,n);e.setQueryData(r,{sessionKey:n,messages:[]})}function Ql(e,t,n,r,i){const s=pe.history(t,n),o=pe.history(r,i),a=e.getQueryData(s);if(!a)return;const l=Array.isArray(a.messages)?a.messages:[];e.setQueryData(o,{sessionKey:i,sessionId:a.sessionId,messages:l}),e.removeQueries({queryKey:s,exact:!0})}function Jl(e,t,n,r){e.setQueryData(pe.sessions,function(s){return Array.isArray(s)?s.map(o=>o.key!==t&&o.friendlyId!==n?o:{...o,lastMessage:r}):s})}function Zl(e,t,n){e.setQueryData(pe.sessions,function(i){return Array.isArray(i)?i.filter(s=>s.key!==t&&s.friendlyId!==n):i}),e.removeQueries({queryKey:["chat","history",n],exact:!1}),t&&t!==n&&e.removeQueries({queryKey:["chat","history",t],exact:!1})}async function eu(e,t,n,r){e.setQueryData(pe.sessions,function(s){return Array.isArray(s)?s.map(o=>o.key===t||o.friendlyId===n?{...o,label:r}:o):s});try{const i=await fetch("/api/sessions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionKey:t,friendlyId:n,label:r})});if(!i.ok){const s=await nt(i);console.error("[updateSessionLabel] Failed to persist:",s)}}catch(i){console.error("[updateSessionLabel] Network error:",i)}}function Ws(e){return!e.content||!Array.isArray(e.content)?"":e.content.filter(t=>t.type==="text").map(t=>t.text||"").join(`
|
|
3
|
+
`)}function tu(e,t,n){const r=[];r.push(`# Conversation: ${e}`),r.push(`Date: ${n.toLocaleString()}`),r.push("");for(const i of t){const s=i.role||"unknown",o=Ws(i);if(o){const a=s==="user"?"User":"Assistant";r.push(`## ${a}`),r.push(""),r.push(o),r.push("")}}return r.join(`
|
|
4
|
+
`)}function nu(e,t,n){const r={title:e,exportDate:n.toISOString(),messages:t.map(i=>({role:i.role,content:i.content,timestamp:i.timestamp}))};return JSON.stringify(r,null,2)}function ru(e,t,n){const r=[];r.push(`Conversation: ${e}`),r.push(`Date: ${n.toLocaleString()}`),r.push("─".repeat(60)),r.push("");for(const i of t){const s=i.role||"unknown",o=Ws(i);if(o){const a=s==="user"?"User":"Assistant";r.push(`${a}:`),r.push(o),r.push("")}}return r.join(`
|
|
5
|
+
`)}function iu(e,t,n){const r=new Date;let i,s,o;switch(n){case"markdown":i=tu(e,t,r),s=`${Xn(e)}.md`,o="text/markdown";break;case"json":i=nu(e,t,r),s=`${Xn(e)}.json`,o="application/json";break;case"txt":i=ru(e,t,r),s=`${Xn(e)}.txt`,o="text/plain";break;default:throw new Error(`Unsupported format: ${n}`)}su(i,s,o)}function Xn(e){return e.replace(/[^a-z0-9-_\s]/gi,"").replace(/\s+/g,"-").toLowerCase().slice(0,50)||"conversation"}function su(e,t,n){const r=new Blob([e],{type:n}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}function ou({open:e,onOpenChange:t,sessionTitle:n,onSave:r,onCancel:i}){return h.jsx($a,{open:e,onOpenChange:t,children:h.jsx(Ba,{children:h.jsxs("div",{className:"p-4",children:[h.jsx(Ha,{className:"mb-1",children:"Rename"}),h.jsx(qa,{className:"mb-4",children:"Enter a new name for this session."}),h.jsx("input",{type:"text",defaultValue:n,onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),r(s.currentTarget.value))},className:"w-full rounded-lg border border-primary-200 bg-primary-50 px-3 py-2 text-sm text-primary-900 outline-none focus:border-primary-400",placeholder:"Session name",autoFocus:!0}),h.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[h.jsx(Ua,{onClick:i,children:"Cancel"}),h.jsx(ye,{onClick:s=>{const o=s.currentTarget.parentElement?.previousElementSibling;r(o.value)},children:"Save"})]})]})})})}function au(e){const{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:s,actionsRef:o,handle:a,triggerId:l,defaultTriggerId:u=null}=e,c=Ka(),f=!!c,p=fl(()=>a?.store??new Wa({open:n??r,activeTriggerId:l!==void 0?l:u,modal:!0,disablePointerDismissal:!0,nested:f,role:"alertdialog"})).current;p.useControlledProp("open",n,r),p.useControlledProp("activeTriggerId",l,u),p.useSyncedValue("nested",f),p.useContextCallback("onOpenChange",i),p.useContextCallback("onOpenChangeComplete",s);const d=p.useState("payload");Va({store:p,actionsRef:o,parentContext:c?.store.context});const g=m.useMemo(()=>({store:p}),[p]);return h.jsx(Xa.Provider,{value:g,children:typeof t=="function"?t({payload:d}):t})}function lu({children:e,...t}){return h.jsx(au,{...t,children:e})}function uu({className:e,children:t}){return h.jsxs(Ya,{children:[h.jsx(Ga,{className:"fixed inset-0 bg-primary-950/20 transition-all duration-150 data-[state=open]:opacity-100 data-[state=closed]:opacity-0"}),h.jsx(Qa,{className:H("fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2","w-[min(400px,92vw)] rounded-xl border border-primary-200 bg-primary-50 p-0 shadow-xl","transition-all duration-150","data-[state=open]:opacity-100 data-[state=closed]:opacity-0","data-[state=open]:scale-100 data-[state=closed]:scale-95",e),children:t})]})}function cu({className:e,...t}){return h.jsx(Ja,{className:H("text-lg font-medium text-primary-900",e),...t})}function fu({className:e,...t}){return h.jsx(Za,{className:H("text-sm text-primary-600",e),...t})}function hu({className:e,...t}){return h.jsx(zs,{render:h.jsx(ye,{variant:"outline",className:H(e)}),...t})}function pu({className:e,...t}){return h.jsx(zs,{render:h.jsx(ye,{variant:"destructive",className:H(e)}),...t})}function du({open:e,onOpenChange:t,sessionTitle:n,onConfirm:r,onCancel:i}){return h.jsx(lu,{open:e,onOpenChange:t,children:h.jsx(uu,{children:h.jsxs("div",{className:"p-4",children:[h.jsx(cu,{className:"mb-1",children:"Delete Session"}),h.jsxs(fu,{className:"mb-4",children:['Are you sure you want to delete "',n,'"? This action cannot be undone.']}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(hu,{onClick:i,children:"Cancel"}),h.jsx(pu,{onClick:r,children:"Delete"})]})]})})})}function mu({controlled:e,default:t,name:n,state:r="value"}){const{current:i}=m.useRef(e!==void 0),[s,o]=m.useState(t),a=i?e:s,l=m.useCallback(u=>{i||o(u)},[]);return[a,l]}function gu(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:i}=e,s=t!==void 0,[o,a]=mu({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:u,transitionStatus:c}=el(o,!0,!0),[f,p]=m.useState(o),[{height:d,width:g},y]=m.useState({height:void 0,width:void 0}),w=_s(),[b,v]=m.useState(),T=b??w,[L,D]=m.useState(!1),[S,$]=m.useState(!1),F=m.useRef(null),B=m.useRef(null),C=m.useRef(null),M=m.useRef(null),j=tl(M,!1),N=mt(I=>{const E=!o,R=Os(nl,I.nativeEvent);if(r(E,R),R.isCanceled)return;const z=M.current;B.current==="css-animation"&&z!=null&&z.style.removeProperty("animation-name"),!L&&!S&&(B.current!=null&&B.current!=="css-animation"&&!l&&E&&u(!0),B.current==="css-animation"&&(!f&&E&&p(!0),!l&&E&&u(!0))),a(E),B.current==="none"&&l&&!E&&u(!1)});return Xe(()=>{s&&B.current==="none"&&!S&&!o&&u(!1)},[s,S,o,t,u]),m.useMemo(()=>({abortControllerRef:F,animationTypeRef:B,disabled:i,handleTrigger:N,height:d,mounted:l,open:o,panelId:T,panelRef:M,runOnceAnimationsFinish:j,setDimensions:y,setHiddenUntilFound:D,setKeepMounted:$,setMounted:u,setOpen:a,setPanelIdState:v,setVisible:p,transitionDimensionRef:C,transitionStatus:c,visible:f,width:g}),[F,B,i,N,d,l,o,T,M,j,y,D,$,u,a,p,C,c,f,g])}const Vs=m.createContext(void 0);function Xs(){const e=m.useContext(Vs);if(e===void 0)throw new Error(_r(15));return e}let en=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=ki.startingStyle]="startingStyle",e[e.endingStyle=ki.endingStyle]="endingStyle",e})({}),xu=(function(e){return e.panelOpen="data-panel-open",e})({});const yu={[en.open]:""},bu={[en.closed]:""},ku={open(e){return e?{[xu.panelOpen]:""}:null}},wu={open(e){return e?yu:bu}},Ys={...wu,...Fs},Su=m.forwardRef(function(t,n){const{render:r,className:i,defaultOpen:s=!1,disabled:o=!1,onOpenChange:a,open:l,...u}=t,c=mt(a),f=gu({open:l,defaultOpen:s,onOpenChange:c,disabled:o}),p=m.useMemo(()=>({open:f.open,disabled:f.disabled,transitionStatus:f.transitionStatus}),[f.open,f.disabled,f.transitionStatus]),d=m.useMemo(()=>({...f,onOpenChange:c,state:p}),[f,c,p]),g=xt("div",t,{state:p,ref:n,props:u,stateAttributesMapping:Ys});return h.jsx(Vs.Provider,{value:d,children:g})}),Cu={...ku,...Fs},vu=m.forwardRef(function(t,n){const{panelId:r,open:i,handleTrigger:s,state:o,disabled:a}=Xs(),{className:l,disabled:u=a,id:c,render:f,nativeButton:p=!0,...d}=t,{getButtonProps:g,buttonRef:y}=rl({disabled:u,focusableWhenDisabled:!0,native:p}),w=m.useMemo(()=>({"aria-controls":i?r:void 0,"aria-expanded":i,onClick:s}),[r,i,s]);return xt("button",t,{state:o,ref:[n,y],props:[w,d,g],stateAttributesMapping:Cu})});let Eu=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e})({});function Tu(e){const{abortControllerRef:t,animationTypeRef:n,externalRef:r,height:i,hiddenUntilFound:s,keepMounted:o,id:a,mounted:l,onOpenChange:u,open:c,panelRef:f,runOnceAnimationsFinish:p,setDimensions:d,setMounted:g,setOpen:y,setVisible:w,transitionDimensionRef:b,visible:v,width:T}=e,L=m.useRef(!1),D=m.useRef(null),S=m.useRef(c),$=m.useRef(c),F=il(),B=m.useMemo(()=>n.current==="css-animation"?!v:!c&&!l,[c,l,v,n]),C=mt(j=>{if(!j)return;if(n.current==null||b.current==null){const E=getComputedStyle(j),R=E.animationName!=="none"&&E.animationName!=="",z=E.transitionDuration!=="0s"&&E.transitionDuration!=="";R&&z||(E.animationName==="none"&&E.transitionDuration!=="0s"?n.current="css-transition":E.animationName!=="none"&&E.transitionDuration==="0s"?n.current="css-animation":n.current="none"),j.getAttribute(Eu.orientation)==="horizontal"||E.transitionProperty.indexOf("width")>-1?b.current="width":b.current="height"}if(n.current!=="css-transition")return;(i===void 0||T===void 0)&&(d({height:j.scrollHeight,width:j.scrollWidth}),$.current&&j.style.setProperty("transition-duration","0s"));let N=-1,I=-1;return N=Oe.request(()=>{$.current=!1,I=Oe.request(()=>{setTimeout(()=>{j.style.removeProperty("transition-duration")})})}),()=>{Oe.cancel(N),Oe.cancel(I)}}),M=hl(r,f,C);return Xe(()=>{if(n.current!=="css-transition")return;const j=f.current;if(!j)return;let N=-1;if(t.current!=null&&(t.current.abort(),t.current=null),c){const I={"justify-content":j.style.justifyContent,"align-items":j.style.alignItems,"align-content":j.style.alignContent,"justify-items":j.style.justifyItems};Object.keys(I).forEach(E=>{j.style.setProperty(E,"initial","important")}),!$.current&&!o&&j.setAttribute(en.startingStyle,""),d({height:j.scrollHeight,width:j.scrollWidth}),N=Oe.request(()=>{Object.entries(I).forEach(([E,R])=>{R===""?j.style.removeProperty(E):j.style.setProperty(E,R)})})}else{if(j.scrollHeight===0&&j.scrollWidth===0)return;d({height:j.scrollHeight,width:j.scrollWidth});const I=new AbortController;t.current=I;const E=I.signal;let R=null;const z=en.endingStyle;return R=new MutationObserver(P=>{P.some(x=>x.type==="attributes"&&x.attributeName===z)&&(R?.disconnect(),R=null,p(()=>{d({height:0,width:0}),j.style.removeProperty("content-visibility"),g(!1),t.current===I&&(t.current=null)},E))}),R.observe(j,{attributes:!0,attributeFilter:[z]}),()=>{R?.disconnect(),F.cancel(),t.current===I&&(I.abort(),t.current=null)}}return()=>{Oe.cancel(N)}},[t,n,F,s,o,l,c,f,p,d,g]),Xe(()=>{if(n.current!=="css-animation")return;const j=f.current;j&&(D.current=j.style.animationName||D.current,j.style.setProperty("animation-name","none"),d({height:j.scrollHeight,width:j.scrollWidth}),!S.current&&!L.current&&j.style.removeProperty("animation-name"),c?(t.current!=null&&(t.current.abort(),t.current=null),g(!0),w(!0)):(t.current=new AbortController,p(()=>{g(!1),w(!1),t.current=null},t.current.signal)))},[t,n,c,f,p,d,g,w,v]),sl(()=>{const j=Oe.request(()=>{S.current=!1});return()=>Oe.cancel(j)}),Xe(()=>{if(!s)return;const j=f.current;if(!j)return;let N=-1,I=-1;return c&&L.current&&(j.style.transitionDuration="0s",d({height:j.scrollHeight,width:j.scrollWidth}),N=Oe.request(()=>{L.current=!1,I=Oe.request(()=>{setTimeout(()=>{j.style.removeProperty("transition-duration")})})})),()=>{Oe.cancel(N),Oe.cancel(I)}},[s,c,f,d]),Xe(()=>{const j=f.current;j&&s&&B&&(j.setAttribute("hidden","until-found"),n.current==="css-transition"&&j.setAttribute(en.startingStyle,""))},[s,B,n,f]),m.useEffect(function(){const N=f.current;if(!N)return;function I(E){L.current=!0,y(!0),u(!0,Os(ol,E))}return N.addEventListener("beforematch",I),()=>{N.removeEventListener("beforematch",I)}},[u,f,y]),m.useMemo(()=>({props:{hidden:B,id:a,ref:M}}),[B,a,M])}let ji=(function(e){return e.collapsiblePanelHeight="--collapsible-panel-height",e.collapsiblePanelWidth="--collapsible-panel-width",e})({});const ju=m.forwardRef(function(t,n){const{className:r,hiddenUntilFound:i,keepMounted:s,render:o,id:a,...l}=t,{abortControllerRef:u,animationTypeRef:c,height:f,mounted:p,onOpenChange:d,open:g,panelId:y,panelRef:w,runOnceAnimationsFinish:b,setDimensions:v,setHiddenUntilFound:T,setKeepMounted:L,setMounted:D,setPanelIdState:S,setOpen:$,setVisible:F,state:B,transitionDimensionRef:C,visible:M,width:j,transitionStatus:N}=Xs(),I=i??!1,E=s??!1;Xe(()=>{if(a)return S(a),()=>{S(void 0)}},[a,S]),Xe(()=>{T(I)},[T,I]),Xe(()=>{L(E)},[L,E]);const{props:R}=Tu({abortControllerRef:u,animationTypeRef:c,externalRef:n,height:f,hiddenUntilFound:I,id:y,keepMounted:E,mounted:p,onOpenChange:d,open:g,panelRef:w,runOnceAnimationsFinish:b,setDimensions:v,setMounted:D,setOpen:$,setVisible:F,transitionDimensionRef:C,visible:M,width:j});al({open:g&&N==="idle",ref:w,onComplete(){g&&v({height:void 0,width:void 0})}});const z=m.useMemo(()=>({...B,transitionStatus:N}),[B,N]),P=xt("div",t,{state:z,ref:[n,w],props:[R,{style:{[ji.collapsiblePanelHeight]:f===void 0?"auto":`${f}px`,[ji.collapsiblePanelWidth]:j===void 0?"auto":`${j}px`}},l],stateAttributesMapping:Ys});return E||I||!E&&p?P:null});function Cn(e){return h.jsx(Su,{...e})}function vn({className:e,...t}){return h.jsx(vu,{className:H("group inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-left text-xs font-medium text-primary-500 transition-colors hover:bg-primary-100 hover:text-primary-700 data-panel-open:text-primary-700",e),...t})}function En({className:e,contentClassName:t,children:n,...r}){return h.jsx(ju,{className:H('flex h-(--collapsible-panel-height) flex-col overflow-hidden text-sm transition-all duration-150 ease-out data-ending-style:h-0 data-starting-style:h-0 [&[hidden]:not([hidden="until-found"])]:hidden',e),...r,children:h.jsx("div",{className:H("pt-1",t),children:n})})}const Gs=m.createContext(void 0);function _n(){const e=m.useContext(Gs);if(e===void 0)throw new Error(_r(53));return e}let Tn=(function(e){return e.scrollAreaCornerHeight="--scroll-area-corner-height",e.scrollAreaCornerWidth="--scroll-area-corner-width",e})({});const fn=500,Ii=16;function $e(e,t,n){if(!e)return 0;const r=getComputedStyle(e),i=n==="x"?"Inline":"Block";return n==="x"&&t==="margin"?parseFloat(r[`${t}InlineStart`])*2:parseFloat(r[`${t}${i}Start`])+parseFloat(r[`${t}${i}End`])}let Iu=(function(e){return e.orientation="data-orientation",e.hovering="data-hovering",e.scrolling="data-scrolling",e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});const hn="base-ui-disable-scrollbar",Qs={className:hn,getElement(e){return h.jsx("style",{nonce:e,href:hn,precedence:"base-ui:low",children:`.${hn}{scrollbar-width:none}.${hn}::-webkit-scrollbar{display:none}`})}};let Rt=(function(e){return e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});const Br={hasOverflowX:e=>e?{[Rt.hasOverflowX]:""}:null,hasOverflowY:e=>e?{[Rt.hasOverflowY]:""}:null,overflowXStart:e=>e?{[Rt.overflowXStart]:""}:null,overflowXEnd:e=>e?{[Rt.overflowXEnd]:""}:null,overflowYStart:e=>e?{[Rt.overflowYStart]:""}:null,overflowYEnd:e=>e?{[Rt.overflowYEnd]:""}:null,cornerHidden:()=>null},Au=m.createContext(void 0),Ru={disableStyleElements:!1};function Nu(){return m.useContext(Au)??Ru}const Du={x:0,y:0},Ai={width:0,height:0},Lu={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},Mu={x:!1,y:!1,corner:!1},Pu=m.forwardRef(function(t,n){const{render:r,className:i,overflowEdgeThreshold:s,...o}=t,a=zu(s),l=_s(),u=wn(),c=wn(),{nonce:f,disableStyleElements:p}=Nu(),[d,g]=m.useState(!1),[y,w]=m.useState(!1),[b,v]=m.useState(!1),[T,L]=m.useState(!1),[D,S]=m.useState(Ai),[$,F]=m.useState(Ai),[B,C]=m.useState(Lu),[M,j]=m.useState(Mu),N=m.useRef(null),I=m.useRef(null),E=m.useRef(null),R=m.useRef(null),z=m.useRef(null),P=m.useRef(null),U=m.useRef(null),x=m.useRef(!1),q=m.useRef(0),ee=m.useRef(0),k=m.useRef(0),ce=m.useRef(0),Q=m.useRef("vertical"),re=m.useRef(Du),be=mt(X=>{const Ae=X.x-re.current.x,ve=X.y-re.current.y;re.current=X,ve!==0&&(v(!0),u.start(fn,()=>{v(!1)})),Ae!==0&&(w(!0),c.start(fn,()=>{w(!1)}))}),he=mt(X=>{X.button===0&&(x.current=!0,q.current=X.clientY,ee.current=X.clientX,Q.current=X.currentTarget.getAttribute(Iu.orientation),I.current&&(k.current=I.current.scrollTop,ce.current=I.current.scrollLeft),z.current&&Q.current==="vertical"&&z.current.setPointerCapture(X.pointerId),P.current&&Q.current==="horizontal"&&P.current.setPointerCapture(X.pointerId))}),te=mt(X=>{if(!x.current)return;const Ae=X.clientY-q.current,ve=X.clientX-ee.current;if(I.current){const Qe=I.current.scrollHeight,Je=I.current.clientHeight,De=I.current.scrollWidth,ut=I.current.clientWidth;if(z.current&&E.current&&Q.current==="vertical"){const Ze=$e(E.current,"padding","y"),it=$e(z.current,"margin","y"),A=z.current.offsetHeight,_=E.current.offsetHeight-A-Ze-it,K=Ae/_;I.current.scrollTop=k.current+K*(Qe-Je),X.preventDefault(),v(!0),u.start(fn,()=>{v(!1)})}if(P.current&&R.current&&Q.current==="horizontal"){const Ze=$e(R.current,"padding","x"),it=$e(P.current,"margin","x"),A=P.current.offsetWidth,_=R.current.offsetWidth-A-Ze-it,K=ve/_;I.current.scrollLeft=ce.current+K*(De-ut),X.preventDefault(),w(!0),c.start(fn,()=>{w(!1)})}}}),oe=mt(X=>{x.current=!1,z.current&&Q.current==="vertical"&&z.current.releasePointerCapture(X.pointerId),P.current&&Q.current==="horizontal"&&P.current.releasePointerCapture(X.pointerId)});function ge(X){L(X.pointerType==="touch")}function Ie(X){if(ge(X),X.pointerType!=="touch"){const Ae=ll(N.current,X.target);g(Ae)}}const de=m.useMemo(()=>({hasOverflowX:!M.x,hasOverflowY:!M.y,overflowXStart:B.xStart,overflowXEnd:B.xEnd,overflowYStart:B.yStart,overflowYEnd:B.yEnd,cornerHidden:M.corner}),[M.x,M.y,M.corner,B]),_e={role:"presentation",onPointerEnter:Ie,onPointerMove:Ie,onPointerDown:ge,onPointerLeave(){g(!1)},style:{position:"relative",[Tn.scrollAreaCornerHeight]:`${D.height}px`,[Tn.scrollAreaCornerWidth]:`${D.width}px`}},Ce=xt("div",t,{state:de,ref:[n,N],props:[_e,o],stateAttributesMapping:Br}),J=m.useMemo(()=>({handlePointerDown:he,handlePointerMove:te,handlePointerUp:oe,handleScroll:be,cornerSize:D,setCornerSize:S,thumbSize:$,setThumbSize:F,touchModality:T,cornerRef:U,scrollingX:y,setScrollingX:w,scrollingY:b,setScrollingY:v,hovering:d,setHovering:g,viewportRef:I,rootRef:N,scrollbarYRef:E,scrollbarXRef:R,thumbYRef:z,thumbXRef:P,rootId:l,hiddenState:M,setHiddenState:j,overflowEdges:B,setOverflowEdges:C,viewportState:de,overflowEdgeThreshold:a}),[he,te,oe,be,D,$,T,y,w,b,v,d,g,l,M,B,de,a]);return h.jsxs(Gs.Provider,{value:J,children:[!p&&Qs.getElement(f),Ce]})});function zu(e){if(typeof e=="number"){const t=Math.max(0,e);return{xStart:t,xEnd:t,yStart:t,yEnd:t}}return{xStart:Math.max(0,e?.xStart||0),xEnd:Math.max(0,e?.xEnd||0),yStart:Math.max(0,e?.yStart||0),yEnd:Math.max(0,e?.yEnd||0)}}const _u=m.createContext(void 0);function ot(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function Ou(e,t){if(typeof IntersectionObserver>"u")return()=>{};const n=new IntersectionObserver(r=>{r.forEach(i=>{i.intersectionRatio>0&&(t(),n.disconnect())})});return n.observe(e),()=>{n.disconnect()}}let gt=(function(e){return e.scrollAreaOverflowXStart="--scroll-area-overflow-x-start",e.scrollAreaOverflowXEnd="--scroll-area-overflow-x-end",e.scrollAreaOverflowYStart="--scroll-area-overflow-y-start",e.scrollAreaOverflowYEnd="--scroll-area-overflow-y-end",e})({}),Ri=!1;function Fu(){Ri||ul||(typeof CSS<"u"&&"registerProperty"in CSS&&[gt.scrollAreaOverflowXStart,gt.scrollAreaOverflowXEnd,gt.scrollAreaOverflowYStart,gt.scrollAreaOverflowYEnd].forEach(e=>{try{CSS.registerProperty({name:e,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),Ri=!0)}const $u=m.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{viewportRef:o,scrollbarYRef:a,scrollbarXRef:l,thumbYRef:u,thumbXRef:c,cornerRef:f,cornerSize:p,setCornerSize:d,setThumbSize:g,rootId:y,setHiddenState:w,hiddenState:b,handleScroll:v,setHovering:T,setOverflowEdges:L,overflowEdges:D,overflowEdgeThreshold:S}=_n(),$=$s(),F=m.useRef(!0),B=wn(),C=wn(),M=mt(()=>{const z=o.current,P=a.current,U=l.current,x=u.current,q=c.current,ee=f.current;if(!z)return;const k=z.scrollHeight,ce=z.scrollWidth,Q=z.clientHeight,re=z.clientWidth,be=z.scrollTop,he=z.scrollLeft;if(k===0||ce===0)return;const te=Q>=k,oe=re>=ce,ge=re/ce,Ie=Q/k,de=Math.max(0,ce-re),_e=Math.max(0,k-Q);let Ce=0,J=0;oe||($==="rtl"?Ce=ot(-he,0,de):Ce=ot(he,0,de),J=de-Ce);const X=te?0:ot(be,0,_e),Ae=te?0:_e-X,ve=oe?0:re,Qe=te?0:Q;let Je=0,De=0;!oe&&!te&&(Je=P?.offsetWidth||0,De=U?.offsetHeight||0);const ut=p.width===0&&p.height===0,Ze=ut?Je:0,it=ut?De:0,A=$e(U,"padding","x"),_=$e(P,"padding","y"),K=$e(q,"margin","x"),Y=$e(x,"margin","y"),ne=ve-A-K,xe=Qe-_-Y,Be=U?Math.min(U.offsetWidth-Ze,ne):ne,Le=P?Math.min(P.offsetHeight-it,xe):xe,He=Math.max(Ii,Be*ge),qe=Math.max(Ii,Le*Ie);if(g(se=>se.height===qe&&se.width===He?se:{width:He,height:qe}),P&&x){const se=P.offsetHeight-qe-_-Y,Me=k-Q,st=Me===0?0:be/Me,kt=Math.min(se,Math.max(0,st*se));x.style.transform=`translate3d(0,${kt}px,0)`}if(U&&q){const se=U.offsetWidth-He-A-K,Me=ce-re,st=Me===0?0:he/Me,kt=$==="rtl"?ot(st*se,-se,0):ot(st*se,0,se);q.style.transform=`translate3d(${kt}px,0,0)`}const fe=ot(Ce,0,de),Ue=ot(J,0,de),Ee=ot(X,0,_e),ct=ot(Ae,0,_e),Kn=[[gt.scrollAreaOverflowXStart,fe],[gt.scrollAreaOverflowXEnd,Ue],[gt.scrollAreaOverflowYStart,Ee],[gt.scrollAreaOverflowYEnd,ct]];for(const[se,Me]of Kn)z.style.setProperty(se,`${Me}px`);ee&&(oe||te?d({width:0,height:0}):!oe&&!te&&d({width:Je,height:De})),w(se=>{const Me=te||oe;return se.y===te&&se.x===oe&&se.corner===Me?se:{y:te,x:oe,corner:Me}});const bt={xStart:!oe&&fe>S.xStart,xEnd:!oe&&Ue>S.xEnd,yStart:!te&&Ee>S.yStart,yEnd:!te&&ct>S.yEnd};L(se=>se.xStart===bt.xStart&&se.xEnd===bt.xEnd&&se.yStart===bt.yStart&&se.yEnd===bt.yEnd?se:bt)});Xe(()=>{if(!o.current)return;Fu();let z=!1;return Ou(o.current,()=>{if(!z){z=!0;return}M()})},[M,o]),Xe(()=>{queueMicrotask(M)},[M,b,$]),Xe(()=>{o.current?.matches(":hover")&&T(!0)},[o,T]),m.useEffect(()=>{const z=o.current;if(typeof ResizeObserver>"u"||!z)return;let P=!1;const U=new ResizeObserver(()=>{if(!P){P=!0;return}M()});return U.observe(z),C.start(0,()=>{const x=z.getAnimations({subtree:!0});x.length!==0&&Promise.all(x.map(q=>q.finished)).then(M).catch(()=>{})}),()=>{U.disconnect(),C.clear()}},[M,o,C]);function j(){F.current=!1}const N={role:"presentation",...y&&{"data-id":`${y}-viewport`},...(!b.x||!b.y)&&{tabIndex:0},className:Qs.className,style:{overflow:"scroll"},onScroll(){o.current&&(M(),F.current||v({x:o.current.scrollLeft,y:o.current.scrollTop}),B.start(100,()=>{F.current=!0}))},onWheel:j,onTouchMove:j,onPointerMove:j,onPointerEnter:j,onKeyDown:j},I=m.useMemo(()=>({hasOverflowX:!b.x,hasOverflowY:!b.y,overflowXStart:D.xStart,overflowXEnd:D.xEnd,overflowYStart:D.yStart,overflowYEnd:D.yEnd,cornerHidden:b.corner}),[b.x,b.y,b.corner,D]),E=xt("div",t,{ref:[n,o],state:I,props:[N,s],stateAttributesMapping:Br}),R=m.useMemo(()=>({computeThumbPosition:M}),[M]);return h.jsx(_u.Provider,{value:R,children:E})}),Js=m.createContext(void 0);function Bu(){const e=m.useContext(Js);if(e===void 0)throw new Error(_r(54));return e}let jn=(function(e){return e.scrollAreaThumbHeight="--scroll-area-thumb-height",e.scrollAreaThumbWidth="--scroll-area-thumb-width",e})({});const Hu=m.forwardRef(function(t,n){const{render:r,className:i,orientation:s="vertical",keepMounted:o=!1,...a}=t,{hovering:l,scrollingX:u,scrollingY:c,hiddenState:f,overflowEdges:p,scrollbarYRef:d,scrollbarXRef:g,viewportRef:y,thumbYRef:w,thumbXRef:b,handlePointerDown:v,handlePointerUp:T,rootId:L,thumbSize:D}=_n(),S=m.useMemo(()=>({hovering:l,scrolling:{horizontal:u,vertical:c}[s],orientation:s,hasOverflowX:!f.x,hasOverflowY:!f.y,overflowXStart:p.xStart,overflowXEnd:p.xEnd,overflowYStart:p.yStart,overflowYEnd:p.yEnd,cornerHidden:f.corner}),[l,u,c,s,f,p]),$=$s();m.useEffect(()=>{const N=y.current,I=s==="vertical"?d.current:g.current;if(!I)return;function E(R){if(!(!N||!I||R.ctrlKey)){if(R.preventDefault(),s==="vertical"){if(N.scrollTop===0&&R.deltaY<0)return}else if(N.scrollLeft===0&&R.deltaX<0)return;if(s==="vertical"){if(N.scrollTop===N.scrollHeight-N.clientHeight&&R.deltaY>0)return}else if(N.scrollLeft===N.scrollWidth-N.clientWidth&&R.deltaX>0)return;s==="vertical"?N.scrollTop+=R.deltaY:N.scrollLeft+=R.deltaX}}return I.addEventListener("wheel",E,{passive:!1}),()=>{I.removeEventListener("wheel",E)}},[s,g,d,y]);const F={...L&&{"data-id":`${L}-scrollbar`},onPointerDown(N){if(N.button===0&&N.currentTarget===N.target&&y.current){if(w.current&&d.current&&s==="vertical"){const I=$e(w.current,"margin","y"),E=$e(d.current,"padding","y"),R=w.current.offsetHeight,z=d.current.getBoundingClientRect(),P=N.clientY-z.top-R/2-E+I/2,U=y.current.scrollHeight,x=y.current.clientHeight,q=d.current.offsetHeight-R-E-I,k=P/q*(U-x);y.current.scrollTop=k}if(b.current&&g.current&&s==="horizontal"){const I=$e(b.current,"margin","x"),E=$e(g.current,"padding","x"),R=b.current.offsetWidth,z=g.current.getBoundingClientRect(),P=N.clientX-z.left-R/2-E+I/2,U=y.current.scrollWidth,x=y.current.clientWidth,q=g.current.offsetWidth-R-E-I,ee=P/q;let k;$==="rtl"?(k=(1-ee)*(U-x),y.current.scrollLeft<=0&&(k=-k)):k=ee*(U-x),y.current.scrollLeft=k}v(N)}},onPointerUp:T,style:{position:"absolute",touchAction:"none",WebkitUserSelect:"none",userSelect:"none",...s==="vertical"&&{top:0,bottom:`var(${Tn.scrollAreaCornerHeight})`,insetInlineEnd:0,[jn.scrollAreaThumbHeight]:`${D.height}px`},...s==="horizontal"&&{insetInlineStart:0,insetInlineEnd:`var(${Tn.scrollAreaCornerWidth})`,bottom:0,[jn.scrollAreaThumbWidth]:`${D.width}px`}}},B=xt("div",t,{ref:[n,s==="vertical"?d:g],state:S,props:[F,a],stateAttributesMapping:Br}),C=m.useMemo(()=>({orientation:s}),[s]),M=s==="vertical"?f.y:f.x;return o||!M?h.jsx(Js.Provider,{value:C,children:B}):null}),qu=m.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{thumbYRef:o,thumbXRef:a,handlePointerDown:l,handlePointerMove:u,handlePointerUp:c,setScrollingX:f,setScrollingY:p}=_n(),{orientation:d}=Bu(),g=m.useMemo(()=>({orientation:d}),[d]);return xt("div",t,{ref:[n,d==="vertical"?o:a],state:g,props:[{onPointerDown:l,onPointerMove:u,onPointerUp(w){d==="vertical"&&p(!1),d==="horizontal"&&f(!1),c(w)},style:{...d==="vertical"&&{height:`var(${jn.scrollAreaThumbHeight})`},...d==="horizontal"&&{width:`var(${jn.scrollAreaThumbWidth})`}}},s]})}),Uu=m.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{cornerRef:o,cornerSize:a,hiddenState:l}=_n(),u=xt("div",t,{ref:[n,o],props:[{style:{position:"absolute",bottom:0,insetInlineEnd:0,width:a.width,height:a.height}},s]});return l.corner?null:u});function Zs({className:e,...t}){return h.jsx(Pu,{className:H("group/scroll-area relative outline-none focus-visible:outline-none",e),...t})}function eo({className:e,...t}){return h.jsx($u,{className:H("h-full w-full outline-none focus-visible:outline-none",e),...t})}function to({className:e,...t}){return h.jsx(Hu,{className:H("flex w-2 touch-none select-none p-0.5 outline-none focus-visible:outline-none","opacity-0 transition-opacity duration-150","data-hovering:opacity-100 data-scrolling:opacity-100 group-hover/scroll-area:opacity-100",e),...t})}function no({className:e,...t}){return h.jsx(qu,{className:H("flex-1 rounded-full bg-primary-500 outline-none focus-visible:outline-none",e),...t})}function Ku({className:e,...t}){return h.jsx(Uu,{className:H("bg-primary-100 outline-none focus-visible:outline-none",e),...t})}function Wu({session:e,active:t,isPinned:n,selectionMode:r=!1,selected:i=!1,onToggleSelect:s,onSelect:o,onTogglePin:a,onRename:l,onDelete:u,onExport:c}){const f=e.label||e.title||e.derivedTitle||e.friendlyId;return h.jsxs(gr,{to:"/chat/$sessionKey",params:{sessionKey:e.friendlyId},onClick:p=>{if(r){p.preventDefault(),p.stopPropagation(),s?.(e);return}o?.()},className:H("group inline-flex items-center justify-between","w-full text-left pl-1.5 pr-0.5 h-8 rounded-lg transition-colors duration-0","select-none",t?"bg-primary-200 text-primary-950":"bg-transparent text-primary-950 [&:hover:not(:has(button:hover))]:bg-primary-200"),children:[h.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[r?h.jsx("span",{"aria-hidden":"true",className:H("inline-flex items-center justify-center size-4 shrink-0 rounded border transition-colors",i?"bg-primary-700 border-primary-700 text-white":"border-primary-300 bg-surface"),children:i?h.jsx("svg",{viewBox:"0 0 12 12",className:"size-3",fill:"none",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{d:"M2.5 6l2.5 2.5 4.5-5"})}):null}):null,h.jsx("div",{className:"flex-1 min-w-0",children:h.jsxs("div",{className:"text-sm font-[450] line-clamp-1",children:[n?h.jsx("span",{className:"mr-1 text-xs text-primary-700","aria-hidden":"true",children:"📌"}):null,f]})})]}),r?null:h.jsxs(Mr,{children:[h.jsx(Pr,{type:"button",onClick:p=>{p.preventDefault(),p.stopPropagation()},className:H("ml-2 inline-flex size-7 items-center justify-center rounded-md text-primary-700","opacity-0 transition-opacity group-hover:opacity-100 hover:bg-primary-200","aria-expanded:opacity-100 aria-expanded:bg-primary-200"),children:h.jsx(ae,{icon:pl,size:20,strokeWidth:1.5})}),h.jsxs(zr,{side:"bottom",align:"end",children:[h.jsxs(vt,{onClick:p=>{p.preventDefault(),p.stopPropagation(),a(e)},className:"gap-2",children:[h.jsx("span",{className:"text-xs","aria-hidden":"true",children:"📌"})," ",n?"Unpin Session":"Pin Session"]}),h.jsxs(vt,{onClick:p=>{p.preventDefault(),p.stopPropagation(),l(e)},className:"gap-2",children:[h.jsx(ae,{icon:dl,size:20,strokeWidth:1.5})," ","Rename"]}),h.jsxs(vt,{onClick:p=>{p.preventDefault(),p.stopPropagation(),c(e)},className:"gap-2",children:[h.jsx(ae,{icon:ml,size:20,strokeWidth:1.5})," ","Export"]}),br(e.key)?null:h.jsxs(vt,{onClick:p=>{p.preventDefault(),p.stopPropagation(),u(e)},className:"text-red-700 gap-2 hover:bg-red-50/80 data-highlighted:bg-red-50/80",children:[h.jsx(ae,{icon:Hs,size:20,strokeWidth:1.5})," ","Delete"]})]})]})]})}function Vu(e,t){return e.active!==t.active||e.isPinned!==t.isPinned||e.selectionMode!==t.selectionMode||e.selected!==t.selected||e.onToggleSelect!==t.onToggleSelect||e.onSelect!==t.onSelect||e.onTogglePin!==t.onTogglePin||e.onRename!==t.onRename||e.onDelete!==t.onDelete||e.onExport!==t.onExport?!1:e.session===t.session?!0:e.session.key===t.session.key&&e.session.friendlyId===t.session.friendlyId&&e.session.label===t.session.label&&e.session.title===t.session.title&&e.session.derivedTitle===t.session.derivedTitle&&e.session.updatedAt===t.session.updatedAt}const Yn=m.memo(Wu,Vu),ro="opencami-pinned-sessions",io="opencami-sidebar-folders",ht={webchat:!1,subagent:!1,cron:!1,other:!1};async function Xu(e){const t=new URLSearchParams;e&&t.set("sessionKey",e);const n=await fetch(`/api/sessions?${t.toString()}`,{method:"DELETE"});if(!n.ok)throw new Error(await nt(n))}async function Yu(e,t,n){const r=[];let i=0;const s=Array.from({length:Math.min(t,e.length)},async function(){for(;i<e.length;){const a=i;i+=1;try{await n(e[a])}catch(l){r.push(l)}}});return await Promise.all(s),r}function Gu(){if(typeof window>"u")return[];try{const e=localStorage.getItem(ro);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function Qu(e){if(!(typeof window>"u"))try{const t=Array.from(new Set(e));localStorage.setItem(ro,JSON.stringify(t))}catch{}}function Ju(){if(typeof window>"u")return{...ht};try{const e=localStorage.getItem(io);if(!e)return{...ht};const t=JSON.parse(e);return!t||typeof t!="object"?{...ht}:{webchat:typeof t.webchat=="boolean"?t.webchat:ht.webchat,subagent:typeof t.subagent=="boolean"?t.subagent:ht.subagent,cron:typeof t.cron=="boolean"?t.cron:ht.cron,other:typeof t.other=="boolean"?t.other:ht.other}}catch{return{...ht}}}function Zu(e){if(!(typeof window>"u"))try{localStorage.setItem(io,JSON.stringify(e))}catch{}}function Gn(e,t,n){return n&&e.key?e.key===n:e.friendlyId===t}const ec=m.memo(function({sessions:t,activeFriendlyId:n,activeSessionKey:r,defaultOpen:i=!0,onSelect:s,onRename:o,onDelete:a,onExport:l}){const u=m.useDeferredValue(t),c=qt(),[f,p]=m.useState(()=>Gu()),[d,g]=m.useState(()=>Ju()),[y,w]=m.useState(!1),[b,v]=m.useState(()=>new Set),T=m.useMemo(()=>new Set(f),[f]),L=u.filter(P=>T.has(P.key)),D=u.filter(P=>!T.has(P.key)),S=L.length>0&&D.length>0,$=m.useMemo(()=>{const P={chat:[],webchat:[],subagent:[],cron:[],other:[]};for(const U of D){const x=U.kind??"other";P[x].push(U)}return P},[D]),F=m.useMemo(()=>u.filter(P=>b.has(P.key)),[b,u]),B=F.length,C=m.useCallback(()=>{w(P=>(P&&v(new Set),!P))},[]),M=m.useCallback(P=>{br(P.key)||v(U=>{const x=new Set(U);return x.has(P.key)?x.delete(P.key):x.add(P.key),x})},[]),j=m.useCallback(()=>{v(new Set(u.filter(P=>!br(P.key)).map(P=>P.key)))},[u]),N=m.useCallback(()=>{w(!1),v(new Set)},[]),I=m.useCallback(async()=>{if(F.length===0||!window.confirm(`Delete ${F.length} sessions? This will archive them.`))return;const U=await Yu(F.map(x=>x.key),10,Xu);U.length>0&&console.error("[sidebar] Bulk delete failed for some sessions",U),w(!1),v(new Set),c.invalidateQueries({queryKey:pe.sessions})},[c,F]),E=m.useCallback(P=>{p(U=>{const q=U.includes(P.key)?U.filter(ee=>ee!==P.key):[...U,P.key];return Qu(q),q})},[]),R=m.useCallback((P,U)=>{g(x=>{const q={...x,[P]:U};return Zu(q),q})},[]);function z(P,U,x){return x.length===0?null:h.jsxs(Cn,{className:"flex flex-col",open:d[P],onOpenChange:q=>R(P,q),children:[h.jsxs(vn,{className:H("w-full justify-between border-l-2 border-primary-200/70 px-2 py-1 text-[11px] font-medium text-primary-500/80 text-balance"),children:[h.jsx("span",{className:"truncate",children:U}),h.jsx("span",{className:H("rounded-full bg-primary-100 px-1.5 py-0.5 text-[10px] font-medium text-primary-700 tabular-nums"),children:x.length})]}),h.jsx(En,{contentClassName:"flex flex-col gap-px",children:x.map(q=>h.jsx(Yn,{session:q,active:Gn(q,n,r),isPinned:!1,selectionMode:y,selected:b.has(q.key),onToggleSelect:M,onSelect:s,onTogglePin:E,onRename:o,onDelete:a,onExport:l},q.key))})]})}return h.jsxs(Cn,{className:"flex h-full flex-col flex-1 min-h-0 w-full",defaultOpen:i,children:[h.jsxs("div",{className:"flex items-center justify-between pr-2 shrink-0",children:[h.jsxs(vn,{className:"w-fit pl-1.5 text-balance",children:["Sessions",h.jsx("span",{className:"opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:h.jsx(ae,{icon:qs,className:"size-3 transition-transform duration-150 group-data-panel-open:rotate-90"})})]}),h.jsx("button",{type:"button",onClick:C,className:H("text-[11px] font-medium px-1.5 py-0.5 rounded-md transition-colors",y?"text-primary-900 bg-primary-200":"text-primary-500 hover:text-primary-700 hover:bg-primary-100"),children:y?"Done":"Select"})]}),h.jsx(En,{className:"w-full flex-1 min-h-0 h-auto data-starting-style:h-0 data-ending-style:h-0",contentClassName:"flex flex-1 min-h-0 flex-col overflow-y-auto",children:h.jsxs(Zs,{className:"flex-1 min-h-0",children:[h.jsx(eo,{className:"min-h-0",children:h.jsxs("div",{className:"flex flex-col gap-2 pl-2 pr-2",children:[L.length>0?h.jsx("div",{className:"flex flex-col gap-px",children:L.map(P=>h.jsx(Yn,{session:P,active:Gn(P,n,r),isPinned:!0,selectionMode:y,selected:b.has(P.key),onToggleSelect:M,onSelect:s,onTogglePin:E,onRename:o,onDelete:a,onExport:l},P.key))}):null,S?h.jsx("div",{className:"my-1 border-t border-primary-200/80"}):null,$.chat.length>0?h.jsxs("div",{className:"flex flex-col gap-px",children:[h.jsx("div",{className:H("border-l-2 border-primary-200/70 px-2 py-1 text-[11px] font-medium text-primary-500/80 text-balance"),children:"💬 Chats"}),h.jsx("div",{className:"flex flex-col gap-px",children:$.chat.map(P=>h.jsx(Yn,{session:P,active:Gn(P,n,r),isPinned:!1,selectionMode:y,selected:b.has(P.key),onToggleSelect:M,onSelect:s,onTogglePin:E,onRename:o,onDelete:a,onExport:l},P.key))})]}):null,z("webchat","🦎 OpenCami",$.webchat),z("subagent","🤖 Sub-agents",$.subagent),z("cron","⏰ Cron / Isolated",$.cron),z("other","📁 Other",$.other)]})}),h.jsx(to,{orientation:"vertical",children:h.jsx(no,{})})]})}),y?h.jsxs("div",{className:"shrink-0 border-t border-primary-200 bg-surface px-2 py-2 flex flex-col gap-1.5",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("span",{className:"text-xs text-primary-600 font-medium",children:[B," selected"]}),h.jsx("button",{type:"button",onClick:j,className:"text-[11px] font-medium text-primary-600 hover:text-primary-800",children:"Select all"})]}),h.jsxs("div",{className:"flex gap-1.5",children:[h.jsxs("button",{type:"button",onClick:I,disabled:B===0,className:H("flex-1 inline-flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-colors",B>0?"bg-red-100 text-red-700 hover:bg-red-200":"bg-primary-100 text-primary-400 cursor-not-allowed"),children:[h.jsx(ae,{icon:Hs,size:14,strokeWidth:1.5}),"Delete"]}),h.jsx("button",{type:"button",onClick:N,className:"flex-1 inline-flex items-center justify-center rounded-md px-2 py-1.5 text-xs font-medium bg-primary-100 text-primary-700 hover:bg-primary-200 transition-colors",children:"Cancel"})]})]}):null]})},tc);function tc(e,t){if(e.activeFriendlyId!==t.activeFriendlyId||e.activeSessionKey!==t.activeSessionKey||e.defaultOpen!==t.defaultOpen||e.onSelect!==t.onSelect||e.onRename!==t.onRename||e.onDelete!==t.onDelete||e.onExport!==t.onExport)return!1;if(e.sessions===t.sessions)return!0;if(e.sessions.length!==t.sessions.length)return!1;for(let n=0;n<e.sessions.length;n+=1){const r=e.sessions[n],i=t.sessions[n];if(r.key!==i.key||r.friendlyId!==i.friendlyId||r.label!==i.label||r.title!==i.title||r.derivedTitle!==i.derivedTitle||r.updatedAt!==i.updatedAt||r.kind!==i.kind)return!1}return!0}function nc(){const[e,t]=m.useState(!1),[n,r]=m.useState(!1),[i,s]=m.useState(null),[o,a]=m.useState(null),l=m.useCallback(async()=>{if(t(!0),s(null),!(n||o)){r(!0);try{const d=await fetch("/api/paths");if(!d.ok)throw new Error(await nt(d));const g=await d.json();a({agentId:String(g.agentId??"main"),stateDir:String(g.stateDir??""),sessionsDir:String(g.sessionsDir??""),storePath:String(g.storePath??"")})}catch(d){s(d instanceof Error?d.message:String(d))}finally{r(!1)}}},[o,n]),u=m.useCallback(()=>{l()},[l]),c=m.useCallback(()=>{t(!1)},[]),f=m.useCallback(()=>{if(o?.sessionsDir)try{navigator.clipboard.writeText(o.sessionsDir)}catch{}},[o]),p=m.useCallback(()=>{if(o?.storePath)try{navigator.clipboard.writeText(o.storePath)}catch{}},[o]);return{settingsOpen:e,setSettingsOpen:t,pathsLoading:n,pathsError:i,paths:o,handleOpenSettings:u,closeSettings:c,copySessionsDir:f,copyStorePath:p}}let Pe=null,Hr=!1,bn=null;function rc(e){Pe=e}function Qn(){return Pe!==null}function Wt(e){Hr=e}function Jn(){return Hr}function In(){Pe=null,Hr=!1}function ic(e,t){if(Pe){if(e&&Pe.sessionKey===e){In();return}t&&Pe.friendlyId===t&&In()}}function sc(e){bn={friendlyId:e,at:Date.now()}}function so(e,t=15e3){return!(!bn||bn.friendlyId!==e||Date.now()-bn.at>t)}function oc(e,t){if(!Pe)return null;if(e&&Pe.sessionKey===e){const n=Pe;return Pe=null,n}if(t&&Pe.friendlyId===t){const n=Pe;return Pe=null,n}return null}const ac=8e3,Ct=new Map;function lc(e){e&&Ct.set(e,{id:e,expiresAt:Date.now()+ac})}function uc(e){e&&Ct.delete(e)}function cc(e){if(Ct.size===0)return e;const t=Date.now();let n=!1;const r=e.filter(i=>{const s=Ct.get(i.key),o=Ct.get(i.friendlyId);return s&&s.expiresAt<=t||o&&o.expiresAt<=t?(s&&s.expiresAt<=t&&Ct.delete(i.key),o&&o.expiresAt<=t&&Ct.delete(i.friendlyId),!0):s||o?(n=!0,!1):!0});return n?r:e}function fc(){const e=qt(),[t,n]=m.useState(!1),[r,i]=m.useState(null),s=Bs({mutationFn:async function(l){const u=new URLSearchParams;l.sessionKey&&u.set("sessionKey",l.sessionKey),l.friendlyId&&u.set("friendlyId",l.friendlyId);const c=await fetch(`/api/sessions?${u.toString()}`,{method:"DELETE"});if(!c.ok)throw new Error(await nt(c));return l},onMutate:async function(l){i(null),lc(l.sessionKey||l.friendlyId),ic(l.sessionKey,l.friendlyId),await e.cancelQueries({queryKey:pe.sessions});const u=e.getQueryData(pe.sessions);return Zl(e,l.sessionKey,l.friendlyId),l.isActive&&(l.sessionKey||l.friendlyId)&&kr(e,l.friendlyId||l.sessionKey,l.sessionKey||l.friendlyId),{previousSessions:u,isActive:l.isActive}},onError:function(l,u,c){c?.previousSessions&&e.setQueryData(pe.sessions,c.previousSessions),uc(u.sessionKey||u.friendlyId),i(l instanceof Error?l.message:String(l))},onSuccess:function(l){l.isActive&&In(),e.invalidateQueries({queryKey:pe.sessions})},onSettled:function(){n(!1)}});return{deleteSession:m.useCallback(async(a,l,u)=>{!a&&!l||(n(!0),await s.mutateAsync({sessionKey:a,friendlyId:l,isActive:u}))},[s]),deleting:t,error:r}}function hc(){const e=qt(),[t,n]=m.useState(!1),[r,i]=m.useState(null),s=Bs({mutationFn:async function(l){const u=await fetch("/api/sessions",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({sessionKey:l.sessionKey,label:l.newTitle})});if(!u.ok)throw new Error(await nt(u));return l},onMutate:async function(l){i(null),await e.cancelQueries({queryKey:pe.sessions});const u=e.getQueryData(pe.sessions);return e.setQueryData(pe.sessions,function(f){return Array.isArray(f)?f.map(p=>p.key!==l.sessionKey?p:{...p,label:l.newTitle,title:l.newTitle}):f}),{previousSessions:u}},onError:function(l,u,c){c?.previousSessions&&e.setQueryData(pe.sessions,c.previousSessions),i(l instanceof Error?l.message:String(l))},onSuccess:function(){e.invalidateQueries({queryKey:pe.sessions})},onSettled:function(){n(!1)}});return{renameSession:m.useCallback(async(a,l)=>{!a||!l.trim()||(n(!0),await s.mutateAsync({sessionKey:a,newTitle:l.trim()}))},[s]),renaming:t,error:r}}function pc({className:e}){return h.jsx("div",{className:e,children:h.jsx("span",{className:"text-xl",children:"🦎"})})}function dc({className:e}){return h.jsx("span",{className:e,style:{background:"linear-gradient(90deg, #10b981, #14b8a6, #06b6d4, #8b5cf6, #ec4899)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text",fontWeight:600},children:"OpenCami"})}const mc=m.lazy(()=>zn(()=>import("./settings-dialog-D0aYDkAM.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.SettingsDialog}))),gc=m.lazy(()=>zn(()=>import("./session-export-dialog-uOlDUzgX.js"),__vite__mapDeps([5,1,3,2])).then(e=>({default:e.SessionExportDialog})));function xc({sessions:e,activeFriendlyId:t,activeSessionKey:n,creatingSession:r,onCreateSession:i,isCollapsed:s,onToggleCollapse:o,onSelectSession:a,onActiveSessionDelete:l,onOpenSearch:u}){const{settingsOpen:c,setSettingsOpen:f,pathsLoading:p,pathsError:d,paths:g,handleOpenSettings:y,closeSettings:w,copySessionsDir:b,copyStorePath:v}=nc(),{deleteSession:T}=fc(),{renameSession:L}=hc(),D={duration:.15,ease:s?"easeIn":"easeOut"},[S,$]=m.useState(!1),[F,B]=m.useState(null),[C,M]=m.useState(""),[j,N]=m.useState(!1),[I,E]=m.useState(null),[R,z]=m.useState(null),[P,U]=m.useState(""),[x,q]=m.useState(!1),[ee,k]=m.useState(null),[ce,Q]=m.useState(null),[re,be]=m.useState(""),he=qt();function te(J){B(J.key),M(J.label||J.title||J.derivedTitle||""),$(!0)}function oe(J){F&&L(F,J),$(!1),B(null)}function ge(J){E(J.key),z(J.friendlyId),U(J.label||J.title||J.derivedTitle||J.friendlyId),N(!0)}function Ie(){if(I&&R){const J=R===t;J&&l&&l(),T(I,R,J)}N(!1),E(null),z(null)}function de(J){k(J.key),Q(J.friendlyId),be(J.label||J.title||J.derivedTitle||J.friendlyId),q(!0)}function _e(J){if(ee&&ce){const X=pe.history(ce,ee),Ae=he.getQueryData(X);Ae?.messages&&iu(re,Ae.messages,J)}q(!1),k(null),Q(null)}const Ce={className:"border-r border-primary-200 h-full overflow-hidden bg-primary-100 flex flex-col"};return h.jsxs(Ke.aside,{initial:!1,animate:{width:s?48:300},transition:D,className:Ce.className,children:[h.jsxs(Ke.div,{layout:!0,transition:{layout:D},className:H("flex items-center h-12 px-2 justify-between"),children:[h.jsx(At,{initial:!1,children:s?null:h.jsx(Ke.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:D,children:h.jsxs(gr,{to:"/new",className:H(Si({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start"),children:[h.jsx(pc,{className:"size-5"}),h.jsx(dc,{})]})})}),h.jsx(Ot,{children:h.jsxs(Ft,{children:[h.jsx($t,{onClick:o,render:h.jsx(ye,{size:"icon-sm",variant:"ghost",children:h.jsx(ae,{icon:gl,size:20,strokeWidth:1.5})})}),h.jsx(Bt,{side:"right",children:s?"Open Sidebar":"Close Sidebar"})]})})]}),h.jsxs("div",{className:"px-2 mb-4 flex flex-col gap-1",children:[h.jsxs(Ke.div,{layout:!0,transition:{layout:D},className:"w-full space-y-2",children:[h.jsxs(ye,{disabled:r,variant:"ghost",size:"sm",onClick:i,onMouseUp:a,className:"w-full pl-1.5 justify-start",children:[h.jsx(ae,{icon:xl,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(At,{initial:!1,mode:"wait",children:!s&&h.jsx(Ke.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:D,className:"overflow-hidden whitespace-nowrap",children:"New Session"})})]}),h.jsx(Ot,{children:h.jsxs(Ft,{children:[h.jsx($t,{asChild:!0,children:h.jsxs(gr,{to:"/files",className:H(Si({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start"),onClick:a,children:[h.jsx(ae,{icon:yl,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(At,{initial:!1,mode:"wait",children:!s&&h.jsx(Ke.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:D,className:"overflow-hidden whitespace-nowrap",children:"Files"})})]})}),s&&h.jsx(Bt,{side:"right",children:"Files"})]})})]}),h.jsx(Ke.div,{layout:!0,transition:{layout:D},className:"w-full",children:h.jsxs(ye,{variant:"ghost",size:"sm",onClick:u,className:"w-full pl-1.5 justify-start",children:[h.jsx(ae,{icon:bl,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(At,{initial:!1,mode:"wait",children:!s&&h.jsx(Ke.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:D,className:"overflow-hidden whitespace-nowrap",children:"Search"})})]})})]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:h.jsx(At,{initial:!1,children:!s&&h.jsx(Ke.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:D,className:"pt-0 flex flex-col w-full min-h-0 h-full",children:h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(ec,{sessions:e,activeFriendlyId:t,activeSessionKey:n,onSelect:a,onRename:te,onDelete:ge,onExport:de})})},"content")})}),h.jsx("div",{className:"px-2 py-3 border-t border-primary-200 bg-primary-100",children:h.jsx(Ke.div,{layout:!0,transition:{layout:D},className:"w-full",children:h.jsxs(ye,{variant:"ghost",size:"sm",onClick:y,title:s?"Settings":void 0,className:"w-full justify-start pl-1.5",children:[h.jsx(ae,{icon:kl,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(At,{initial:!1,mode:"wait",children:!s&&h.jsx(Ke.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:D,className:"overflow-hidden whitespace-nowrap",children:"Settings"})})]})})}),c&&h.jsx(m.Suspense,{fallback:null,children:h.jsx(mc,{open:c,onOpenChange:f,pathsLoading:p,pathsError:d,paths:g,onClose:w,onCopySessionsDir:b,onCopyStorePath:v})}),h.jsx(ou,{open:S,onOpenChange:$,sessionTitle:C,onSave:oe,onCancel:()=>$(!1)}),h.jsx(du,{open:j,onOpenChange:N,sessionTitle:P,onConfirm:Ie,onCancel:()=>N(!1)}),x&&h.jsx(m.Suspense,{fallback:null,children:h.jsx(gc,{open:x,onOpenChange:q,sessionTitle:re,onExport:_e,onCancel:()=>q(!1)})})]})}function yc(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const r=e[n],i=t[n];if(r.key!==i.key||r.friendlyId!==i.friendlyId||r.label!==i.label||r.title!==i.title||r.derivedTitle!==i.derivedTitle||r.updatedAt!==i.updatedAt)return!1}return!0}function bc(e,t){return!(e.activeFriendlyId!==t.activeFriendlyId||e.activeSessionKey!==t.activeSessionKey||e.creatingSession!==t.creatingSession||e.isCollapsed!==t.isCollapsed||!yc(e.sessions,t.sessions))}const kc=m.memo(xc,bc);function Ni(e){if(e<=0)return"0";if(e>=1e6){const t=e/1e6,n=t.toFixed(1);return n.endsWith(".0")?`${Math.round(t)}M`:`${n}M`}if(e>=1e5)return`${Math.round(e/1e3)}K`;if(e>=1e4)return`${Math.round(e/1e3)}K`;if(e>=1e3){const t=e/1e3,n=t.toFixed(1);return n.endsWith(".0")?`${Math.round(t)}K`:`${n}K`}return String(Math.round(e))}function Di(e){return e>=90?{bar:"bg-red-500",text:"text-red-600 dark:text-red-400"}:e>=70?{bar:"bg-yellow-500",text:"text-yellow-600 dark:text-yellow-400"}:{bar:"bg-emerald-500",text:"text-emerald-600 dark:text-emerald-400"}}function wc({totalTokens:e,contextTokens:t,className:n}){const{percentage:r,usedStr:i,maxStr:s,colors:o,hasData:a,isNearlyFull:l}=m.useMemo(()=>{if(typeof t!="number"||t<=0)return{percentage:0,usedStr:"",maxStr:"",colors:Di(0),hasData:!1,isNearlyFull:!1};const f=typeof e=="number"&&e>0?e:0,p=Math.min(100,Math.round(f/t*100));return{percentage:p,usedStr:Ni(f),maxStr:Ni(t),colors:Di(p),hasData:!0,isNearlyFull:p>=95}},[e,t]);if(!a)return null;const u=typeof e=="number"&&e>0?e.toLocaleString():"0",c=typeof t=="number"?t.toLocaleString():"0";return h.jsxs("div",{className:H("group relative flex items-center gap-1.5",n),title:`Context: ${u} / ${c} tokens (${r}%)`,children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("div",{className:"w-12 h-1.5 rounded-full bg-primary-200 dark:bg-primary-700 overflow-hidden shrink-0 group-hover:h-2 transition-all",children:h.jsx("div",{className:H("h-full rounded-full transition-all duration-500 ease-out",o.bar,l&&"animate-pulse"),style:{width:`${r}%`}})}),h.jsx("span",{className:H("text-[10px] leading-none font-medium tabular-nums whitespace-nowrap",l?o.text:"text-primary-500 dark:text-primary-400"),children:i})]}),h.jsx("div",{className:H("absolute right-0 top-full mt-1 z-50","pointer-events-none opacity-0 scale-95","group-hover:pointer-events-auto group-hover:opacity-100 group-hover:scale-100","transition-all duration-150 origin-top-right"),children:h.jsxs("div",{className:H("rounded-md border border-primary-200 dark:border-primary-700","bg-surface shadow-lg px-3 py-2","text-xs whitespace-nowrap"),children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[h.jsx("span",{className:"text-primary-500 dark:text-primary-400",children:"Context window"}),h.jsxs("span",{className:H("font-semibold",o.text),children:[r,"%"]})]}),h.jsxs("div",{className:"flex items-center gap-1.5 text-primary-700 dark:text-primary-300",children:[h.jsx("span",{className:"font-medium",children:i}),h.jsx("span",{className:"text-primary-400",children:"/"}),h.jsx("span",{children:s}),h.jsx("span",{className:"text-primary-400",children:"tokens"})]}),h.jsx("div",{className:"w-full h-1.5 rounded-full bg-primary-200 dark:bg-primary-700 overflow-hidden mt-1.5",children:h.jsx("div",{className:H("h-full rounded-full transition-all duration-500 ease-out",o.bar),style:{width:`${r}%`}})}),l&&h.jsx("div",{className:"mt-1.5 text-[10px] text-red-500 dark:text-red-400 font-medium",children:"⚠ Context nearly full — consider /compact"})]})})]})}const Sc=m.memo(wc);function Cc({activeTitle:e,wrapperRef:t,showSidebarButton:n=!1,onOpenSidebar:r,totalTokens:i,contextTokens:s}){return h.jsxs("div",{ref:t,className:"border-b border-primary-200 px-4 h-12 flex items-center bg-surface",children:[n?h.jsx(ye,{size:"icon-sm",variant:"ghost",onClick:r,className:"mr-2 text-primary-800 hover:bg-primary-100","aria-label":"Open sidebar",children:h.jsx(ae,{icon:wl,size:18,strokeWidth:1.6})}):null,h.jsx("div",{className:"text-sm font-medium truncate flex-1 min-w-0",children:e}),h.jsx(Sc,{totalTokens:i,contextTokens:s,className:"ml-3 hidden sm:flex"})]})}const vc=m.memo(Cc);function Ec(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Tc(e){const t=new Date(e);return Ec(t,new Date)?new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit"}).format(t):new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short"}).format(t)}function jc(e){return new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(e))}function Ic({timestamp:e}){const t=Tc(e),n=jc(e);return h.jsx(Ot,{children:h.jsxs(Ft,{children:[h.jsx($t,{className:"inline-flex items-center text-xs text-primary-600",children:t}),h.jsx(Bt,{side:"top",children:n})]})})}function Ac({text:e,align:t,timestamp:n,forceVisible:r=!1}){const[i,s]=m.useState(!1),[o,a]=m.useState("idle"),l=m.useRef(null),u=m.useRef(null),[c,f]=m.useState(()=>{if(typeof window>"u")return!0;try{const w=localStorage.getItem("opencami-tts-enabled");return w===null?!0:w==="true"}catch{return!0}});m.useEffect(()=>{function w(b){b.key==="opencami-tts-enabled"&&f(b.newValue===null?!0:b.newValue==="true")}return window.addEventListener("storage",w),()=>window.removeEventListener("storage",w)},[]),m.useEffect(()=>()=>{l.current&&(l.current.pause(),l.current=null),u.current&&(URL.revokeObjectURL(u.current),u.current=null)},[]);const p=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{s(!1)}},d=async()=>{if(o==="playing"){l.current&&(l.current.pause(),l.current=null),u.current&&(URL.revokeObjectURL(u.current),u.current=null),a("idle");return}a("loading");try{const w=await fetch("/api/tts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:e})});if(!w.ok)throw new Error("TTS failed");const b=await w.blob(),v=URL.createObjectURL(b);u.current=v;const T=new Audio(v);l.current=T,T.onended=()=>{a("idle"),u.current&&(URL.revokeObjectURL(u.current),u.current=null),l.current=null},T.onerror=()=>{a("idle"),u.current&&(URL.revokeObjectURL(u.current),u.current=null),l.current=null},await T.play(),a("playing")}catch{a("idle"),u.current&&(URL.revokeObjectURL(u.current),u.current=null),l.current=null}},g=t==="end"?"justify-end":"justify-start",y=t==="start"&&c&&e.trim().length>0;return h.jsxs("div",{className:H("flex items-center gap-2 text-xs text-primary-600 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 duration-100 ease-out",r?"opacity-100":"opacity-0",g),children:[h.jsx(Ot,{children:h.jsxs(Ft,{children:[h.jsx($t,{type:"button",onClick:()=>{p().catch(()=>{})},className:"inline-flex items-center justify-center rounded border border-transparent bg-transparent p-1 text-primary-700 hover:text-primary-900 hover:bg-primary-100",children:h.jsx(ae,{icon:i?Us:Sl,size:16,strokeWidth:1.6})}),h.jsx(Bt,{side:"top",children:"Copy"})]})}),y&&h.jsx(Ot,{children:h.jsxs(Ft,{children:[h.jsx($t,{type:"button",onClick:()=>{d().catch(()=>{})},disabled:o==="loading",className:H("inline-flex items-center justify-center rounded border border-transparent bg-transparent p-1 text-primary-700 hover:text-primary-900 hover:bg-primary-100",o==="loading"&&"opacity-60 cursor-wait"),children:h.jsx(ae,{icon:o==="loading"?Cl:o==="playing"?vl:El,size:16,strokeWidth:1.6,className:H(o==="loading"&&"animate-spin")})}),h.jsx(Bt,{side:"top",children:o==="loading"?"Generating speech…":o==="playing"?"Stop":"Listen"})]})}),h.jsx(Ic,{timestamp:n})]})}function qr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var jt=qr();function oo(e){jt=e}var tn={exec:()=>null};function ie(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(je.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,t)};return r}var Rc=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),je={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},Nc=/^(?:[ \t]*(?:\n|$))+/,Dc=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Lc=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ln=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Mc=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ur=/(?:[*+-]|\d{1,9}[.)])/,ao=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,lo=ie(ao).replace(/bull/g,Ur).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Pc=ie(ao).replace(/bull/g,Ur).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Kr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,zc=/^[^\n]+/,Wr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,_c=ie(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Wr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Oc=ie(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ur).getRegex(),On="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Vr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Fc=ie("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Vr).replace("tag",On).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),uo=ie(Kr).replace("hr",ln).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",On).getRegex(),$c=ie(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",uo).getRegex(),Xr={blockquote:$c,code:Dc,def:_c,fences:Lc,heading:Mc,hr:ln,html:Fc,lheading:lo,list:Oc,newline:Nc,paragraph:uo,table:tn,text:zc},Li=ie("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ln).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",On).getRegex(),Bc={...Xr,lheading:Pc,table:Li,paragraph:ie(Kr).replace("hr",ln).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Li).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",On).getRegex()},Hc={...Xr,html:ie(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Vr).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:tn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ie(Kr).replace("hr",ln).replace("heading",` *#{1,6} *[^
|
|
6
|
+
]`).replace("lheading",lo).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},qc=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Uc=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,co=/^( {2,}|\\)\n(?!\s*$)/,Kc=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Fn=/[\p{P}\p{S}]/u,Yr=/[\s\p{P}\p{S}]/u,fo=/[^\s\p{P}\p{S}]/u,Wc=ie(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Yr).getRegex(),ho=/(?!~)[\p{P}\p{S}]/u,Vc=/(?!~)[\s\p{P}\p{S}]/u,Xc=/(?:[^\s\p{P}\p{S}]|~)/u,Yc=ie(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Rc?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),po=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Gc=ie(po,"u").replace(/punct/g,Fn).getRegex(),Qc=ie(po,"u").replace(/punct/g,ho).getRegex(),mo="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Jc=ie(mo,"gu").replace(/notPunctSpace/g,fo).replace(/punctSpace/g,Yr).replace(/punct/g,Fn).getRegex(),Zc=ie(mo,"gu").replace(/notPunctSpace/g,Xc).replace(/punctSpace/g,Vc).replace(/punct/g,ho).getRegex(),ef=ie("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,fo).replace(/punctSpace/g,Yr).replace(/punct/g,Fn).getRegex(),tf=ie(/\\(punct)/,"gu").replace(/punct/g,Fn).getRegex(),nf=ie(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),rf=ie(Vr).replace("(?:-->|$)","-->").getRegex(),sf=ie("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",rf).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),An=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,of=ie(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",An).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),go=ie(/^!?\[(label)\]\[(ref)\]/).replace("label",An).replace("ref",Wr).getRegex(),xo=ie(/^!?\[(ref)\](?:\[\])?/).replace("ref",Wr).getRegex(),af=ie("reflink|nolink(?!\\()","g").replace("reflink",go).replace("nolink",xo).getRegex(),Mi=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Gr={_backpedal:tn,anyPunctuation:tf,autolink:nf,blockSkip:Yc,br:co,code:Uc,del:tn,emStrongLDelim:Gc,emStrongRDelimAst:Jc,emStrongRDelimUnd:ef,escape:qc,link:of,nolink:xo,punctuation:Wc,reflink:go,reflinkSearch:af,tag:sf,text:Kc,url:tn},lf={...Gr,link:ie(/^!?\[(label)\]\((.*?)\)/).replace("label",An).getRegex(),reflink:ie(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",An).getRegex()},wr={...Gr,emStrongRDelimAst:Zc,emStrongLDelim:Qc,url:ie(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Mi).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:ie(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Mi).getRegex()},uf={...wr,br:ie(co).replace("{2,}","*").getRegex(),text:ie(wr.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},pn={normal:Xr,gfm:Bc,pedantic:Hc},Vt={normal:Gr,gfm:wr,breaks:uf,pedantic:lf},cf={"&":"&","<":"<",">":">",'"':""","'":"'"},Pi=e=>cf[e];function at(e,t){if(t){if(je.escapeTest.test(e))return e.replace(je.escapeReplace,Pi)}else if(je.escapeTestNoEncode.test(e))return e.replace(je.escapeReplaceNoEncode,Pi);return e}function zi(e){try{e=encodeURI(e).replace(je.percentDecode,"%")}catch{return null}return e}function _i(e,t){let n=e.replace(je.findPipe,(s,o,a)=>{let l=!1,u=o;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(je.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(je.slashPipe,"|");return r}function Xt(e,t,n){let r=e.length;if(r===0)return"";let i=0;for(;i<r&&e.charAt(r-i-1)===t;)i++;return e.slice(0,r-i)}function ff(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Oi(e,t,n,r,i){let s=t.href,o=t.title||null,a=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function hf(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
7
|
+
`).map(s=>{let o=s.match(n.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
|
|
8
|
+
`)}var Rn=class{options;rules;lexer;constructor(e){this.options=e||jt}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Xt(n,`
|
|
9
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=hf(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=Xt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Xt(t[0],`
|
|
10
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Xt(t[0],`
|
|
11
|
+
`).split(`
|
|
12
|
+
`),r="",i="",s=[];for(;n.length>0;){let o=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=!0;else if(!o)a.push(n[l]);else break;n=n.slice(l);let u=a.join(`
|
|
13
|
+
`),c=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
14
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
15
|
+
${u}`:u,i=i?`${i}
|
|
16
|
+
${c}`:c;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,s,!0),this.lexer.state.top=f,n.length===0)break;let p=s.at(-1);if(p?.type==="code")break;if(p?.type==="blockquote"){let d=p,g=d.raw+`
|
|
17
|
+
`+n.join(`
|
|
18
|
+
`),y=this.blockquote(g);s[s.length-1]=y,r=r.substring(0,r.length-d.raw.length)+y.raw,i=i.substring(0,i.length-d.text.length)+y.text;break}else if(p?.type==="list"){let d=p,g=d.raw+`
|
|
19
|
+
`+n.join(`
|
|
20
|
+
`),y=this.list(g);s[s.length-1]=y,r=r.substring(0,r.length-p.raw.length)+y.raw,i=i.substring(0,i.length-d.raw.length)+y.raw,n=g.substring(s.at(-1).raw.length).split(`
|
|
21
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),o=!1;for(;e;){let l=!1,u="",c="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;u=t[0],e=e.substring(u.length);let f=t[2].split(`
|
|
22
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,y=>" ".repeat(3*y.length)),p=e.split(`
|
|
23
|
+
`,1)[0],d=!f.trim(),g=0;if(this.options.pedantic?(g=2,c=f.trimStart()):d?g=t[1].length+1:(g=t[2].search(this.rules.other.nonSpaceChar),g=g>4?1:g,c=f.slice(g),g+=t[1].length),d&&this.rules.other.blankLine.test(p)&&(u+=p+`
|
|
24
|
+
`,e=e.substring(p.length+1),l=!0),!l){let y=this.rules.other.nextBulletRegex(g),w=this.rules.other.hrRegex(g),b=this.rules.other.fencesBeginRegex(g),v=this.rules.other.headingBeginRegex(g),T=this.rules.other.htmlBeginRegex(g);for(;e;){let L=e.split(`
|
|
25
|
+
`,1)[0],D;if(p=L,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),D=p):D=p.replace(this.rules.other.tabCharGlobal," "),b.test(p)||v.test(p)||T.test(p)||y.test(p)||w.test(p))break;if(D.search(this.rules.other.nonSpaceChar)>=g||!p.trim())c+=`
|
|
26
|
+
`+D.slice(g);else{if(d||f.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||b.test(f)||v.test(f)||w.test(f))break;c+=`
|
|
27
|
+
`+p}!d&&!p.trim()&&(d=!0),u+=L+`
|
|
28
|
+
`,e=e.substring(L.length+1),f=D.slice(g)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(o=!0)),i.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),i.raw+=u}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),l.tokens[0]?.type==="text"||l.tokens[0]?.type==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let c=this.lexer.inlineQueue.length-1;c>=0;c--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)){this.lexer.inlineQueue[c].src=this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask,"");break}}let u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let c={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};l.checked=c.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=c.raw+l.tokens[0].raw,l.tokens[0].text=c.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(c)):l.tokens.unshift({type:"paragraph",raw:c.raw,text:c.raw,tokens:[c]}):l.tokens.unshift(c)}}if(!i.loose){let u=l.tokens.filter(f=>f.type==="space"),c=u.length>0&&u.some(f=>this.rules.other.anyLine.test(f.raw));i.loose=c}}if(i.loose)for(let l of i.items){l.loose=!0;for(let u of l.tokens)u.type==="text"&&(u.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=_i(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
29
|
+
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<n.length;o++)s.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:s.align[o]});for(let o of i)s.rows.push(_i(o,s.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:s.align[l]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
30
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=Xt(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=ff(t[2],"()");if(s===-2)return;if(s>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Oi(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return Oi(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,s,o,a=i,l=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*e.length+i);(r=u.exec(t))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let c=[...r[0]][0].length,f=e.slice(0,i+r.index+c+o);if(Math.min(i,o)%2){let d=f.slice(1,-1);return{type:"em",raw:f,text:d,tokens:this.lexer.inlineTokens(d)}}let p=f.slice(2,-2);return{type:"strong",raw:f,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},We=class Sr{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||jt,this.options.tokenizer=this.options.tokenizer||new Rn,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:je,block:pn.normal,inline:Vt.normal};this.options.pedantic?(n.block=pn.pedantic,n.inline=Vt.pedantic):this.options.gfm&&(n.block=pn.gfm,this.options.breaks?n.inline=Vt.breaks:n.inline=Vt.gfm),this.tokenizer.rules=n}static get rules(){return{block:pn,inline:Vt}}static lex(t,n){return new Sr(n).lex(t)}static lexInline(t,n){return new Sr(n).inlineTokens(t)}lex(t){t=t.replace(je.carriageReturn,`
|
|
31
|
+
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){for(this.options.pedantic&&(t=t.replace(je.tabCharGlobal," ").replace(je.spaceLine,""));t;){let i;if(this.options.extensions?.block?.some(o=>(i=o.call({lexer:this},t,n))?(t=t.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(t)){t=t.substring(i.raw.length);let o=n.at(-1);i.raw.length===1&&o!==void 0?o.raw+=`
|
|
32
|
+
`:n.push(i);continue}if(i=this.tokenizer.code(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
33
|
+
`)?"":`
|
|
34
|
+
`)+i.raw,o.text+=`
|
|
35
|
+
`+i.text,this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(i=this.tokenizer.fences(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
36
|
+
`)?"":`
|
|
37
|
+
`)+i.raw,o.text+=`
|
|
38
|
+
`+i.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(t)){t=t.substring(i.raw.length),n.push(i);continue}let s=t;if(this.options.extensions?.startBlock){let o=1/0,a=t.slice(1),l;this.options.extensions.startBlock.forEach(u=>{l=u.call({lexer:this},a),typeof l=="number"&&l>=0&&(o=Math.min(o,l))}),o<1/0&&o>=0&&(s=t.substring(0,o+1))}if(this.state.top&&(i=this.tokenizer.paragraph(s))){let o=n.at(-1);r&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(`
|
|
39
|
+
`)?"":`
|
|
40
|
+
`)+i.raw,o.text+=`
|
|
41
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i),r=s.length!==t.length,t=t.substring(i.raw.length);continue}if(i=this.tokenizer.text(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
42
|
+
`)?"":`
|
|
43
|
+
`)+i.raw,o.text+=`
|
|
44
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(t){let o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r=t,i=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)l.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let o=!1,a="";for(;t;){o||(a=""),o=!1;let l;if(this.options.extensions?.inline?.some(c=>(l=c.call({lexer:this},t,n))?(t=t.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(l.raw.length);let c=n.at(-1);l.type==="text"&&c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(t,r,a)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(t)){t=t.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(t))){t=t.substring(l.raw.length),n.push(l);continue}let u=t;if(this.options.extensions?.startInline){let c=1/0,f=t.slice(1),p;this.options.extensions.startInline.forEach(d=>{p=d.call({lexer:this},f),typeof p=="number"&&p>=0&&(c=Math.min(c,p))}),c<1/0&&c>=0&&(u=t.substring(0,c+1))}if(l=this.tokenizer.inlineText(u)){t=t.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(a=l.raw.slice(-1)),o=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):n.push(l);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return n}},Nn=class{options;parser;constructor(e){this.options=e||jt}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(je.notSpaceStart)?.[0],i=e.replace(je.endingNewline,"")+`
|
|
45
|
+
`;return r?'<pre><code class="language-'+at(r)+'">'+(n?i:at(i,!0))+`</code></pre>
|
|
46
|
+
`:"<pre><code>"+(n?i:at(i,!0))+`</code></pre>
|
|
47
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
48
|
+
${this.parser.parse(e)}</blockquote>
|
|
49
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
50
|
+
`}hr(e){return`<hr>
|
|
51
|
+
`}list(e){let t=e.ordered,n=e.start,r="";for(let o=0;o<e.items.length;o++){let a=e.items[o];r+=this.listitem(a)}let i=t?"ol":"ul",s=t&&n!==1?' start="'+n+'"':"";return"<"+i+s+`>
|
|
52
|
+
`+r+"</"+i+`>
|
|
53
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
54
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
55
|
+
`}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let s=e.rows[i];n="";for(let o=0;o<s.length;o++)n+=this.tablecell(s[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
56
|
+
<thead>
|
|
57
|
+
`+t+`</thead>
|
|
58
|
+
`+r+`</table>
|
|
59
|
+
`}tablerow({text:e}){return`<tr>
|
|
60
|
+
${e}</tr>
|
|
61
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
62
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${at(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=zi(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+at(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=zi(e);if(i===null)return at(n);e=i;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${at(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:at(e.text)}},Qr=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Ve=class Cr{options;renderer;textRenderer;constructor(t){this.options=t||jt,this.options.renderer=this.options.renderer||new Nn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Qr}static parse(t,n){return new Cr(n).parse(t)}static parseInline(t,n){return new Cr(n).parseInline(t)}parse(t){let n="";for(let r=0;r<t.length;r++){let i=t[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=a||"";continue}}let s=i;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,n=this.renderer){let r="";for(let i=0;i<t.length;i++){let s=t[i];if(this.options.extensions?.renderers?.[s.type]){let a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){r+=a||"";continue}}let o=s;switch(o.type){case"escape":{r+=n.text(o);break}case"html":{r+=n.html(o);break}case"link":{r+=n.link(o);break}case"image":{r+=n.image(o);break}case"checkbox":{r+=n.checkbox(o);break}case"strong":{r+=n.strong(o);break}case"em":{r+=n.em(o);break}case"codespan":{r+=n.codespan(o);break}case"br":{r+=n.br(o);break}case"del":{r+=n.del(o);break}case"text":{r+=n.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},Zt=class{options;block;constructor(e){this.options=e||jt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?We.lex:We.lexInline}provideParser(){return this.block?Ve.parse:Ve.parseInline}},pf=class{defaults=qr();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ve;Renderer=Nn;TextRenderer=Qr;Lexer=We;Tokenizer=Rn;Hooks=Zt;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of i.rows)for(let o of s)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let o=i[s].flat(1/0);n=n.concat(this.walkTokens(o,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new Nn(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=n.renderer[o],l=i[o];i[o]=(...u)=>{let c=a.apply(i,u);return c===!1&&(c=l.apply(i,u)),c||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new Rn(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=n.tokenizer[o],l=i[o];i[o]=(...u)=>{let c=a.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Zt;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=n.hooks[o],l=i[o];Zt.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Zt.passThroughHooksRespectAsync.has(s))return(async()=>{let f=await a.call(i,u);return l.call(i,f)})();let c=a.call(i,u);return l.call(i,c)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(i,u);return f===!1&&(f=await l.apply(i,u)),f})();let c=a.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return We.lex(e,t??this.defaults)}parser(e,t){return Ve.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,a=await(i.hooks?await i.hooks.provideLexer():e?We.lex:We.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():e?Ve.parse:Ve.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():e?We.lex:We.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():e?Ve.parse:Ve.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(e,t){return n=>{if(n.message+=`
|
|
63
|
+
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+at(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Et=new pf;function le(e,t){return Et.parse(e,t)}le.options=le.setOptions=function(e){return Et.setOptions(e),le.defaults=Et.defaults,oo(le.defaults),le};le.getDefaults=qr;le.defaults=jt;le.use=function(...e){return Et.use(...e),le.defaults=Et.defaults,oo(le.defaults),le};le.walkTokens=function(e,t){return Et.walkTokens(e,t)};le.parseInline=Et.parseInline;le.Parser=Ve;le.parser=Ve.parse;le.Renderer=Nn;le.TextRenderer=Qr;le.Lexer=We;le.lexer=We.lex;le.Tokenizer=Rn;le.Hooks=Zt;le.parse=le;le.options;le.setOptions;le.use;le.walkTokens;le.parseInline;Ve.parse;We.lex;const df=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,mf=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gf={};function Fi(e,t){return(gf.jsx?mf:df).test(e)}var Nt={},Zn,$i;function xf(){if($i)return Zn;$i=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
|
|
64
|
+
`,u="/",c="*",f="",p="comment",d="declaration";function g(w,b){if(typeof w!="string")throw new TypeError("First argument must be a string");if(!w)return[];b=b||{};var v=1,T=1;function L(I){var E=I.match(t);E&&(v+=E.length);var R=I.lastIndexOf(l);T=~R?I.length-R:T+I.length}function D(){var I={line:v,column:T};return function(E){return E.position=new S(I),B(),E}}function S(I){this.start=I,this.end={line:v,column:T},this.source=b.source}S.prototype.content=w;function $(I){var E=new Error(b.source+":"+v+":"+T+": "+I);if(E.reason=I,E.filename=b.source,E.line=v,E.column=T,E.source=w,!b.silent)throw E}function F(I){var E=I.exec(w);if(E){var R=E[0];return L(R),w=w.slice(R.length),E}}function B(){F(n)}function C(I){var E;for(I=I||[];E=M();)E!==!1&&I.push(E);return I}function M(){var I=D();if(!(u!=w.charAt(0)||c!=w.charAt(1))){for(var E=2;f!=w.charAt(E)&&(c!=w.charAt(E)||u!=w.charAt(E+1));)++E;if(E+=2,f===w.charAt(E-1))return $("End of comment missing");var R=w.slice(2,E-2);return T+=2,L(R),w=w.slice(E),T+=2,I({type:p,comment:R})}}function j(){var I=D(),E=F(r);if(E){if(M(),!F(i))return $("property missing ':'");var R=F(s),z=I({type:d,property:y(E[0].replace(e,f)),value:R?y(R[0].replace(e,f)):f});return F(o),z}}function N(){var I=[];C(I);for(var E;E=j();)E!==!1&&(I.push(E),C(I));return I}return B(),N()}function y(w){return w?w.replace(a,f):f}return Zn=g,Zn}var Bi;function yf(){if(Bi)return Nt;Bi=1;var e=Nt&&Nt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.default=n;const t=e(xf());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),a=typeof i=="function";return o.forEach(l=>{if(l.type!=="declaration")return;const{property:u,value:c}=l;a?i(u,c,l):c&&(s=s||{},s[u]=c)}),s}return Nt}var Yt={},Hi;function bf(){if(Hi)return Yt;Hi=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||e.test(u)},o=function(u,c){return c.toUpperCase()},a=function(u,c){return"".concat(c,"-")},l=function(u,c){return c===void 0&&(c={}),s(u)?u:(u=u.toLowerCase(),c.reactCompat?u=u.replace(i,a):u=u.replace(r,a),u.replace(t,o))};return Yt.camelCase=l,Yt}var Gt,qi;function kf(){if(qi)return Gt;qi=1;var e=Gt&&Gt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(yf()),n=bf();function r(i,s){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(a,l){a&&l&&(o[(0,n.camelCase)(a,s)]=l)}),o}return r.default=r,Gt=r,Gt}var wf=kf();const Sf=Ms(wf),yo=bo("end"),Jr=bo("start");function bo(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Cf(e){const t=Jr(e),n=yo(e);if(t&&n)return{start:t,end:n}}function nn(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Ui(e.position):"start"in e||"end"in e?Ui(e):"line"in e||"column"in e?vr(e):""}function vr(e){return Ki(e&&e.line)+":"+Ki(e&&e.column)}function Ui(e){return vr(e&&e.start)+"-"+vr(e&&e.end)}function Ki(e){return e&&typeof e=="number"?e:1}class Se extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=nn(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Se.prototype.file="";Se.prototype.name="";Se.prototype.reason="";Se.prototype.message="";Se.prototype.stack="";Se.prototype.column=void 0;Se.prototype.line=void 0;Se.prototype.ancestors=void 0;Se.prototype.cause=void 0;Se.prototype.fatal=void 0;Se.prototype.place=void 0;Se.prototype.ruleId=void 0;Se.prototype.source=void 0;const Zr={}.hasOwnProperty,vf=new Map,Ef=/[A-Z]/g,Tf=new Set(["table","tbody","thead","tfoot","tr"]),jf=new Set(["td","th"]),ko="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function If(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=zf(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Pf(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Fr:Nl,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=wo(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function wo(e,t,n){if(t.type==="element")return Af(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Rf(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Df(e,t,n);if(t.type==="mdxjsEsm")return Nf(e,t);if(t.type==="root")return Lf(e,t,n);if(t.type==="text")return Mf(e,t)}function Af(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Fr,e.schema=i),e.ancestors.push(t);const s=Co(e,t.tagName,!1),o=_f(e,t);let a=ti(e,t);return Tf.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!Dl(l):!0})),So(e,o,s,t),ei(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Rf(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}on(e,t.position)}function Nf(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);on(e,t.position)}function Df(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Fr,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:Co(e,t.name,!0),o=Of(e,t),a=ti(e,t);return So(e,o,s,t),ei(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Lf(e,t,n){const r={};return ei(r,ti(e,t)),e.create(t,e.Fragment,r,n)}function Mf(e,t){return t.value}function So(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function ei(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Pf(e,t,n){return r;function r(i,s,o,a){const u=Array.isArray(o.children)?n:t;return a?u(s,o,a):u(s,o)}}function zf(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=Jr(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function _f(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Zr.call(t.properties,i)){const s=Ff(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&jf.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Of(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else on(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else on(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function ti(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:vf;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const u=i.get(l)||0;o=l+"-"+u,i.set(l,u+1)}}const a=wo(e,s,o);a!==void 0&&n.push(a)}return n}function Ff(e,t,n){const r=Ll(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Ml(n):Pl(n)),r.property==="style"){let i=typeof n=="object"?n:$f(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Bf(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Fl[r.property]||r.property:r.attribute,n]}}function $f(e,t){try{return Sf(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Se("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=ko+"#cannot-parse-style-attribute",i}}function Co(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=Fi(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=Fi(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Zr.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);on(e)}function on(e,t){const n=new Se("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=ko+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Bf(e){const t={};let n;for(n in e)Zr.call(e,n)&&(t[Hf(n)]=e[n]);return t}function Hf(e){let t=e.replace(Ef,qf);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function qf(e){return"-"+e.toLowerCase()}const er={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Uf={};function ni(e,t){const n=Uf,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return vo(e,r,i)}function vo(e,t,n){if(Kf(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Wi(e.children,t,n)}return Array.isArray(e)?Wi(e,t,n):""}function Wi(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=vo(e[i],t,n);return r.join("")}function Kf(e){return!!(e&&typeof e=="object")}const Vi=document.createElement("i");function ri(e){const t="&"+e+";";Vi.innerHTML=t;const n=Vi.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ze(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Fe(e,t){return e.length>0?(ze(e,e.length,0,t),e):t}const Xi={}.hasOwnProperty;function Eo(e){const t={};let n=-1;for(;++n<e.length;)Wf(t,e[n]);return t}function Wf(e,t){let n;for(n in t){const i=(Xi.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){Xi.call(i,o)||(i[o]=[]);const a=s[o];Vf(i[o],Array.isArray(a)?a:a?[a]:[])}}}function Vf(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);ze(e,0,0,r)}function To(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ge(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Te=yt(/[A-Za-z]/),we=yt(/[\dA-Za-z]/),Xf=yt(/[#-'*+\--9=?A-Z^-~]/);function Dn(e){return e!==null&&(e<32||e===127)}const Er=yt(/\d/),Yf=yt(/[\dA-Fa-f]/),Gf=yt(/[!-/:-@[-`{-~]/);function W(e){return e!==null&&e<-2}function ue(e){return e!==null&&(e<0||e===32)}function G(e){return e===-2||e===-1||e===32}const $n=yt(new RegExp("\\p{P}|\\p{S}","u")),Tt=yt(/\s/);function yt(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Ut(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&we(e.charCodeAt(n+1))&&we(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Z(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return G(l)?(e.enter(n),a(l)):t(l)}function a(l){return G(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const Qf={tokenize:Jf};function Jf(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Z(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return W(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const Zf={tokenize:eh},Yi={tokenize:th};function eh(e){const t=this,n=[];let r=0,i,s,o;return a;function a(T){if(r<n.length){const L=n[r];return t.containerState=L[1],e.attempt(L[0].continuation,l,u)(T)}return u(T)}function l(T){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const L=t.events.length;let D=L,S;for(;D--;)if(t.events[D][0]==="exit"&&t.events[D][1].type==="chunkFlow"){S=t.events[D][1].end;break}b(r);let $=L;for(;$<t.events.length;)t.events[$][1].end={...S},$++;return ze(t.events,D+1,0,t.events.slice(L)),t.events.length=$,u(T)}return a(T)}function u(T){if(r===n.length){if(!i)return p(T);if(i.currentConstruct&&i.currentConstruct.concrete)return g(T);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Yi,c,f)(T)}function c(T){return i&&v(),b(r),p(T)}function f(T){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(T)}function p(T){return t.containerState={},e.attempt(Yi,d,g)(T)}function d(T){return r++,n.push([t.currentConstruct,t.containerState]),p(T)}function g(T){if(T===null){i&&v(),b(0),e.consume(T);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),y(T)}function y(T){if(T===null){w(e.exit("chunkFlow"),!0),b(0),e.consume(T);return}return W(T)?(e.consume(T),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(T),y)}function w(T,L){const D=t.sliceStream(T);if(L&&D.push(null),T.previous=s,s&&(s.next=T),s=T,i.defineSkip(T.start),i.write(D),t.parser.lazy[T.start.line]){let S=i.events.length;for(;S--;)if(i.events[S][1].start.offset<o&&(!i.events[S][1].end||i.events[S][1].end.offset>o))return;const $=t.events.length;let F=$,B,C;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){if(B){C=t.events[F][1].end;break}B=!0}for(b(r),S=$;S<t.events.length;)t.events[S][1].end={...C},S++;ze(t.events,F+1,0,t.events.slice($)),t.events.length=S}}function b(T){let L=n.length;for(;L-- >T;){const D=n[L];t.containerState=D[1],D[0].exit.call(t,e)}n.length=T}function v(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function th(e,t,n){return Z(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ht(e){if(e===null||ue(e)||Tt(e))return 1;if($n(e))return 2}function Bn(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Tr={name:"attention",resolveAll:nh,tokenize:rh};function nh(e,t){let n=-1,r,i,s,o,a,l,u,c;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},p={...e[n][1].start};Gi(f,-l),Gi(p,l),o={type:l>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Fe(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Fe(u,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),u=Fe(u,Bn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Fe(u,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(c=2,u=Fe(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):c=0,ze(e,r-1,n-r+3,u),n=r+u.length-c-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function rh(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ht(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const u=e.exit("attentionSequence"),c=Ht(l),f=!c||c===2&&i||n.includes(l),p=!i||i===2&&c||n.includes(r);return u._open=!!(s===42?f:f&&(i||!p)),u._close=!!(s===42?p:p&&(c||!f)),t(l)}}function Gi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const ih={name:"autolink",tokenize:sh};function sh(e,t,n){let r=0;return i;function i(d){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(d){return Te(d)?(e.consume(d),o):d===64?n(d):u(d)}function o(d){return d===43||d===45||d===46||we(d)?(r=1,a(d)):u(d)}function a(d){return d===58?(e.consume(d),r=0,l):(d===43||d===45||d===46||we(d))&&r++<32?(e.consume(d),a):(r=0,u(d))}function l(d){return d===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),t):d===null||d===32||d===60||Dn(d)?n(d):(e.consume(d),l)}function u(d){return d===64?(e.consume(d),c):Xf(d)?(e.consume(d),u):n(d)}function c(d){return we(d)?f(d):n(d)}function f(d){return d===46?(e.consume(d),r=0,c):d===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),t):p(d)}function p(d){if((d===45||we(d))&&r++<63){const g=d===45?p:f;return e.consume(d),g}return n(d)}}const un={partial:!0,tokenize:oh};function oh(e,t,n){return r;function r(s){return G(s)?Z(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||W(s)?t(s):n(s)}}const jo={continuation:{tokenize:lh},exit:uh,name:"blockQuote",tokenize:ah};function ah(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return G(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function lh(e,t,n){const r=this;return i;function i(o){return G(o)?Z(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(jo,t,n)(o)}}function uh(e){e.exit("blockQuote")}const Io={name:"characterEscape",tokenize:ch};function ch(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return Gf(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const Ao={name:"characterReference",tokenize:fh};function fh(e,t,n){const r=this;let i=0,s,o;return a;function a(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),l}function l(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,o=we,c(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=Yf,c):(e.enter("characterReferenceValue"),s=7,o=Er,c(f))}function c(f){if(f===59&&i){const p=e.exit("characterReferenceValue");return o===we&&!ri(r.sliceSerialize(p))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(f)&&i++<s?(e.consume(f),c):n(f)}}const Qi={partial:!0,tokenize:ph},Ji={concrete:!0,name:"codeFenced",tokenize:hh};function hh(e,t,n){const r=this,i={partial:!0,tokenize:D};let s=0,o=0,a;return l;function l(S){return u(S)}function u(S){const $=r.events[r.events.length-1];return s=$&&$[1].type==="linePrefix"?$[2].sliceSerialize($[1],!0).length:0,a=S,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(S)}function c(S){return S===a?(o++,e.consume(S),c):o<3?n(S):(e.exit("codeFencedFenceSequence"),G(S)?Z(e,f,"whitespace")(S):f(S))}function f(S){return S===null||W(S)?(e.exit("codeFencedFence"),r.interrupt?t(S):e.check(Qi,y,L)(S)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(S))}function p(S){return S===null||W(S)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(S)):G(S)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Z(e,d,"whitespace")(S)):S===96&&S===a?n(S):(e.consume(S),p)}function d(S){return S===null||W(S)?f(S):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(S))}function g(S){return S===null||W(S)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(S)):S===96&&S===a?n(S):(e.consume(S),g)}function y(S){return e.attempt(i,L,w)(S)}function w(S){return e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),b}function b(S){return s>0&&G(S)?Z(e,v,"linePrefix",s+1)(S):v(S)}function v(S){return S===null||W(S)?e.check(Qi,y,L)(S):(e.enter("codeFlowValue"),T(S))}function T(S){return S===null||W(S)?(e.exit("codeFlowValue"),v(S)):(e.consume(S),T)}function L(S){return e.exit("codeFenced"),t(S)}function D(S,$,F){let B=0;return C;function C(E){return S.enter("lineEnding"),S.consume(E),S.exit("lineEnding"),M}function M(E){return S.enter("codeFencedFence"),G(E)?Z(S,j,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):j(E)}function j(E){return E===a?(S.enter("codeFencedFenceSequence"),N(E)):F(E)}function N(E){return E===a?(B++,S.consume(E),N):B>=o?(S.exit("codeFencedFenceSequence"),G(E)?Z(S,I,"whitespace")(E):I(E)):F(E)}function I(E){return E===null||W(E)?(S.exit("codeFencedFence"),$(E)):F(E)}}}function ph(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const tr={name:"codeIndented",tokenize:mh},dh={partial:!0,tokenize:gh};function mh(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),Z(e,s,"linePrefix",5)(u)}function s(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):W(u)?e.attempt(dh,o,l)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||W(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),a)}function l(u){return e.exit("codeIndented"),t(u)}}function gh(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):W(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Z(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):W(o)?i(o):n(o)}}const xh={name:"codeText",previous:bh,resolve:yh,tokenize:kh};function yh(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function bh(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function kh(e,t,n){let r=0,i,s;return o;function o(f){return e.enter("codeText"),e.enter("codeTextSequence"),a(f)}function a(f){return f===96?(e.consume(f),r++,a):(e.exit("codeTextSequence"),l(f))}function l(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),l):f===96?(s=e.enter("codeTextSequence"),i=0,c(f)):W(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||W(f)?(e.exit("codeTextData"),l(f)):(e.consume(f),u)}function c(f){return f===96?(e.consume(f),i++,c):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",u(f))}}class wh{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Qt(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Qt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Qt(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Qt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Qt(this.left,n.reverse())}}}function Qt(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Ro(e){const t={};let n=-1,r,i,s,o,a,l,u;const c=new wh(e);for(;++n<c.length;){for(;n in t;)n=t[n];if(r=c.get(n),n&&r[1].type==="chunkFlow"&&c.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Sh(c,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=c.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(c.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...c.get(i)[1].start},a=c.slice(i,n),a.unshift(r),c.splice(i,n-i+1,a))}}return ze(e,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function Sh(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],u={};let c,f,p=-1,d=n,g=0,y=0;const w=[y];for(;d;){for(;e.get(++i)[1]!==d;);s.push(i),d._tokenizer||(c=r.sliceStream(d),d.next||c.push(null),f&&o.defineSkip(d.start),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(c),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=d,d=d.next}for(d=n;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(y=p+1,w.push(y),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(o.events=[],d?(d._tokenizer=void 0,d.previous=void 0):w.pop(),p=w.length;p--;){const b=a.slice(w[p],w[p+1]),v=s.pop();l.push([v,v+b.length-1]),e.splice(v,2,b)}for(l.reverse(),p=-1;++p<l.length;)u[g+l[p][0]]=g+l[p][1],g+=l[p][1]-l[p][0]-1;return u}const Ch={resolve:Eh,tokenize:Th},vh={partial:!0,tokenize:jh};function Eh(e){return Ro(e),e}function Th(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):W(a)?e.check(vh,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function jh(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Z(e,s,"linePrefix")}function s(o){if(o===null||W(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function No(e,t,n,r,i,s,o,a,l){const u=l||Number.POSITIVE_INFINITY;let c=0;return f;function f(b){return b===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(b),e.exit(s),p):b===null||b===32||b===41||Dn(b)?n(b):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),y(b))}function p(b){return b===62?(e.enter(s),e.consume(b),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),d(b))}function d(b){return b===62?(e.exit("chunkString"),e.exit(a),p(b)):b===null||b===60||W(b)?n(b):(e.consume(b),b===92?g:d)}function g(b){return b===60||b===62||b===92?(e.consume(b),d):d(b)}function y(b){return!c&&(b===null||b===41||ue(b))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(b)):c<u&&b===40?(e.consume(b),c++,y):b===41?(e.consume(b),c--,y):b===null||b===32||b===40||Dn(b)?n(b):(e.consume(b),b===92?w:y)}function w(b){return b===40||b===41||b===92?(e.consume(b),y):y(b)}}function Do(e,t,n,r,i,s){const o=this;let a=0,l;return u;function u(d){return e.enter(r),e.enter(i),e.consume(d),e.exit(i),e.enter(s),c}function c(d){return a>999||d===null||d===91||d===93&&!l||d===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(d):d===93?(e.exit(s),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):W(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),f(d))}function f(d){return d===null||d===91||d===93||W(d)||a++>999?(e.exit("chunkString"),c(d)):(e.consume(d),l||(l=!G(d)),d===92?p:f)}function p(d){return d===91||d===92||d===93?(e.consume(d),a++,f):f(d)}}function Lo(e,t,n,r,i,s){let o;return a;function a(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),o=p===40?41:p,l):n(p)}function l(p){return p===o?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),u(p))}function u(p){return p===o?(e.exit(s),l(o)):p===null?n(p):W(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),Z(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(p))}function c(p){return p===o||p===null||W(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?f:c)}function f(p){return p===o||p===92?(e.consume(p),c):c(p)}}function rn(e,t){let n;return r;function r(i){return W(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):G(i)?Z(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Ih={name:"definition",tokenize:Rh},Ah={partial:!0,tokenize:Nh};function Rh(e,t,n){const r=this;let i;return s;function s(d){return e.enter("definition"),o(d)}function o(d){return Do.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)}function a(d){return i=Ge(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),d===58?(e.enter("definitionMarker"),e.consume(d),e.exit("definitionMarker"),l):n(d)}function l(d){return ue(d)?rn(e,u)(d):u(d)}function u(d){return No(e,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(d)}function c(d){return e.attempt(Ah,f,f)(d)}function f(d){return G(d)?Z(e,p,"whitespace")(d):p(d)}function p(d){return d===null||W(d)?(e.exit("definition"),r.parser.defined.push(i),t(d)):n(d)}}function Nh(e,t,n){return r;function r(a){return ue(a)?rn(e,i)(a):n(a)}function i(a){return Lo(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return G(a)?Z(e,o,"whitespace")(a):o(a)}function o(a){return a===null||W(a)?t(a):n(a)}}const Dh={name:"hardBreakEscape",tokenize:Lh};function Lh(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return W(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Mh={name:"headingAtx",resolve:Ph,tokenize:zh};function Ph(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},ze(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function zh(e,t,n){let r=0;return i;function i(c){return e.enter("atxHeading"),s(c)}function s(c){return e.enter("atxHeadingSequence"),o(c)}function o(c){return c===35&&r++<6?(e.consume(c),o):c===null||ue(c)?(e.exit("atxHeadingSequence"),a(c)):n(c)}function a(c){return c===35?(e.enter("atxHeadingSequence"),l(c)):c===null||W(c)?(e.exit("atxHeading"),t(c)):G(c)?Z(e,a,"whitespace")(c):(e.enter("atxHeadingText"),u(c))}function l(c){return c===35?(e.consume(c),l):(e.exit("atxHeadingSequence"),a(c))}function u(c){return c===null||c===35||ue(c)?(e.exit("atxHeadingText"),a(c)):(e.consume(c),u)}}const _h=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Zi=["pre","script","style","textarea"],Oh={concrete:!0,name:"htmlFlow",resolveTo:Bh,tokenize:Hh},Fh={partial:!0,tokenize:Uh},$h={partial:!0,tokenize:qh};function Bh(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Hh(e,t,n){const r=this;let i,s,o,a,l;return u;function u(k){return c(k)}function c(k){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(k),f}function f(k){return k===33?(e.consume(k),p):k===47?(e.consume(k),s=!0,y):k===63?(e.consume(k),i=3,r.interrupt?t:x):Te(k)?(e.consume(k),o=String.fromCharCode(k),w):n(k)}function p(k){return k===45?(e.consume(k),i=2,d):k===91?(e.consume(k),i=5,a=0,g):Te(k)?(e.consume(k),i=4,r.interrupt?t:x):n(k)}function d(k){return k===45?(e.consume(k),r.interrupt?t:x):n(k)}function g(k){const ce="CDATA[";return k===ce.charCodeAt(a++)?(e.consume(k),a===ce.length?r.interrupt?t:j:g):n(k)}function y(k){return Te(k)?(e.consume(k),o=String.fromCharCode(k),w):n(k)}function w(k){if(k===null||k===47||k===62||ue(k)){const ce=k===47,Q=o.toLowerCase();return!ce&&!s&&Zi.includes(Q)?(i=1,r.interrupt?t(k):j(k)):_h.includes(o.toLowerCase())?(i=6,ce?(e.consume(k),b):r.interrupt?t(k):j(k)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(k):s?v(k):T(k))}return k===45||we(k)?(e.consume(k),o+=String.fromCharCode(k),w):n(k)}function b(k){return k===62?(e.consume(k),r.interrupt?t:j):n(k)}function v(k){return G(k)?(e.consume(k),v):C(k)}function T(k){return k===47?(e.consume(k),C):k===58||k===95||Te(k)?(e.consume(k),L):G(k)?(e.consume(k),T):C(k)}function L(k){return k===45||k===46||k===58||k===95||we(k)?(e.consume(k),L):D(k)}function D(k){return k===61?(e.consume(k),S):G(k)?(e.consume(k),D):T(k)}function S(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(e.consume(k),l=k,$):G(k)?(e.consume(k),S):F(k)}function $(k){return k===l?(e.consume(k),l=null,B):k===null||W(k)?n(k):(e.consume(k),$)}function F(k){return k===null||k===34||k===39||k===47||k===60||k===61||k===62||k===96||ue(k)?D(k):(e.consume(k),F)}function B(k){return k===47||k===62||G(k)?T(k):n(k)}function C(k){return k===62?(e.consume(k),M):n(k)}function M(k){return k===null||W(k)?j(k):G(k)?(e.consume(k),M):n(k)}function j(k){return k===45&&i===2?(e.consume(k),R):k===60&&i===1?(e.consume(k),z):k===62&&i===4?(e.consume(k),q):k===63&&i===3?(e.consume(k),x):k===93&&i===5?(e.consume(k),U):W(k)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Fh,ee,N)(k)):k===null||W(k)?(e.exit("htmlFlowData"),N(k)):(e.consume(k),j)}function N(k){return e.check($h,I,ee)(k)}function I(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),E}function E(k){return k===null||W(k)?N(k):(e.enter("htmlFlowData"),j(k))}function R(k){return k===45?(e.consume(k),x):j(k)}function z(k){return k===47?(e.consume(k),o="",P):j(k)}function P(k){if(k===62){const ce=o.toLowerCase();return Zi.includes(ce)?(e.consume(k),q):j(k)}return Te(k)&&o.length<8?(e.consume(k),o+=String.fromCharCode(k),P):j(k)}function U(k){return k===93?(e.consume(k),x):j(k)}function x(k){return k===62?(e.consume(k),q):k===45&&i===2?(e.consume(k),x):j(k)}function q(k){return k===null||W(k)?(e.exit("htmlFlowData"),ee(k)):(e.consume(k),q)}function ee(k){return e.exit("htmlFlow"),t(k)}}function qh(e,t,n){const r=this;return i;function i(o){return W(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Uh(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(un,t,n)}}const Kh={name:"htmlText",tokenize:Wh};function Wh(e,t,n){const r=this;let i,s,o;return a;function a(x){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(x),l}function l(x){return x===33?(e.consume(x),u):x===47?(e.consume(x),D):x===63?(e.consume(x),T):Te(x)?(e.consume(x),F):n(x)}function u(x){return x===45?(e.consume(x),c):x===91?(e.consume(x),s=0,g):Te(x)?(e.consume(x),v):n(x)}function c(x){return x===45?(e.consume(x),d):n(x)}function f(x){return x===null?n(x):x===45?(e.consume(x),p):W(x)?(o=f,z(x)):(e.consume(x),f)}function p(x){return x===45?(e.consume(x),d):f(x)}function d(x){return x===62?R(x):x===45?p(x):f(x)}function g(x){const q="CDATA[";return x===q.charCodeAt(s++)?(e.consume(x),s===q.length?y:g):n(x)}function y(x){return x===null?n(x):x===93?(e.consume(x),w):W(x)?(o=y,z(x)):(e.consume(x),y)}function w(x){return x===93?(e.consume(x),b):y(x)}function b(x){return x===62?R(x):x===93?(e.consume(x),b):y(x)}function v(x){return x===null||x===62?R(x):W(x)?(o=v,z(x)):(e.consume(x),v)}function T(x){return x===null?n(x):x===63?(e.consume(x),L):W(x)?(o=T,z(x)):(e.consume(x),T)}function L(x){return x===62?R(x):T(x)}function D(x){return Te(x)?(e.consume(x),S):n(x)}function S(x){return x===45||we(x)?(e.consume(x),S):$(x)}function $(x){return W(x)?(o=$,z(x)):G(x)?(e.consume(x),$):R(x)}function F(x){return x===45||we(x)?(e.consume(x),F):x===47||x===62||ue(x)?B(x):n(x)}function B(x){return x===47?(e.consume(x),R):x===58||x===95||Te(x)?(e.consume(x),C):W(x)?(o=B,z(x)):G(x)?(e.consume(x),B):R(x)}function C(x){return x===45||x===46||x===58||x===95||we(x)?(e.consume(x),C):M(x)}function M(x){return x===61?(e.consume(x),j):W(x)?(o=M,z(x)):G(x)?(e.consume(x),M):B(x)}function j(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),i=x,N):W(x)?(o=j,z(x)):G(x)?(e.consume(x),j):(e.consume(x),I)}function N(x){return x===i?(e.consume(x),i=void 0,E):x===null?n(x):W(x)?(o=N,z(x)):(e.consume(x),N)}function I(x){return x===null||x===34||x===39||x===60||x===61||x===96?n(x):x===47||x===62||ue(x)?B(x):(e.consume(x),I)}function E(x){return x===47||x===62||ue(x)?B(x):n(x)}function R(x){return x===62?(e.consume(x),e.exit("htmlTextData"),e.exit("htmlText"),t):n(x)}function z(x){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),P}function P(x){return G(x)?Z(e,U,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):U(x)}function U(x){return e.enter("htmlTextData"),o(x)}}const ii={name:"labelEnd",resolveAll:Gh,resolveTo:Qh,tokenize:Jh},Vh={tokenize:Zh},Xh={tokenize:ep},Yh={tokenize:tp};function Gh(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&ze(e,0,e.length,n),e}function Qh(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},c={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",u,t]],a=Fe(a,e.slice(s+1,s+r+3)),a=Fe(a,[["enter",c,t]]),a=Fe(a,Bn(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=Fe(a,[["exit",c,t],e[o-2],e[o-1],["exit",u,t]]),a=Fe(a,e.slice(o+1)),a=Fe(a,[["exit",l,t]]),ze(e,s,e.length,a),e}function Jh(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(p){return s?s._inactive?f(p):(o=r.parser.defined.includes(Ge(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),l):n(p)}function l(p){return p===40?e.attempt(Vh,c,o?c:f)(p):p===91?e.attempt(Xh,c,o?u:f)(p):o?c(p):f(p)}function u(p){return e.attempt(Yh,c,f)(p)}function c(p){return t(p)}function f(p){return s._balanced=!0,n(p)}}function Zh(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return ue(f)?rn(e,s)(f):s(f)}function s(f){return f===41?c(f):No(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function o(f){return ue(f)?rn(e,l)(f):c(f)}function a(f){return n(f)}function l(f){return f===34||f===39||f===40?Lo(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):c(f)}function u(f){return ue(f)?rn(e,c)(f):c(f)}function c(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function ep(e,t,n){const r=this;return i;function i(a){return Do.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Ge(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function tp(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const np={name:"labelStartImage",resolveAll:ii.resolveAll,tokenize:rp};function rp(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const ip={name:"labelStartLink",resolveAll:ii.resolveAll,tokenize:sp};function sp(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const nr={name:"lineEnding",tokenize:op};function op(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Z(e,t,"linePrefix")}}const kn={name:"thematicBreak",tokenize:ap};function ap(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),o(u)}function o(u){return i=u,a(u)}function a(u){return u===i?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||W(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),G(u)?Z(e,a,"whitespace")(u):a(u))}}const Ne={continuation:{tokenize:fp},exit:pp,name:"list",tokenize:cp},lp={partial:!0,tokenize:dp},up={partial:!0,tokenize:hp};function cp(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(d){const g=r.containerState.type||(d===42||d===43||d===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||d===r.containerState.marker:Er(d)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),d===42||d===45?e.check(kn,n,u)(d):u(d);if(!r.interrupt||d===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(d)}return n(d)}function l(d){return Er(d)&&++o<10?(e.consume(d),l):(!r.interrupt||o<2)&&(r.containerState.marker?d===r.containerState.marker:d===41||d===46)?(e.exit("listItemValue"),u(d)):n(d)}function u(d){return e.enter("listItemMarker"),e.consume(d),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||d,e.check(un,r.interrupt?n:c,e.attempt(lp,p,f))}function c(d){return r.containerState.initialBlankLine=!0,s++,p(d)}function f(d){return G(d)?(e.enter("listItemPrefixWhitespace"),e.consume(d),e.exit("listItemPrefixWhitespace"),p):n(d)}function p(d){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(d)}}function fp(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(un,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Z(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!G(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(up,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Z(e,e.attempt(Ne,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function hp(e,t,n){const r=this;return Z(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function pp(e){e.exit(this.containerState.type)}function dp(e,t,n){const r=this;return Z(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!G(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const es={name:"setextUnderline",resolveTo:mp,tokenize:gp};function mp(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function gp(e,t,n){const r=this;let i;return s;function s(u){let c=r.events.length,f;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){f=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===i?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),G(u)?Z(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||W(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const xp={tokenize:yp};function yp(e){const t=this,n=e.attempt(un,r,e.attempt(this.parser.constructs.flowInitial,i,Z(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Ch,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const bp={resolveAll:Po()},kp=Mo("string"),wp=Mo("text");function Mo(e){return{resolveAll:Po(e==="text"?Sp:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(c){return u(c)?s(c):a(c)}function a(c){if(c===null){n.consume(c);return}return n.enter("data"),n.consume(c),l}function l(c){return u(c)?(n.exit("data"),s(c)):(n.consume(c),l)}function u(c){if(c===null)return!0;const f=i[c];let p=-1;if(f)for(;++p<f.length;){const d=f[p];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function Po(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function Sp(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const u=i[s];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(u===-2)l=!0,a++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Cp={42:Ne,43:Ne,45:Ne,48:Ne,49:Ne,50:Ne,51:Ne,52:Ne,53:Ne,54:Ne,55:Ne,56:Ne,57:Ne,62:jo},vp={91:Ih},Ep={[-2]:tr,[-1]:tr,32:tr},Tp={35:Mh,42:kn,45:[es,kn],60:Oh,61:es,95:kn,96:Ji,126:Ji},jp={38:Ao,92:Io},Ip={[-5]:nr,[-4]:nr,[-3]:nr,33:np,38:Ao,42:Tr,60:[ih,Kh],91:ip,92:[Dh,Io],93:ii,95:Tr,96:xh},Ap={null:[Tr,bp]},Rp={null:[42,95]},Np={null:[]},Dp=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Rp,contentInitial:vp,disable:Np,document:Cp,flow:Tp,flowInitial:Ep,insideSpan:Ap,string:jp,text:Ip},Symbol.toStringTag,{value:"Module"}));function Lp(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:$(D),check:$(S),consume:v,enter:T,exit:L,interrupt:$(S,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,events:[],now:g,parser:e,previous:null,sliceSerialize:p,sliceStream:d,write:f};let c=t.tokenize.call(u,l);return t.resolveAll&&s.push(t),u;function f(M){return o=Fe(o,M),w(),o[o.length-1]!==null?[]:(F(t,0),u.events=Bn(s,u.events,u),u.events)}function p(M,j){return Pp(d(M),j)}function d(M){return Mp(o,M)}function g(){const{_bufferIndex:M,_index:j,line:N,column:I,offset:E}=r;return{_bufferIndex:M,_index:j,line:N,column:I,offset:E}}function y(M){i[M.line]=M.column,C()}function w(){let M;for(;r._index<o.length;){const j=o[r._index];if(typeof j=="string")for(M=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===M&&r._bufferIndex<j.length;)b(j.charCodeAt(r._bufferIndex));else b(j)}}function b(M){c=c(M)}function v(M){W(M)?(r.line++,r.column=1,r.offset+=M===-3?2:1,C()):M!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=M}function T(M,j){const N=j||{};return N.type=M,N.start=g(),u.events.push(["enter",N,u]),a.push(N),N}function L(M){const j=a.pop();return j.end=g(),u.events.push(["exit",j,u]),j}function D(M,j){F(M,j.from)}function S(M,j){j.restore()}function $(M,j){return N;function N(I,E,R){let z,P,U,x;return Array.isArray(I)?ee(I):"tokenize"in I?ee([I]):q(I);function q(re){return be;function be(he){const te=he!==null&&re[he],oe=he!==null&&re.null,ge=[...Array.isArray(te)?te:te?[te]:[],...Array.isArray(oe)?oe:oe?[oe]:[]];return ee(ge)(he)}}function ee(re){return z=re,P=0,re.length===0?R:k(re[P])}function k(re){return be;function be(he){return x=B(),U=re,re.partial||(u.currentConstruct=re),re.name&&u.parser.constructs.disable.null.includes(re.name)?Q():re.tokenize.call(j?Object.assign(Object.create(u),j):u,l,ce,Q)(he)}}function ce(re){return M(U,x),E}function Q(re){return x.restore(),++P<z.length?k(z[P]):R}}}function F(M,j){M.resolveAll&&!s.includes(M)&&s.push(M),M.resolve&&ze(u.events,j,u.events.length-j,M.resolve(u.events.slice(j),u)),M.resolveTo&&(u.events=M.resolveTo(u.events,u))}function B(){const M=g(),j=u.previous,N=u.currentConstruct,I=u.events.length,E=Array.from(a);return{from:I,restore:R};function R(){r=M,u.previous=j,u.currentConstruct=N,u.events.length=I,a=E,C()}}function C(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Mp(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function Pp(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
65
|
+
`;break}case-3:{o=`\r
|
|
66
|
+
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function zp(e){const r={constructs:Eo([Dp,...(e||{}).extensions||[]]),content:i(Qf),defined:[],document:i(Zf),flow:i(xp),lazy:{},string:i(kp),text:i(wp)};return r;function i(s){return o;function o(a){return Lp(r,s,a)}}}function _p(e){for(;!Ro(e););return e}const ts=/[\0\t\n\r]/g;function Op(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let u,c,f,p,d;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(ts.lastIndex=f,u=ts.exec(s),p=u&&u.index!==void 0?u.index:s.length,d=s.charCodeAt(p),!u){t=s.slice(f);break}if(d===10&&f===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),f<p&&(l.push(s.slice(f,p)),e+=p-f),d){case 0:{l.push(65533),e++;break}case 9:{for(c=Math.ceil(e/4)*4,l.push(-2);e++<c;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const Fp=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function $p(e){return e.replace(Fp,Bp)}function Bp(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return To(n.slice(s?2:1),s?16:10)}return ri(n)||e}const zo={}.hasOwnProperty;function Hp(e,t,n){return typeof t!="string"&&(n=t,t=void 0),qp(n)(_p(zp(n).document().write(Op()(e,t,!0))))}function qp(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(ve),autolinkProtocol:B,autolinkEmail:B,atxHeading:s(Ce),blockQuote:s(oe),characterEscape:B,characterReference:B,codeFenced:s(ge),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(ge,o),codeText:s(Ie,o),codeTextData:B,data:B,codeFlowValue:B,definition:s(de),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(_e),hardBreakEscape:s(J),hardBreakTrailing:s(J),htmlFlow:s(X,o),htmlFlowData:B,htmlText:s(X,o),htmlTextData:B,image:s(Ae),label:o,link:s(ve),listItem:s(Je),listItemValue:p,listOrdered:s(Qe,f),listUnordered:s(Qe),paragraph:s(De),reference:k,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Ce),strong:s(ut),thematicBreak:s(it)},exit:{atxHeading:l(),atxHeadingSequence:D,autolink:l(),autolinkEmail:te,autolinkProtocol:he,blockQuote:l(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:Q,characterReferenceMarkerNumeric:Q,characterReferenceValue:re,characterReference:be,codeFenced:l(w),codeFencedFence:y,codeFencedFenceInfo:d,codeFencedFenceMeta:g,codeFlowValue:C,codeIndented:l(b),codeText:l(E),codeTextData:C,data:C,definition:l(),definitionDestinationString:L,definitionLabelString:v,definitionTitleString:T,emphasis:l(),hardBreakEscape:l(j),hardBreakTrailing:l(j),htmlFlow:l(N),htmlFlowData:C,htmlText:l(I),htmlTextData:C,image:l(z),label:U,labelText:P,lineEnding:M,link:l(R),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ce,resourceDestinationString:x,resourceTitleString:q,resource:ee,setextHeading:l(F),setextHeadingLineSequence:$,setextHeadingText:S,strong:l(),thematicBreak:l()}};_o(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(A){let _={type:"root",children:[]};const K={stack:[_],tokenStack:[],config:t,enter:a,exit:u,buffer:o,resume:c,data:n},Y=[];let ne=-1;for(;++ne<A.length;)if(A[ne][1].type==="listOrdered"||A[ne][1].type==="listUnordered")if(A[ne][0]==="enter")Y.push(ne);else{const xe=Y.pop();ne=i(A,xe,ne)}for(ne=-1;++ne<A.length;){const xe=t[A[ne][0]];zo.call(xe,A[ne][1].type)&&xe[A[ne][1].type].call(Object.assign({sliceSerialize:A[ne][2].sliceSerialize},K),A[ne][1])}if(K.tokenStack.length>0){const xe=K.tokenStack[K.tokenStack.length-1];(xe[1]||ns).call(K,void 0,xe[0])}for(_.position={start:pt(A.length>0?A[0][1].start:{line:1,column:1,offset:0}),end:pt(A.length>0?A[A.length-2][1].end:{line:1,column:1,offset:0})},ne=-1;++ne<t.transforms.length;)_=t.transforms[ne](_)||_;return _}function i(A,_,K){let Y=_-1,ne=-1,xe=!1,Be,Le,He,qe;for(;++Y<=K;){const fe=A[Y];switch(fe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{fe[0]==="enter"?ne++:ne--,qe=void 0;break}case"lineEndingBlank":{fe[0]==="enter"&&(Be&&!qe&&!ne&&!He&&(He=Y),qe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:qe=void 0}if(!ne&&fe[0]==="enter"&&fe[1].type==="listItemPrefix"||ne===-1&&fe[0]==="exit"&&(fe[1].type==="listUnordered"||fe[1].type==="listOrdered")){if(Be){let Ue=Y;for(Le=void 0;Ue--;){const Ee=A[Ue];if(Ee[1].type==="lineEnding"||Ee[1].type==="lineEndingBlank"){if(Ee[0]==="exit")continue;Le&&(A[Le][1].type="lineEndingBlank",xe=!0),Ee[1].type="lineEnding",Le=Ue}else if(!(Ee[1].type==="linePrefix"||Ee[1].type==="blockQuotePrefix"||Ee[1].type==="blockQuotePrefixWhitespace"||Ee[1].type==="blockQuoteMarker"||Ee[1].type==="listItemIndent"))break}He&&(!Le||He<Le)&&(Be._spread=!0),Be.end=Object.assign({},Le?A[Le][1].start:fe[1].end),A.splice(Le||Y,0,["exit",Be,fe[2]]),Y++,K++}if(fe[1].type==="listItemPrefix"){const Ue={type:"listItem",_spread:!1,start:Object.assign({},fe[1].start),end:void 0};Be=Ue,A.splice(Y,0,["enter",Ue,fe[2]]),Y++,K++,He=void 0,qe=!0}}}return A[_][1]._spread=xe,K}function s(A,_){return K;function K(Y){a.call(this,A(Y),Y),_&&_.call(this,Y)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(A,_,K){this.stack[this.stack.length-1].children.push(A),this.stack.push(A),this.tokenStack.push([_,K||void 0]),A.position={start:pt(_.start),end:void 0}}function l(A){return _;function _(K){A&&A.call(this,K),u.call(this,K)}}function u(A,_){const K=this.stack.pop(),Y=this.tokenStack.pop();if(Y)Y[0].type!==A.type&&(_?_.call(this,A,Y[0]):(Y[1]||ns).call(this,A,Y[0]));else throw new Error("Cannot close `"+A.type+"` ("+nn({start:A.start,end:A.end})+"): it’s not open");K.position.end=pt(A.end)}function c(){return ni(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(A){if(this.data.expectingFirstListItemValue){const _=this.stack[this.stack.length-2];_.start=Number.parseInt(this.sliceSerialize(A),10),this.data.expectingFirstListItemValue=void 0}}function d(){const A=this.resume(),_=this.stack[this.stack.length-1];_.lang=A}function g(){const A=this.resume(),_=this.stack[this.stack.length-1];_.meta=A}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const A=this.resume(),_=this.stack[this.stack.length-1];_.value=A.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function b(){const A=this.resume(),_=this.stack[this.stack.length-1];_.value=A.replace(/(\r?\n|\r)$/g,"")}function v(A){const _=this.resume(),K=this.stack[this.stack.length-1];K.label=_,K.identifier=Ge(this.sliceSerialize(A)).toLowerCase()}function T(){const A=this.resume(),_=this.stack[this.stack.length-1];_.title=A}function L(){const A=this.resume(),_=this.stack[this.stack.length-1];_.url=A}function D(A){const _=this.stack[this.stack.length-1];if(!_.depth){const K=this.sliceSerialize(A).length;_.depth=K}}function S(){this.data.setextHeadingSlurpLineEnding=!0}function $(A){const _=this.stack[this.stack.length-1];_.depth=this.sliceSerialize(A).codePointAt(0)===61?1:2}function F(){this.data.setextHeadingSlurpLineEnding=void 0}function B(A){const K=this.stack[this.stack.length-1].children;let Y=K[K.length-1];(!Y||Y.type!=="text")&&(Y=Ze(),Y.position={start:pt(A.start),end:void 0},K.push(Y)),this.stack.push(Y)}function C(A){const _=this.stack.pop();_.value+=this.sliceSerialize(A),_.position.end=pt(A.end)}function M(A){const _=this.stack[this.stack.length-1];if(this.data.atHardBreak){const K=_.children[_.children.length-1];K.position.end=pt(A.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(_.type)&&(B.call(this,A),C.call(this,A))}function j(){this.data.atHardBreak=!0}function N(){const A=this.resume(),_=this.stack[this.stack.length-1];_.value=A}function I(){const A=this.resume(),_=this.stack[this.stack.length-1];_.value=A}function E(){const A=this.resume(),_=this.stack[this.stack.length-1];_.value=A}function R(){const A=this.stack[this.stack.length-1];if(this.data.inReference){const _=this.data.referenceType||"shortcut";A.type+="Reference",A.referenceType=_,delete A.url,delete A.title}else delete A.identifier,delete A.label;this.data.referenceType=void 0}function z(){const A=this.stack[this.stack.length-1];if(this.data.inReference){const _=this.data.referenceType||"shortcut";A.type+="Reference",A.referenceType=_,delete A.url,delete A.title}else delete A.identifier,delete A.label;this.data.referenceType=void 0}function P(A){const _=this.sliceSerialize(A),K=this.stack[this.stack.length-2];K.label=$p(_),K.identifier=Ge(_).toLowerCase()}function U(){const A=this.stack[this.stack.length-1],_=this.resume(),K=this.stack[this.stack.length-1];if(this.data.inReference=!0,K.type==="link"){const Y=A.children;K.children=Y}else K.alt=_}function x(){const A=this.resume(),_=this.stack[this.stack.length-1];_.url=A}function q(){const A=this.resume(),_=this.stack[this.stack.length-1];_.title=A}function ee(){this.data.inReference=void 0}function k(){this.data.referenceType="collapsed"}function ce(A){const _=this.resume(),K=this.stack[this.stack.length-1];K.label=_,K.identifier=Ge(this.sliceSerialize(A)).toLowerCase(),this.data.referenceType="full"}function Q(A){this.data.characterReferenceType=A.type}function re(A){const _=this.sliceSerialize(A),K=this.data.characterReferenceType;let Y;K?(Y=To(_,K==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Y=ri(_);const ne=this.stack[this.stack.length-1];ne.value+=Y}function be(A){const _=this.stack.pop();_.position.end=pt(A.end)}function he(A){C.call(this,A);const _=this.stack[this.stack.length-1];_.url=this.sliceSerialize(A)}function te(A){C.call(this,A);const _=this.stack[this.stack.length-1];_.url="mailto:"+this.sliceSerialize(A)}function oe(){return{type:"blockquote",children:[]}}function ge(){return{type:"code",lang:null,meta:null,value:""}}function Ie(){return{type:"inlineCode",value:""}}function de(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function _e(){return{type:"emphasis",children:[]}}function Ce(){return{type:"heading",depth:0,children:[]}}function J(){return{type:"break"}}function X(){return{type:"html",value:""}}function Ae(){return{type:"image",title:null,url:"",alt:null}}function ve(){return{type:"link",title:null,url:"",children:[]}}function Qe(A){return{type:"list",ordered:A.type==="listOrdered",start:null,spread:A._spread,children:[]}}function Je(A){return{type:"listItem",spread:A._spread,checked:null,children:[]}}function De(){return{type:"paragraph",children:[]}}function ut(){return{type:"strong",children:[]}}function Ze(){return{type:"text",value:""}}function it(){return{type:"thematicBreak"}}}function pt(e){return{line:e.line,column:e.column,offset:e.offset}}function _o(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?_o(e,r):Up(e,r)}}function Up(e,t){let n;for(n in t)if(zo.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function ns(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+nn({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+nn({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+nn({start:t.start,end:t.end})+") is still open")}function Kp(e){const t=this;t.parser=n;function n(r){return Hp(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Wp(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Vp(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
67
|
+
`}]}function Xp(e,t){const n=t.value?t.value+`
|
|
68
|
+
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function Yp(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Gp(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Qp(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Ut(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,l);const u={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,u),e.applyData(t,u)}function Jp(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Zp(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Oo(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function ed(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Oo(e,t);const i={src:Ut(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function td(e,t){const n={src:Ut(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function nd(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function rd(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Oo(e,t);const i={href:Ut(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function id(e,t){const n={href:Ut(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function sd(e,t,n){const r=e.all(t),i=n?od(n):Fo(t),s={},o=[];if(typeof t.checked=="boolean"){const c=r[0];let f;c&&c.type==="element"&&c.tagName==="p"?f=c:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const c=r[a];(i||a!==0||c.type!=="element"||c.tagName!=="p")&&o.push({type:"text",value:`
|
|
69
|
+
`}),c.type==="element"&&c.tagName==="p"&&!i?o.push(...c.children):o.push(c)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
|
|
70
|
+
`});const u={type:"element",tagName:"li",properties:s,children:o};return e.patch(t,u),e.applyData(t,u)}function od(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=Fo(n[r])}return t}function Fo(e){const t=e.spread;return t??e.children.length>1}function ad(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function ld(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ud(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function cd(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function fd(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=Jr(t.children[1]),l=yo(t.children[t.children.length-1]);a&&l&&(o.position={start:a,end:l}),i.push(o)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function hd(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:t.children.length;let l=-1;const u=[];for(;++l<a;){const f=t.children[l],p={},d=o?o[l]:void 0;d&&(p.align=d);let g={type:"element",tagName:s,properties:p,children:[]};f&&(g.children=e.all(f),e.patch(f,g),g=e.applyData(f,g)),u.push(g)}const c={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,c),e.applyData(t,c)}function pd(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const rs=9,is=32;function dd(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(ss(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(ss(t.slice(i),i>0,!1)),s.join("")}function ss(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===rs||s===is;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===rs||s===is;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function md(e,t){const n={type:"text",value:dd(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function gd(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const xd={blockquote:Wp,break:Vp,code:Xp,delete:Yp,emphasis:Gp,footnoteReference:Qp,heading:Jp,html:Zp,imageReference:ed,image:td,inlineCode:nd,linkReference:rd,link:id,listItem:sd,list:ad,paragraph:ld,root:ud,strong:cd,table:fd,tableCell:pd,tableRow:hd,text:md,thematicBreak:gd,toml:dn,yaml:dn,definition:dn,footnoteDefinition:dn};function dn(){}const $o=-1,Hn=0,sn=1,Ln=2,si=3,oi=4,ai=5,li=6,Bo=7,Ho=8,os=typeof self=="object"?self:globalThis,yd=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,o]=t[i];switch(s){case Hn:case $o:return n(o,i);case sn:{const a=n([],i);for(const l of o)a.push(r(l));return a}case Ln:{const a=n({},i);for(const[l,u]of o)a[r(l)]=r(u);return a}case si:return n(new Date(o),i);case oi:{const{source:a,flags:l}=o;return n(new RegExp(a,l),i)}case ai:{const a=n(new Map,i);for(const[l,u]of o)a.set(r(l),r(u));return a}case li:{const a=n(new Set,i);for(const l of o)a.add(r(l));return a}case Bo:{const{name:a,message:l}=o;return n(new os[a](l),i)}case Ho:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}}return n(new os[s](o),i)};return r},as=e=>yd(new Map,e)(0),Dt="",{toString:bd}={},{keys:kd}=Object,Jt=e=>{const t=typeof e;if(t!=="object"||!e)return[Hn,t];const n=bd.call(e).slice(8,-1);switch(n){case"Array":return[sn,Dt];case"Object":return[Ln,Dt];case"Date":return[si,Dt];case"RegExp":return[oi,Dt];case"Map":return[ai,Dt];case"Set":return[li,Dt];case"DataView":return[sn,n]}return n.includes("Array")?[sn,n]:n.includes("Error")?[Bo,n]:[Ln,n]},mn=([e,t])=>e===Hn&&(t==="function"||t==="symbol"),wd=(e,t,n,r)=>{const i=(o,a)=>{const l=r.push(o)-1;return n.set(a,l),l},s=o=>{if(n.has(o))return n.get(o);let[a,l]=Jt(o);switch(a){case Hn:{let c=o;switch(l){case"bigint":a=Ho,c=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);c=null;break;case"undefined":return i([$o],o)}return i([a,c],o)}case sn:{if(l){let p=o;return l==="DataView"?p=new Uint8Array(o.buffer):l==="ArrayBuffer"&&(p=new Uint8Array(o)),i([l,[...p]],o)}const c=[],f=i([a,c],o);for(const p of o)c.push(s(p));return f}case Ln:{if(l)switch(l){case"BigInt":return i([l,o.toString()],o);case"Boolean":case"Number":case"String":return i([l,o.valueOf()],o)}if(t&&"toJSON"in o)return s(o.toJSON());const c=[],f=i([a,c],o);for(const p of kd(o))(e||!mn(Jt(o[p])))&&c.push([s(p),s(o[p])]);return f}case si:return i([a,o.toISOString()],o);case oi:{const{source:c,flags:f}=o;return i([a,{source:c,flags:f}],o)}case ai:{const c=[],f=i([a,c],o);for(const[p,d]of o)(e||!(mn(Jt(p))||mn(Jt(d))))&&c.push([s(p),s(d)]);return f}case li:{const c=[],f=i([a,c],o);for(const p of o)(e||!mn(Jt(p)))&&c.push(s(p));return f}}const{message:u}=o;return i([a,{name:l,message:u}],o)};return s},ls=(e,{json:t,lossy:n}={})=>{const r=[];return wd(!(t||n),!!t,new Map,r)(e),r},Mn=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?as(ls(e,t)):structuredClone(e):(e,t)=>as(ls(e,t));function Sd(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Cd(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function vd(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Sd,r=e.options.footnoteBackLabel||Cd,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[l]);if(!u)continue;const c=e.all(u),f=String(u.identifier).toUpperCase(),p=Ut(f.toLowerCase());let d=0;const g=[],y=e.footnoteCounts.get(f);for(;y!==void 0&&++d<=y;){g.length>0&&g.push({type:"text",value:" "});let v=typeof n=="string"?n:n(l,d);typeof v=="string"&&(v={type:"text",value:v}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,d),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}const w=c[c.length-1];if(w&&w.type==="element"&&w.tagName==="p"){const v=w.children[w.children.length-1];v&&v.type==="text"?v.value+=" ":w.children.push({type:"text",value:" "}),w.children.push(...g)}else c.push(...g);const b={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(c,!0)};e.patch(u,b),a.push(b)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Mn(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
71
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
|
|
72
|
+
`}]}}const qn=(function(e){if(e==null)return Id;if(typeof e=="function")return Un(e);if(typeof e=="object")return Array.isArray(e)?Ed(e):Td(e);if(typeof e=="string")return jd(e);throw new Error("Expected function, string, or object as test")});function Ed(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=qn(e[n]);return Un(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function Td(e){const t=e;return Un(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function jd(e){return Un(t);function t(n){return n&&n.type===e}}function Un(e){return t;function t(n,r,i){return!!(Ad(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Id(){return!0}function Ad(e){return e!==null&&typeof e=="object"&&"type"in e}const qo=[],Rd=!0,jr=!1,Nd="skip";function Uo(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=qn(i),o=r?-1:1;a(e,void 0,[])();function a(l,u,c){const f=l&&typeof l=="object"?l:{};if(typeof f.type=="string"){const d=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(d?"<"+d+">":""))+")"})}return p;function p(){let d=qo,g,y,w;if((!t||s(l,u,c[c.length-1]||void 0))&&(d=Dd(n(l,c)),d[0]===jr))return d;if("children"in l&&l.children){const b=l;if(b.children&&d[0]!==Nd)for(y=(r?b.children.length:-1)+o,w=c.concat(b);y>-1&&y<b.children.length;){const v=b.children[y];if(g=a(v,y,w)(),g[0]===jr)return g;y=typeof g[1]=="number"?g[1]:y+o}}return d}}}function Dd(e){return Array.isArray(e)?e:typeof e=="number"?[Rd,e]:e==null?qo:[e]}function ui(e,t,n,r){let i,s,o;typeof t=="function"&&typeof n!="function"?(s=void 0,o=t,i=n):(s=t,o=n,i=r),Uo(e,s,a,i);function a(l,u){const c=u[u.length-1],f=c?c.children.indexOf(l):void 0;return o(l,f,c)}}const Ir={}.hasOwnProperty,Ld={};function Md(e,t){const n=t||Ld,r=new Map,i=new Map,s=new Map,o={...xd,...n.handlers},a={all:u,applyData:zd,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:l,options:n,patch:Pd,wrap:Od};return ui(e,function(c){if(c.type==="definition"||c.type==="footnoteDefinition"){const f=c.type==="definition"?r:i,p=String(c.identifier).toUpperCase();f.has(p)||f.set(p,c)}}),a;function l(c,f){const p=c.type,d=a.handlers[p];if(Ir.call(a.handlers,p)&&d)return d(a,c,f);if(a.options.passThrough&&a.options.passThrough.includes(p)){if("children"in c){const{children:y,...w}=c,b=Mn(w);return b.children=a.all(c),b}return Mn(c)}return(a.options.unknownHandler||_d)(a,c,f)}function u(c){const f=[];if("children"in c){const p=c.children;let d=-1;for(;++d<p.length;){const g=a.one(p[d],c);if(g){if(d&&p[d-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=us(g.value)),!Array.isArray(g)&&g.type==="element")){const y=g.children[0];y&&y.type==="text"&&(y.value=us(y.value))}Array.isArray(g)?f.push(...g):f.push(g)}}}return f}}function Pd(e,t){e.position&&(t.position=Cf(e))}function zd(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&s&&Object.assign(n.properties,Mn(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function _d(e,t){const n=t.data||{},r="value"in t&&!(Ir.call(n,"hProperties")||Ir.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Od(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
73
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
74
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
75
|
+
`}),n}function us(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function cs(e,t){const n=Md(e,t),r=n.one(e,void 0),i=vd(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
|
|
76
|
+
`},i),s}function Fd(e,t){return e&&"run"in e?async function(n,r){const i=cs(n,{file:r,...t});await e.run(i,r)}:function(n,r){return cs(n,{file:r,...e||t})}}function fs(e){if(e)throw e}var rr,hs;function $d(){if(hs)return rr;hs=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},s=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var c=e.call(u,"constructor"),f=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!c&&!f)return!1;var p;for(p in u);return typeof p>"u"||e.call(u,p)},o=function(u,c){n&&c.name==="__proto__"?n(u,c.name,{enumerable:!0,configurable:!0,value:c.newValue,writable:!0}):u[c.name]=c.newValue},a=function(u,c){if(c==="__proto__")if(e.call(u,c)){if(r)return r(u,c).value}else return;return u[c]};return rr=function l(){var u,c,f,p,d,g,y=arguments[0],w=1,b=arguments.length,v=!1;for(typeof y=="boolean"&&(v=y,y=arguments[1]||{},w=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});w<b;++w)if(u=arguments[w],u!=null)for(c in u)f=a(y,c),p=a(u,c),y!==p&&(v&&p&&(s(p)||(d=i(p)))?(d?(d=!1,g=f&&i(f)?f:[]):g=f&&s(f)?f:{},o(y,{name:c,newValue:l(v,g,p)})):typeof p<"u"&&o(y,{name:c,newValue:p}));return y},rr}var Bd=$d();const ir=Ms(Bd);function Ar(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Hd(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(l,...u){const c=e[++s];let f=-1;if(l){o(l);return}for(;++f<i.length;)(u[f]===null||u[f]===void 0)&&(u[f]=i[f]);i=u,c?qd(c,a)(...u):o(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function qd(e,t){let n;return r;function r(...o){const a=e.length>o.length;let l;a&&o.push(i);try{l=e.apply(this,o)}catch(u){const c=u;if(a&&n)throw c;return i(c)}a||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(o,...a){n||(n=!0,t(o,...a))}function s(o){i(null,o)}}const tt={basename:Ud,dirname:Kd,extname:Wd,join:Vd,sep:"/"};function Ud(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');cn(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,a=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function Kd(e){if(cn(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function Wd(e){cn(e);let t=e.length,n=-1,r=0,i=-1,s=0,o;for(;t--;){const a=e.codePointAt(t);if(a===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),a===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function Vd(...e){let t=-1,n;for(;++t<e.length;)cn(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Xd(n)}function Xd(e){cn(e);const t=e.codePointAt(0)===47;let n=Yd(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function Yd(e,t){let n="",r=0,i=-1,s=0,o=-1,a,l;for(;++o<=e.length;){if(o<e.length)a=e.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,s=0}else a===46&&s>-1?s++:s=-1}return n}function cn(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Gd={cwd:Qd};function Qd(){return"/"}function Rr(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Jd(e){if(typeof e=="string")e=new URL(e);else if(!Rr(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Zd(e)}function Zd(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const sr=["history","path","basename","stem","extname","dirname"];class Ko{constructor(t){let n;t?Rr(t)?n={path:t}:typeof t=="string"||em(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":Gd.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<sr.length;){const s=sr[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)sr.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?tt.basename(this.path):void 0}set basename(t){ar(t,"basename"),or(t,"basename"),this.path=tt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?tt.dirname(this.path):void 0}set dirname(t){ps(this.basename,"dirname"),this.path=tt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?tt.extname(this.path):void 0}set extname(t){if(or(t,"extname"),ps(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=tt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Rr(t)&&(t=Jd(t)),ar(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?tt.basename(this.path,this.extname):void 0}set stem(t){ar(t,"stem"),or(t,"stem"),this.path=tt.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new Se(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function or(e,t){if(e&&e.includes(tt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+tt.sep+"`")}function ar(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function ps(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function em(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const tm=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),nm={}.hasOwnProperty;class ci extends tm{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Hd()}copy(){const t=new ci;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(ir(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(cr("data",this.frozen),this.namespace[t]=n,this):nm.call(this.namespace,t)&&this.namespace[t]||void 0:t?(cr("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=gn(t),r=this.parser||this.Parser;return lr("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),lr("process",this.parser||this.Parser),ur("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=gn(t),l=r.parse(a);r.run(l,a,function(c,f,p){if(c||!f||!p)return u(c);const d=f,g=r.stringify(d,p);sm(g)?p.value=g:p.result=g,u(c,p)});function u(c,f){c||!f?o(c):s?s(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),lr("processSync",this.parser||this.Parser),ur("processSync",this.compiler||this.Compiler),this.process(t,i),ms("processSync","process",n),r;function i(s,o){n=!0,fs(s),r=o}}run(t,n,r){ds(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(o,a){const l=gn(n);i.run(t,l,u);function u(c,f,p){const d=f||t;c?a(c):o?o(d):r(void 0,d,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),ms("runSync","run",r),i;function s(o,a){fs(o),i=a,r=!0}}stringify(t,n){this.freeze();const r=gn(n),i=this.compiler||this.Compiler;return ur("stringify",i),ds(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(cr("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[c,...f]=u;l(c,f)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(u.plugins),u.settings&&(i.settings=ir(!0,i.settings,u.settings))}function a(u){let c=-1;if(u!=null)if(Array.isArray(u))for(;++c<u.length;){const f=u[c];s(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,c){let f=-1,p=-1;for(;++f<r.length;)if(r[f][0]===u){p=f;break}if(p===-1)r.push([u,...c]);else if(c.length>0){let[d,...g]=c;const y=r[p][1];Ar(y)&&Ar(d)&&(d=ir(!0,y,d)),r[p]=[u,d,...g]}}}}const rm=new ci().freeze();function lr(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ur(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function cr(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ds(e){if(!Ar(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function ms(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function gn(e){return im(e)?e:new Ko(e)}function im(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function sm(e){return typeof e=="string"||om(e)}function om(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const am="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",gs=[],xs={allowDangerousHtml:!0},lm=/^(https?|ircs?|mailto|xmpp)$/i,um=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function cm(e){const t=fm(e),n=hm(e);return pm(t.runSync(t.parse(n),n),e)}function fm(e){const t=e.rehypePlugins||gs,n=e.remarkPlugins||gs,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...xs}:xs;return rm().use(Kp).use(n).use(Fd,r).use(t)}function hm(e){const t=e.children||"",n=new Ko;return typeof t=="string"&&(n.value=t),n}function pm(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,o=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||dm;for(const c of um)Object.hasOwn(t,c.from)&&(""+c.from+(c.to?"use `"+c.to+"` instead":"remove it")+am+c.id,void 0);return ui(e,u),If(e,{Fragment:h.Fragment,components:i,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function u(c,f,p){if(c.type==="raw"&&p&&typeof f=="number")return o?p.children.splice(f,1):p.children[f]={type:"text",value:c.value},f;if(c.type==="element"){let d;for(d in er)if(Object.hasOwn(er,d)&&Object.hasOwn(c.properties,d)){const g=c.properties[d],y=er[d];(y===null||y.includes(c.tagName))&&(c.properties[d]=l(String(g||""),d,c))}}if(c.type==="element"){let d=n?!n.includes(c.tagName):s?s.includes(c.tagName):!1;if(!d&&r&&typeof f=="number"&&(d=!r(c,f,p)),d&&p&&typeof f=="number")return a&&c.children?p.children.splice(f,1,...c.children):p.children.splice(f,1),f}}}function dm(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||lm.test(e.slice(0,t))?e:""}function mm(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Wo(e,t,n){const i=qn((n||{}).ignore||[]),s=gm(t);let o=-1;for(;++o<s.length;)Uo(e,"text",a);function a(u,c){let f=-1,p;for(;++f<c.length;){const d=c[f],g=p?p.children:void 0;if(i(d,g?g.indexOf(d):void 0,p))return;p=d}if(p)return l(u,c)}function l(u,c){const f=c[c.length-1],p=s[o][0],d=s[o][1];let g=0;const w=f.children.indexOf(u);let b=!1,v=[];p.lastIndex=0;let T=p.exec(u.value);for(;T;){const L=T.index,D={index:T.index,input:T.input,stack:[...c,u]};let S=d(...T,D);if(typeof S=="string"&&(S=S.length>0?{type:"text",value:S}:void 0),S===!1?p.lastIndex=L+1:(g!==L&&v.push({type:"text",value:u.value.slice(g,L)}),Array.isArray(S)?v.push(...S):S&&v.push(S),g=L+T[0].length,b=!0),!p.global)break;T=p.exec(u.value)}return b?(g<u.value.length&&v.push({type:"text",value:u.value.slice(g)}),f.children.splice(w,1,...v)):v=[u],w+v.length}}function gm(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([xm(i[0]),ym(i[1])])}return t}function xm(e){return typeof e=="string"?new RegExp(mm(e),"g"):e}function ym(e){return typeof e=="function"?e:function(){return e}}function bm(e){Wo(e,[/\r?\n|\r/g,km])}function km(){return{type:"break"}}function wm(){return function(e){bm(e)}}const fr="phrasing",hr=["autolink","link","image","label"];function Sm(){return{transforms:[Am],enter:{literalAutolink:vm,literalAutolinkEmail:pr,literalAutolinkHttp:pr,literalAutolinkWww:pr},exit:{literalAutolink:Im,literalAutolinkEmail:jm,literalAutolinkHttp:Em,literalAutolinkWww:Tm}}}function Cm(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:fr,notInConstruct:hr},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:fr,notInConstruct:hr},{character:":",before:"[ps]",after:"\\/",inConstruct:fr,notInConstruct:hr}]}}function vm(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function pr(e){this.config.enter.autolinkProtocol.call(this,e)}function Em(e){this.config.exit.autolinkProtocol.call(this,e)}function Tm(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function jm(e){this.config.exit.autolinkEmail.call(this,e)}function Im(e){this.exit(e)}function Am(e){Wo(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Rm],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Nm]],{ignore:["link","linkReference"]})}function Rm(e,t,n,r,i){let s="";if(!Vo(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Dm(n)))return!1;const o=Lm(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:s+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function Nm(e,t,n,r){return!Vo(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Dm(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Lm(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=vi(e,"(");let s=vi(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function Vo(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Tt(n)||$n(n))&&(!t||n!==47)}Xo.peek=Hm;function Mm(){this.buffer()}function Pm(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function zm(){this.buffer()}function _m(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Om(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ge(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Fm(e){this.exit(e)}function $m(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ge(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Bm(e){this.exit(e)}function Hm(){return"["}function Xo(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const o=n.enter("footnoteReference"),a=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),a(),o(),s+=i.move("]"),s}function qm(){return{enter:{gfmFootnoteCallString:Mm,gfmFootnoteCall:Pm,gfmFootnoteDefinitionLabelString:zm,gfmFootnoteDefinition:_m},exit:{gfmFootnoteCallString:Om,gfmFootnoteCall:Fm,gfmFootnoteDefinitionLabelString:$m,gfmFootnoteDefinition:Bm}}}function Um(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Xo},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,o){const a=s.createTracker(o);let l=a.move("[^");const u=s.enter("footnoteDefinition"),c=s.enter("label");return l+=a.move(s.safe(s.associationId(r),{before:l,after:"]"})),c(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((t?`
|
|
77
|
+
`:" ")+s.indentLines(s.containerFlow(r,a.current()),t?Yo:Km))),u(),l}}function Km(e,t,n){return t===0?e:Yo(e,t,n)}function Yo(e,t,n){return(n?"":" ")+e}const Wm=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Go.peek=Qm;function Vm(){return{canContainEols:["delete"],enter:{strikethrough:Ym},exit:{strikethrough:Gm}}}function Xm(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Wm}],handlers:{delete:Go}}}function Ym(e){this.enter({type:"delete",children:[]},e)}function Gm(e){this.exit(e)}function Go(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function Qm(){return"~"}function Jm(e){return e.length}function Zm(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Jm,s=[],o=[],a=[],l=[];let u=0,c=-1;for(;++c<e.length;){const y=[],w=[];let b=-1;for(e[c].length>u&&(u=e[c].length);++b<e[c].length;){const v=eg(e[c][b]);if(n.alignDelimiters!==!1){const T=i(v);w[b]=T,(l[b]===void 0||T>l[b])&&(l[b]=T)}y.push(v)}o[c]=y,a[c]=w}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<u;)s[f]=ys(r[f]);else{const y=ys(r);for(;++f<u;)s[f]=y}f=-1;const p=[],d=[];for(;++f<u;){const y=s[f];let w="",b="";y===99?(w=":",b=":"):y===108?w=":":y===114&&(b=":");let v=n.alignDelimiters===!1?1:Math.max(1,l[f]-w.length-b.length);const T=w+"-".repeat(v)+b;n.alignDelimiters!==!1&&(v=w.length+v+b.length,v>l[f]&&(l[f]=v),d[f]=v),p[f]=T}o.splice(1,0,p),a.splice(1,0,d),c=-1;const g=[];for(;++c<o.length;){const y=o[c],w=a[c];f=-1;const b=[];for(;++f<u;){const v=y[f]||"";let T="",L="";if(n.alignDelimiters!==!1){const D=l[f]-(w[f]||0),S=s[f];S===114?T=" ".repeat(D):S===99?D%2?(T=" ".repeat(D/2+.5),L=" ".repeat(D/2-.5)):(T=" ".repeat(D/2),L=T):L=" ".repeat(D)}n.delimiterStart!==!1&&!f&&b.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&v==="")&&(n.delimiterStart!==!1||f)&&b.push(" "),n.alignDelimiters!==!1&&b.push(T),b.push(v),n.alignDelimiters!==!1&&b.push(L),n.padding!==!1&&b.push(" "),(n.delimiterEnd!==!1||f!==u-1)&&b.push("|")}g.push(n.delimiterEnd===!1?b.join("").replace(/ +$/,""):b.join(""))}return g.join(`
|
|
78
|
+
`)}function eg(e){return e==null?"":String(e)}function ys(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function tg(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const o=n.indentLines(n.containerFlow(e,s.current()),ng);return i(),o}function ng(e,t,n){return">"+(n?"":" ")+e}function rg(e,t){return bs(e,t.inConstruct,!0)&&!bs(e,t.notInConstruct,!1)}function bs(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function ks(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
79
|
+
`&&rg(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
80
|
+
`}function ig(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+t.length,r=n.indexOf(t,i);return o}function sg(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function og(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function ag(e,t,n,r){const i=og(n),s=e.value||"",o=i==="`"?"GraveAccent":"Tilde";if(sg(e,n)){const f=n.enter("codeIndented"),p=n.indentLines(s,lg);return f(),p}const a=n.createTracker(r),l=i.repeat(Math.max(ig(s,i)+1,3)),u=n.enter("codeFenced");let c=a.move(l);if(e.lang){const f=n.enter(`codeFencedLang${o}`);c+=a.move(n.safe(e.lang,{before:c,after:" ",encode:["`"],...a.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${o}`);c+=a.move(" "),c+=a.move(n.safe(e.meta,{before:c,after:`
|
|
81
|
+
`,encode:["`"],...a.current()})),f()}return c+=a.move(`
|
|
82
|
+
`),s&&(c+=a.move(s+`
|
|
83
|
+
`)),c+=a.move(l),u(),c}function lg(e,t,n){return(n?"":" ")+e}function fi(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function ug(e,t,n,r){const i=fi(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("definition");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("[");return u+=l.move(n.safe(n.associationId(e),{before:u,after:"]",...l.current()})),u+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":`
|
|
84
|
+
`,...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(n.safe(e.title,{before:u,after:i,...l.current()})),u+=l.move(i),a()),o(),u}function cg(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function an(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Pn(e,t,n){const r=Ht(e),i=Ht(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Qo.peek=fg;function Qo(e,t,n,r){const i=cg(n),s=n.enter("emphasis"),o=n.createTracker(r),a=o.move(i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const u=l.charCodeAt(0),c=Pn(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(l=an(u)+l.slice(1));const f=l.charCodeAt(l.length-1),p=Pn(r.after.charCodeAt(0),f,i);p.inside&&(l=l.slice(0,-1)+an(f));const d=o.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:c.outside},a+l+d}function fg(e,t,n){return n.options.emphasis||"*"}function hg(e,t){let n=!1;return ui(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,jr}),!!((!e.depth||e.depth<3)&&ni(e)&&(t.options.setext||n))}function pg(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(hg(e,n)){const c=n.enter("headingSetext"),f=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
|
|
85
|
+
`,after:`
|
|
86
|
+
`});return f(),c(),p+`
|
|
87
|
+
`+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
|
|
88
|
+
`))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(o+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
|
89
|
+
`,...s.current()});return/^[\t ]/.test(u)&&(u=an(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),l(),a(),u}Jo.peek=dg;function Jo(e){return e.value||""}function dg(){return"<"}Zo.peek=mg;function Zo(e,t,n,r){const i=fi(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("![");return u+=l.move(n.safe(e.alt,{before:u,after:"]",...l.current()})),u+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(n.safe(e.title,{before:u,after:i,...l.current()})),u+=l.move(i),a()),u+=l.move(")"),o(),u}function mg(){return"!"}ea.peek=gg;function ea(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const u=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const c=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=c,s(),i==="full"||!u||u!==f?l+=a.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function gg(){return"!"}ta.peek=xg;function ta(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.exec(r);){let u=l.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(l.index+1)}}return i+r+i}function xg(){return"`"}function na(e,t){const n=ni(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}ra.peek=yg;function ra(e,t,n,r){const i=fi(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(na(e,n)){const c=n.stack;n.stack=[],a=n.enter("autolink");let f=o.move("<");return f+=o.move(n.containerPhrasing(e,{before:f,after:">",...o.current()})),f+=o.move(">"),a(),n.stack=c,f}a=n.enter("link"),l=n.enter("label");let u=o.move("[");return u+=o.move(n.containerPhrasing(e,{before:u,after:"](",...o.current()})),u+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),l()),u+=o.move(")"),a(),u}function yg(e,t,n){return na(e,n)?"<":"["}ia.peek=bg;function ia(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const u=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const c=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=c,s(),i==="full"||!u||u!==f?l+=a.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function bg(){return"["}function hi(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function kg(e){const t=hi(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function wg(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function sa(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Sg(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=e.ordered?wg(n):hi(n);const a=e.ordered?o==="."?")":".":kg(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const c=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&c&&(!c.children||!c.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),sa(n)===o&&c){let f=-1;for(;++f<e.children.length;){const p=e.children[f];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const u=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),u}function Cg(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function vg(e,t,n,r){const i=Cg(n);let s=n.bulletCurrent||hi(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const l=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,a.current()),c);return l(),u;function c(f,p,d){return p?(d?"":" ".repeat(o))+f:(d?s:s+" ".repeat(o-s.length))+f}}function Eg(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(e,r);return s(),i(),o}const Tg=qn(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function jg(e,t,n,r){return(e.children.some(function(o){return Tg(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Ig(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}oa.peek=Ag;function oa(e,t,n,r){const i=Ig(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const u=l.charCodeAt(0),c=Pn(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(l=an(u)+l.slice(1));const f=l.charCodeAt(l.length-1),p=Pn(r.after.charCodeAt(0),f,i);p.inside&&(l=l.slice(0,-1)+an(f));const d=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:c.outside},a+l+d}function Ag(e,t,n){return n.options.strong||"*"}function Rg(e,t,n,r){return n.safe(e.value,r)}function Ng(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Dg(e,t,n){const r=(sa(n)+(n.options.ruleSpaces?" ":"")).repeat(Ng(n));return n.options.ruleSpaces?r.slice(0,-1):r}const aa={blockquote:tg,break:ks,code:ag,definition:ug,emphasis:Qo,hardBreak:ks,heading:pg,html:Jo,image:Zo,imageReference:ea,inlineCode:ta,link:ra,linkReference:ia,list:Sg,listItem:vg,paragraph:Eg,root:jg,strong:oa,text:Rg,thematicBreak:Dg};function Lg(){return{enter:{table:Mg,tableData:ws,tableHeader:ws,tableRow:zg},exit:{codeText:_g,table:Pg,tableData:dr,tableHeader:dr,tableRow:dr}}}function Mg(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function Pg(e){this.exit(e),this.data.inTable=void 0}function zg(e){this.enter({type:"tableRow",children:[]},e)}function dr(e){this.exit(e)}function ws(e){this.enter({type:"tableCell",children:[]},e)}function _g(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Og));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Og(e,t){return t==="|"?t:e}function Fg(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
90
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:o,tableCell:l,tableRow:a}};function o(d,g,y,w){return u(c(d,y,w),d.align)}function a(d,g,y,w){const b=f(d,y,w),v=u([b]);return v.slice(0,v.indexOf(`
|
|
91
|
+
`))}function l(d,g,y,w){const b=y.enter("tableCell"),v=y.enter("phrasing"),T=y.containerPhrasing(d,{...w,before:s,after:s});return v(),b(),T}function u(d,g){return Zm(d,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function c(d,g,y){const w=d.children;let b=-1;const v=[],T=g.enter("table");for(;++b<w.length;)v[b]=f(w[b],g,y);return T(),v}function f(d,g,y){const w=d.children;let b=-1;const v=[],T=g.enter("tableRow");for(;++b<w.length;)v[b]=l(w[b],d,g,y);return T(),v}function p(d,g,y){let w=aa.inlineCode(d,g,y);return y.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function $g(){return{exit:{taskListCheckValueChecked:Ss,taskListCheckValueUnchecked:Ss,paragraph:Hg}}}function Bg(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:qg}}}function Ss(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Hg(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function qg(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=aa.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(c){return c+o}}function Ug(){return[Sm(),qm(),Vm(),Lg(),$g()]}function Kg(e){return{extensions:[Cm(),Um(e),Xm(),Fg(e),Bg()]}}const Wg={tokenize:Jg,partial:!0},la={tokenize:Zg,partial:!0},ua={tokenize:ex,partial:!0},ca={tokenize:tx,partial:!0},Vg={tokenize:nx,partial:!0},fa={name:"wwwAutolink",tokenize:Gg,previous:pa},ha={name:"protocolAutolink",tokenize:Qg,previous:da},lt={name:"emailAutolink",tokenize:Yg,previous:ma},rt={};function Xg(){return{text:rt}}let St=48;for(;St<123;)rt[St]=lt,St++,St===58?St=65:St===91&&(St=97);rt[43]=lt;rt[45]=lt;rt[46]=lt;rt[95]=lt;rt[72]=[lt,ha];rt[104]=[lt,ha];rt[87]=[lt,fa];rt[119]=[lt,fa];function Yg(e,t,n){const r=this;let i,s;return o;function o(f){return!Nr(f)||!ma.call(r,r.previous)||pi(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(f))}function a(f){return Nr(f)?(e.consume(f),a):f===64?(e.consume(f),l):n(f)}function l(f){return f===46?e.check(Vg,c,u)(f):f===45||f===95||we(f)?(s=!0,e.consume(f),l):c(f)}function u(f){return e.consume(f),i=!0,l}function c(f){return s&&i&&Te(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function Gg(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!pa.call(r,r.previous)||pi(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Wg,e.attempt(la,e.attempt(ua,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function Qg(e,t,n){const r=this;let i="",s=!1;return o;function o(f){return(f===72||f===104)&&da.call(r,r.previous)&&!pi(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),e.consume(f),a):n(f)}function a(f){if(Te(f)&&i.length<5)return i+=String.fromCodePoint(f),e.consume(f),a;if(f===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(f),l}return n(f)}function l(f){return f===47?(e.consume(f),s?u:(s=!0,l)):n(f)}function u(f){return f===null||Dn(f)||ue(f)||Tt(f)||$n(f)?n(f):e.attempt(la,e.attempt(ua,c),n)(f)}function c(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function Jg(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function Zg(e,t,n){let r,i,s;return o;function o(u){return u===46||u===95?e.check(ca,l,a)(u):u===null||ue(u)||Tt(u)||u!==45&&$n(u)?l(u):(s=!0,e.consume(u),o)}function a(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),o}function l(u){return i||r||!s?n(u):t(u)}}function ex(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(ca,t,s)(o):o===null||ue(o)||Tt(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function tx(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||ue(a)||Tt(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||ue(a)||Tt(a)?t(a):r(a)}function s(a){return Te(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):Te(a)?(e.consume(a),o):n(a)}}function nx(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return we(s)?n(s):t(s)}}function pa(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ue(e)}function da(e){return!Te(e)}function ma(e){return!(e===47||Nr(e))}function Nr(e){return e===43||e===45||e===46||e===95||we(e)}function pi(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const rx={tokenize:fx,partial:!0};function ix(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:lx,continuation:{tokenize:ux},exit:cx}},text:{91:{name:"gfmFootnoteCall",tokenize:ax},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:sx,resolveTo:ox}}}}function sx(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const u=Ge(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function ox(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function ax(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(f){if(s>999||f===93&&!o||f===null||f===91||ue(f))return n(f);if(f===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Ge(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return ue(f)||(o=!0),s++,e.consume(f),f===92?c:u}function c(f){return f===91||f===92||f===93?(e.consume(f),s++,u):u(f)}}function lx(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(g)}function c(g){if(o>999||g===93&&!a||g===null||g===91||ue(g))return n(g);if(g===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return s=Ge(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return ue(g)||(a=!0),o++,e.consume(g),g===92?f:c}function f(g){return g===91||g===92||g===93?(e.consume(g),o++,c):c(g)}function p(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),i.includes(s)||i.push(s),Z(e,d,"gfmFootnoteDefinitionWhitespace")):n(g)}function d(g){return t(g)}}function ux(e,t,n){return e.check(un,t,e.attempt(rx,t,n))}function cx(e){e.exit("gfmFootnoteDefinition")}function fx(e,t,n){const r=this;return Z(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function hx(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]==="exit"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type="strikethroughSequence",o[u][1].type="strikethroughSequence";const c={type:"strikethrough",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},f={type:"strikethroughText",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},p=[["enter",c,a],["enter",o[u][1],a],["exit",o[u][1],a],["enter",f,a]],d=a.parser.constructs.insideSpan.null;d&&ze(p,p.length,0,Bn(d,o.slice(u+1,l),a)),ze(p,p.length,0,[["exit",f,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",c,a]]),ze(o,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const u=this.previous,c=this.events;let f=0;return p;function p(g){return u===126&&c[c.length-1][1].type!=="characterEscape"?l(g):(o.enter("strikethroughSequenceTemporary"),d(g))}function d(g){const y=Ht(u);if(g===126)return f>1?l(g):(o.consume(g),f++,d);if(f<2&&!n)return l(g);const w=o.exit("strikethroughSequenceTemporary"),b=Ht(g);return w._open=!b||b===2&&!!y,w._close=!y||y===2&&!!b,a(g)}}}class px{constructor(){this.map=[]}add(t,n,r){dx(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function dx(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function mx(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function gx(){return{flow:{null:{name:"table",tokenize:xx,resolveAll:yx}}}}function xx(e,t,n){const r=this;let i=0,s=0,o;return a;function a(C){let M=r.events.length-1;for(;M>-1;){const I=r.events[M][1].type;if(I==="lineEnding"||I==="linePrefix")M--;else break}const j=M>-1?r.events[M][1].type:null,N=j==="tableHead"||j==="tableRow"?S:l;return N===S&&r.parser.lazy[r.now().line]?n(C):N(C)}function l(C){return e.enter("tableHead"),e.enter("tableRow"),u(C)}function u(C){return C===124||(o=!0,s+=1),c(C)}function c(C){return C===null?n(C):W(C)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),d):n(C):G(C)?Z(e,c,"whitespace")(C):(s+=1,o&&(o=!1,i+=1),C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),o=!0,c):(e.enter("data"),f(C)))}function f(C){return C===null||C===124||ue(C)?(e.exit("data"),c(C)):(e.consume(C),C===92?p:f)}function p(C){return C===92||C===124?(e.consume(C),f):f(C)}function d(C){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(C):(e.enter("tableDelimiterRow"),o=!1,G(C)?Z(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):g(C))}function g(C){return C===45||C===58?w(C):C===124?(o=!0,e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),y):D(C)}function y(C){return G(C)?Z(e,w,"whitespace")(C):w(C)}function w(C){return C===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),b):C===45?(s+=1,b(C)):C===null||W(C)?L(C):D(C)}function b(C){return C===45?(e.enter("tableDelimiterFiller"),v(C)):D(C)}function v(C){return C===45?(e.consume(C),v):C===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),T):(e.exit("tableDelimiterFiller"),T(C))}function T(C){return G(C)?Z(e,L,"whitespace")(C):L(C)}function L(C){return C===124?g(C):C===null||W(C)?!o||i!==s?D(C):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(C)):D(C)}function D(C){return n(C)}function S(C){return e.enter("tableRow"),$(C)}function $(C){return C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),$):C===null||W(C)?(e.exit("tableRow"),t(C)):G(C)?Z(e,$,"whitespace")(C):(e.enter("data"),F(C))}function F(C){return C===null||C===124||ue(C)?(e.exit("data"),$(C)):(e.consume(C),C===92?B:F)}function B(C){return C===92||C===124?(e.consume(C),F):F(C)}}function yx(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,u,c,f;const p=new px;for(;++n<e.length;){const d=e[n],g=d[1];d[0]==="enter"?g.type==="tableHead"?(a=!1,l!==0&&(Cs(p,t,l,u,c),c=void 0,l=0),u={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",u,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,c={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",c,t]])),i=g.type==="tableDelimiterRow"?2:c?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],f=xn(p,t,s,i,void 0,f),s=[0,0,0,0]),o[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],f=xn(p,t,s,i,void 0,f)),s=o,o=[s[1],n,0,0])):g.type==="tableHead"?(a=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],f=xn(p,t,s,i,n,f)):o[1]!==0&&(f=xn(p,t,o,i,n,f)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Cs(p,t,l,u,c),p.consume(t.events),n=-1;++n<t.events.length;){const d=t.events[n];d[0]==="enter"&&d[1].type==="table"&&(d[1]._align=mx(t.events,n))}return e}function xn(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Mt(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Mt(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=Mt(t.events,n[2]),c=Mt(t.events,n[3]),f={type:a,start:Object.assign({},u),end:Object.assign({},c)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const p=t.events[n[2]],d=t.events[n[3]];if(p[1].end=Object.assign({},d[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,y=n[3]-n[2]-1;e.add(g,y,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return i!==void 0&&(s.end=Object.assign({},Mt(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Cs(e,t,n,r,i){const s=[],o=Mt(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function Mt(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const bx={name:"tasklistCheck",tokenize:wx};function kx(){return{text:{91:bx}}}function wx(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return ue(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return W(l)?t(l):G(l)?e.check({tokenize:Sx},t,n)(l):n(l)}}function Sx(e,t,n){return Z(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function Cx(e){return Eo([Xg(),ix(),hx(e),gx(),kx()])}const vx={};function Ex(e){const t=this,n=e||vx,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Cx(n)),s.push(Ug()),o.push(Kg(n))}function Tx(e){return le.lexer(e).map(n=>n.raw)}function jx(e){if(!e)return"text";const t=e.match(/language-(\w+)/);return t?t[1]:"text"}const ga={code:function({className:t,children:n}){if(!t?.includes("language-"))return h.jsx("code",{className:"rounded bg-primary-100 px-1.5 py-1 text-sm font-mono text-primary-900 border border-primary-200",children:n});const i=jx(t);return h.jsx(zl,{content:String(n??""),language:i,className:"w-full"})},pre:function({children:t}){return h.jsx(h.Fragment,{children:t})},h1:function({children:t}){return h.jsx("h1",{className:"text-xl font-medium text-primary-950",children:t})},h2:function({children:t}){return h.jsx("h2",{className:"text-lg font-medium text-primary-900",children:t})},h3:function({children:t}){return h.jsx("h3",{className:"font-medium text-primary-900",children:t})},p:function({children:t}){return h.jsx("p",{className:"text-primary-950 text-pretty leading-relaxed",children:t})},ul:function({children:t}){return h.jsx("ul",{className:"ml-4 list-disc text-primary-950 marker:text-primary-400",children:t})},ol:function({children:t}){return h.jsx("ol",{className:"ml-4 list-decimal text-primary-950 marker:text-primary-500",children:t})},li:function({children:t}){return h.jsx("li",{className:"leading-relaxed",children:t})},a:function({children:t,href:n}){return h.jsx("a",{href:n,className:"text-primary-950 underline decoration-primary-300 underline-offset-4 transition-colors hover:text-primary-950 hover:decoration-primary-500",target:"_blank",rel:"noopener noreferrer",children:t})},blockquote:function({children:t}){return h.jsx("blockquote",{className:"border-l-2 border-primary-300 pl-4 text-primary-900 italic",children:t})},strong:function({children:t}){return h.jsx("strong",{className:"font-medium text-primary-950",children:t})},em:function({children:t}){return h.jsx("em",{className:"italic text-primary-950",children:t})},hr:function(){return h.jsx("hr",{className:"my-3 border-primary-200"})},table:function({children:t}){return h.jsx("div",{className:"overflow-x-auto",children:h.jsx("table",{className:"w-full border-collapse text-sm",children:t})})},thead:function({children:t}){return h.jsx("thead",{className:"border-b border-primary-200 bg-primary-50",children:t})},tbody:function({children:t}){return h.jsx("tbody",{className:"divide-y divide-primary-100",children:t})},tr:function({children:t}){return h.jsx("tr",{className:"transition-colors hover:bg-primary-50/50",children:t})},th:function({children:t}){return h.jsx("th",{className:"px-3 py-2 text-left font-medium text-primary-950",children:t})},td:function({children:t}){return h.jsx("td",{className:"px-3 py-2 text-primary-950",children:t})}},xa=m.memo(function({content:t,components:n=ga}){return h.jsx(cm,{remarkPlugins:[Ex,wm],components:n,children:t})},function(t,n){return t.content===n.content});xa.displayName="MemoizedMarkdownBlock";function Ix({children:e,id:t,className:n,components:r=ga}){const i=m.useId(),s=t??i,o=m.useMemo(()=>Tx(e),[e]);return h.jsx("div",{className:H("flex flex-col gap-2",n),children:o.map((a,l)=>h.jsx(xa,{content:a,components:r},`${s}-block-${l}`))})}const ya=m.memo(Ix);ya.displayName="Markdown";function ba({children:e,className:t,...n}){return h.jsx("div",{className:H("flex gap-3 w-full",t),...n,children:e})}function Ax({children:e,markdown:t=!1,className:n,...r}){const i=H("rounded-[12px] break-words whitespace-normal min-w-0",n);return t?h.jsx(ya,{className:i,...r,children:e}):h.jsx("div",{className:i,...r,children:e})}function Rx(){const[e,t]=m.useState(()=>typeof window<"u"?window.innerWidth<768:!1);return m.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia("(max-width: 767px)"),r=i=>t(i.matches);return n.addEventListener("change",r),t(n.matches),()=>n.removeEventListener("change",r)},[]),e}function Nx({content:e}){const t=Rx();return h.jsx("div",{className:"inline-flex flex-col",children:h.jsxs(Cn,{defaultOpen:!t,children:[h.jsxs(vn,{render:h.jsx(ye,{variant:"ghost",className:"h-auto gap-1.5 px-1.5 py-0.5 -mx-2"}),children:[h.jsx("span",{className:"text-sm font-medium text-primary-900",children:"Thinking"}),h.jsx(ae,{icon:Or,size:14,strokeWidth:1.5,className:"text-primary-900 transition-transform duration-150 group-data-panel-open:rotate-180"})]}),h.jsx(En,{children:h.jsx("div",{className:"pt-1 mb-3",children:h.jsx("p",{className:"text-sm text-primary-700 whitespace-pre-wrap",children:e})})})]})})}function Dx({toolPart:e,defaultOpen:t=!1}){const{state:n,input:r,output:i,toolCallId:s}=e,o=l=>{if(l===null)return"null";if(l===void 0)return"undefined";if(typeof l=="string")try{return JSON.parse(l)}catch{return l}return l},a=l=>{const u=o(l);return typeof u=="object"&&u!==null?h.jsx("pre",{className:"whitespace-pre-wrap break-all font-mono text-xs leading-relaxed",children:JSON.stringify(u,null,2)}):h.jsx("span",{className:"break-all",children:String(u)})};return h.jsx("div",{className:"inline-flex flex-col",children:h.jsxs(Cn,{defaultOpen:t,children:[h.jsxs(vn,{render:h.jsx(ye,{variant:"ghost",className:"h-auto gap-1.5 px-1.5 py-0.5 -mx-2"}),children:[h.jsx("span",{className:"text-sm font-medium text-primary-900",children:e.type}),h.jsx(ae,{icon:Or,size:14,strokeWidth:1.5,className:"text-primary-900 transition-transform duration-150 group-data-panel-open:rotate-180"})]}),h.jsx(En,{className:"mt-1",children:h.jsxs("div",{className:"space-y-2 bg-primary-100 p-2 border border-primary-200",children:[r&&Object.keys(r).length>0&&h.jsxs("div",{className:"border border-primary-200 bg-primary-50 p-3",children:[h.jsx("h4",{className:"text-primary-600 mb-2 text-xs font-medium",children:"Input"}),h.jsx("div",{className:"max-h-40 overflow-auto space-y-2 font-mono text-xs text-primary-800",children:Object.entries(r).map(([l,u])=>h.jsxs("div",{className:"break-all",children:[h.jsxs("span",{className:"text-primary-500",children:[l,":"]})," ",h.jsx("span",{className:"text-primary-700",children:a(u)})]},l))})]}),i&&h.jsxs("div",{className:"border border-primary-200 bg-primary-50 p-3",children:[h.jsx("h4",{className:"text-primary-600 mb-2 text-xs font-medium",children:"Output"}),h.jsx("div",{className:"max-h-40 overflow-auto font-mono text-xs text-primary-800",children:a(i)})]}),n==="output-error"&&e.errorText&&h.jsxs("div",{className:"rounded-md bg-red-50 p-2",children:[h.jsx("h4",{className:"mb-1 text-xs font-medium text-red-600",children:"Error"}),h.jsx("div",{className:"text-xs text-red-700",children:e.errorText})]}),n==="input-streaming"&&h.jsx("div",{className:"text-primary-500 text-xs",children:"Processing..."}),s&&h.jsx("div",{className:"text-primary-400 text-xs",children:h.jsxs("span",{className:"font-mono tabular-nums",children:["ID: ",s.slice(0,16),"..."]})})]})})]})})}function Lx(e,t){const n=t!==void 0,r=t?.isError??!1;let i;n?r?i="output-error":i="output-available":i="input-available";let s;return r&&t?.content?.[0]?.type==="text"&&(s=t.content[0].text||"Unknown error"),{type:e.name||"unknown",state:i,input:e.arguments,output:t?.details,toolCallId:e.id,errorText:s}}function vs(e){return Pt(e).map(n=>{const r=n.id??"",i=n.name??"",s=n.partialJson??"",o=n.arguments?JSON.stringify(n.arguments):"";return`${r}|${i}|${s}|${o}`}).join("||")}function Mx(e){if(!e)return"missing";const n=(Array.isArray(e.content)?e.content:[]).map(i=>i.type==="text"?String(i.text??""):"").join("").trim(),r=e.details?JSON.stringify(e.details):"";return`${e.toolCallId??""}|${e.toolName??""}|${e.isError?"1":"0"}|${n}|${r}`}function Es(e,t){if(!t)return"";const n=Pt(e);return n.length===0?"":n.map(r=>r.id?Mx(t.get(r.id)):"missing").join("||")}function Px(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e12?e*1e3:e;if(typeof e=="string"){const t=Date.parse(e);if(!Number.isNaN(t))return t}return null}function Ts(e){const t=[e.createdAt,e.created_at,e.timestamp,e.time,e.ts];for(const n of t){const r=Px(n);if(r)return r}return null}function Dr(e){const n=(Array.isArray(e.content)?e.content:[]).find(r=>r.type==="thinking");return n&&"thinking"in n?String(n.thinking??""):null}function zx(e){const t=Array.isArray(e.content)?e.content:[],n=[];for(const r of t)r.type==="image"&&"source"in r&&typeof r.source?.data=="string"&&n.push(r);return n}function _x({message:e,toolResultsByCallId:t,forceActionsVisible:n=!1,isStreaming:r=!1,wrapperRef:i,wrapperClassName:s,wrapperScrollMarginTop:o}){const{settings:a}=_l(),l=e.role||"assistant",u=Ye(e),c=Dr(e),f=zx(e),p=l==="user",d=yr(e),g=l==="assistant"?Pt(e):[],y=g.length>0;return h.jsxs("div",{ref:i,style:{contentVisibility:"auto",containIntrinsicSize:"auto 120px",...typeof o=="number"?{scrollMarginTop:`${o}px`}:void 0},className:H("group flex flex-col gap-1",s,p?"items-end":"items-start"),children:[c&&a.showReasoningBlocks&&h.jsx("div",{className:"w-full max-w-[900px]",children:h.jsx(Nx,{content:c})}),f.length>0&&h.jsx("div",{className:H("flex flex-wrap gap-2 mb-2",p?"justify-end":"justify-start"),children:f.map((w,b)=>h.jsx("img",{src:`data:${w.source.media_type};base64,${w.source.data}`,alt:`Attachment ${b+1}`,loading:"lazy",decoding:"async",className:"max-w-[300px] max-h-[300px] rounded-lg object-cover"},b))}),h.jsx(ba,{className:H(p?"flex-row-reverse":""),children:h.jsx(Ax,{markdown:!p,className:H("text-primary-900 opencami-text-size",p?"bg-primary-100 px-4 py-2.5 max-w-[85%]":"bg-transparent w-full",!p&&r&&"stream-fade-in"),children:u})}),y&&a.showToolMessages&&h.jsx("div",{className:"w-full max-w-[900px] mt-2 flex flex-col gap-3",children:g.map(w=>{const b=w.id?t?.get(w.id):void 0,v=Lx(w,b);return h.jsx(Dx,{toolPart:v,defaultOpen:!1},w.id||w.name)})}),!y&&h.jsx(Ac,{text:u,timestamp:d,align:p?"end":"start",forceVisible:n})]})}function Ox(e,t){return!(e.forceActionsVisible!==t.forceActionsVisible||e.isStreaming!==t.isStreaming||e.wrapperClassName!==t.wrapperClassName||e.wrapperRef!==t.wrapperRef||e.wrapperScrollMarginTop!==t.wrapperScrollMarginTop||(e.message.role||"assistant")!==(t.message.role||"assistant")||Ye(e.message)!==Ye(t.message)||Dr(e.message)!==Dr(t.message)||vs(e.message)!==vs(t.message)||Es(e.message,e.toolResultsByCallId)!==Es(t.message,t.toolResultsByCallId)||Ts(e.message)!==Ts(t.message))}const mr=m.memo(_x,Ox),Fx=[/```[\s\S]*?```/g,/`[^`]+`/g,/\b(function|const|let|var|class|import|export|return|async|await)\b/g];function $x(e){const t=[],n=e.match(/"([^"]+)"|'([^']+)'/g);n&&t.push(...n.map(s=>s.replace(/['"]/g,"")));const r=e.match(/\b[A-Z][a-z]+(?:\s+[A-Z][a-z]+)*\b/g);r&&t.push(...r.filter(s=>!["I","The","A","An","This"].includes(s)));const i=e.match(/`([^`]+)`/g);return i&&t.push(...i.map(s=>s.replace(/`/g,""))),[...new Set(t)].slice(0,5)}function Bx(e){return Fx.some(t=>t.test(e))}function Hx(e){return/^[\s]*[-*•\d]+[.)\s]/m.test(e)||/\b(first|second|third|1\.|2\.|3\.)/i.test(e)}function qx(e){return/\b(alternatively|another|other option|could also|you might|consider)\b/i.test(e)}function Ux(e){return/\b(because|since|due to|reason|why|how|what|when|where)\b/i.test(e)}function Kx(e){return/\b(however|but|note|warning|caution|careful|important|keep in mind|be aware)\b/i.test(e)}function Wx(e){const t=[],n=$x(e);if(Bx(e)&&(t.push({text:"Can you explain this code step by step?",type:"clarify"}),t.push({text:"How would I modify this for my use case?",type:"actionable"})),Hx(e)&&(t.push({text:"Can you elaborate on the first point?",type:"expand"}),t.push({text:"Which of these is most important to start with?",type:"actionable"})),qx(e)&&(t.push({text:"What are the pros and cons of each approach?",type:"alternative"}),t.push({text:"Which option would you recommend and why?",type:"clarify"})),Ux(e)&&t.length<3&&t.push({text:"Can you give me a practical example?",type:"example"}),Kx(e)&&t.length<3&&t.push({text:"What potential issues should I watch out for?",type:"clarify"}),n.length>0&&t.length<3){const s=n[0];t.push({text:`Tell me more about ${s}`,type:"expand"})}const r=[{text:"Can you give me a concrete example?",type:"example"},{text:"What would be the next steps?",type:"actionable"},{text:"How does this work in practice?",type:"expand"},{text:"Are there any common mistakes to avoid?",type:"clarify"},{text:"Can you simplify this explanation?",type:"clarify"}],i=new Set(t.map(s=>s.type));for(const s of r){if(t.length>=3)break;i.has(s.type)||(t.push(s),i.add(s.type))}for(const s of r){if(t.length>=3)break;t.some(o=>o.text===s.text)||t.push(s)}return t.slice(0,3)}function js(e){return Wx(e).map(t=>t.text)}const zt=Tl()(Ol(e=>({settings:{useLlmTitles:!1,useLlmFollowUps:!1,openaiApiKey:""},updateSettings:t=>e(n=>({settings:{...n.settings,...t}})),clearApiKey:()=>e(t=>({settings:{...t.settings,openaiApiKey:""}}))}),{name:"llm-settings"}));function ub(){const e=zt(o=>o.settings),t=zt(o=>o.updateSettings),n=zt(o=>o.clearApiKey),[r,i]=m.useState({hasEnvKey:!1,hasUserKey:!!e.openaiApiKey,isAvailable:!!e.openaiApiKey,isLoading:!0,error:null});m.useEffect(()=>{let o=!1;async function a(){try{const l=await fetch("/api/llm-features");if(!l.ok)throw new Error("Failed to check LLM status");const u=await l.json();if(o)return;const c=!!e.openaiApiKey;i({hasEnvKey:u.hasEnvKey,hasUserKey:c,isAvailable:u.hasEnvKey||c,isLoading:!1,error:null})}catch(l){if(o)return;i(u=>({...u,isLoading:!1,error:l instanceof Error?l.message:"Failed to check status"}))}}return a(),()=>{o=!0}},[e.openaiApiKey]);const s=m.useCallback(async o=>{try{const l=await(await fetch("/api/llm-features",{method:"POST",headers:{"Content-Type":"application/json","X-OpenAI-API-Key":o},body:JSON.stringify({action:"test"})})).json();return l.ok?{valid:l.valid??!1,error:l.error}:{valid:!1,error:l.error||"Test failed"}}catch(a){return{valid:!1,error:a instanceof Error?a.message:"Network error"}}},[]);return{settings:e,updateSettings:t,clearApiKey:n,status:r,testApiKey:s}}async function Vx(e,t,n){const r={"Content-Type":"application/json"};t&&(r["X-OpenAI-API-Key"]=t);const i=await fetch("/api/llm-features",{method:"POST",headers:r,body:JSON.stringify({action:"followups",conversationContext:e}),signal:n});if(!i.ok)throw new Error(`API error: ${i.status}`);const s=await i.json();return s.ok&&Array.isArray(s.suggestions)&&s.suggestions.length>0?s.suggestions:[]}function Xx(e,t,n){const r=zt(L=>L.settings),i=r.useLlmFollowUps,s=r.openaiApiKey,{minResponseLength:o=50,timeoutMs:a=8e3,heuristicsOnly:l}=n??{},u=l??!i,[c,f]=m.useState([]),[p,d]=m.useState(!1),[g,y]=m.useState(null),[w,b]=m.useState(null),v=m.useRef(""),T=m.useRef(null);return m.useEffect(()=>{if(!e||e.trim().length<o){f([]),b(null),d(!1),y(null);return}const L=e.slice(0,200)+e.length;if(L===v.current)return;if(v.current=L,T.current&&T.current.abort(),u){const F=js(e);f(F),b("heuristic"),d(!1),y(null);return}const D=new AbortController;T.current=D,d(!0),y(null);const S=js(e);f(S),b("heuristic");const $=t?`Context: ${t}
|
|
92
|
+
|
|
93
|
+
Assistant's response:
|
|
94
|
+
${e.slice(0,2e3)}`:`Assistant's response:
|
|
95
|
+
${e.slice(0,2e3)}`;return Vx($,s,D.signal).then(F=>{D.signal.aborted||(F.length>0&&(f(F),b("llm")),d(!1))}).catch(F=>{D.signal.aborted||(y(F instanceof Error?F.message:String(F)),d(!1))}),()=>{}},[e,t,o,a,u,s]),{suggestions:c,isLoading:p,error:g,source:w}}function Yx({responseText:e,contextSummary:t,onSuggestionClick:n,disabled:r=!1,className:i}){const{suggestions:s,isLoading:o,source:a}=Xx(e,t,{minResponseLength:50,timeoutMs:8e3});return s.length===0&&!o?null:h.jsxs("div",{className:H("flex flex-col gap-2 mt-3",i),children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-primary-500",children:[h.jsx("span",{className:"text-primary-400",children:"✨"}),h.jsx("span",{children:o?h.jsxs("span",{className:"flex items-center gap-1",children:["Thinking of follow-ups",h.jsx(ae,{icon:jl,size:12,strokeWidth:2,className:"animate-spin text-primary-400"})]}):a==="llm"?"AI suggestions":"Follow-up suggestions"})]}),h.jsx("div",{className:"flex flex-wrap gap-2",children:s.map((l,u)=>h.jsxs("button",{type:"button",disabled:r,onClick:()=>n(l),className:H("group inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full","text-sm text-primary-700 bg-primary-50 border border-primary-200","hover:bg-primary-100 hover:border-primary-300 hover:text-primary-900","focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:ring-offset-1","transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-primary-50 disabled:hover:border-primary-200",o&&"opacity-75"),children:[h.jsx("span",{children:l}),h.jsx(ae,{icon:qs,size:14,strokeWidth:2,className:"text-primary-400 group-hover:text-primary-600 group-hover:translate-x-0.5 transition-all duration-150"})]},`${u}-${l.slice(0,20)}`))})]})}const Is=m.memo(Yx);function Gx({className:e,variant:t="outline",scrollRef:n,...r}){const[i,s]=m.useState(!0),[o,a]=m.useState(!1),l=m.useRef(0),u=m.useCallback(()=>{const c=n.current;if(!c)return;const f=Math.abs(c.scrollHeight-c.scrollTop-c.clientHeight)<100;s(f)},[n]);return m.useLayoutEffect(()=>{const c=n.current;if(!c)return;const f=()=>{l.current=c.scrollTop,u()},p=new MutationObserver(()=>{c&&(c.scrollTop!==l.current&&(l.current=c.scrollTop),u())});return u(),c.addEventListener("scroll",f),p.observe(c,{childList:!0,subtree:!0}),()=>{c.removeEventListener("scroll",f),p.disconnect()}},[u,n]),m.useLayoutEffect(()=>{if(i){a(!1);return}const c=window.setTimeout(()=>{a(!0)},200);return()=>window.clearTimeout(c)},[i]),h.jsx(ye,{variant:"secondary",size:"icon-sm",className:H("pointer-events-auto rounded-full shadow-md","transition-all duration-100 ease-in-out",!i&&o?"translate-y-0 scale-100 opacity-100":"pointer-events-none translate-y-4 scale-98 opacity-0",e),onClick:()=>{const c=n.current;c&&(c.scrollTop=c.scrollHeight,s(!0))},...r,children:h.jsx(ae,{icon:Or,size:18,strokeWidth:1.8})})}function Qx({className:e,viewportRef:t,scrollRef:n,viewportProps:r}){return h.jsxs(Zs,{className:H("relative flex flex-1 min-h-0 flex-col",e),children:[h.jsx(eo,{className:"relative will-change-transform",ref:t,...r}),h.jsx("div",{className:"relative mx-auto w-full max-w-full px-5 sm:max-w-[768px] sm:min-w-[400px] ",children:h.jsx("div",{className:"pointer-events-none absolute bottom-10 right-10 z-50",children:h.jsx(Gx,{scrollRef:n})})}),h.jsx(to,{orientation:"vertical",children:h.jsx(no,{})}),h.jsx(Ku,{})]})}function Jx(e,t){if(e===t)return!0;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(e[i]!==t[i])return!1;return!0}function Zx(e,t){return!(e.className!==t.className||e.viewportRef!==t.viewportRef||e.scrollRef!==t.scrollRef||!Jx(e.viewportProps,t.viewportProps))}const ey=m.memo(Qx,Zx);function ty({viewportNode:e,children:t}){return e?_a.createPortal(h.jsx("div",{className:"relative flex w-full flex-col",children:t}),e):null}function ny({children:e,className:t,onUserScroll:n,...r}){const i=m.useRef(null),[s,o]=m.useState(null),a=m.useCallback(function(u){i.current=u,o(u)},[]);return m.useLayoutEffect(()=>{const l=i.current;if(!l)return;const u=()=>{n?.(l.scrollTop)};return l.addEventListener("scroll",u),()=>l.removeEventListener("scroll",u)},[n]),h.jsxs(h.Fragment,{children:[h.jsx(ey,{className:t,viewportRef:a,scrollRef:i,viewportProps:r}),h.jsx(ty,{viewportNode:s,children:e})]})}const ry=m.memo(ny);function iy({children:e,className:t,...n}){return h.jsx("div",{className:H("flex w-full flex-col min-h-full",t),...n,children:h.jsx("div",{className:"mx-auto w-full max-w-full px-2 md:px-5 sm:max-w-[768px] sm:min-w-[400px] flex flex-col flex-1 min-h-full",children:h.jsx("div",{className:"flex flex-col space-y-3 md:space-y-6",children:e})})})}function sy({...e}){return h.jsx("div",{className:"h-px w-full shrink-0 scroll-mt-4 pt-6","aria-hidden":"true",...e})}function oy({as:e="span",className:t,duration:n=4,spread:r=20,children:i,...s}){const o=Math.min(Math.max(r,5),45),a=e;return h.jsx(a,{className:H("bg-size-[200%_auto] bg-clip-text font-medium text-transparent","animate-[shimmer_4s_infinite_linear]",t),style:{backgroundImage:`linear-gradient(to right, var(--color-primary-600) ${50-o}%, var(--color-primary-950) 50%, var(--color-primary-600) ${50+o}%)`,animationDuration:`${n}s`},...s,children:i})}function ay({className:e}){return h.jsxs("div",{className:H("flex items-center gap-2",e),children:[h.jsxs("div",{className:"relative flex h-1.5 w-1.5",children:[h.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary-400 opacity-75"}),h.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-size-[200%_auto] animate-[shimmer_2s_infinite_linear]",style:{backgroundImage:"linear-gradient(to right, var(--color-primary-600) 0%, var(--color-primary-950) 50%, var(--color-primary-600) 100%)"}})]}),h.jsx(oy,{className:"text-sm",duration:2,children:"Generating..."})]})}function ly({messages:e,loading:t,empty:n,emptyState:r,notice:i,noticePosition:s="start",waitingForResponse:o,isStreaming:a=!1,sessionKey:l,pinToTop:u,pinGroupMinHeight:c,headerHeight:f,contentStyle:p,onFollowUpClick:d}){const g=m.useRef(null),y=m.useRef(null),w=m.useRef(!1),b=m.useRef(u),v=m.useRef(void 0),T=m.useMemo(()=>e.filter(N=>N.role!=="toolResult"),[e]),L=m.useMemo(()=>{const N=new Map;for(const I of e){if(I.role!=="toolResult")continue;const E=I.toolCallId;typeof E=="string"&&E.trim().length>0&&N.set(E,I)}return N},[e]),D=T.map((N,I)=>({message:N,index:I})).filter(({message:N})=>N.role!=="user").map(({index:N})=>N).pop(),S=T.map((N,I)=>({message:N,index:I})).filter(({message:N})=>N.role==="user").map(({index:N})=>N).pop(),$=o&&(typeof S!="number"||typeof D!="number"||D<S),F=typeof S=="number"?S:-1,B=u&&F>=0,C=typeof D=="number"?T[D]:void 0,M=C?Ye(C):"",j=!o&&M.length>0&&d!==void 0&&(typeof S!="number"||typeof D!="number"||D>S);return m.useLayoutEffect(()=>{if(!t){if(u){const N=!b.current||v.current!==S;b.current=!0,v.current=S,N&&y.current&&(w.current=!0,y.current.scrollIntoView({behavior:"auto",block:"start"}),window.setTimeout(()=>{w.current=!1},0));return}b.current=!1,v.current=S,g.current&&(w.current=!0,g.current.scrollIntoView({behavior:"auto",block:"end"}),window.setTimeout(()=>{w.current=!1},0))}},[t,T.length,l,u,S]),h.jsx(ry,{className:"flex-1 min-h-0 -mb-4",children:h.jsxs(iy,{className:"pt-6",style:p,children:[i&&s==="start"?i:null,n&&!i?r??h.jsx("div",{"aria-hidden":!0}):B?h.jsxs(h.Fragment,{children:[T.slice(0,F).map((N,I)=>{const E=N.__optimisticId||N.id||I,R=typeof D=="number"&&I===D,z=typeof D=="number"&&I===D,P=N.role==="assistant"&&Pt(N).length>0;return h.jsx(mr,{message:N,toolResultsByCallId:P?L:void 0,forceActionsVisible:R,isStreaming:z&&a},E)}),h.jsxs("div",{className:"flex flex-col space-y-3 md:space-y-6",style:{minHeight:`${Math.max(0,c-24)}px`},children:[T.slice(F).map((N,I)=>{const E=F+I,R=N.__optimisticId||N.id||E,z=typeof D=="number"&&E===D,P=typeof D=="number"&&E===D,U=E===S?y:void 0,x=E===S?"scroll-mt-0":void 0,q=E===S?f:void 0,ee=N.role==="assistant"&&Pt(N).length>0;return h.jsx(mr,{message:N,toolResultsByCallId:ee?L:void 0,forceActionsVisible:z,isStreaming:P&&a,wrapperRef:U,wrapperClassName:x,wrapperScrollMarginTop:q},R)}),$?h.jsx("div",{className:"py-2",children:h.jsx(ay,{})}):null,j&&d?h.jsx(Is,{responseText:M,onSuggestionClick:d,disabled:o}):null]})]}):h.jsxs(h.Fragment,{children:[T.map((N,I)=>{const E=N.__optimisticId||N.id||I,R=typeof D=="number"&&I===D,z=typeof D=="number"&&I===D,P=N.role==="assistant"&&Pt(N).length>0;return h.jsx(mr,{message:N,toolResultsByCallId:P?L:void 0,forceActionsVisible:R,isStreaming:z&&a},E)}),j&&d?h.jsx(Is,{responseText:M,onSuggestionClick:d,disabled:o}):null]}),i&&s==="end"?i:null,h.jsx(sy,{ref:g})]})})}function uy(e,t){return e.messages===t.messages&&e.loading===t.loading&&e.empty===t.empty&&e.emptyState===t.emptyState&&e.notice===t.notice&&e.noticePosition===t.noticePosition&&e.waitingForResponse===t.waitingForResponse&&e.isStreaming===t.isStreaming&&e.sessionKey===t.sessionKey&&e.pinToTop===t.pinToTop&&e.pinGroupMinHeight===t.pinGroupMinHeight&&e.headerHeight===t.headerHeight&&e.contentStyle===t.contentStyle&&e.onFollowUpClick===t.onFollowUpClick}const cy=m.memo(ly,uy),ka=m.createContext({isLoading:!1,value:"",setValue:()=>{},maxHeight:240,onSubmit:void 0,disabled:!1,textareaRef:Oa.createRef()});let _t=null,As=!1;function fy(){As||typeof window>"u"||(As=!0,window.addEventListener("keydown",e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey)return;const t=e.target;if(!t)return;const n=t.tagName.toLowerCase();if(n==="input"||n==="textarea"||n==="select"||t.isContentEditable)return;const r=e.key.length===1,i=e.key==="Backspace";!r&&!i||!_t||_t.disabled||_t.focus()}))}function wa(){return m.useContext(ka)}function hy({className:e,isLoading:t=!1,maxHeight:n=240,value:r,onValueChange:i,onSubmit:s,children:o,disabled:a=!1,onClick:l,...u}){const[c,f]=m.useState(r||""),p=m.useRef(null);fy();function d(y){f(y),i?.(y)}function g(y){a||p.current?.focus(),l?.(y)}return h.jsx(Ot,{children:h.jsx(ka.Provider,{value:{isLoading:t,value:r??c,setValue:i??d,maxHeight:n,onSubmit:s,disabled:a,textareaRef:p},children:h.jsx("div",{onClick:g,className:H("bg-surface cursor-text rounded-[22px] outline outline-ink/10 shadow-[0px_12px_32px_0px_rgba(0,0,0,0.05)] py-3 gap-3 flex flex-col",a&&"cursor-not-allowed opacity-60",e),...u,children:o})})})}function py({className:e,onKeyDown:t,disableAutosize:n=!1,inputRef:r,...i}){const{value:s,setValue:o,maxHeight:a,onSubmit:l,disabled:u,textareaRef:c}=wa();function f(y){!y||n||(y.style.height="auto",typeof a=="number"?y.style.height=`${Math.min(y.scrollHeight,a)}px`:y.style.height=`min(${y.scrollHeight}px, ${a})`)}function p(y){c.current=y,typeof r=="function"?r(y):r&&"current"in r&&(r.current=y),y?_t=y:_t===y&&(_t=null),f(y)}m.useLayoutEffect(()=>{if(!c.current||n)return;const y=c.current;y.style.height="auto",typeof a=="number"?y.style.height=`${Math.min(y.scrollHeight,a)}px`:y.style.height=`min(${y.scrollHeight}px, ${a})`},[s,a,n]);function d(y){f(y.target),o(y.target.value)}function g(y){y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),l?.()),t?.(y)}return h.jsx("textarea",{ref:p,value:s,onChange:d,onKeyDown:g,className:H("text-primary-950 opencami-text-size min-h-[28px] w-full resize-none border-none bg-transparent shadow-none outline-none focus-visible:ring-0 pl-4 pr-1 placeholder:text-primary-500",e),rows:1,readOnly:u,"aria-disabled":u,...i})}function dy({children:e,className:t,...n}){return h.jsx("div",{className:H("flex items-center gap-2",t),...n,children:e})}function Rs({tooltip:e,children:t,className:n,side:r="top",...i}){const{disabled:s}=wa();return h.jsxs(Ft,{...i,children:[h.jsx($t,{disabled:s,onClick:o=>o.stopPropagation(),children:t}),h.jsx(Bt,{side:r,className:n,children:e})]})}const Sa="opencami-selected-model";function my(){if(typeof window>"u")return null;try{return localStorage.getItem(Sa)}catch{return null}}function gy(e){if(!(typeof window>"u"))try{localStorage.setItem(Sa,e)}catch{}}function xy({className:e,onModelChange:t}){const[n,r]=m.useState([]),[i,s]=m.useState(""),[o,a]=m.useState(!0),[l,u]=m.useState(null);m.useEffect(()=>{let g=!0;async function y(){try{a(!0),u(null);const w=await fetch("/api/models");if(!w.ok)throw new Error("Failed to fetch models");const b=await w.json();if(!g)return;if(b.ok&&b.models.length>0){r(b.models);const v=my(),T=v&&b.models.some(L=>L.id===v)?v:b.defaultModel;s(T),t?.(T)}else throw new Error("No models available")}catch(w){if(!g)return;console.error("[model-selector] Error fetching models:",w),u(w instanceof Error?w.message:"Failed to load models"),r([{id:"default",name:"Default Model"}]),s("default")}finally{g&&a(!1)}}return y(),()=>{g=!1}},[t]);function c(g){s(g),gy(g),t?.(g)}if(o)return h.jsxs("div",{className:H("flex items-center gap-2 text-xs text-primary-500",e),children:[h.jsx(ae,{icon:Wn,size:14}),h.jsx("span",{children:"Loading..."})]});if(l||n.length===0)return null;const f=n.find(g=>g.id===i),p=f?.name||"Select Model",d=(()=>{if(!f?.name)return p;const y=f.name.replace(/\s*\([^)]*\)\s*$/,"").trim(),w=y.split(/\s+/);return w.length>3?w.slice(0,3).join(" "):y})();return n.length===1?h.jsxs("div",{className:H("flex items-center gap-2 text-xs text-primary-500",e),children:[h.jsx(ae,{icon:Wn,size:14}),h.jsx("span",{className:"font-[450] md:hidden",children:d}),h.jsx("span",{className:"font-[450] hidden md:inline",children:p})]}):h.jsxs(Mr,{children:[h.jsxs(Pr,{className:H("inline-flex h-7 items-center gap-2 rounded-md px-2 text-xs font-[450] text-primary-600 hover:text-primary-900 hover:bg-primary-100",e),children:[h.jsx(ae,{icon:Wn,size:14}),h.jsx("span",{className:"md:hidden",children:d}),h.jsx("span",{className:"hidden md:inline",children:p})]}),h.jsx(zr,{side:"top",align:"start",children:n.map(g=>h.jsxs(vt,{onClick:()=>c(g.id),className:"justify-between min-w-[180px]",children:[h.jsx("span",{children:g.name}),i===g.id&&h.jsx(ae,{icon:Us,size:14,className:"text-primary-600"})]},g.id))})]})}const Ca="opencami-personas-enabled",Lr="opencami-active-persona";function yy(){if(typeof window>"u")return!0;try{const e=localStorage.getItem(Ca);return e===null?!0:e==="true"}catch{return!0}}function by(){if(typeof window>"u")return null;try{const e=localStorage.getItem(Lr);return e?JSON.parse(e):null}catch{return null}}function Ns(e){if(!(typeof window>"u"))try{e?localStorage.setItem(Lr,JSON.stringify(e)):localStorage.removeItem(Lr)}catch{}}const ky={core:"Core",creative:"Creative",curator:"Curator",learning:"Learning",lifestyle:"Lifestyle",professional:"Professional"};function wy({className:e,onSelect:t}){const[n,r]=m.useState({}),[i,s]=m.useState(null),[o,a]=m.useState(!0),[l,u]=m.useState(!1),[c,f]=m.useState(yy);m.useEffect(()=>{const y=w=>{w.key===Ca&&f(w.newValue===null?!0:w.newValue==="true")};return window.addEventListener("storage",y),()=>window.removeEventListener("storage",y)},[]),m.useEffect(()=>{let y=!0;async function w(){try{a(!0);const b=await fetch("/api/personas");if(!b.ok){u(!1);return}const v=await b.json();if(!y)return;v.ok&&v.available?(r(v.personas),u(!0),s(by())):u(!1)}catch{if(!y)return;u(!1)}finally{y&&a(!1)}}return w(),()=>{y=!1}},[]);const p=m.useCallback(y=>{s(y),Ns(y),t(`/persona ${y.id}`)},[t]),d=m.useCallback(()=>{s(null),Ns(null),t("/persona exit")},[t]);if(o||!l||!c)return null;const g=Object.entries(n);return g.length===0?null:h.jsxs(Mr,{children:[h.jsxs(Pr,{className:H("inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-[450] text-primary-600 hover:text-primary-900 hover:bg-primary-100",e),children:[h.jsx("span",{className:"text-sm","aria-hidden":"true",children:"🎭"}),i?h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx("span",{children:i.emoji}),h.jsx("span",{children:i.name})]}):h.jsx("span",{children:"Persona"})]}),h.jsxs(zr,{side:"top",align:"start",className:"w-[300px] max-h-[360px] overflow-y-auto",children:[i&&h.jsxs(h.Fragment,{children:[h.jsxs(vt,{onClick:d,className:"text-red-600 hover:bg-red-50",children:[h.jsx("span",{className:"text-sm",children:"✕"}),h.jsx("span",{children:"Exit Persona"}),h.jsxs("span",{className:"ml-auto text-[10px] text-primary-400",children:[i.emoji," ",i.name]})]}),h.jsx("div",{className:"my-1 h-px bg-primary-200"})]}),g.map(([y,w])=>h.jsxs("div",{children:[h.jsx("div",{className:"px-2 pb-0.5 pt-2 text-[10px] font-semibold uppercase tracking-wider text-primary-400",children:ky[y]??y}),w.map(b=>h.jsxs(vt,{onClick:()=>p(b),className:"justify-between",children:[h.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[h.jsx("span",{className:"text-sm flex-shrink-0",children:b.emoji}),h.jsx("span",{className:"truncate",children:b.name})]}),h.jsx("span",{className:"text-[11px] text-primary-400 truncate ml-2 max-w-[140px]",children:b.description})]},b.id))]},y))]})]})}const Sy=[{command:"/new",description:"Start a new conversation",usage:"/new"},{command:"/reset",description:"Reset conversation context",usage:"/reset"},{command:"/abort",description:"Abort current generation",usage:"/abort"},{command:"/status",description:"Show session status card",usage:"/status"},{command:"/usage",description:"Show token usage",usage:"/usage [off|tokens|full]"},{command:"/models",description:"List available models",usage:"/models"},{command:"/agents",description:"List available agents",usage:"/agents"},{command:"/sessions",description:"List active sessions",usage:"/sessions"},{command:"/model",description:"Switch model for this session",usage:"/model <alias>"},{command:"/reasoning",description:"Toggle reasoning mode",usage:"/reasoning [on|off|stream]"},{command:"/think",description:"Set thinking budget",usage:"/think [off|minimal|low|medium|high]"},{command:"/verbose",description:"Toggle verbose output",usage:"/verbose [on|full|off]"},{command:"/tts",description:"Text-to-speech controls",usage:"/tts [status|off|always]"},{command:"/settings",description:"Show current settings",usage:"/settings"},{command:"/help",description:"Show help",usage:"/help"}];function Cy({className:e,onCommandSelect:t}){const[n,r]=m.useState(!1);function i(s){t?.(s),r(!1)}return h.jsxs(h.Fragment,{children:[h.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>r(!0),className:H("h-7 w-7 p-0",e),title:"Show commands (Ctrl+/)",children:h.jsx(ae,{icon:Ci,size:16,className:"text-primary-500"})}),n&&h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:h.jsxs("div",{className:"bg-white dark:bg-neutral-900 border border-primary-200 dark:border-neutral-700 rounded-xl shadow-2xl w-full max-w-lg max-h-[80vh] overflow-hidden",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-primary-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-800",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ae,{icon:Ci,size:18,className:"text-primary-600 dark:text-primary-400"}),h.jsx("h2",{className:"font-semibold text-primary-900 dark:text-white",children:"Slash Commands"})]}),h.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>r(!1),className:"h-7 w-7 p-0",children:h.jsx(ae,{icon:Ks,size:16})})]}),h.jsxs("div",{className:"overflow-y-auto max-h-[60vh] p-2 bg-white dark:bg-neutral-900",children:[h.jsx("div",{className:"text-xs text-primary-500 dark:text-neutral-400 px-2 py-1 mb-2",children:"Type these commands in the chat input"}),Sy.map(s=>h.jsxs("button",{onClick:()=>i(s.command),className:"w-full flex items-start gap-3 px-3 py-2 rounded-lg hover:bg-primary-100 dark:hover:bg-neutral-800 transition-colors text-left",children:[h.jsx("code",{className:"text-sm font-mono font-medium text-primary-700 dark:text-primary-300 bg-primary-100 dark:bg-neutral-800 px-1.5 py-0.5 rounded min-w-[80px]",children:s.command}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-sm text-primary-900 dark:text-neutral-100",children:s.description}),s.usage&&s.usage!==s.command&&h.jsx("div",{className:"text-xs text-primary-500 dark:text-neutral-500 font-mono mt-0.5",children:s.usage})]})]},s.command))]}),h.jsx("div",{className:"px-4 py-2 border-t border-primary-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-800",children:h.jsxs("div",{className:"text-xs text-primary-500 dark:text-neutral-400",children:["Press ",h.jsx("kbd",{className:"px-1 py-0.5 bg-primary-200 dark:bg-neutral-700 rounded text-primary-700 dark:text-neutral-300",children:"Esc"})," to close"]})})]})})]})}const vy=10*1024*1024,Lt=1280,Ey=.75,Ty=300*1024,jy=["image/png","image/jpeg","image/gif","image/webp"],Iy=".png,.jpg,.jpeg,.gif,.webp";function Ay(){if(typeof document>"u")return!1;try{const e=document.createElement("canvas");return!!(e.getContext&&e.getContext("2d"))}catch{return!1}}async function Ry(e){if(!Ay())throw new Error("Image compression not available in this browser");return new Promise((t,n)=>{const r=new Image,i=URL.createObjectURL(e),s=()=>{URL.revokeObjectURL(i)};r.onload=()=>{try{let o=r.width,a=r.height;(o>Lt||a>Lt)&&(o>a?(a=Math.round(a*Lt/o),o=Lt):(o=Math.round(o*Lt/a),a=Lt));const l=document.createElement("canvas");l.width=o,l.height=a;const u=l.getContext("2d");if(!u){s(),n(new Error("Failed to get canvas context"));return}u.drawImage(r,0,0,o,a);const c=e.type==="image/png"?"image/png":"image/jpeg";let f=Ey,p=l.toDataURL(c,f);if(c==="image/jpeg"){const g=Ty*1.37;for(;p.length>g&&f>.3;)f-=.1,p=l.toDataURL(c,f)}const d=p.split(",")[1];if(!d){s(),n(new Error("Failed to encode image"));return}s(),t(d)}catch(o){s(),n(o instanceof Error?o:new Error("Image compression failed"))}},r.onerror=()=>{s(),n(new Error("Failed to load image"))},r.src=i})}function Ny(e){return jy.includes(e.type)}function Dy({onFileSelect:e,disabled:t=!1,className:n}){const r=m.useRef(null),i=m.useCallback(()=>{r.current?.click()},[]),s=m.useCallback(async o=>{const a=o.target.files?.[0];if(!a)return;o.target.value="";const l=crypto.randomUUID();if(!Ny(a)){e({id:l,file:a,preview:null,type:"image",base64:null,error:"Unsupported file type. Please use PNG, JPG, GIF, or WebP images."});return}if(a.size>vy){e({id:l,file:a,preview:null,type:"image",base64:null,error:"Image is too large. Maximum size is 10MB."});return}try{const u=await Ry(a),c=URL.createObjectURL(a);e({id:l,file:a,preview:c,type:"image",base64:u})}catch(u){e({id:l,file:a,preview:null,type:"image",base64:null,error:u instanceof Error?u.message:"Failed to process image"})}},[e]);return h.jsxs(h.Fragment,{children:[h.jsx("input",{ref:r,type:"file",accept:Iy,onChange:s,className:"hidden","aria-hidden":"true"}),h.jsx(ye,{variant:"ghost",size:"icon-sm",onClick:i,disabled:t,className:n,"aria-label":"Attach image",type:"button",children:h.jsx(ae,{icon:Il,size:18,strokeWidth:1.8})})]})}function Ly(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function My(e){const t=e.split(".");return t.length>1&&t.pop()?.toUpperCase()||""}function Py({attachment:e,onRemove:t,className:n}){m.useEffect(()=>()=>{e.preview&&URL.revokeObjectURL(e.preview)},[e.preview]);const r=!!e.error;return h.jsxs("div",{className:H("relative flex items-center gap-3 rounded-xl border p-2 pr-3",r?"border-red-300 bg-red-50":"border-primary-200 bg-primary-50",n),children:[h.jsx("div",{className:"relative shrink-0",children:e.type==="image"&&e.preview?h.jsx("img",{src:e.preview,alt:e.file.name,className:"h-12 w-12 rounded-lg object-cover"}):h.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-lg bg-primary-100",children:h.jsx(ae,{icon:Al,size:24,className:"text-primary-500"})})}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"truncate text-sm font-medium text-primary-900",children:e.file.name}),r?h.jsx("p",{className:"text-xs text-red-600",children:e.error}):h.jsxs("p",{className:"text-xs text-primary-500",children:[My(e.file.name)," •"," ",Ly(e.file.size)]})]}),h.jsx(ye,{variant:"ghost",size:"icon-sm",onClick:()=>t(e.id),className:"h-6 w-6 shrink-0 rounded-full hover:bg-primary-200","aria-label":"Remove attachment",type:"button",children:h.jsx(ae,{icon:Ks,size:14})})]})}function zy({attachments:e,onRemove:t,className:n}){return e.length===0?null:h.jsx("div",{className:H("flex flex-col gap-2 px-4",n),children:e.map(r=>h.jsx(Py,{attachment:r,onRemove:t},r.id))})}function _y({commands:e,selectedIndex:t,onSelect:n,className:r}){return e.length===0?null:h.jsx("div",{className:H("absolute left-2 right-2 md:left-5 md:right-5 bottom-full mb-2 z-20 rounded-xl border border-white/10 bg-neutral-900/95 shadow-2xl backdrop-blur-sm overflow-hidden",r),role:"listbox","aria-label":"Slash commands",children:h.jsx("div",{className:"max-h-56 overflow-y-auto p-1",children:e.map((i,s)=>{const o=s===t;return h.jsx("button",{type:"button",role:"option","aria-selected":o,onMouseDown:a=>{a.preventDefault(),n(i)},className:H("w-full rounded-md px-3 py-2 text-left transition-colors",o?"bg-neutral-800":"hover:bg-neutral-800/80"),children:h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("code",{className:"min-w-[90px] font-mono text-xs text-primary-300",children:i.command}),h.jsx("span",{className:"text-xs text-neutral-300",children:i.description})]})},i.command)})})})}const Oy=m.memo(_y),Ds=[{command:"/haiku",description:"Switch to Claude Haiku 4.5"},{command:"/sonnet",description:"Switch to Claude Sonnet 4.5"},{command:"/opus",description:"Switch to Claude Opus 4.5"},{command:"/opus46",description:"Switch to Claude Opus 4.6"},{command:"/codex",description:"Switch to GPT 5.3 Codex"},{command:"/glm",description:"Switch to GLM 4.7"},{command:"/kimi",description:"Switch to Kimi K2.5"},{command:"/minimax",description:"Switch to MiniMax M2.1"},{command:"/grok",description:"Switch to Grok 4.1 Fast"},{command:"/model",description:"Show model picker or switch model"},{command:"/new",description:"New chat (optional: /new model)"},{command:"/reset",description:"Reset session"},{command:"/stop",description:"Stop current generation"},{command:"/compact",description:"Compact conversation context"},{command:"/help",description:"Show available commands"},{command:"/commands",description:"List all commands"},{command:"/status",description:"Show session status & usage"},{command:"/whoami",description:"Show your sender ID"},{command:"/context",description:"Show context window details"},{command:"/usage",description:"Toggle usage footer (off/tokens/full/cost)"},{command:"/think",description:"Set thinking level (off/low/medium/high)"},{command:"/reasoning",description:"Toggle reasoning (on/off/stream)"},{command:"/verbose",description:"Toggle verbose mode (on/full/off)"},{command:"/elevated",description:"Toggle elevated permissions (on/off/ask)"},{command:"/exec",description:"Configure exec settings"},{command:"/queue",description:"Show/configure message queue"},{command:"/tts",description:"Text-to-speech (off/always/tagged/status)"},{command:"/subagents",description:"List/stop/log sub-agent runs"},{command:"/followups",description:"Show follow-up suggestions"},{command:"/skill",description:"Run a skill by name"},{command:"/allowlist",description:"List/add/remove allowlist entries"},{command:"/approve",description:"Resolve exec approval (allow/deny)"},{command:"/config",description:"Show/get/set config (owner-only)"},{command:"/debug",description:"Runtime overrides (owner-only)"},{command:"/send",description:"Toggle message sending (on/off)"},{command:"/restart",description:"Restart gateway"},{command:"/activation",description:"Set activation mode (mention/always)"},{command:"/dock-telegram",description:"Switch replies to Telegram"},{command:"/dock-discord",description:"Switch replies to Discord"},{command:"/bash",description:"Run host shell command"}];function Fy({onSubmit:e,isLoading:t,disabled:n,wrapperRef:r,inputRef:i}){const[s,o]=m.useState(""),[a,l]=m.useState(""),[u,c]=m.useState([]),[f,p]=m.useState(0),[d,g]=m.useState(!1),y=m.useRef(null),w=m.useMemo(()=>/^\/\S*$/.test(s)&&!d,[s,d]),b=m.useMemo(()=>w?s.slice(1).toLowerCase():"",[w,s]),v=m.useMemo(()=>w?b?Ds.filter(R=>R.command.slice(1).toLowerCase().startsWith(b)):Ds:[],[w,b]),T=m.useCallback(R=>{y.current=R,i&&(typeof i=="function"?i(R):i.current=R)},[i]),L=m.useCallback(()=>{typeof window>"u"||window.requestAnimationFrame(()=>{y.current?.focus()})},[]),D=m.useCallback(()=>{o(""),c([]),p(0),g(!1),L()},[L]),S=m.useCallback(R=>{c(z=>[...z,R])},[]),$=m.useCallback(R=>{c(z=>z.filter(P=>P.id!==R))},[]),F=m.useCallback(R=>{o(R),p(0),g(!1),L()},[L]),B=m.useCallback(R=>{o(R),p(0),g(!1)},[]),C=m.useCallback(R=>{o(`${R.command} `),p(0),g(!1),L()},[L]),M=m.useCallback(()=>{if(n)return;if(w&&v.length>0){const P=Math.min(f,v.length-1);C(v[P]);return}const R=s.trim(),z=u.filter(P=>!P.error&&P.base64);R.length===0&&z.length===0||(e(R,{reset:D,setValue:F,model:a||void 0,attachments:z}),L())},[n,w,v,f,C,s,u,e,D,F,a,L]),j=m.useCallback(R=>{e(R,{reset:D,setValue:F,model:a||void 0,attachments:[]}),L()},[L,e,D,F,a]),N=m.useCallback(R=>{if(w){if(R.key==="Escape"){R.preventDefault(),g(!0),p(0);return}if(v.length!==0){if(R.key==="ArrowDown"){R.preventDefault(),p(z=>(z+1)%v.length);return}if(R.key==="ArrowUp"){R.preventDefault(),p(z=>(z-1+v.length)%v.length);return}if(R.key==="Tab"){R.preventDefault();const z=Math.min(f,v.length-1);C(v[z])}}}},[w,v,f,C]),I=u.filter(R=>!R.error&&R.base64),E=n||s.trim().length===0&&I.length===0;return h.jsx("div",{className:"mx-auto w-full max-w-full px-2 md:px-5 sm:max-w-[768px] sm:min-w-[400px] relative pb-1 md:pb-3",ref:r,children:h.jsxs(hy,{value:s,onValueChange:B,onSubmit:M,isLoading:t,disabled:n,children:[h.jsx(zy,{attachments:u,onRemove:$}),w&&v.length>0&&h.jsx(Oy,{commands:v,selectedIndex:Math.min(f,v.length-1),onSelect:C}),h.jsx(py,{placeholder:"Type a message…",inputRef:T,onKeyDown:N}),h.jsxs(dy,{className:"justify-between px-3",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(xy,{onModelChange:l}),h.jsx(wy,{onSelect:j}),h.jsx(Cy,{onCommandSelect:R=>B(R+" ")})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Rs,{tooltip:"Attach file",children:h.jsx(Dy,{onFileSelect:S,disabled:n})}),h.jsx(Rs,{tooltip:"Send message",children:h.jsx(ye,{onClick:M,disabled:E,size:"icon-sm",className:"rounded-full","aria-label":"Send message",children:h.jsx(ae,{icon:Rl,size:18,strokeWidth:2})})})]})]})]})})}const $y=m.memo(Fy);function By({title:e,description:t,detail:n,actionLabel:r,onAction:i,className:s}){return h.jsx("div",{className:H("w-full max-w-[900px]",s),children:h.jsx(ba,{children:h.jsxs("div",{className:"w-full rounded-xl border border-primary-200 bg-primary-50 p-4 text-primary-900",children:[h.jsx("div",{className:"text-balance font-medium",children:e}),h.jsx("div",{className:"mt-2 text-pretty text-primary-700",children:t}),n?h.jsx("div",{className:"mt-2 text-xs text-primary-600",children:n}):null,r&&i?h.jsx("div",{className:"mt-3",children:h.jsx(ye,{size:"sm",variant:"outline",onClick:i,children:r})}):null]})})})}function Hy({state:e,error:t,onRetry:n,className:r}){const i=e==="checking",s=i?"Checking gateway connection...":"OpenClaw gateway is unreachable",o=i?"This dashboard needs access to the OpenClaw gateway configured by your server environment variables.":"";return h.jsx(By,{title:s,description:i?o:h.jsxs(h.Fragment,{children:["We could not reach the gateway from the dashboard server. Start the gateway and confirm your server environment has"," ",h.jsx("span",{className:"font-mono",children:"CLAWDBOT_GATEWAY_URL"})," plus"," ",h.jsx("span",{className:"font-mono",children:"CLAWDBOT_GATEWAY_TOKEN"})," (or"," ",h.jsx("span",{className:"font-mono",children:"CLAWDBOT_GATEWAY_PASSWORD"}),")."]}),detail:i?null:t,actionLabel:i?void 0:"Retry",onAction:i?void 0:n,className:r})}function qy(){const e=m.useRef(null),t=m.useRef(null),n=m.useRef(null),[r,i]=m.useState(0),[s,o]=m.useState(0);return m.useLayoutEffect(()=>{const a=e.current,l=t.current,u=n.current;if(!u)return;const c=()=>{const p=a?.offsetHeight??0,d=l?.offsetHeight??0,g=u.clientHeight;u.style.setProperty("--chat-header-height",`${Math.max(0,p)}px`),u.style.setProperty("--chat-composer-height",`${Math.max(0,d)}px`),o(p),i(Math.max(0,g-p-d))};c();const f=new ResizeObserver(()=>c());return a&&f.observe(a),l&&f.observe(l),()=>f.disconnect()},[]),{headerRef:e,composerRef:t,mainRef:n,pinGroupMinHeight:r,headerHeight:s}}function Uy({activeFriendlyId:e,activeSessionKey:t,forcedSessionKey:n,isNewChat:r,isRedirecting:i,activeExists:s,sessionsReady:o,queryClient:a}){const l=n||t||e,u=pe.history(e,l),c=Sn({queryKey:u,queryFn:async function(){const v=a.getQueryData(u),T=Array.isArray(v?.messages)?v.messages.filter(S=>S.status==="sending"||S.__optimisticId?!0:!!S.clientId):[],L=await Vl({sessionKey:l,friendlyId:e});if(!T.length)return L;const D=Ky(L.messages,T);return{...L,messages:D}},enabled:!r&&!!e&&!i&&(!o||s),placeholderData:function(){return a.getQueryData(u)},gcTime:1e3*60*10}),f=m.useRef(""),p=m.useRef([]),d=m.useMemo(()=>{const b=Array.isArray(c.data?.messages)?c.data.messages:[],v=b[b.length-1],T=v&&typeof v.id=="string"?v.id:"",L=`${b.length}:${v?.role??""}:${T}:${Ye(v??{content:[]}).slice(-32)}`;return L===f.current?p.current:(f.current=L,p.current=b,b)},[c.data?.messages]),g=c.error instanceof Error?c.error.message:null,y=m.useMemo(()=>{if(n)return n;const b=c.data?.sessionKey;return typeof b=="string"&&b.trim().length>0?b.trim():t},[t,n,c.data?.sessionKey]);return{historyQuery:c,historyMessages:d,displayMessages:d,historyError:g,resolvedSessionKey:y,activeCanonicalKey:r?"new":y||e,sessionKeyForHistory:l}}function Ky(e,t){if(!t.length)return e;const n=[...e];for(const r of t)e.some(s=>{if(r.clientId&&s.clientId&&r.clientId===s.clientId||r.__optimisticId&&s.__optimisticId&&r.__optimisticId===s.__optimisticId)return!0;if(r.role&&s.role&&r.role!==s.role)return!1;const o=Ye(r);if(!o||o!==Ye(s))return!1;const a=yr(r),l=yr(s);return Math.abs(a-l)<=1e4})||n.push(r);return n}function Wy(e){const[t,n]=m.useState(!1);return m.useLayoutEffect(()=>{const r=window.matchMedia("(max-width: 768px)"),i=()=>n(r.matches);return i(),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[]),m.useLayoutEffect(()=>{t&&dt(e,function(i){return{...i,isSidebarCollapsed:!0}})},[t,e]),{isMobile:t}}function Vy({activeFriendlyId:e,isNewChat:t,forcedSessionKey:n}){const r=Sn({queryKey:pe.sessions,queryFn:Wl,refetchInterval:3e4}),i=m.useMemo(()=>{const f=r.data??[];return cc(f)},[r.data]),s=m.useMemo(()=>i.find(f=>f.friendlyId===e),[i,e]),o=m.useMemo(()=>t||n||so(e)?!0:i.some(f=>f.friendlyId===e),[e,n,t,i]),a=s?.key??"",l=m.useMemo(()=>s?s.label||s.title||s.derivedTitle||s.friendlyId:e,[e,s]),u=r.error instanceof Error?r.error.message:null,c=m.useMemo(()=>({totalTokens:s?.totalTokens,contextTokens:s?.contextTokens}),[s?.totalTokens,s?.contextTokens]);return{sessionsQuery:r,sessions:i,activeSession:s,activeExists:o,activeSessionKey:a,activeTitle:l,activeTokens:c,sessionsError:u}}function Xy(){const e=zt(u=>u.settings),[t,n]=m.useState(!1),[r,i]=m.useState(null),[s,o]=m.useState(null),a=m.useRef(null);return{generateTitle:m.useCallback(async u=>{a.current&&a.current.abort();const c=new AbortController;a.current=c,n(!0);try{const f={"Content-Type":"application/json"};e.openaiApiKey&&(f["X-OpenAI-API-Key"]=e.openaiApiKey);const p=await fetch("/api/llm-features",{method:"POST",headers:f,body:JSON.stringify({action:"title",message:u}),signal:c.signal});if(!p.ok)throw new Error(`API error: ${p.status}`);const d=await p.json();if(c.signal.aborted)throw new Error("Aborted");const g=d.title||u.slice(0,50),y=d.source||"heuristic";return i(g),o(y),{title:g,source:y,error:d.error}}catch(f){if(f instanceof Error&&f.name==="AbortError")throw f;const p=Yy(u);return i(p),o("heuristic"),{title:p,source:"heuristic",error:f instanceof Error?f.message:"Unknown error"}}finally{n(!1),a.current===c&&(a.current=null)}},[e.openaiApiKey]),isGenerating:t,lastTitle:r,lastSource:s}}function Yy(e){let t=e.replace(/```[\s\S]*?```/g," ");t=t.replace(/`[^`]+`/g," "),t=t.replace(/https?:\/\/[^\s]+/g," "),t=t.replace(/[^\w\s.,!?'-]/g," "),t=t.replace(/\s+/g," ").trim();let i=t.split(/\s+/).filter(s=>{if(s.length<=2){const o=s.toUpperCase();return["AI","ML","UI","UX","API","CSS","JS"].includes(o)}return!0}).slice(0,6).join(" ");return i=i.replace(/[.,!?]+$/,""),i.length>60&&(i=i.slice(0,57)+"..."),i||e.slice(0,50)}function Gy(){return zt(e=>e.settings.useLlmTitles)}const yn={active:!1,text:"",tools:[],sessionKey:null};function Qy(e){const[t,n]=m.useState(yn),r=m.useRef(null),i=m.useRef(e.onDone),s=m.useRef(e.onError);i.current=e.onDone,s.current=e.onError;const o=m.useCallback(()=>{r.current&&(r.current.close(),r.current=null),n(yn)},[]),a=m.useCallback(l=>{r.current&&(r.current.close(),r.current=null),n({active:!0,text:"",tools:[],sessionKey:l});const u=new EventSource(`/api/stream?sessionKey=${encodeURIComponent(l)}`);r.current=u,u.addEventListener("delta",c=>{try{const f=JSON.parse(c.data);n(p=>({...p,text:p.text+f.text}))}catch{}}),u.addEventListener("tool",c=>{try{const f=JSON.parse(c.data);n(p=>{const d=p.tools.findIndex(y=>y.id===f.id),g=[...p.tools];return d>=0?g[d]={name:f.name,status:f.status,id:f.id}:g.push({name:f.name,status:f.status,id:f.id}),{...p,tools:g}})}catch{}}),u.addEventListener("done",c=>{try{const f=JSON.parse(c.data);u.close(),r.current=null,n(yn),i.current(f.sessionKey)}catch{}}),u.onerror=()=>{u.readyState===EventSource.CLOSED&&(u.close(),r.current=null,n(yn),s.current?.("Stream connection lost"))}},[]);return{streaming:t,startStream:a,stopStream:o}}function Jy(e){const t=m.useCallback(n=>{const r=n.target,i=r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable;if(n.key==="Escape"){e.onEscape?.();return}if(n.key==="?"&&!i&&!n.metaKey&&!n.ctrlKey){n.preventDefault(),e.onShowHelp?.();return}if(i)return;const o=navigator.platform.toUpperCase().indexOf("MAC")>=0?n.metaKey:n.ctrlKey;if(o&&n.key==="k"&&!n.shiftKey){n.preventDefault(),e.onNewChat?.();return}if(o&&n.key==="/"){n.preventDefault(),e.onFocusInput?.();return}if(o&&n.shiftKey&&n.key==="C"){n.preventDefault(),e.onCopyLastResponse?.();return}if(o&&n.key==="f"&&!n.shiftKey){n.preventDefault(),e.onSearch?.();return}if(o&&n.shiftKey&&n.key==="F"){n.preventDefault(),e.onSearchGlobal?.();return}},[e]);m.useEffect(()=>(window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}),[t])}function Ls(e){const{threshold:t=50,edgeWidth:n,onMove:r,onSwipe:i,onCancel:s,direction:o,enabled:a=!0}=e,l=m.useRef({startX:0,startY:0,tracking:!1,directionLocked:!1}),u=m.useCallback(p=>{if(!a)return;const d=p.touches[0];d&&(n!==void 0&&d.clientX>n||(l.current={startX:d.clientX,startY:d.clientY,tracking:!0,directionLocked:!1}))},[a,n]),c=m.useCallback(p=>{const d=l.current;if(!d.tracking)return;const g=p.touches[0];if(!g)return;const y=g.clientX-d.startX,w=g.clientY-d.startY,b=Math.abs(y),v=Math.abs(w);if(!d.directionLocked){if(b<5&&v<5)return;if(v>b){d.tracking=!1,s?.();return}d.directionLocked=!0}o==="left"&&y>0||o==="right"&&y<0||(p.preventDefault(),r?.(y))},[o,r,s]),f=m.useCallback(p=>{const d=l.current;if(!d.tracking)return;d.tracking=!1;const g=p.changedTouches[0];if(!g){s?.();return}const y=g.clientX-d.startX,w=Math.abs(y);if(!d.directionLocked||w<t){s?.();return}const b=y>0?"right":"left";if(o&&b!==o){s?.();return}i(b)},[o,s,i,t]);return{onTouchStart:u,onTouchMove:c,onTouchEnd:f}}const Zy=m.lazy(()=>zn(()=>import("./keyboard-shortcuts-dialog-agsWJ36q.js"),__vite__mapDeps([6,1,3,2])).then(e=>({default:e.KeyboardShortcutsDialog}))),eb=m.lazy(()=>zn(()=>import("./search-dialog-CHwnOyPS.js"),__vite__mapDeps([7,1,2,3,4])).then(e=>({default:e.SearchDialog})));function tb({activeFriendlyId:e,isNewChat:t=!1,onSessionResolved:n,forcedSessionKey:r}){const i=Ps(),s=qt(),[o,a]=m.useState(!1),[l,u]=m.useState(!1),[c,f]=m.useState(null),[p,d]=m.useState(!1),{headerRef:g,composerRef:y,mainRef:w,pinGroupMinHeight:b,headerHeight:v}=qy(),[T,L]=m.useState(()=>Qn()||Jn()),[D,S]=m.useState(()=>Qn()||Jn()),[$,F]=m.useState(!1),[B,C]=m.useState(!1),[M,j]=m.useState("global"),[N,I]=m.useState(!1),E=m.useRef(null),R=m.useRef(null),z=m.useRef(null),P=m.useRef(""),U=m.useRef(()=>{}),x=m.useRef(!1),{isMobile:q}=Wy(s),{sessionsQuery:ee,sessions:k,activeExists:ce,activeSessionKey:Q,activeTitle:re,activeTokens:be,sessionsError:he}=Vy({activeFriendlyId:e,isNewChat:t,forcedSessionKey:r}),{historyQuery:te,historyMessages:oe,displayMessages:ge,historyError:Ie,resolvedSessionKey:de,activeCanonicalKey:_e,sessionKeyForHistory:Ce}=Uy({activeFriendlyId:e,activeSessionKey:Q,forcedSessionKey:r,isNewChat:t,isRedirecting:p,activeExists:ce,sessionsReady:ee.isSuccess,queryClient:s}),J=Sn({queryKey:cl,queryFn:function(){return wi(s)},initialData:function(){return wi(s)},staleTime:1/0}),X=Sn({queryKey:["gateway","status"],queryFn:Xl,retry:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:"always"}),Ae=m.useRef(Date.now()),ve=X.error instanceof Error?X.error.message:X.data&&!X.data.ok?X.data.error||"Gateway unavailable":null,Qe=ve??he??Ie,Je=m.useCallback(()=>{X.refetch()},[X]),De=J.data?.isSidebarCollapsed??!1,ut=Ls({enabled:q&&De,edgeWidth:40,threshold:50,direction:"right",onSwipe:()=>{dt(s,O=>({...O,isSidebarCollapsed:!1}))}}),Ze=Ls({enabled:q&&!De,threshold:50,direction:"left",onSwipe:()=>{dt(s,O=>({...O,isSidebarCollapsed:!0}))}}),it=m.useCallback(()=>{f(null),d(!0),i({to:"/new",replace:!0})},[i]),A=m.useCallback(()=>{R.current&&(window.clearInterval(R.current),R.current=null),z.current&&(window.clearTimeout(z.current),z.current=null)},[]),_=m.useCallback(()=>{A(),Wt(!1),L(!1),I(!1)},[A]),K=Gy(),{generateTitle:Y}=Xy(),ne=m.useRef(new Set),xe=150,Be=600,Le=m.useCallback(()=>{!e||t||(R.current&&window.clearInterval(R.current),I(!0),R.current=window.setInterval(()=>{U.current()},xe))},[e,t]),He=m.useCallback(O=>{te.refetch(),s.invalidateQueries({queryKey:pe.sessions}),_()},[te,s,_]),qe=m.useCallback(O=>{console.warn("[stream] SSE error, falling back to polling")},[]),{streaming:fe,startStream:Ue,stopStream:Ee}=Qy({onDone:He,onError:qe}),ct=m.useMemo(()=>{if(!fe.active||!fe.text)return null;const O=[];for(const V of fe.tools)O.push({type:"toolCall",name:V.name,id:V.id});return O.push({type:"text",text:fe.text}),{role:"assistant",content:O,__streaming:!0,timestamp:Date.now()}},[fe.active,fe.text,fe.tools]),Kn=m.useMemo(()=>{if(!ct)return ge;const O=[...ge],V=O[O.length-1];if(V?.role==="assistant"&&ct){const me=Ye(V);return fe.text.length>me.length&&(O[O.length-1]=ct),O}return[...O,ct]},[ge,ct,fe.text]),bt=m.useMemo(()=>({}),[]);U.current=function(){te.refetch()},m.useEffect(()=>{if(p){c&&f(null);return}if(se){c&&f(null);return}if(ee.isSuccess&&!ce){c&&f(null);return}const O=he??Ie??ve;if(!O){c?.startsWith("Failed to load")&&f(null);return}Ei(O)&&i({to:"/connect",replace:!0});const V=he?`Failed to load sessions. ${he}`:Ie?`Failed to load history. ${Ie}`:ve?`Gateway unavailable. ${ve}`:null;V&&f(V)},[c,ve,Ie,p,i,he]);const se=!t&&!r&&!so(e)&&ee.isSuccess&&k.length>0&&!k.some(O=>O.friendlyId===e)&&!te.isFetching&&!te.isSuccess;m.useEffect(()=>{if(p){if(t){d(!1);return}!se&&ee.isSuccess&&d(!1)}},[t,p,ee.isSuccess,se]),m.useEffect(()=>{t||ee.isSuccess&&k.length!==0&&se&&(In(),kr(s,e,Ce),i({to:"/new",replace:!0}))},[e,te.isFetching,te.isSuccess,t,i,s,Ce,k,ee.isSuccess,se]);const Me=se||p,st=m.useRef("fast");m.useEffect(()=>{const O=oe[oe.length-1];if(!O||O.role!=="assistant")return;const V=`${oe.length}:${Ye(O).slice(-64)}`;V!==P.current&&(P.current=V,st.current!=="fast"&&R.current&&(window.clearInterval(R.current),R.current=window.setInterval(()=>{U.current()},xe),st.current="fast"),z.current&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>{R.current&&(window.clearInterval(R.current),R.current=window.setInterval(()=>{U.current()},Be),st.current="slow"),z.current=window.setTimeout(()=>{_(),st.current="fast"},3e3)},1500))},[oe,_]),m.useEffect(()=>{if(!K||t||p)return;const O=r||de||Q;if(!O||ne.current.has(O))return;const V=oe.filter(Re=>Re.role==="user"),me=oe.filter(Re=>Re.role==="assistant");if(V.length===0||me.length===0||V.length!==1)return;const et=Ye(V[0]);!et||et.length<5||(ne.current.add(O),(async()=>{try{const Re=await Y(et);Re.title&&await eu(s,O,e,Re.title)}catch(Re){console.error("[smart-title] Error generating title:",Re)}})())},[K,t,p,r,de,Q,e,oe,Y,s]),m.useEffect(()=>{if(t||e){if(x.current){x.current=!1;return}if(Qn()||Jn()){L(!0),S(!0);return}A(),Ee(),P.current="",L(!1),S(!1),I(!1)}},[e,t,A,Ee]),m.useLayoutEffect(()=>{if(t)return;const O=oc(r||de||Q,e);if(!O)return;x.current=!0;const V=pe.history(O.friendlyId,O.sessionKey),me=s.getQueryData(V);(Array.isArray(me?.messages)?me.messages:[]).some(wt=>!!(O.optimisticMessage.clientId&&(wt.clientId===O.optimisticMessage.clientId||wt.__optimisticId===O.optimisticMessage.clientId)||O.optimisticMessage.__optimisticId&&wt.__optimisticId===O.optimisticMessage.__optimisticId))||Vn(s,O.friendlyId,O.sessionKey,O.optimisticMessage),L(!0),S(!0),kt(O.sessionKey,O.friendlyId,O.message,!0,O.attachments)},[e,Q,r,t,s,de]);function kt(O,V,me,et=!1,Re,wt){let It="";if(!et){const{clientId:ke,optimisticMessage:Kt}=Ti(me,Re);It=ke,Vn(s,V,O,Kt),Jl(s,O,V,Kt)}Wt(!0),a(!0),f(null),L(!0),S(!0);const ft=Re?.map(ke=>({mimeType:ke.file.type,content:ke.base64}));Ue(O),Le(),fetch("/api/send",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({sessionKey:O,friendlyId:V,message:me,thinking:"low",idempotencyKey:crypto.randomUUID(),attachments:ft,model:wt||void 0})}).then(async ke=>{if(!ke.ok)throw new Error(await nt(ke))}).catch(ke=>{const Kt=ke instanceof Error?ke.message:String(ke);if(Ei(Kt)){i({to:"/connect",replace:!0});return}It&&Yl(s,V,O,It,function(za){return{...za,status:"error"}}),f(`Failed to send message. ${Kt}`),Wt(!1),L(!1),S(!1)}).finally(()=>{a(!1)})}const di=m.useCallback(async()=>{u(!0);try{const O=await fetch("/api/sessions",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({})});if(!O.ok)throw new Error(await nt(O));const V=await O.json(),me=typeof V.sessionKey=="string"?V.sessionKey:"",et=typeof V.friendlyId=="string"&&V.friendlyId.trim().length>0?V.friendlyId.trim():xr(me);if(!me||!et)throw new Error("Invalid session response");return s.invalidateQueries({queryKey:pe.sessions}),{sessionKey:me,friendlyId:et}}finally{u(!1)}},[s]),va=m.useCallback((O,V)=>{const me=V.attachments;if(O.length===0&&(!me||me.length===0))return;if(V.reset(),t){const{clientId:Re,optimisticId:wt,optimisticMessage:It}=Ti(O,me);Vn(s,"new","new",It),Wt(!0),a(!0),L(!0),S(!0),di().then(({sessionKey:ft,friendlyId:ke})=>{if(sc(ke),rc({sessionKey:ft,friendlyId:ke,message:O,optimisticMessage:It,attachments:me}),n){n({sessionKey:ft,friendlyId:ke});return}i({to:"/chat/$sessionKey",params:{sessionKey:ke},replace:!0})}).catch(ft=>{Gl(s,"new","new",Re,wt),V.setValue(O),f(`Failed to create session. ${ft instanceof Error?ft.message:String(ft)}`),Wt(!1),L(!1),S(!1),a(!1)});return}kt(r||de||Q,e,O,!1,me,V.model)},[e,Q,di,r,t,i,n,s,de]),mi=m.useCallback(()=>{L(!1),S(!1),kr(s,"new","new"),i({to:"/new"}),q&&dt(s,function(V){return{...V,isSidebarCollapsed:!0}})},[q,i,s]),Ea=m.useCallback(()=>{dt(s,function(V){return{...V,isSidebarCollapsed:!V.isSidebarCollapsed}})},[s]),Ta=m.useCallback(()=>{q&&dt(s,function(V){return{...V,isSidebarCollapsed:!0}})},[q,s]),ja=m.useCallback(()=>{dt(s,function(V){return{...V,isSidebarCollapsed:!1}})},[s]),Ia=m.useCallback(O=>{if(t||!O.trim())return;const V=r||de||Q;V&&kt(V,e,O.trim())},[e,Q,r,t,de]),Aa=m.useCallback(()=>{E.current?.focus()},[]),Ra=m.useCallback(()=>{if($){F(!1);return}document.activeElement instanceof HTMLElement&&document.activeElement.blur()},[$]),Na=m.useCallback(()=>{const O=[...ge].reverse().find(me=>me.role==="assistant");if(!O)return;const V=Ye(O);V&&navigator.clipboard.writeText(V).catch(()=>{})},[ge]),Da=m.useCallback(()=>{F(!0)},[]),La=m.useCallback(()=>{j(t?"global":"current"),C(!0)},[t]),gi=m.useCallback(()=>{j("global"),C(!0)},[]);Jy({onNewChat:mi,onFocusInput:Aa,onEscape:Ra,onCopyLastResponse:Na,onShowHelp:Da,onSearch:La,onSearchGlobal:gi});const xi=te.isLoading&&!te.data||p,yi=!!ve&&X.errorUpdatedAt>Ae.current,Ma=!xi&&ge.length===0,Pa=m.useMemo(()=>!yi||!Qe?null:h.jsx(Hy,{state:"error",error:Qe,onRetry:Je}),[Qe,Je,yi]),bi=h.jsx(kc,{sessions:k,activeFriendlyId:e,activeSessionKey:Ce,creatingSession:l,onCreateSession:mi,isCollapsed:q?!1:De,onToggleCollapse:Ea,onSelectSession:Ta,onActiveSessionDelete:it,onOpenSearch:gi});return h.jsxs("div",{className:"h-screen bg-surface text-primary-900",children:[h.jsxs("div",{className:H("h-full overflow-hidden",q?"relative":"grid grid-cols-[auto_1fr]"),children:[Me?null:q?h.jsxs(h.Fragment,{children:[!De&&h.jsx("div",{className:"fixed inset-0 z-40 bg-black/40 transition-opacity duration-200",onClick:()=>dt(s,O=>({...O,isSidebarCollapsed:!0})),...Ze}),h.jsx("div",{className:H("fixed inset-y-0 left-0 z-50 w-[300px] transition-transform duration-150 safe-area-top",De?"-translate-x-full":"translate-x-0"),...Ze,children:bi})]}):bi,h.jsxs("main",{className:"flex flex-col h-full min-h-0",ref:w,...ut,children:[h.jsx(vc,{activeTitle:re,wrapperRef:g,showSidebarButton:q,onOpenSidebar:ja,totalTokens:be.totalTokens,contextTokens:be.contextTokens}),Me?null:h.jsxs(h.Fragment,{children:[h.jsx(cy,{messages:Kn,loading:xi,empty:Ma,notice:Pa,noticePosition:"end",waitingForResponse:T,isStreaming:N,sessionKey:_e,pinToTop:D,pinGroupMinHeight:b,headerHeight:v,contentStyle:bt,onFollowUpClick:Ia}),h.jsx($y,{onSubmit:va,isLoading:o,disabled:o,wrapperRef:y,inputRef:E})]})]})]}),$&&h.jsx(m.Suspense,{fallback:null,children:h.jsx(Zy,{open:$,onOpenChange:F})}),B&&h.jsx(m.Suspense,{fallback:null,children:h.jsx(eb,{open:B,onOpenChange:C,sessions:k,currentFriendlyId:e,currentSessionKey:Q,mode:M,onJumpToMessage:O=>{C(!1),O.friendlyId&&i({to:"/chat/$sessionKey",params:{sessionKey:O.friendlyId}})}})})]})}function nb(){const e=qt(),t=Ps(),[n,r]=m.useState(null),i=Fa.useParams(),s=typeof i.sessionKey=="string"?i.sessionKey:"main",o=s==="new",a=n?.friendlyId===s?n.sessionKey:void 0,l=m.useCallback(function(c){Ql(e,"new","new",c.friendlyId,c.sessionKey),r({friendlyId:c.friendlyId,sessionKey:c.sessionKey}),t({to:"/chat/$sessionKey",params:{sessionKey:c.friendlyId},replace:!0})},[t,e]);return h.jsx(tb,{activeFriendlyId:s,isNewChat:o,forcedSessionKey:a,onSessionResolved:o?l:void 0})}const cb=Object.freeze(Object.defineProperty({__proto__:null,component:nb},Symbol.toStringTag,{value:"Module"}));export{cb as $,Nu as a,ub as b,pe as c,mu as u};
|