@ensocode/server 0.2.14 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/out/phone/assets/{abnfDiagram-VCTEODGH-Cega0ZB0.js → abnfDiagram-VCTEODGH-DdiNp4j7.js} +1 -1
- package/out/phone/assets/architecture-7GRP2DOG-B6XPzuQu.js +1 -0
- package/out/phone/assets/{architectureDiagram-5GKGNRK7-C8f9RvZ3.js → architectureDiagram-5GKGNRK7-BMPnLJ2s.js} +1 -1
- package/out/phone/assets/{blockDiagram-I7D4REHJ-BZvd5QEd.js → blockDiagram-I7D4REHJ-gT7-o8Mw.js} +1 -1
- package/out/phone/assets/{c4Diagram-7LVT6UL2-CJ2qv8Ii.js → c4Diagram-7LVT6UL2-Jquqp3VQ.js} +1 -1
- package/out/phone/assets/channel-o_G6mfBV.js +1 -0
- package/out/phone/assets/{chunk-4HAMMTFA-QpMUBcfy.js → chunk-4HAMMTFA-YQFUQRqX.js} +1 -1
- package/out/phone/assets/{chunk-75Z2AOVW-DAFs7o0e.js → chunk-75Z2AOVW-BqHLON2E.js} +1 -1
- package/out/phone/assets/{chunk-DU6HZSFF-CHnDtYge.js → chunk-DU6HZSFF-CfA8U5r3.js} +1 -1
- package/out/phone/assets/{chunk-F27PBJKO-BdAamljM.js → chunk-F27PBJKO-BNT7J3tF.js} +1 -1
- package/out/phone/assets/{chunk-GMAD6QVW-DwZMixrA.js → chunk-GMAD6QVW-CIuSusWI.js} +1 -1
- package/out/phone/assets/{chunk-GVQU2GXP-C4OAfnrk.js → chunk-GVQU2GXP-CaBgSaik.js} +1 -1
- package/out/phone/assets/{chunk-IMKFNOWR-C3kpXYrw.js → chunk-IMKFNOWR-C2Smg1aj.js} +1 -1
- package/out/phone/assets/{chunk-L3NEJ4N5-D056XKtd.js → chunk-L3NEJ4N5-BZ6UVkkR.js} +1 -1
- package/out/phone/assets/{chunk-OSK3NFVY-BS9ju3v0.js → chunk-OSK3NFVY-BxOOthv7.js} +1 -1
- package/out/phone/assets/{chunk-P2QGCYS3-BlTpKqmw.js → chunk-P2QGCYS3-BXnn6tZa.js} +1 -1
- package/out/phone/assets/{chunk-POPQ4Y6H-Dxxk_blH.js → chunk-POPQ4Y6H-DvDXaO8a.js} +1 -1
- package/out/phone/assets/{chunk-PWAF6VOD-BcNAXNJ7.js → chunk-PWAF6VOD-DrHMV5jh.js} +1 -1
- package/out/phone/assets/{chunk-SHT3W25Y-BgymU7VM.js → chunk-SHT3W25Y-D64aGSiu.js} +1 -1
- package/out/phone/assets/{chunk-SVP7TREG-BQ0V0mhL.js → chunk-SVP7TREG-Bvf9vq1C.js} +1 -1
- package/out/phone/assets/{chunk-TICWLB2K-CwD4Xciz.js → chunk-TICWLB2K-BxVM5xux.js} +1 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-B7aLIKjD.js +1 -0
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-B7aLIKjD.js +1 -0
- package/out/phone/assets/{cynefin-OW5HDTMX-BtpkGoWh.js → cynefin-OW5HDTMX-BK64oPGb.js} +1 -1
- package/out/phone/assets/{cynefinDiagram-5FMLGOSQ-S3Likhk7.js → cynefinDiagram-5FMLGOSQ-BmRV0tsD.js} +1 -1
- package/out/phone/assets/{dagre-GXQ25YYZ-DYwTFga-.js → dagre-GXQ25YYZ-CM8jhy74.js} +1 -1
- package/out/phone/assets/{diagram-S7CK7UJ4-DCgm4mSi.js → diagram-S7CK7UJ4-DLC1N3P7.js} +1 -1
- package/out/phone/assets/{diagram-UQ7AKVKN-BEJP1vbS.js → diagram-UQ7AKVKN-Cs-BNe7D.js} +1 -1
- package/out/phone/assets/{diagram-VSXAHHWV-D-zTGZ-C.js → diagram-VSXAHHWV-DOyx18IJ.js} +1 -1
- package/out/phone/assets/{diagram-VX7I27RA-DyALsXBK.js → diagram-VX7I27RA-JIO8i4XO.js} +1 -1
- package/out/phone/assets/{diagram-Z3DM3KII-2moOTbgb.js → diagram-Z3DM3KII-BKvMMlI9.js} +1 -1
- package/out/phone/assets/{ebnfDiagram-PWID7BFC-qEwH7k_f.js → ebnfDiagram-PWID7BFC-DwXn766M.js} +1 -1
- package/out/phone/assets/{erDiagram-RLTQ6QDP-YhtKvjVT.js → erDiagram-RLTQ6QDP-BIPLcGkZ.js} +1 -1
- package/out/phone/assets/eventmodeling-NTZA5JFV-CzeS60xJ.js +1 -0
- package/out/phone/assets/flowDiagram-HODETNUW-C3cjv9GE.js +1 -0
- package/out/phone/assets/{ganttDiagram-EL5Y4UJY-JjCptSO9.js → ganttDiagram-EL5Y4UJY-OpKwlmBE.js} +1 -1
- package/out/phone/assets/{gitGraph-4MIJSDKK--upNpeoD.js → gitGraph-4MIJSDKK-BtGMlgKE.js} +1 -1
- package/out/phone/assets/{gitGraphDiagram-WWUBYQGX-G4lioX9s.js → gitGraphDiagram-WWUBYQGX-BnPYThwR.js} +1 -1
- package/out/phone/assets/{info-A6RAGUB7-DimHr4wm.js → info-A6RAGUB7-BXuZDF4f.js} +1 -1
- package/out/phone/assets/{infoDiagram-27XIBGKW-mUBJ5ulK.js → infoDiagram-27XIBGKW-BzEFVoGV.js} +1 -1
- package/out/phone/assets/{ishikawaDiagram-5VMMS53U-BeD9kEgT.js → ishikawaDiagram-5VMMS53U-CqzxZls6.js} +1 -1
- package/out/phone/assets/{journeyDiagram-3NMN7TZE-GY0or-wH.js → journeyDiagram-3NMN7TZE-BUZ_Ec1_.js} +1 -1
- package/out/phone/assets/{kanban-definition-UXKFOSKX-HKJcUWdV.js → kanban-definition-UXKFOSKX-CGqYB68a.js} +1 -1
- package/out/phone/assets/{line-5zNSEFjF.js → line-4xV-GxLd.js} +1 -1
- package/out/phone/assets/{main-DUhek_LZ.js → main-BRzVEcO0.js} +3 -3
- package/out/phone/assets/{mermaid-parser.core-CESNvrmx.js → mermaid-parser.core-CWazhUdP.js} +3 -3
- package/out/phone/assets/{mermaid.core-CHMT4qDd.js → mermaid.core-uPr3mNB_.js} +4 -4
- package/out/phone/assets/{mindmap-definition-YA3MSWOX-D4UPhmEW.js → mindmap-definition-YA3MSWOX-DQMhX2hJ.js} +1 -1
- package/out/phone/assets/{packet-AYTQ26CC-yYeqVBt3.js → packet-AYTQ26CC--MQV7EpA.js} +1 -1
- package/out/phone/assets/{pegDiagram-XKGWAZYB-C1BeG2En.js → pegDiagram-XKGWAZYB-DKT8F42l.js} +1 -1
- package/out/phone/assets/{pie-WAS4IAKB-C7qbVkkZ.js → pie-WAS4IAKB-C3YJ4E0K.js} +1 -1
- package/out/phone/assets/{pieDiagram-E7YTZNPT-BZtPOCXT.js → pieDiagram-E7YTZNPT-WCuvt6DR.js} +1 -1
- package/out/phone/assets/{quadrantDiagram-AXDQQJYC-DBuAxCC3.js → quadrantDiagram-AXDQQJYC-BMZcEdAY.js} +1 -1
- package/out/phone/assets/{radar-RG4KPBEZ-B_BGy3Kr.js → radar-RG4KPBEZ-Bkngi7mP.js} +1 -1
- package/out/phone/assets/{railroad-74A4TZTK-BsjBmeHC.js → railroad-74A4TZTK-ConFcGHQ.js} +1 -1
- package/out/phone/assets/railroad-abnf-HS5TGJTU-ro6K5G-P.js +1 -0
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-_AmvO1_Q.js +1 -0
- package/out/phone/assets/railroad-peg-WCYAUIDC-CarWCbDL.js +1 -0
- package/out/phone/assets/{railroadDiagram-O6MQD6OU-D9evVxPR.js → railroadDiagram-O6MQD6OU-vlaFld5I.js} +1 -1
- package/out/phone/assets/{requirementDiagram-BXWQKSXE-i6bxa2IL.js → requirementDiagram-BXWQKSXE-DDJtB2mq.js} +1 -1
- package/out/phone/assets/{sankeyDiagram-P5KCCOFB-DH4NVC2Q.js → sankeyDiagram-P5KCCOFB-BE29ANL7.js} +1 -1
- package/out/phone/assets/{sequenceDiagram-WJ2MYXX4-DlhlGayV.js → sequenceDiagram-WJ2MYXX4-BgXfAzTQ.js} +1 -1
- package/out/phone/assets/{stateDiagram-D77RDMKH-D_DPdH7w.js → stateDiagram-D77RDMKH-BXEeCzLp.js} +1 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-D7ug_mka.js +1 -0
- package/out/phone/assets/{swimlanes-42K2YHIH-CjSAu_NP.js → swimlanes-42K2YHIH-CNYD9hWb.js} +1 -1
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-DihAAFZH.js +8 -0
- package/out/phone/assets/{timeline-definition-24CTP7MA-CKjtgbMT.js → timeline-definition-24CTP7MA-B34iHcRi.js} +1 -1
- package/out/phone/assets/{treeView-Q6P3EWNA-CcXW5eXy.js → treeView-Q6P3EWNA-C9bXQ-TU.js} +1 -1
- package/out/phone/assets/{treemap-WGGIJYW6-D-A5QN7t.js → treemap-WGGIJYW6-LtNmJYia.js} +1 -1
- package/out/phone/assets/{vennDiagram-4TSXK5OY-Cv7gtgfd.js → vennDiagram-4TSXK5OY-DmSF3N-m.js} +1 -1
- package/out/phone/assets/{wardley-WFR3VGLG-D_tvgGg1.js → wardley-WFR3VGLG-DjnxuhK_.js} +1 -1
- package/out/phone/assets/{wardleyDiagram-VM6X3IG4-DePRObWV.js → wardleyDiagram-VM6X3IG4-D5KJWGJd.js} +1 -1
- package/out/phone/assets/{xychartDiagram-S5SC5T6Z-BHYMMB0o.js → xychartDiagram-S5SC5T6Z-Dgjyk0ME.js} +1 -1
- package/out/phone/index.html +1 -1
- package/out/renderer/assets/{settings-CuIYYlTo.js → settings-CnuroHqZ.js} +1 -1
- package/out/renderer/settings.html +1 -1
- package/out/server/agent.js +1 -1
- package/out/server/index.js +87 -15
- package/package.json +1 -1
- package/out/phone/assets/architecture-7GRP2DOG-DCck1MrK.js +0 -1
- package/out/phone/assets/channel-C8BU0RXD.js +0 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-CmkyfP4T.js +0 -1
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-CmkyfP4T.js +0 -1
- package/out/phone/assets/eventmodeling-NTZA5JFV-CXVB8WB2.js +0 -1
- package/out/phone/assets/flowDiagram-HODETNUW-BENXTitz.js +0 -1
- package/out/phone/assets/railroad-abnf-HS5TGJTU-CT8IgF_S.js +0 -1
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-CWaJQOMi.js +0 -1
- package/out/phone/assets/railroad-peg-WCYAUIDC-SNjLanew.js +0 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-CoPt9ntw.js +0 -1
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-BGqrea9i.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-aPuBvESs.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/html-BsvMqTlf.js","assets/javascript-DcMHgNcu.js","assets/css-DlBQoFxe.js","assets/angular-ts-ocjSXnvf.js","assets/scss-BaZL6t2Y.js","assets/apl-D8Zaj6f9.js","assets/xml-C01ajBW7.js","assets/java-D7h0NA_A.js","assets/json-DePJdKYk.js","assets/astro-CbVusc_k.js","assets/typescript-BTGs5etX.js","assets/postcss-BXeXVLqQ.js","assets/tsx-DvWhG4dC.js","assets/blade-BuKMbjJR.js","assets/html-derivative-D9FvRNj4.js","assets/sql-DvarVTMJ.js","assets/bsl-_VjlB9mv.js","assets/sdbl-bTVj8UrX.js","assets/c-BNQJhXlP.js","assets/cairo-DLTphjLi.js","assets/python-gzcpVVnB.js","assets/chapel-CFMD-Djs.js","assets/cobol-qSrRm_BU.js","assets/coffee-BP03ytLP.js","assets/cpp-CUBNVKxn.js","assets/regexp-I2jnduhj.js","assets/glsl-CyFpZtQv.js","assets/crystal-CCpd0BXH.js","assets/shellscript-B51zB43X.js","assets/edge-k_uo0VIr.js","assets/elixir-CJS91GrO.js","assets/elm-Bmx6Fs0i.js","assets/erb-yi0ZozmI.js","assets/ruby-D1ky9XZ0.js","assets/haml-Dds4VdNJ.js","assets/graphql-BIyAKkG2.js","assets/jsx-BUUYi3qs.js","assets/lua-Z49wBRLR.js","assets/yaml-BWCS3NLV.js","assets/erlang-Cphh6RMH.js","assets/markdown-BYOwaDjH.js","assets/fortran-fixed-form-DEKoE2YW.js","assets/fortran-free-form-CYNrtFtB.js","assets/fsharp-D13ZGOAj.js","assets/gdresource-xMC7jr7x.js","assets/gdshader-CBce3t8t.js","assets/gdscript-DYvRD3hg.js","assets/git-commit-BSykSTBG.js","assets/diff-woXpYk--.js","assets/git-rebase-C-RR1FSc.js","assets/glimmer-js-Di6EiJvU.js","assets/glimmer-ts-C2P-EwIP.js","assets/hack-DDi4pUY-.js","assets/handlebars-C81KA5yo.js","assets/http-c4_vT9ST.js","assets/hurl-BqZA9I9Q.js","assets/csv-Dx-8-gkx.js","assets/hxml-Dcm88srW.js","assets/haxe-C8oCnwJJ.js","assets/jinja-CixBDh_U.js","assets/jison-Ru_S5AEn.js","assets/julia-CaY0JZD0.js","assets/r-CvCSiWB_.js","assets/just-Q4EdCjF5.js","assets/perl-BtArmf81.js","assets/latex-t1iljvl0.js","assets/tex-JPaUWOrn.js","assets/liquid-DEL4RHa9.js","assets/marko-DYWPPmCl.js","assets/less-DVTAwKKz.js","assets/mdc-CsAWFGA9.js","assets/nextflow-BJtWHP5T.js","assets/nextflow-groovy-DJMQeKeT.js","assets/nginx-BrbrEdla.js","assets/nim-BjwzhXka.js","assets/org-TFl3N09_.js","assets/clojure-DqKBuwfJ.js","assets/csharp-oqKa8noW.js","assets/dart-CnvKMtbv.js","assets/docker-IyjqRm3v.js","assets/go-rLFTqkRN.js","assets/groovy-CacY0gHj.js","assets/ini-B5eOa1yu.js","assets/make-Dixweg8N.js","assets/objective-c-D1A_Heim.js","assets/ocaml-O90oeIOV.js","assets/php-Cx25uSIP.js","assets/vb-DOwzaHZ0.js","assets/raku-B3gFvitq.js","assets/rust-Cfkwpbl8.js","assets/scala-BiFt_7mu.js","assets/zig-CMLA9XwU.js","assets/xsl-CCLNyvR3.js","assets/pug-B4bk2kWf.js","assets/qml-g4UDed-8.js","assets/razor-BSt2ayLr.js","assets/rst-BucurtmO.js","assets/cmake-Bj61d0ZC.js","assets/sas-CUQt684o.js","assets/shaderlab-TOUzSsQk.js","assets/hlsl-Cvrh5tZx.js","assets/shellsession-B-KBpmJs.js","assets/soy-D5xCHD_M.js","assets/sparql-D_iOobhT.js","assets/turtle-ByJddavk.js","assets/stata-8TbiBYrm.js","assets/surrealql-DalIYx4r.js","assets/svelte-D4FIy7cP.js","assets/templ-DP4lTcEq.js","assets/ts-tags-CNUq3so9.js","assets/twig-Chu5fnNS.js","assets/typst--WwEKe8X.js","assets/bat-qdxAdBWQ.js","assets/bibtex-Ci_nEsc7.js","assets/jsonc-CYpm1nAK.js","assets/log-BNLmms1o.js","assets/powershell-CCSX75yM.js","assets/swift-CyEgAFGc.js","assets/system-verilog-Dh5ihWbf.js","assets/verilog-B2gwz-sJ.js","assets/vue-DjCn01CB.js","assets/vue-html-BXjKVtKk.js","assets/vue-vine-By_xyXdL.js","assets/stylus-B6D30XZt.js","assets/mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-aPuBvESs.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/html-BsvMqTlf.js","assets/javascript-DcMHgNcu.js","assets/css-DlBQoFxe.js","assets/angular-ts-ocjSXnvf.js","assets/scss-BaZL6t2Y.js","assets/apl-D8Zaj6f9.js","assets/xml-C01ajBW7.js","assets/java-D7h0NA_A.js","assets/json-DePJdKYk.js","assets/astro-CbVusc_k.js","assets/typescript-BTGs5etX.js","assets/postcss-BXeXVLqQ.js","assets/tsx-DvWhG4dC.js","assets/blade-BuKMbjJR.js","assets/html-derivative-D9FvRNj4.js","assets/sql-DvarVTMJ.js","assets/bsl-_VjlB9mv.js","assets/sdbl-bTVj8UrX.js","assets/c-BNQJhXlP.js","assets/cairo-DLTphjLi.js","assets/python-gzcpVVnB.js","assets/chapel-CFMD-Djs.js","assets/cobol-qSrRm_BU.js","assets/coffee-BP03ytLP.js","assets/cpp-CUBNVKxn.js","assets/regexp-I2jnduhj.js","assets/glsl-CyFpZtQv.js","assets/crystal-CCpd0BXH.js","assets/shellscript-B51zB43X.js","assets/edge-k_uo0VIr.js","assets/elixir-CJS91GrO.js","assets/elm-Bmx6Fs0i.js","assets/erb-yi0ZozmI.js","assets/ruby-D1ky9XZ0.js","assets/haml-Dds4VdNJ.js","assets/graphql-BIyAKkG2.js","assets/jsx-BUUYi3qs.js","assets/lua-Z49wBRLR.js","assets/yaml-BWCS3NLV.js","assets/erlang-Cphh6RMH.js","assets/markdown-BYOwaDjH.js","assets/fortran-fixed-form-DEKoE2YW.js","assets/fortran-free-form-CYNrtFtB.js","assets/fsharp-D13ZGOAj.js","assets/gdresource-xMC7jr7x.js","assets/gdshader-CBce3t8t.js","assets/gdscript-DYvRD3hg.js","assets/git-commit-BSykSTBG.js","assets/diff-woXpYk--.js","assets/git-rebase-C-RR1FSc.js","assets/glimmer-js-Di6EiJvU.js","assets/glimmer-ts-C2P-EwIP.js","assets/hack-DDi4pUY-.js","assets/handlebars-C81KA5yo.js","assets/http-c4_vT9ST.js","assets/hurl-BqZA9I9Q.js","assets/csv-Dx-8-gkx.js","assets/hxml-Dcm88srW.js","assets/haxe-C8oCnwJJ.js","assets/jinja-CixBDh_U.js","assets/jison-Ru_S5AEn.js","assets/julia-CaY0JZD0.js","assets/r-CvCSiWB_.js","assets/just-Q4EdCjF5.js","assets/perl-BtArmf81.js","assets/latex-t1iljvl0.js","assets/tex-JPaUWOrn.js","assets/liquid-DEL4RHa9.js","assets/marko-DYWPPmCl.js","assets/less-DVTAwKKz.js","assets/mdc-CsAWFGA9.js","assets/nextflow-BJtWHP5T.js","assets/nextflow-groovy-DJMQeKeT.js","assets/nginx-BrbrEdla.js","assets/nim-BjwzhXka.js","assets/org-TFl3N09_.js","assets/clojure-DqKBuwfJ.js","assets/csharp-oqKa8noW.js","assets/dart-CnvKMtbv.js","assets/docker-IyjqRm3v.js","assets/go-rLFTqkRN.js","assets/groovy-CacY0gHj.js","assets/ini-B5eOa1yu.js","assets/make-Dixweg8N.js","assets/objective-c-D1A_Heim.js","assets/ocaml-O90oeIOV.js","assets/php-Cx25uSIP.js","assets/vb-DOwzaHZ0.js","assets/raku-B3gFvitq.js","assets/rust-Cfkwpbl8.js","assets/scala-BiFt_7mu.js","assets/zig-CMLA9XwU.js","assets/xsl-CCLNyvR3.js","assets/pug-B4bk2kWf.js","assets/qml-g4UDed-8.js","assets/razor-BSt2ayLr.js","assets/rst-BucurtmO.js","assets/cmake-Bj61d0ZC.js","assets/sas-CUQt684o.js","assets/shaderlab-TOUzSsQk.js","assets/hlsl-Cvrh5tZx.js","assets/shellsession-B-KBpmJs.js","assets/soy-D5xCHD_M.js","assets/sparql-D_iOobhT.js","assets/turtle-ByJddavk.js","assets/stata-8TbiBYrm.js","assets/surrealql-DalIYx4r.js","assets/svelte-D4FIy7cP.js","assets/templ-DP4lTcEq.js","assets/ts-tags-CNUq3so9.js","assets/twig-Chu5fnNS.js","assets/typst--WwEKe8X.js","assets/bat-qdxAdBWQ.js","assets/bibtex-Ci_nEsc7.js","assets/jsonc-CYpm1nAK.js","assets/log-BNLmms1o.js","assets/powershell-CCSX75yM.js","assets/swift-CyEgAFGc.js","assets/system-verilog-Dh5ihWbf.js","assets/verilog-B2gwz-sJ.js","assets/vue-DjCn01CB.js","assets/vue-html-BXjKVtKk.js","assets/vue-vine-By_xyXdL.js","assets/stylus-B6D30XZt.js","assets/mermaid.core-uPr3mNB_.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-oBChb5qS.js","assets/chunk-DU6HZSFF-CfA8U5r3.js","assets/chunk-75Z2AOVW-BqHLON2E.js","assets/dist-B_J_HbC0.js","assets/chunk-PWAF6VOD-DrHMV5jh.js","assets/chunk-GMAD6QVW-CIuSusWI.js","assets/chunk-P2QGCYS3-BXnn6tZa.js","assets/chunk-4HAMMTFA-YQFUQRqX.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-GVQU2GXP-CaBgSaik.js","assets/chunk-OSK3NFVY-BxOOthv7.js","assets/line-4xV-GxLd.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/graphlib-DS17s2tU.js","assets/chunk-L3NEJ4N5-BZ6UVkkR.js","assets/jsQR-B1eQcpQl.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{i as e,n as t,t as n}from"./rolldown-runtime-Dd_uD5pT.js";import{A as r,C as i,D as a,F as o,I as s,K as c,L as l,M as u,N as d,O as f,P as p,R as m,S as h,X as g,Y as _,_ as v,a as y,b,d as x,f as S,g as C,h as w,i as T,k as E,l as D,m as O,n as k,o as A,p as j,q as M,r as N,s as P,t as F,u as I,v as L,w as R,x as z,y as B}from"./storage-XVpAo_5O.js";var V=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),ee=n(((e,t)=>{t.exports=V()})),H=n((e=>{var t=g();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.8`})),U=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=H()})),W=n((e=>{var t=ee(),n=g(),r=U();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?M(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var N=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},L=[],R=-1;function z(e){return{current:e}}function B(e){0>R||(e.current=L[R],L[R]=null,R--)}function V(e,t){R++,L[R]=e.current,e.current=t}var H=z(null),W=z(null),te=z(null),ne=z(null);function re(e,t){switch(V(te,t),V(W,e),V(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Wd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Wd(t),e=Gd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(H),V(H,e)}function ie(){B(H),B(W),B(te)}function G(e){e.memoizedState!==null&&V(ne,e);var t=H.current,n=Gd(t,e.type);t!==n&&(V(W,e),V(H,n))}function ae(e){W.current===e&&(B(H),B(W)),ne.current===e&&(B(ne),tp._currentValue=I)}var oe,se;function ce(e){if(oe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);oe=t&&t[1]||``,se=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+oe+e+se}var le=!1;function ue(e,t){if(!e||le)return``;le=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -1613,7 +1613,7 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
1613
1613
|
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
1614
1614
|
`,...a.current()});return/^[\t ]/.test(l)&&(l=z8(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}H8.peek=iae;function H8(e){return e.value||``}function iae(){return`<`}U8.peek=aae;function U8(e,t,n,r){let i=R8(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function aae(){return`!`}W8.peek=oae;function W8(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function oae(){return`!`}G8.peek=sae;function G8(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function sae(){return"`"}function K8(e,t){let n=P0(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))}q8.peek=cae;function q8(e,t,n,r){let i=R8(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(K8(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function cae(e,t,n){return K8(e,n)?`<`:`[`}J8.peek=lae;function J8(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function lae(){return`[`}function Y8(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function uae(e){let t=Y8(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function dae(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function X8(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function fae(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?dae(n):Y8(n),s=e.ordered?o===`.`?`)`:`.`:uae(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.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&&(c=!0),X8(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function pae(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function mae(e,t,n,r){let i=pae(n),a=n.bulletCurrent||Y8(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function hae(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var gae=D6([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function _ae(e,t,n,r){return(e.children.some(function(e){return gae(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function vae(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Z8.peek=yae;function Z8(e,t,n,r){let i=vae(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=B8(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=z8(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=B8(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+z8(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function yae(e,t,n){return n.options.strong||`*`}function bae(e,t,n,r){return n.safe(e.value,r)}function xae(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Sae(e,t,n){let r=(X8(n)+(n.options.ruleSpaces?` `:``)).repeat(xae(n));return n.options.ruleSpaces?r.slice(0,-1):r}var Q8={blockquote:Gie,break:L8,code:Zie,definition:$ie,emphasis:V8,hardBreak:L8,heading:rae,html:H8,image:U8,imageReference:W8,inlineCode:G8,link:q8,linkReference:J8,list:fae,listItem:mae,paragraph:hae,root:_ae,strong:Z8,text:bae,thematicBreak:Sae};function Cae(){return{enter:{table:wae,tableData:e5,tableHeader:e5,tableRow:Eae},exit:{codeText:Dae,table:Tae,tableData:$8,tableHeader:$8,tableRow:$8}}}function wae(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function Tae(e){this.exit(e),this.data.inTable=void 0}function Eae(e){this.enter({type:`tableRow`,children:[]},e)}function $8(e){this.exit(e)}function e5(e){this.enter({type:`tableCell`,children:[]},e)}function Dae(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Oae));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Oae(e,t){return t===`|`?t:e}function kae(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
1615
1615
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
1616
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Uie(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Q8.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Aae(){return{exit:{taskListCheckValueChecked:t5,taskListCheckValueUnchecked:t5,paragraph:Mae}}}function jae(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Nae}}}function t5(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Mae(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Nae(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Q8.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Pae(){return[fie(),Nie(),Lie(),Cae(),Aae()]}function Fae(e){return{extensions:[pie(),Pie(e),Rie(),kae(e),jae()]}}var Iae={tokenize:Hae,partial:!0},n5={tokenize:Uae,partial:!0},r5={tokenize:Wae,partial:!0},i5={tokenize:Gae,partial:!0},Lae={tokenize:Kae,partial:!0},a5={name:`wwwAutolink`,tokenize:Bae,previous:u5},o5={name:`protocolAutolink`,tokenize:Vae,previous:d5},s5={name:`emailAutolink`,tokenize:zae,previous:f5},c5={};function Rae(){return{text:c5}}for(var l5=48;l5<123;)c5[l5]=s5,l5++,l5===58?l5=65:l5===91&&(l5=97);c5[43]=s5,c5[45]=s5,c5[46]=s5,c5[95]=s5,c5[72]=[s5,o5],c5[104]=[s5,o5],c5[87]=[s5,a5],c5[119]=[s5,a5];function zae(e,t,n){let r=this,i,a;return o;function o(t){return!p5(t)||!f5.call(r,r.previous)||m5(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return p5(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Lae,u,l)(t):t===45||t===95||Y0(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&J0(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Bae(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!u5.call(r,r.previous)||m5(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Iae,e.attempt(n5,e.attempt(r5,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Vae(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&d5.call(r,r.previous)&&!m5(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(J0(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Z0(t)||n2(t)||a2(t)||i2(t)?n(t):e.attempt(n5,e.attempt(r5,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Hae(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Uae(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(i5,c,s)(t):t===null||n2(t)||a2(t)||t!==45&&i2(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Wae(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(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(i5,t,a)(o):o===null||n2(o)||a2(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Gae(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||n2(o)||a2(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||n2(e)||a2(e)?t(e):r(e)}function a(e){return J0(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):J0(t)?(e.consume(t),o):n(t)}}function Kae(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Y0(e)?n(e):t(e)}}function u5(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||n2(e)}function d5(e){return!J0(e)}function f5(e){return!(e===47||p5(e))}function p5(e){return e===43||e===45||e===46||e===95||Y0(e)}function m5(e){let t=e.length,n=!1;for(;t--;){let 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}var qae={tokenize:toe,partial:!0};function Jae(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Qae,continuation:{tokenize:$ae},exit:eoe}},text:{91:{name:`gfmFootnoteCall`,tokenize:Zae},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Yae,resolveTo:Xae}}}}function Yae(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=q0(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Xae(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`;let 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++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Zae(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||n2(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(q0(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return n2(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Qae(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||n2(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=q0(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return n2(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),c2(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function $ae(e,t,n){return e.check(C2,t,e.attempt(qae,t,n))}function eoe(e){e.exit(`gfmFootnoteDefinition`)}function toe(e,t,n){let r=this;return c2(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function noe(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&B0(o,o.length,0,g2(s,e.slice(r+1,n),t)),B0(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),B0(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=h2(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=h2(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var roe=class{constructor(){this.map=[]}add(e,t,n){ioe(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function ioe(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 aoe(e,t){let n=!1,r=[];for(;t<e.length;){let 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`){let e=r.length-1;r[e]=r[e]===`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 ooe(){return{flow:{null:{name:`table`,tokenize:soe,resolveAll:coe}}}}function soe(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):t2(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):r2(t)?c2(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||n2(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,r2(t)?c2(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return r2(t)?c2(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||t2(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return r2(t)?c2(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||t2(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||t2(n)?(e.exit(`tableRow`),t(n)):r2(n)?c2(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||n2(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function coe(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new roe;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(g5(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=h5(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=h5(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=h5(f,t,o,i,n,d)):(o[0]=o[1],d=h5(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&g5(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=aoe(t.events,n))}return e}function h5(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},_5(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=_5(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=_5(t.events,n[2]),a=_5(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},_5(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function g5(e,t,n,r,i){let a=[],o=_5(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function _5(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var loe={name:`tasklistCheck`,tokenize:doe};function uoe(){return{text:{91:loe}}}function doe(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return n2(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return t2(r)?t(r):r2(r)?e.check({tokenize:foe},t,n)(r):n(r)}}function foe(e,t,n){return c2(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function poe(e){return U0([Rae(),Jae(),noe(e),ooe(),uoe()])}var moe={};function hoe(e){let t=this,n=e||moe,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(poe(n)),a.push(Pae()),o.push(Fae(n))}function goe(e){let[t,n]=G.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=G.useRef(null),i=G.useRef(null),a=G.useRef(null),o=G.useRef(null),s=G.useRef(!0),c=G.useRef(null),l=Zv(),u=G.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return(0,J.jsx)(vO.Provider,{value:u,children:(0,J.jsx)(gO.Provider,{value:void 0,children:(0,J.jsx)(rk,{...e})})})}var v5=500,_oe=G.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=yO(!1),{store:m}=_O(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=G.useRef(null),v=G.useRef(null),y=ry(),b=ry(),x=G.useRef(!1),S=G.useRef(null);function C(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),x.current=!1,s.current?.setOpen(!0,Kv(Nv,n)),b.start(v5,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,vy(e),C(e.clientX,e.clientY,e.nativeEvent);let t=Dv(_.current);S.current?.abort();let n=new AbortController;S.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!x.current)return;b.clear(),x.current=!1;let t=My(e);jy(u.current,t)||p&&t&&uk(t)===p||s.current?.setOpen(!1,Kv(Hv,e))},{once:!0,signal:n.signal})}function T(){y.clear(),v.current=null}function E(e){if(g){T();return}if(d.current=!1,e.touches.length!==1){T();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,y.start(v5,()=>{C(n.x,n.y,e.nativeEvent)})}function D(e){if(e.touches.length!==1){T();return}if(y.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&T()}}return G.useEffect(()=>()=>{S.current?.abort()},[]),G.useEffect(()=>{function e(e){if(g)return;let t=My(e);(jy(_.current,t)||jy(c.current,t)||jy(l.current,t))&&e.preventDefault()}return Ky(Dv(_.current),`contextmenu`,e)},[l,g,c]),Wn(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:q_})}),voe=goe;function yoe(e){return(0,J.jsx)(_oe,{"data-slot":`context-menu-trigger`,...e})}function boe({children:e,className:t,zIndex:n,...r}){return(0,J.jsxs)(RO,{children:[(0,J.jsx)(bO,{className:`fixed inset-0 z-40`,"data-enso-float":``,style:n===void 0?void 0:{zIndex:n-1}}),(0,J.jsx)(JO,{className:`z-50`,"data-slot":`context-menu-positioner`,style:n===void 0?void 0:{zIndex:n},children:(0,J.jsx)(FO,{className:q(Pk,t),"data-slot":`context-menu-popup`,...r,children:(0,J.jsx)(`div`,{className:`max-h-(--available-height) w-full overflow-y-auto p-1.5`,children:e})})})]})}function xoe({className:e,variant:t=`default`,...n}){return(0,J.jsx)(MO,{className:q(Lk,e),"data-slot":`context-menu-item`,"data-variant":t,...n})}function y5(){let e=navigator.userAgent;return e.includes(`Mac`)?`Reveal in Finder`:e.includes(`Linux`)?`Open Containing Folder`:`Reveal in File Explorer`}function b5({image:e,onClose:t}){let{t:n}=Ro();return(0,J.jsx)(uE,{open:e!==null,onOpenChange:e=>{e||t()},children:(0,J.jsxs)(hE,{className:`max-w-4xl`,children:[(0,J.jsxs)(gE,{children:[(0,J.jsx)(_E,{children:n(`Image preview`)}),(0,J.jsx)(xte,{className:`break-all`,children:e?.rel})]}),(0,J.jsx)(vE,{className:`max-h-[70vh]`,children:e&&(0,J.jsx)(`img`,{src:e.dataUrl,alt:e.rel,className:`mx-auto max-h-[65vh] max-w-full object-contain`})}),(0,J.jsx)(bte,{children:(0,J.jsx)(ji,{variant:`outline`,onClick:t,children:n(`Close`)})})]})})}var Soe=`position:fixed;left:0;top:0;width:800px;height:600px;overflow:hidden;opacity:0;pointer-events:none;visibility:hidden;contain:strict;`;function Coe(e){return!e.includes(`<svg`)||/\bfocusable=/.test(e)?e:e.replace(`<svg`,`<svg focusable="false" tabindex="-1"`)}var x5=null,S5=null,C5=Promise.resolve(),woe=0;async function Toe(){return S5||(x5||=Y(()=>import(`./mermaid.core-CHMT4qDd.js`).then(e=>(S5=e.default,S5)),__vite__mapDeps([126,127,128,1,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143])).catch(e=>{throw x5=null,e}),x5)}function Eoe(e){let t=C5.then(e,e);return C5=t.then(()=>void 0,()=>void 0),t}async function Doe(e,t){return Eoe(async()=>{let n=await Toe();n.initialize({startOnLoad:!1,theme:t,securityLevel:`loose`,fontFamily:`inherit`,suppressErrorRendering:!0,flowchart:{htmlLabels:!1,useMaxWidth:!0}});let r=`ensoMermaid${++woe}`,i=document.createElement(`div`);i.setAttribute(`aria-hidden`,`true`),i.style.cssText=Soe,document.body.appendChild(i);try{let{svg:t}=await n.render(r,e,i);return Coe(t)}finally{i.remove(),document.getElementById(r)?.remove(),document.getElementById(`d${r}`)?.remove()}})}var w5=.1,T5=.1;function Ooe({code:e,streaming:t=!1,className:n}){let{t:r}=Ro(),i=(0,G.useRef)(null),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(1),[d,f]=(0,G.useState)({x:0,y:0}),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1);QT(h);let _=(0,G.useRef)({x:0,y:0}),v=(0,G.useRef)({x:0,y:0}),y=(0,G.useRef)(null),b=(0,G.useRef)(!1),x=O1()===`dark`?`dark`:`default`;(0,G.useEffect)(()=>{if(t){o(null),c(null);return}let n=!1;return(async()=>{if(!e.trim()){o(null),c(null);return}try{let t=await Doe(e,x);n||(o(t),c(null),u(1),f({x:0,y:0}))}catch(e){n||(c(e instanceof Error?e.message:`Mermaid render failed`),o(null))}})(),()=>{n=!0}},[e,x,t]);let S=(0,G.useCallback)(()=>u(e=>e+w5),[]),C=(0,G.useCallback)(()=>u(e=>Math.max(e-w5,T5)),[]),w=(0,G.useCallback)(()=>{u(1),f({x:0,y:0})},[]),T=(0,G.useCallback)(()=>{g(!1),u(1),f({x:0,y:0})},[]),E=(0,G.useCallback)(()=>{g(!0),requestAnimationFrame(()=>{let e=y.current?.querySelector(`svg`),t=y.current?.getBoundingClientRect();if(!e||!t?.width||!t.height)return;let n=e.getBoundingClientRect(),r=Math.min((t.width-48)/n.width,(t.height-48)/n.height);u(Math.round(r*100)/100),f({x:0,y:0})})},[]),D=(0,G.useCallback)(e=>{if(!h)return;e.preventDefault();let t=e.deltaY>0?-.1:w5;u(e=>Math.round(Math.max(e+t,T5)*100)/100)},[h]),O=(0,G.useCallback)(e=>{!h||e.button!==0||(m(!0),b.current=!1,_.current={x:e.clientX,y:e.clientY},v.current={...d})},[h,d]),k=(0,G.useCallback)(e=>{if(!p)return;let t=e.clientX-_.current.x,n=e.clientY-_.current.y;(Math.abs(t)>2||Math.abs(n)>2)&&(b.current=!0),f({x:v.current.x+t,y:v.current.y+n})},[p]),A=(0,G.useCallback)(()=>m(!1),[]),j=(0,G.useCallback)(e=>{e.stopPropagation()},[]),M=(0,G.useCallback)(()=>{b.current||T()},[T]),N=e=>{let t=e===`sm`?`h-6 w-6`:`h-7 w-7`,n=e===`sm`?`h-3.5 w-3.5`:`h-4 w-4`,i=e===`sm`?`h-6 min-w-[2.5rem]`:`h-7 min-w-[3rem]`;return(0,J.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background/95 p-1 shadow-sm`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:S,className:q(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Zoom in`),children:(0,J.jsx)(Nt,{className:n})}),(0,J.jsxs)(`button`,{type:`button`,onClick:w,className:q(`flex items-center justify-center rounded text-xs transition-colors hover:bg-accent hover:text-accent-foreground`,i),title:r(`Reset zoom`),children:[Math.round(l*100),`%`]}),(0,J.jsx)(`button`,{type:`button`,onClick:C,disabled:l<=T5,className:q(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t,l<=T5&&`cursor-not-allowed opacity-50`),title:r(`Zoom out`),children:(0,J.jsx)(xt,{className:n})}),l!==1&&(0,J.jsx)(`button`,{type:`button`,onClick:w,className:q(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Fit to original size`),children:(0,J.jsx)(It,{className:n})}),(0,J.jsx)(`div`,{className:`mx-0.5 h-4 w-px bg-border`}),h?(0,J.jsx)(`button`,{type:`button`,onClick:T,className:q(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Exit fullscreen`),children:(0,J.jsx)(bt,{className:n})}):(0,J.jsx)(`button`,{type:`button`,onClick:E,className:q(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`View fullscreen`),children:(0,J.jsx)(mt,{className:n})})]})};return s?(0,J.jsxs)(`div`,{className:q(`overflow-x-auto rounded-lg border border-destructive/50`,n),children:[(0,J.jsx)(`div`,{className:`flex items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:(0,J.jsx)(`span`,{children:r(`Mermaid render error`)})}),(0,J.jsx)(`pre`,{className:`p-4 text-sm`,children:(0,J.jsx)(`code`,{className:`block font-mono leading-relaxed text-muted-foreground`,children:e})}),(0,J.jsx)(`div`,{className:`border-t border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground`,children:s})]}):a?(0,J.jsxs)(`div`,{className:q(`relative rounded-lg border border-border bg-muted/30`,n),style:{userSelect:`none`,WebkitUserSelect:`none`},children:[(0,J.jsx)(`div`,{ref:i,className:q(`max-h-[min(50vh,20rem)] overflow-hidden [overflow-anchor:none]`,h&&(p?`cursor-grabbing`:`cursor-grab`)),onWheel:D,onMouseDown:O,onMouseMove:k,onMouseUp:A,onMouseLeave:A,onDoubleClick:h?void 0:E,children:(0,J.jsx)(`div`,{className:`origin-center transition-transform duration-100 ease-out`,style:{transform:`translate(${d.x}px, ${d.y}px) scale(${l})`},children:(0,J.jsx)(`div`,{className:`p-4`,dangerouslySetInnerHTML:{__html:a}})})}),(0,J.jsx)(`div`,{className:`absolute right-2 bottom-2`,children:N(`sm`)}),h&&(0,J.jsxs)(`div`,{className:`fixed inset-0 flex select-none flex-col bg-background`,style:{zIndex:lE.TOAST},"data-enso-float":``,onClick:M,onKeyDown:e=>{e.key===`Escape`&&T()},children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border bg-muted/30 px-4 py-2`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-muted-foreground`,children:r(`Mermaid preview`)}),(0,J.jsx)(`button`,{type:`button`,onClick:T,className:`flex h-7 w-7 items-center justify-center rounded-md border border-border bg-background/95 text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,title:r(`Exit fullscreen`),children:(0,J.jsx)(sn,{className:`h-4 w-4`})})]}),(0,J.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,J.jsx)(`div`,{ref:y,className:q(`absolute inset-0 flex select-none items-center justify-center overflow-hidden`,p?`cursor-grabbing`:`cursor-grab`),onWheel:D,onMouseDown:O,onMouseMove:k,onMouseUp:A,onMouseLeave:A,onClick:j,onKeyDown:j,children:(0,J.jsx)(`div`,{className:`origin-center transition-transform duration-100 ease-out`,style:{transform:`translate(${d.x}px, ${d.y}px) scale(${l})`},children:(0,J.jsx)(`div`,{className:`p-4`,dangerouslySetInnerHTML:{__html:a}})})}),(0,J.jsx)(`div`,{className:`absolute right-4 bottom-4`,children:N(`md`)})]})]})]}):(0,J.jsx)(`div`,{className:q(`flex items-center justify-center rounded-lg border border-border bg-muted/30 p-8`,n),children:(0,J.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`Loading Mermaid diagram...`)})})}var koe=/^[a-z][a-z\d+.-]*:/i,Aoe=/^(?:https?|ircs?|mailto|xmpp):/i,joe=/^(?:[a-z]:[\\/]|\\\\)/i;function E5(e){let t=/^(.*?):(\d+)(?:-\d+)?$/.exec(e);if(!t)return{path:e};let n=Number(t[2]);return n>0?{path:t[1],line:n}:{path:t[1]}}function Moe(e){try{return decodeURIComponent(e)}catch{return null}}function Noe(e){let t=e.search(/[?#]/);return t<0?e:e.slice(0,t)}function Poe(e){try{let t=new URL(e);if(t.protocol!==`file:`)return null;let n=decodeURIComponent(t.pathname);return n?(t.hostname&&t.hostname.toLowerCase()!==`localhost`?n=`//${t.hostname}${n}`:/^\/[a-z]:[\\/]/i.test(n)&&(n=n.slice(1)),n):null}catch{return null}}function D5(e){let t=e.trim();if(!t||t.startsWith(`#`)||t.startsWith(`?`))return{kind:`external`};if(/^file:/i.test(t)){let e=Poe(t);return e?{kind:`local`,path:e}:{kind:`blocked`}}if(Aoe.test(t)||t.startsWith(`//`))return{kind:`external`};let n=Moe(Noe(t));return n==null||n.includes(`\0`)||koe.test(n)&&!joe.test(n)?{kind:`blocked`}:{kind:`local`,path:n}}function O5(e){let t=e.replace(/\\/g,`/`),n=/^[a-z]:\//i.test(t)||t.startsWith(`//`);if(!n&&!t.startsWith(`/`))return null;let r=/^[a-z]:\//i.test(t)?t.slice(0,2).toLowerCase():null,i=(r||n?t.slice(2):t.slice(1)).split(`/`),a=[];for(let e of i)if(!(!e||e===`.`)){if(e===`..`){if(a.length===0)return null;a.pop()}else a.push(e)}return r?{value:`${r}/${a.join(`/`)}`.replace(/\/$/,``),windows:!0}:n?{value:`//${a.join(`/`)}`,windows:!0}:{value:`/${a.join(`/`)}`.replace(/\/$/,``)||`/`,windows:!1}}function k5(e){let t=e.replace(/\\/g,`/`),n=[];for(let e of t.split(`/`))if(!(!e||e===`.`)){if(e===`..`){if(n.length===0)return null;n.pop()}else{if(e.includes(`\0`))return null;n.push(e)}}return n.join(`/`)}function A5(e,t){if(!t)return O5(e)?null:k5(e);let n=O5(t);if(!n)return null;let r=n.windows&&/^\/[a-z]:[\\/]/i.test(e)?e.slice(1):e,i=O5(r);if(!i)return r===e?k5(e):null;if(i.windows!==n.windows)return null;let a=n.value.toLowerCase(),o=i.value.toLowerCase();if(o===a)return``;let s=n.value.endsWith(`/`)?n.value:`${n.value}/`;return o.startsWith(s.toLowerCase())?k5(i.value.slice(s.length)):null}function Foe(e){if(!e)return;let t=e.split(`:`).at(-1)??e;return/\.(\w+)$/.exec(t)?.[1]||(/^[\w-]+$/.test(e)?e:void 0)}var Ioe={note:{label:`Note`,border:`border-blue-500`,text:`text-blue-600 dark:text-blue-400`},tip:{label:`Tip`,border:`border-green-500`,text:`text-green-600 dark:text-green-400`},important:{label:`Important`,border:`border-purple-500`,text:`text-purple-600 dark:text-purple-400`},warning:{label:`Warning`,border:`border-amber-500`,text:`text-amber-600 dark:text-amber-400`},caution:{label:`Caution`,border:`border-red-500`,text:`text-red-600 dark:text-red-400`}};function Loe(){return e=>{R6(e,`blockquote`,e=>{let t=e.children[0];if(t?.type!==`paragraph`)return;let n=t.children[0];if(n?.type!==`text`)return;let r=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/i.exec(n.value);if(!r)return;n.value=n.value.slice(r[0].length),n.value||t.children.shift();let i=r[1].toLowerCase();e.data={...e.data,hProperties:{...e.data?.hProperties,"data-alert":i,dataAlert:i}}})}}var Roe=/^(?:[\w.@-]+\/)+[\w.@-]+\.\w{1,8}(?::\d+(?:-\d+)?)?$|^[\w.-]+\.\w{1,8}:\d+(?:-\d+)?$/,zoe=[hoe,Loe],j5=(0,G.createContext)({text:``,streaming:!1,searchQuery:``,activeNth:-1}),M5=(0,G.createContext)(null);function N5(e,t){switch(e){case`invalid-path`:return t(`The link is outside the current workspace.`);case`unsupported`:return t(`This link is not available on the local computer.`);case`unavailable`:return t(`The linked file or folder is unavailable.`);case`unsupported-viewer`:return t(`This file format cannot be previewed inside EnsoCode.`);case`too-large`:return t(`The image is too large to preview.`);case`invalid-application`:return t(`The selected application path is invalid.`);case`application-unavailable`:return t(`VS Code is unavailable. Install it or select another application.`);default:return e}}async function Boe(e,t,n,r){try{let r=A5(t,e.cwd);if(r===null)throw Error(`invalid-path`);let i=await window.electronAPI.workspaceFiles.openContext({conversationId:e.conversationId,projectId:e.projectId,rel:r,itemId:n});if(!i.ok)throw Error(i.error)}catch(e){kE({type:`error`,title:r(`Could not open local file link`),description:N5(e instanceof Error?e.message:String(e),r)})}}function P5({context:e,file:t,children:n}){let{t:r}=Ro(),i=u(e=>e.contextMenuOpen).filter(e=>e.enabled);return i.length===0?n:(0,J.jsxs)(voe,{children:[(0,J.jsx)(yoe,{render:n,onContextMenu:e=>e.stopPropagation()}),(0,J.jsx)(boe,{className:`min-w-48`,children:i.map(n=>{let i=n.target===`application`?(n.applicationPath.split(/[/\\]/).at(-1)??n.applicationPath).replace(/\.(?:exe|app)$/i,``):`VS Code`;return(0,J.jsx)(xoe,{closeOnClick:!0,onClick:()=>void Boe(e,t,n.id,r),children:n.target===`reveal`?r(y5()):r(`Open in {{app}}`,{app:i})},n.id)})})]})}function F5(e){let t=D5(e);if(t.kind===`external`)return{classification:t,line:void 0};let n=E5(t.kind===`local`?t.path:e);return n.line&&/\.[\w]+$/.test(n.path)?{classification:D5(n.path),line:n.line}:{classification:t,line:void 0}}function Voe(e){let t=e?.children;if(t?.length!==1)return null;let n=t[0],r=n.tagName===`code`&&n.children?.length===1?n.children[0]:null;return r?.type===`text`&&typeof r.value==`string`?r.value:null}function Hoe({children:e,href:t,node:n}){let{t:r}=Ro(),i=(0,G.useContext)(M5),[a,o]=(0,G.useState)(null),{classification:s,line:c}=F5(t??``),l=s.kind===`local`&&i!==null,u=l?Voe(n):null,d=e=>{kE({type:`error`,title:r(`Could not open local file link`),description:N5(e,r)})},f=async e=>{if(!i||s.kind!==`local`)return;let t=A5(s.path,i.cwd);if(t==null){d(`invalid-path`);return}if(!e&&c){dG(i.conversationId,t,c);return}let n={conversationId:i.conversationId,projectId:i.projectId,rel:t};try{if(e){let e=await window.electronAPI.workspaceFiles.reveal(n);e.ok||d(e.error);return}let t=await window.electronAPI.workspaceFiles.open(n);if(!t.ok){d(t.error);return}if(t.target===`handled`)return;if(t.viewer===`image`){let e=z1(t.rel);if(!e){d(`unsupported-viewer`);return}let r=await window.electronAPI.workspaceFiles.readImage({...n,rel:t.rel});if(!r.ok){d(r.error);return}let i=`data:${e};base64,`;if(!r.dataUrl.startsWith(i)||!/^[A-Za-z0-9+/=]+$/.test(r.dataUrl.slice(i.length))){d(`unsupported-viewer`);return}o({rel:t.rel,dataUrl:r.dataUrl})}else t.viewer===`markdown`?dG(i.conversationId,t.rel,void 0,`markdown`):dG(i.conversationId,t.rel)}catch(e){d(e instanceof Error?e.message:String(e))}},p=e=>{s.kind!==`external`&&(e.preventDefault(),l&&f(!1))},m=(0,J.jsx)(`a`,{href:s.kind===`external`&&t||void 0,className:q(`text-brand underline decoration-brand/40 underline-offset-2 transition-colors hover:decoration-brand`,l&&`cursor-pointer break-all`),role:l?`link`:void 0,tabIndex:l?0:void 0,...s.kind===`external`?{target:`_blank`,rel:`noreferrer`}:{},onClick:p,onKeyDown:e=>{l&&e.key===`Enter`&&(e.preventDefault(),f(!1))},children:u??e});if(!l||s.kind!==`local`||!i)return m;let h=(0,J.jsx)(P5,{context:i,file:s.path,children:m});return u===null?(0,J.jsxs)(`span`,{className:`inline`,children:[h,(0,J.jsx)(`button`,{type:`button`,className:`ml-1 inline-flex rounded p-0.5 align-middle text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":r(y5()),title:r(y5()),onClick:()=>void f(!0),children:(0,J.jsx)($e,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(b5,{image:a,onClose:()=>o(null)})]}):(0,J.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-0.5 rounded-[5px] border border-border/70 bg-muted/70 py-px pr-0.5 pl-1 align-baseline font-mono text-xs`,children:[h,(0,J.jsx)(`button`,{type:`button`,className:`inline-flex shrink-0 rounded-[3px] p-0.5 text-muted-foreground hover:bg-background hover:text-foreground`,"aria-label":r(y5()),title:r(y5()),onClick:()=>void f(!0),children:(0,J.jsx)($e,{className:`h-3 w-3`})}),(0,J.jsx)(b5,{image:a,onClose:()=>o(null)})]})}function Uoe(e,t,n=!0){let r=D8(e);return r||t!==`href`?r:n&&F5(e).classification.kind===`local`?e:``}var Woe={p:({children:e})=>{let{searchQuery:t,activeNth:n}=(0,G.useContext)(j5);return(0,J.jsx)(`p`,{className:`my-2 leading-[1.7] first:mt-0 last:mb-0`,children:t.trim()?HI(e,t,n,{n:0}):e})},a:Hoe,ul:({children:e})=>(0,J.jsx)(`ul`,{className:`my-2 list-disc pl-5 space-y-1 marker:text-muted-foreground`,children:e}),ol:({children:e})=>(0,J.jsx)(`ol`,{className:`my-2 list-decimal pl-5 space-y-1 marker:text-muted-foreground`,children:e}),h1:({children:e})=>(0,J.jsx)(`h1`,{className:`mt-3 mb-1.5 text-base font-semibold`,children:e}),h2:({children:e})=>(0,J.jsx)(`h2`,{className:`mt-3 mb-1.5 text-base font-semibold`,children:e}),h3:({children:e})=>(0,J.jsx)(`h3`,{className:`mt-2 mb-1 text-sm font-semibold`,children:e}),blockquote:({children:e,node:t})=>{let{t:n}=Ro(),r=t?.properties,i=Ioe[String(r?.dataAlert??r?.[`data-alert`]??``)];return i?(0,J.jsxs)(`blockquote`,{className:q(`my-1.5 border-l-2 pl-3`,i.border),children:[(0,J.jsx)(`p`,{className:q(`mt-1.5 mb-0.5 text-xs font-semibold`,i.text),children:n(i.label)}),e]}):(0,J.jsx)(`blockquote`,{className:`my-2 border-l-2 border-brand/30 pl-3 text-muted-foreground`,children:e})},code:({children:e})=>{let{t}=Ro(),n=(0,G.useContext)(M5),r=typeof e==`string`?e:``;if(r&&Roe.test(r)){let{path:e,line:i}=E5(r),a=(0,J.jsx)(`button`,{type:`button`,onClick:()=>{if(!n){navigator.clipboard.writeText(e);return}let r=A5(e,n.cwd);if(!r){kE({type:`error`,title:t(`Could not open local file link`),description:t(`The link is outside the current workspace.`)});return}dG(n.conversationId,r,i)},title:r,className:`inline-flex max-w-full items-center rounded-[5px] border border-border/70 bg-muted/70 px-1 py-px align-baseline font-mono text-xs text-brand transition-colors hover:bg-muted`,children:(0,J.jsx)(`span`,{className:`truncate`,children:r})});return n?(0,J.jsx)(P5,{context:n,file:e,children:a}):a}return(0,J.jsx)(`code`,{className:`rounded-[5px] border border-border/70 bg-muted/70 px-1 py-px font-mono text-xs`,children:e})},pre:({node:e})=>{let{streaming:t}=(0,G.useContext)(j5),n=e?.children?.[0],r=n&&`properties`in n?n.properties:void 0,i=/language-(\S+)/.exec(r?.className?.join(` `)??``)?.[1],a=n&&`children`in n?n.children?.[0]:void 0,o=(a&&`value`in a?String(a.value):``).replace(/\n$/,``),s=Foe(i);return s?.toLowerCase()===`mermaid`?(0,J.jsx)(Ooe,{code:o,streaming:t}):(0,J.jsx)(jG,{code:o,language:s,streaming:t})},table:({children:e,node:t})=>{let{text:n,streaming:r}=(0,G.useContext)(j5),i=t?.position?.start?.offset,a=t?.position?.end?.offset,o=i!==void 0&&a!==void 0?n.slice(i,a):null;return(0,J.jsxs)(`div`,{className:`group/table relative my-2 min-w-0 max-w-full overflow-x-auto overscroll-x-contain [-webkit-overflow-scrolling:touch]`,children:[(0,J.jsx)(`table`,{className:`w-max min-w-full border-collapse text-xs [overflow-wrap:normal]`,children:e}),o&&!r&&(0,J.jsx)(kG,{text:o,className:`absolute top-0.5 right-0.5 rounded-md border bg-background/80 p-1.5 text-muted-foreground opacity-0 backdrop-blur transition-opacity group-hover/table:opacity-100`})]})},th:({children:e})=>(0,J.jsx)(`th`,{className:`whitespace-nowrap border-b border-border px-2 py-1 text-left font-medium`,children:e}),td:({children:e})=>(0,J.jsx)(`td`,{className:`whitespace-nowrap border-b border-border/50 px-2 py-1`,children:e}),hr:()=>(0,J.jsx)(`hr`,{className:`my-3 border-border`})};function I5({text:e,streaming:t=!1,searchQuery:n=``,activeNth:r=-1}){let i=(0,G.useContext)(M5)!==null,a=(0,G.useMemo)(()=>({text:e,streaming:t,searchQuery:n,activeNth:r}),[e,t,n,r]),o=(0,G.useMemo)(()=>(e,t)=>Uoe(e,t,i),[i]);return(0,J.jsx)(j5.Provider,{value:a,children:(0,J.jsx)(`div`,{className:t?`t-stream-live`:void 0,children:(0,J.jsx)(rie,{remarkPlugins:zoe,components:Woe,urlTransform:o,children:e})})})}function L5({hits:e,defaultOpen:t=!1}){let{t:n}=Ro();return e.length===0?(0,J.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n(`No results`)}):(0,J.jsx)(`ul`,{className:`divide-y divide-border/60`,children:e.map(e=>(0,J.jsx)(Koe,{hit:e,defaultOpen:t},e.id))})}function Goe({view:e}){let{t}=Ro(),n=e.written?e.deduplicated&&t(`Identical memory already exists, nothing new was written`):t(`Similar memories already exist, nothing was written`);return(0,J.jsxs)(J.Fragment,{children:[n&&(0,J.jsx)(`p`,{className:`px-3 pt-2 text-xs text-muted-foreground`,children:n}),e.written?(0,J.jsx)(L5,{hits:[e.memory],defaultOpen:!0}):(0,J.jsx)(L5,{hits:e.candidates})]})}function Koe({hit:e,defaultOpen:t}){let{t:n}=Ro(),[r,i]=(0,G.useState)(t);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:e=>{let t=window.getSelection();t?.toString()&&e.currentTarget.contains(t.anchorNode)||i(e=>!e)},className:`block w-full cursor-pointer px-3 py-2 text-left transition-colors hover:bg-muted/40`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:q(`min-w-0 flex-1 font-medium text-foreground text-xs`,r?`break-words`:`truncate`),children:e.title}),e.unitType&&(0,J.jsx)(cO,{variant:`secondary`,size:`sm`,children:e.unitType}),e.space&&(0,J.jsx)(cO,{variant:`outline`,size:`sm`,children:n(e.space===`global`?`Global`:`Project`)}),e.score!==null&&(0,J.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums`,children:e.score.toFixed(2)})]}),(0,J.jsx)(`span`,{className:q(`mt-0.5 whitespace-pre-wrap break-words text-muted-foreground text-xs leading-relaxed`,r?`block`:`line-clamp-2`),children:e.content})]})})}var R5=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function z5(e){if(!e)return null;try{let t=JSON.parse(e);return R5(t)?t:null}catch{return null}}function B5(e,t){if(!Array.isArray(e))return null;let n=[];for(let r of e){if(!R5(r)||typeof r.id!=`string`||!r.id||typeof r.title!=`string`||typeof r.content!=`string`)return null;let{spaceId:e,[t]:i}=r;n.push({id:r.id,title:r.title,content:r.content,unitType:typeof r.unitType==`string`&&r.unitType?r.unitType:null,space:e===`global`?`global`:typeof e==`string`&&e.startsWith(`proj:`)?`project`:null,score:typeof i==`number`&&Number.isFinite(i)?i:null})}return n}function qoe(e){let t=z5(e);return t?B5(t.results,`score`):null}function Joe(e,t){let n=z5(e);if(n?.status===`candidates_found`){let e=B5(n.candidates,`similarity`);return e?{written:!1,candidates:e}:null}if(n?.status!==`inserted`||!R5(n.memory)||!t)return null;let r=B5([{...n.memory,content:t}],`score`)?.[0];return r?{written:!0,deduplicated:n.deduplicated===!0,memory:r}:null}var V5=G.createContext(void 0);function H5(e){let t=G.useContext(V5);if(t===void 0&&!e)throw Error(En(50));return t}var Yoe={...$C,instantType:e=>e.instantType,adaptiveOrigin:e=>e.adaptiveOrigin,closeDelay:e=>e.closeDelay},Xoe=class extends wC{constructor(e,t,n){let r=new WC;super(Zoe(e,r,t,n),Qoe(r),Yoe)}setOpen=(e,t)=>{let{inlineRectCoordsRef:n}=this.context;RC(this,e,t,{onBeforeDispatch(){let r=t.event;e&&t.reason===`trigger-hover`&&t.trigger&&`clientX`in r&&`clientY`in r&&n.current?.element!==t.trigger&&rC(n,t.trigger,r.clientX,r.clientY)}})}};function Zoe(e,t,n,r=!1){let i={...KC(),instantType:void 0,adaptiveOrigin:void 0,closeDelay:300,...e};return i.floatingRootContext=qC(t,n,r),i}function Qoe(e){return{popupRef:G.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e,inlineRectCoordsRef:{current:void 0}}}function U5(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,onOpenChangeComplete:i,actionsRef:a,handle:o,triggerId:s,defaultTriggerId:c=null,children:l}=e,u=NC((e,r)=>new Xoe({open:n,openProp:t,activeTriggerId:c,triggerIdProp:s},e,r));u.useControlledProp(`openProp`,t),u.useControlledProp(`triggerIdProp`,s),u.useContextCallback(`onOpenChange`,r),u.useContextCallback(`onOpenChangeComplete`,i);let d=u.useState(`open`),f=u.useState(`activeTriggerId`),p=u.useState(`mounted`),m=u.useState(`payload`);BC(u,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:h}=VC(d,u,()=>{u.context.inlineRectCoordsRef.current=void 0});Z(()=>{d&&(f??u.set(`payload`,void 0))},[u,f,d]),G.useImperativeHandle(a,()=>({unmount:h,close:()=>u.setOpen(!1,Kv(Wv))}),[h,u]);let g=d||p;return(0,J.jsxs)(V5.Provider,{value:u,children:[o&&(0,J.jsx)(PC,{handle:o,store:u}),g&&(0,J.jsx)($oe,{store:u}),typeof l==`function`?l({payload:m}):l]})}function $oe({store:e}){let t=Wx(e.useState(`floatingRootContext`));return HC(e,{activeTriggerProps:t.reference,inactiveTriggerProps:t.trigger,popupProps:t.floating}),null}var ese=pC(function(e){return H5(!0)?(0,J.jsx)(U5,{...e}):(0,J.jsx)(Ax,{children:(0,J.jsx)(U5,{...e})})}),W5=G.createContext(void 0);function tse(){let e=G.useContext(W5);if(e===void 0)throw Error(En(48));return e}var nse=G.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return H5().useState(`mounted`)||n?(0,J.jsx)(W5.Provider,{value:n,children:(0,J.jsx)(wte,{ref:t,...r})}):null}),rse=mC(function(e,t){let{render:n,className:r,delay:i,closeDelay:a,id:o,payload:s,handle:c,style:l,...u}=e,d=H5(!0),f=ew(c)??d;if(!f)throw Error(En(89));let p=Qv(o),m=f.useState(`isTriggerActive`,p),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`floatingRootContext`),_=f.context.inlineRectCoordsRef,v=G.useRef(null),y=i??600,b=a??300,{registerTrigger:x,isMountedByThisTrigger:S}=zC(p,v,f,{payload:s,closeDelay:b}),C=pw(g,{mouseOnly:!0,move:!1,handleClose:Aw(),delay:()=>({open:y,close:b}),triggerElementRef:v,isActiveTrigger:m,isClosing:()=>f.select(`transitionStatus`)===`ending`}),w=aw(g,{delay:y}),T={open:h},E=f.useState(`triggerProps`,S),D=nC(_,h);return Wn(`a`,e,{state:T,ref:[t,x,v],props:[C,w.reference,E,D,{id:p},u],stateAttributesMapping:K_})}),G5=G.createContext(void 0);function ise(){let e=G.useContext(G5);if(e===void 0)throw Error(En(49));return e}var ase=G.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=hx,style:g,..._}=e,v=H5(),y=tse(),b=Ox(),x=v.useState(`open`),S=v.useState(`mounted`),C=v.useState(`floatingRootContext`),w=v.useState(`instantType`),T=v.useState(`transitionStatus`),E=v.useState(`adaptiveOrigin`),D=v.context.inlineRectCoordsRef,O=TE({anchor:i,floatingRootContext:C,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:y,nodeId:b,collisionAvoidance:h,adaptiveOrigin:E,inline:iC(D)}),k=O.update;Z(()=>{x&&S&&k()},[x,S,k]);let A=OE(e,{open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:w},{styles:O.positionerStyles,transitionStatus:T,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!S,inert:!x});return(0,J.jsx)(G5.Provider,{value:O,children:(0,J.jsx)(kx,{id:b,children:A})})}),ose=G.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,o=H5(),{side:s,align:c}=ise(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`closeDelay`);return AC({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),dw(p,{closeDelay:m}),Wn(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,o.useStateSetter(`popupElement`)],props:[jC,f,DE(d),a],stateAttributesMapping:Y_})}),sse=ese;function cse({...e}){return(0,J.jsx)(rse,{"data-slot":`preview-card-trigger`,...e})}function lse({className:e,children:t,align:n=`center`,sideOffset:r=4,...i}){return(0,J.jsx)(nse,{children:(0,J.jsx)(ase,{align:n,className:`z-50`,"data-slot":`preview-card-positioner`,sideOffset:r,children:(0,J.jsx)(ose,{className:q(`relative flex w-64 origin-(--transform-origin) text-balance rounded-lg border bg-popover bg-clip-padding p-4 text-popover-foreground text-sm shadow-lg transition-[scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,e),"data-slot":`preview-card-content`,...i,children:t})})})}var K5={mask:`text-sky-600 dark:text-sky-400`,warn:`text-amber-600 dark:text-amber-400`,block:`text-red-600 dark:text-red-400`},use={mask:Ht,warn:Bt,block:Vt},dse={mask:`Mask`,warn:`Warn only`,block:`Block`},fse={system:`System prompt`,user:`Your message`,tool_result:`Tool output`,tool_args:`Tool arguments`,assistant:`Earlier replies`,tools:`Tool descriptions`};function pse({report:e}){let{t}=Ro(),n=s(e);if(!n)return null;let r=use[n],i=new Set(e.hits.map(e=>e.token)).size;return(0,J.jsxs)(sse,{children:[(0,J.jsxs)(cse,{render:(0,J.jsx)(`span`,{className:q(`inline-flex shrink-0 items-center gap-0.5 text-[11px]`,K5[n]),"data-privacy-mask":n}),children:[(0,J.jsx)(r,{className:`size-3.5`}),(0,J.jsx)(`span`,{className:`tabular-nums`,children:i})]}),(0,J.jsxs)(lse,{className:`w-72 text-xs`,children:[(0,J.jsx)(`p`,{className:`mb-1.5 font-medium`,children:t(`Privacy masking`)}),(0,J.jsx)(`ul`,{className:`space-y-1`,children:e.hits.map(e=>(0,J.jsxs)(`li`,{className:`flex flex-wrap gap-x-2`,children:[(0,J.jsx)(`span`,{className:K5[e.action],children:t(dse[e.action])}),(0,J.jsx)(`span`,{children:e.kind}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:t(fse[e.where]??e.where)}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e.preview}),e.count>1&&(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[`×`,e.count]})]},`${e.token}-${e.action}-${e.where}`))}),e.restored>0&&(0,J.jsx)(`p`,{className:`mt-1.5 text-muted-foreground`,children:t(`Restored {{count}} in the reply`,{count:e.restored})})]})]})}var mse=/^\[.+#[0-9A-Fa-f]{4}\]$/;function hse(e){let t=e.indexOf(`
|
|
1616
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Uie(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Q8.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Aae(){return{exit:{taskListCheckValueChecked:t5,taskListCheckValueUnchecked:t5,paragraph:Mae}}}function jae(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Nae}}}function t5(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Mae(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Nae(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Q8.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Pae(){return[fie(),Nie(),Lie(),Cae(),Aae()]}function Fae(e){return{extensions:[pie(),Pie(e),Rie(),kae(e),jae()]}}var Iae={tokenize:Hae,partial:!0},n5={tokenize:Uae,partial:!0},r5={tokenize:Wae,partial:!0},i5={tokenize:Gae,partial:!0},Lae={tokenize:Kae,partial:!0},a5={name:`wwwAutolink`,tokenize:Bae,previous:u5},o5={name:`protocolAutolink`,tokenize:Vae,previous:d5},s5={name:`emailAutolink`,tokenize:zae,previous:f5},c5={};function Rae(){return{text:c5}}for(var l5=48;l5<123;)c5[l5]=s5,l5++,l5===58?l5=65:l5===91&&(l5=97);c5[43]=s5,c5[45]=s5,c5[46]=s5,c5[95]=s5,c5[72]=[s5,o5],c5[104]=[s5,o5],c5[87]=[s5,a5],c5[119]=[s5,a5];function zae(e,t,n){let r=this,i,a;return o;function o(t){return!p5(t)||!f5.call(r,r.previous)||m5(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return p5(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Lae,u,l)(t):t===45||t===95||Y0(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&J0(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Bae(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!u5.call(r,r.previous)||m5(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Iae,e.attempt(n5,e.attempt(r5,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Vae(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&d5.call(r,r.previous)&&!m5(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(J0(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Z0(t)||n2(t)||a2(t)||i2(t)?n(t):e.attempt(n5,e.attempt(r5,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Hae(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Uae(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(i5,c,s)(t):t===null||n2(t)||a2(t)||t!==45&&i2(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Wae(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(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(i5,t,a)(o):o===null||n2(o)||a2(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Gae(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||n2(o)||a2(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||n2(e)||a2(e)?t(e):r(e)}function a(e){return J0(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):J0(t)?(e.consume(t),o):n(t)}}function Kae(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Y0(e)?n(e):t(e)}}function u5(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||n2(e)}function d5(e){return!J0(e)}function f5(e){return!(e===47||p5(e))}function p5(e){return e===43||e===45||e===46||e===95||Y0(e)}function m5(e){let t=e.length,n=!1;for(;t--;){let 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}var qae={tokenize:toe,partial:!0};function Jae(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Qae,continuation:{tokenize:$ae},exit:eoe}},text:{91:{name:`gfmFootnoteCall`,tokenize:Zae},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Yae,resolveTo:Xae}}}}function Yae(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=q0(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Xae(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`;let 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++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Zae(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||n2(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(q0(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return n2(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Qae(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||n2(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=q0(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return n2(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),c2(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function $ae(e,t,n){return e.check(C2,t,e.attempt(qae,t,n))}function eoe(e){e.exit(`gfmFootnoteDefinition`)}function toe(e,t,n){let r=this;return c2(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function noe(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&B0(o,o.length,0,g2(s,e.slice(r+1,n),t)),B0(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),B0(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=h2(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=h2(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var roe=class{constructor(){this.map=[]}add(e,t,n){ioe(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function ioe(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 aoe(e,t){let n=!1,r=[];for(;t<e.length;){let 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`){let e=r.length-1;r[e]=r[e]===`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 ooe(){return{flow:{null:{name:`table`,tokenize:soe,resolveAll:coe}}}}function soe(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):t2(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):r2(t)?c2(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||n2(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,r2(t)?c2(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return r2(t)?c2(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||t2(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return r2(t)?c2(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||t2(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||t2(n)?(e.exit(`tableRow`),t(n)):r2(n)?c2(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||n2(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function coe(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new roe;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(g5(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=h5(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=h5(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=h5(f,t,o,i,n,d)):(o[0]=o[1],d=h5(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&g5(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=aoe(t.events,n))}return e}function h5(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},_5(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=_5(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=_5(t.events,n[2]),a=_5(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},_5(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function g5(e,t,n,r,i){let a=[],o=_5(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function _5(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var loe={name:`tasklistCheck`,tokenize:doe};function uoe(){return{text:{91:loe}}}function doe(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return n2(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return t2(r)?t(r):r2(r)?e.check({tokenize:foe},t,n)(r):n(r)}}function foe(e,t,n){return c2(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function poe(e){return U0([Rae(),Jae(),noe(e),ooe(),uoe()])}var moe={};function hoe(e){let t=this,n=e||moe,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(poe(n)),a.push(Pae()),o.push(Fae(n))}function goe(e){let[t,n]=G.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=G.useRef(null),i=G.useRef(null),a=G.useRef(null),o=G.useRef(null),s=G.useRef(!0),c=G.useRef(null),l=Zv(),u=G.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return(0,J.jsx)(vO.Provider,{value:u,children:(0,J.jsx)(gO.Provider,{value:void 0,children:(0,J.jsx)(rk,{...e})})})}var v5=500,_oe=G.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=yO(!1),{store:m}=_O(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=G.useRef(null),v=G.useRef(null),y=ry(),b=ry(),x=G.useRef(!1),S=G.useRef(null);function C(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),x.current=!1,s.current?.setOpen(!0,Kv(Nv,n)),b.start(v5,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,vy(e),C(e.clientX,e.clientY,e.nativeEvent);let t=Dv(_.current);S.current?.abort();let n=new AbortController;S.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!x.current)return;b.clear(),x.current=!1;let t=My(e);jy(u.current,t)||p&&t&&uk(t)===p||s.current?.setOpen(!1,Kv(Hv,e))},{once:!0,signal:n.signal})}function T(){y.clear(),v.current=null}function E(e){if(g){T();return}if(d.current=!1,e.touches.length!==1){T();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,y.start(v5,()=>{C(n.x,n.y,e.nativeEvent)})}function D(e){if(e.touches.length!==1){T();return}if(y.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&T()}}return G.useEffect(()=>()=>{S.current?.abort()},[]),G.useEffect(()=>{function e(e){if(g)return;let t=My(e);(jy(_.current,t)||jy(c.current,t)||jy(l.current,t))&&e.preventDefault()}return Ky(Dv(_.current),`contextmenu`,e)},[l,g,c]),Wn(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:q_})}),voe=goe;function yoe(e){return(0,J.jsx)(_oe,{"data-slot":`context-menu-trigger`,...e})}function boe({children:e,className:t,zIndex:n,...r}){return(0,J.jsxs)(RO,{children:[(0,J.jsx)(bO,{className:`fixed inset-0 z-40`,"data-enso-float":``,style:n===void 0?void 0:{zIndex:n-1}}),(0,J.jsx)(JO,{className:`z-50`,"data-slot":`context-menu-positioner`,style:n===void 0?void 0:{zIndex:n},children:(0,J.jsx)(FO,{className:q(Pk,t),"data-slot":`context-menu-popup`,...r,children:(0,J.jsx)(`div`,{className:`max-h-(--available-height) w-full overflow-y-auto p-1.5`,children:e})})})]})}function xoe({className:e,variant:t=`default`,...n}){return(0,J.jsx)(MO,{className:q(Lk,e),"data-slot":`context-menu-item`,"data-variant":t,...n})}function y5(){let e=navigator.userAgent;return e.includes(`Mac`)?`Reveal in Finder`:e.includes(`Linux`)?`Open Containing Folder`:`Reveal in File Explorer`}function b5({image:e,onClose:t}){let{t:n}=Ro();return(0,J.jsx)(uE,{open:e!==null,onOpenChange:e=>{e||t()},children:(0,J.jsxs)(hE,{className:`max-w-4xl`,children:[(0,J.jsxs)(gE,{children:[(0,J.jsx)(_E,{children:n(`Image preview`)}),(0,J.jsx)(xte,{className:`break-all`,children:e?.rel})]}),(0,J.jsx)(vE,{className:`max-h-[70vh]`,children:e&&(0,J.jsx)(`img`,{src:e.dataUrl,alt:e.rel,className:`mx-auto max-h-[65vh] max-w-full object-contain`})}),(0,J.jsx)(bte,{children:(0,J.jsx)(ji,{variant:`outline`,onClick:t,children:n(`Close`)})})]})})}var Soe=`position:fixed;left:0;top:0;width:800px;height:600px;overflow:hidden;opacity:0;pointer-events:none;visibility:hidden;contain:strict;`;function Coe(e){return!e.includes(`<svg`)||/\bfocusable=/.test(e)?e:e.replace(`<svg`,`<svg focusable="false" tabindex="-1"`)}var x5=null,S5=null,C5=Promise.resolve(),woe=0;async function Toe(){return S5||(x5||=Y(()=>import(`./mermaid.core-uPr3mNB_.js`).then(e=>(S5=e.default,S5)),__vite__mapDeps([126,127,128,1,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143])).catch(e=>{throw x5=null,e}),x5)}function Eoe(e){let t=C5.then(e,e);return C5=t.then(()=>void 0,()=>void 0),t}async function Doe(e,t){return Eoe(async()=>{let n=await Toe();n.initialize({startOnLoad:!1,theme:t,securityLevel:`loose`,fontFamily:`inherit`,suppressErrorRendering:!0,flowchart:{htmlLabels:!1,useMaxWidth:!0}});let r=`ensoMermaid${++woe}`,i=document.createElement(`div`);i.setAttribute(`aria-hidden`,`true`),i.style.cssText=Soe,document.body.appendChild(i);try{let{svg:t}=await n.render(r,e,i);return Coe(t)}finally{i.remove(),document.getElementById(r)?.remove(),document.getElementById(`d${r}`)?.remove()}})}var w5=.1,T5=.1;function Ooe({code:e,streaming:t=!1,className:n}){let{t:r}=Ro(),i=(0,G.useRef)(null),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(1),[d,f]=(0,G.useState)({x:0,y:0}),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1);QT(h);let _=(0,G.useRef)({x:0,y:0}),v=(0,G.useRef)({x:0,y:0}),y=(0,G.useRef)(null),b=(0,G.useRef)(!1),x=O1()===`dark`?`dark`:`default`;(0,G.useEffect)(()=>{if(t){o(null),c(null);return}let n=!1;return(async()=>{if(!e.trim()){o(null),c(null);return}try{let t=await Doe(e,x);n||(o(t),c(null),u(1),f({x:0,y:0}))}catch(e){n||(c(e instanceof Error?e.message:`Mermaid render failed`),o(null))}})(),()=>{n=!0}},[e,x,t]);let S=(0,G.useCallback)(()=>u(e=>e+w5),[]),C=(0,G.useCallback)(()=>u(e=>Math.max(e-w5,T5)),[]),w=(0,G.useCallback)(()=>{u(1),f({x:0,y:0})},[]),T=(0,G.useCallback)(()=>{g(!1),u(1),f({x:0,y:0})},[]),E=(0,G.useCallback)(()=>{g(!0),requestAnimationFrame(()=>{let e=y.current?.querySelector(`svg`),t=y.current?.getBoundingClientRect();if(!e||!t?.width||!t.height)return;let n=e.getBoundingClientRect(),r=Math.min((t.width-48)/n.width,(t.height-48)/n.height);u(Math.round(r*100)/100),f({x:0,y:0})})},[]),D=(0,G.useCallback)(e=>{if(!h)return;e.preventDefault();let t=e.deltaY>0?-.1:w5;u(e=>Math.round(Math.max(e+t,T5)*100)/100)},[h]),O=(0,G.useCallback)(e=>{!h||e.button!==0||(m(!0),b.current=!1,_.current={x:e.clientX,y:e.clientY},v.current={...d})},[h,d]),k=(0,G.useCallback)(e=>{if(!p)return;let t=e.clientX-_.current.x,n=e.clientY-_.current.y;(Math.abs(t)>2||Math.abs(n)>2)&&(b.current=!0),f({x:v.current.x+t,y:v.current.y+n})},[p]),A=(0,G.useCallback)(()=>m(!1),[]),j=(0,G.useCallback)(e=>{e.stopPropagation()},[]),M=(0,G.useCallback)(()=>{b.current||T()},[T]),N=e=>{let t=e===`sm`?`h-6 w-6`:`h-7 w-7`,n=e===`sm`?`h-3.5 w-3.5`:`h-4 w-4`,i=e===`sm`?`h-6 min-w-[2.5rem]`:`h-7 min-w-[3rem]`;return(0,J.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background/95 p-1 shadow-sm`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:S,className:q(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Zoom in`),children:(0,J.jsx)(Nt,{className:n})}),(0,J.jsxs)(`button`,{type:`button`,onClick:w,className:q(`flex items-center justify-center rounded text-xs transition-colors hover:bg-accent hover:text-accent-foreground`,i),title:r(`Reset zoom`),children:[Math.round(l*100),`%`]}),(0,J.jsx)(`button`,{type:`button`,onClick:C,disabled:l<=T5,className:q(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t,l<=T5&&`cursor-not-allowed opacity-50`),title:r(`Zoom out`),children:(0,J.jsx)(xt,{className:n})}),l!==1&&(0,J.jsx)(`button`,{type:`button`,onClick:w,className:q(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Fit to original size`),children:(0,J.jsx)(It,{className:n})}),(0,J.jsx)(`div`,{className:`mx-0.5 h-4 w-px bg-border`}),h?(0,J.jsx)(`button`,{type:`button`,onClick:T,className:q(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Exit fullscreen`),children:(0,J.jsx)(bt,{className:n})}):(0,J.jsx)(`button`,{type:`button`,onClick:E,className:q(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`View fullscreen`),children:(0,J.jsx)(mt,{className:n})})]})};return s?(0,J.jsxs)(`div`,{className:q(`overflow-x-auto rounded-lg border border-destructive/50`,n),children:[(0,J.jsx)(`div`,{className:`flex items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:(0,J.jsx)(`span`,{children:r(`Mermaid render error`)})}),(0,J.jsx)(`pre`,{className:`p-4 text-sm`,children:(0,J.jsx)(`code`,{className:`block font-mono leading-relaxed text-muted-foreground`,children:e})}),(0,J.jsx)(`div`,{className:`border-t border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground`,children:s})]}):a?(0,J.jsxs)(`div`,{className:q(`relative rounded-lg border border-border bg-muted/30`,n),style:{userSelect:`none`,WebkitUserSelect:`none`},children:[(0,J.jsx)(`div`,{ref:i,className:q(`max-h-[min(50vh,20rem)] overflow-hidden [overflow-anchor:none]`,h&&(p?`cursor-grabbing`:`cursor-grab`)),onWheel:D,onMouseDown:O,onMouseMove:k,onMouseUp:A,onMouseLeave:A,onDoubleClick:h?void 0:E,children:(0,J.jsx)(`div`,{className:`origin-center transition-transform duration-100 ease-out`,style:{transform:`translate(${d.x}px, ${d.y}px) scale(${l})`},children:(0,J.jsx)(`div`,{className:`p-4`,dangerouslySetInnerHTML:{__html:a}})})}),(0,J.jsx)(`div`,{className:`absolute right-2 bottom-2`,children:N(`sm`)}),h&&(0,J.jsxs)(`div`,{className:`fixed inset-0 flex select-none flex-col bg-background`,style:{zIndex:lE.TOAST},"data-enso-float":``,onClick:M,onKeyDown:e=>{e.key===`Escape`&&T()},children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border bg-muted/30 px-4 py-2`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-muted-foreground`,children:r(`Mermaid preview`)}),(0,J.jsx)(`button`,{type:`button`,onClick:T,className:`flex h-7 w-7 items-center justify-center rounded-md border border-border bg-background/95 text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,title:r(`Exit fullscreen`),children:(0,J.jsx)(sn,{className:`h-4 w-4`})})]}),(0,J.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,J.jsx)(`div`,{ref:y,className:q(`absolute inset-0 flex select-none items-center justify-center overflow-hidden`,p?`cursor-grabbing`:`cursor-grab`),onWheel:D,onMouseDown:O,onMouseMove:k,onMouseUp:A,onMouseLeave:A,onClick:j,onKeyDown:j,children:(0,J.jsx)(`div`,{className:`origin-center transition-transform duration-100 ease-out`,style:{transform:`translate(${d.x}px, ${d.y}px) scale(${l})`},children:(0,J.jsx)(`div`,{className:`p-4`,dangerouslySetInnerHTML:{__html:a}})})}),(0,J.jsx)(`div`,{className:`absolute right-4 bottom-4`,children:N(`md`)})]})]})]}):(0,J.jsx)(`div`,{className:q(`flex items-center justify-center rounded-lg border border-border bg-muted/30 p-8`,n),children:(0,J.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`Loading Mermaid diagram...`)})})}var koe=/^[a-z][a-z\d+.-]*:/i,Aoe=/^(?:https?|ircs?|mailto|xmpp):/i,joe=/^(?:[a-z]:[\\/]|\\\\)/i;function E5(e){let t=/^(.*?):(\d+)(?:-\d+)?$/.exec(e);if(!t)return{path:e};let n=Number(t[2]);return n>0?{path:t[1],line:n}:{path:t[1]}}function Moe(e){try{return decodeURIComponent(e)}catch{return null}}function Noe(e){let t=e.search(/[?#]/);return t<0?e:e.slice(0,t)}function Poe(e){try{let t=new URL(e);if(t.protocol!==`file:`)return null;let n=decodeURIComponent(t.pathname);return n?(t.hostname&&t.hostname.toLowerCase()!==`localhost`?n=`//${t.hostname}${n}`:/^\/[a-z]:[\\/]/i.test(n)&&(n=n.slice(1)),n):null}catch{return null}}function D5(e){let t=e.trim();if(!t||t.startsWith(`#`)||t.startsWith(`?`))return{kind:`external`};if(/^file:/i.test(t)){let e=Poe(t);return e?{kind:`local`,path:e}:{kind:`blocked`}}if(Aoe.test(t)||t.startsWith(`//`))return{kind:`external`};let n=Moe(Noe(t));return n==null||n.includes(`\0`)||koe.test(n)&&!joe.test(n)?{kind:`blocked`}:{kind:`local`,path:n}}function O5(e){let t=e.replace(/\\/g,`/`),n=/^[a-z]:\//i.test(t)||t.startsWith(`//`);if(!n&&!t.startsWith(`/`))return null;let r=/^[a-z]:\//i.test(t)?t.slice(0,2).toLowerCase():null,i=(r||n?t.slice(2):t.slice(1)).split(`/`),a=[];for(let e of i)if(!(!e||e===`.`)){if(e===`..`){if(a.length===0)return null;a.pop()}else a.push(e)}return r?{value:`${r}/${a.join(`/`)}`.replace(/\/$/,``),windows:!0}:n?{value:`//${a.join(`/`)}`,windows:!0}:{value:`/${a.join(`/`)}`.replace(/\/$/,``)||`/`,windows:!1}}function k5(e){let t=e.replace(/\\/g,`/`),n=[];for(let e of t.split(`/`))if(!(!e||e===`.`)){if(e===`..`){if(n.length===0)return null;n.pop()}else{if(e.includes(`\0`))return null;n.push(e)}}return n.join(`/`)}function A5(e,t){if(!t)return O5(e)?null:k5(e);let n=O5(t);if(!n)return null;let r=n.windows&&/^\/[a-z]:[\\/]/i.test(e)?e.slice(1):e,i=O5(r);if(!i)return r===e?k5(e):null;if(i.windows!==n.windows)return null;let a=n.value.toLowerCase(),o=i.value.toLowerCase();if(o===a)return``;let s=n.value.endsWith(`/`)?n.value:`${n.value}/`;return o.startsWith(s.toLowerCase())?k5(i.value.slice(s.length)):null}function Foe(e){if(!e)return;let t=e.split(`:`).at(-1)??e;return/\.(\w+)$/.exec(t)?.[1]||(/^[\w-]+$/.test(e)?e:void 0)}var Ioe={note:{label:`Note`,border:`border-blue-500`,text:`text-blue-600 dark:text-blue-400`},tip:{label:`Tip`,border:`border-green-500`,text:`text-green-600 dark:text-green-400`},important:{label:`Important`,border:`border-purple-500`,text:`text-purple-600 dark:text-purple-400`},warning:{label:`Warning`,border:`border-amber-500`,text:`text-amber-600 dark:text-amber-400`},caution:{label:`Caution`,border:`border-red-500`,text:`text-red-600 dark:text-red-400`}};function Loe(){return e=>{R6(e,`blockquote`,e=>{let t=e.children[0];if(t?.type!==`paragraph`)return;let n=t.children[0];if(n?.type!==`text`)return;let r=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/i.exec(n.value);if(!r)return;n.value=n.value.slice(r[0].length),n.value||t.children.shift();let i=r[1].toLowerCase();e.data={...e.data,hProperties:{...e.data?.hProperties,"data-alert":i,dataAlert:i}}})}}var Roe=/^(?:[\w.@-]+\/)+[\w.@-]+\.\w{1,8}(?::\d+(?:-\d+)?)?$|^[\w.-]+\.\w{1,8}:\d+(?:-\d+)?$/,zoe=[hoe,Loe],j5=(0,G.createContext)({text:``,streaming:!1,searchQuery:``,activeNth:-1}),M5=(0,G.createContext)(null);function N5(e,t){switch(e){case`invalid-path`:return t(`The link is outside the current workspace.`);case`unsupported`:return t(`This link is not available on the local computer.`);case`unavailable`:return t(`The linked file or folder is unavailable.`);case`unsupported-viewer`:return t(`This file format cannot be previewed inside EnsoCode.`);case`too-large`:return t(`The image is too large to preview.`);case`invalid-application`:return t(`The selected application path is invalid.`);case`application-unavailable`:return t(`VS Code is unavailable. Install it or select another application.`);default:return e}}async function Boe(e,t,n,r){try{let r=A5(t,e.cwd);if(r===null)throw Error(`invalid-path`);let i=await window.electronAPI.workspaceFiles.openContext({conversationId:e.conversationId,projectId:e.projectId,rel:r,itemId:n});if(!i.ok)throw Error(i.error)}catch(e){kE({type:`error`,title:r(`Could not open local file link`),description:N5(e instanceof Error?e.message:String(e),r)})}}function P5({context:e,file:t,children:n}){let{t:r}=Ro(),i=u(e=>e.contextMenuOpen).filter(e=>e.enabled);return i.length===0?n:(0,J.jsxs)(voe,{children:[(0,J.jsx)(yoe,{render:n,onContextMenu:e=>e.stopPropagation()}),(0,J.jsx)(boe,{className:`min-w-48`,children:i.map(n=>{let i=n.target===`application`?(n.applicationPath.split(/[/\\]/).at(-1)??n.applicationPath).replace(/\.(?:exe|app)$/i,``):`VS Code`;return(0,J.jsx)(xoe,{closeOnClick:!0,onClick:()=>void Boe(e,t,n.id,r),children:n.target===`reveal`?r(y5()):r(`Open in {{app}}`,{app:i})},n.id)})})]})}function F5(e){let t=D5(e);if(t.kind===`external`)return{classification:t,line:void 0};let n=E5(t.kind===`local`?t.path:e);return n.line&&/\.[\w]+$/.test(n.path)?{classification:D5(n.path),line:n.line}:{classification:t,line:void 0}}function Voe(e){let t=e?.children;if(t?.length!==1)return null;let n=t[0],r=n.tagName===`code`&&n.children?.length===1?n.children[0]:null;return r?.type===`text`&&typeof r.value==`string`?r.value:null}function Hoe({children:e,href:t,node:n}){let{t:r}=Ro(),i=(0,G.useContext)(M5),[a,o]=(0,G.useState)(null),{classification:s,line:c}=F5(t??``),l=s.kind===`local`&&i!==null,u=l?Voe(n):null,d=e=>{kE({type:`error`,title:r(`Could not open local file link`),description:N5(e,r)})},f=async e=>{if(!i||s.kind!==`local`)return;let t=A5(s.path,i.cwd);if(t==null){d(`invalid-path`);return}if(!e&&c){dG(i.conversationId,t,c);return}let n={conversationId:i.conversationId,projectId:i.projectId,rel:t};try{if(e){let e=await window.electronAPI.workspaceFiles.reveal(n);e.ok||d(e.error);return}let t=await window.electronAPI.workspaceFiles.open(n);if(!t.ok){d(t.error);return}if(t.target===`handled`)return;if(t.viewer===`image`){let e=z1(t.rel);if(!e){d(`unsupported-viewer`);return}let r=await window.electronAPI.workspaceFiles.readImage({...n,rel:t.rel});if(!r.ok){d(r.error);return}let i=`data:${e};base64,`;if(!r.dataUrl.startsWith(i)||!/^[A-Za-z0-9+/=]+$/.test(r.dataUrl.slice(i.length))){d(`unsupported-viewer`);return}o({rel:t.rel,dataUrl:r.dataUrl})}else t.viewer===`markdown`?dG(i.conversationId,t.rel,void 0,`markdown`):dG(i.conversationId,t.rel)}catch(e){d(e instanceof Error?e.message:String(e))}},p=e=>{s.kind!==`external`&&(e.preventDefault(),l&&f(!1))},m=(0,J.jsx)(`a`,{href:s.kind===`external`&&t||void 0,className:q(`text-brand underline decoration-brand/40 underline-offset-2 transition-colors hover:decoration-brand`,l&&`cursor-pointer break-all`),role:l?`link`:void 0,tabIndex:l?0:void 0,...s.kind===`external`?{target:`_blank`,rel:`noreferrer`}:{},onClick:p,onKeyDown:e=>{l&&e.key===`Enter`&&(e.preventDefault(),f(!1))},children:u??e});if(!l||s.kind!==`local`||!i)return m;let h=(0,J.jsx)(P5,{context:i,file:s.path,children:m});return u===null?(0,J.jsxs)(`span`,{className:`inline`,children:[h,(0,J.jsx)(`button`,{type:`button`,className:`ml-1 inline-flex rounded p-0.5 align-middle text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":r(y5()),title:r(y5()),onClick:()=>void f(!0),children:(0,J.jsx)($e,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(b5,{image:a,onClose:()=>o(null)})]}):(0,J.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-0.5 rounded-[5px] border border-border/70 bg-muted/70 py-px pr-0.5 pl-1 align-baseline font-mono text-xs`,children:[h,(0,J.jsx)(`button`,{type:`button`,className:`inline-flex shrink-0 rounded-[3px] p-0.5 text-muted-foreground hover:bg-background hover:text-foreground`,"aria-label":r(y5()),title:r(y5()),onClick:()=>void f(!0),children:(0,J.jsx)($e,{className:`h-3 w-3`})}),(0,J.jsx)(b5,{image:a,onClose:()=>o(null)})]})}function Uoe(e,t,n=!0){let r=D8(e);return r||t!==`href`?r:n&&F5(e).classification.kind===`local`?e:``}var Woe={p:({children:e})=>{let{searchQuery:t,activeNth:n}=(0,G.useContext)(j5);return(0,J.jsx)(`p`,{className:`my-2 leading-[1.7] first:mt-0 last:mb-0`,children:t.trim()?HI(e,t,n,{n:0}):e})},a:Hoe,ul:({children:e})=>(0,J.jsx)(`ul`,{className:`my-2 list-disc pl-5 space-y-1 marker:text-muted-foreground`,children:e}),ol:({children:e})=>(0,J.jsx)(`ol`,{className:`my-2 list-decimal pl-5 space-y-1 marker:text-muted-foreground`,children:e}),h1:({children:e})=>(0,J.jsx)(`h1`,{className:`mt-3 mb-1.5 text-base font-semibold`,children:e}),h2:({children:e})=>(0,J.jsx)(`h2`,{className:`mt-3 mb-1.5 text-base font-semibold`,children:e}),h3:({children:e})=>(0,J.jsx)(`h3`,{className:`mt-2 mb-1 text-sm font-semibold`,children:e}),blockquote:({children:e,node:t})=>{let{t:n}=Ro(),r=t?.properties,i=Ioe[String(r?.dataAlert??r?.[`data-alert`]??``)];return i?(0,J.jsxs)(`blockquote`,{className:q(`my-1.5 border-l-2 pl-3`,i.border),children:[(0,J.jsx)(`p`,{className:q(`mt-1.5 mb-0.5 text-xs font-semibold`,i.text),children:n(i.label)}),e]}):(0,J.jsx)(`blockquote`,{className:`my-2 border-l-2 border-brand/30 pl-3 text-muted-foreground`,children:e})},code:({children:e})=>{let{t}=Ro(),n=(0,G.useContext)(M5),r=typeof e==`string`?e:``;if(r&&Roe.test(r)){let{path:e,line:i}=E5(r),a=(0,J.jsx)(`button`,{type:`button`,onClick:()=>{if(!n){navigator.clipboard.writeText(e);return}let r=A5(e,n.cwd);if(!r){kE({type:`error`,title:t(`Could not open local file link`),description:t(`The link is outside the current workspace.`)});return}dG(n.conversationId,r,i)},title:r,className:`inline-flex max-w-full items-center rounded-[5px] border border-border/70 bg-muted/70 px-1 py-px align-baseline font-mono text-xs text-brand transition-colors hover:bg-muted`,children:(0,J.jsx)(`span`,{className:`truncate`,children:r})});return n?(0,J.jsx)(P5,{context:n,file:e,children:a}):a}return(0,J.jsx)(`code`,{className:`rounded-[5px] border border-border/70 bg-muted/70 px-1 py-px font-mono text-xs`,children:e})},pre:({node:e})=>{let{streaming:t}=(0,G.useContext)(j5),n=e?.children?.[0],r=n&&`properties`in n?n.properties:void 0,i=/language-(\S+)/.exec(r?.className?.join(` `)??``)?.[1],a=n&&`children`in n?n.children?.[0]:void 0,o=(a&&`value`in a?String(a.value):``).replace(/\n$/,``),s=Foe(i);return s?.toLowerCase()===`mermaid`?(0,J.jsx)(Ooe,{code:o,streaming:t}):(0,J.jsx)(jG,{code:o,language:s,streaming:t})},table:({children:e,node:t})=>{let{text:n,streaming:r}=(0,G.useContext)(j5),i=t?.position?.start?.offset,a=t?.position?.end?.offset,o=i!==void 0&&a!==void 0?n.slice(i,a):null;return(0,J.jsxs)(`div`,{className:`group/table relative my-2 min-w-0 max-w-full overflow-x-auto overscroll-x-contain [-webkit-overflow-scrolling:touch]`,children:[(0,J.jsx)(`table`,{className:`w-max min-w-full border-collapse text-xs [overflow-wrap:normal]`,children:e}),o&&!r&&(0,J.jsx)(kG,{text:o,className:`absolute top-0.5 right-0.5 rounded-md border bg-background/80 p-1.5 text-muted-foreground opacity-0 backdrop-blur transition-opacity group-hover/table:opacity-100`})]})},th:({children:e})=>(0,J.jsx)(`th`,{className:`whitespace-nowrap border-b border-border px-2 py-1 text-left font-medium`,children:e}),td:({children:e})=>(0,J.jsx)(`td`,{className:`whitespace-nowrap border-b border-border/50 px-2 py-1`,children:e}),hr:()=>(0,J.jsx)(`hr`,{className:`my-3 border-border`})};function I5({text:e,streaming:t=!1,searchQuery:n=``,activeNth:r=-1}){let i=(0,G.useContext)(M5)!==null,a=(0,G.useMemo)(()=>({text:e,streaming:t,searchQuery:n,activeNth:r}),[e,t,n,r]),o=(0,G.useMemo)(()=>(e,t)=>Uoe(e,t,i),[i]);return(0,J.jsx)(j5.Provider,{value:a,children:(0,J.jsx)(`div`,{className:t?`t-stream-live`:void 0,children:(0,J.jsx)(rie,{remarkPlugins:zoe,components:Woe,urlTransform:o,children:e})})})}function L5({hits:e,defaultOpen:t=!1}){let{t:n}=Ro();return e.length===0?(0,J.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n(`No results`)}):(0,J.jsx)(`ul`,{className:`divide-y divide-border/60`,children:e.map(e=>(0,J.jsx)(Koe,{hit:e,defaultOpen:t},e.id))})}function Goe({view:e}){let{t}=Ro(),n=e.written?e.deduplicated&&t(`Identical memory already exists, nothing new was written`):t(`Similar memories already exist, nothing was written`);return(0,J.jsxs)(J.Fragment,{children:[n&&(0,J.jsx)(`p`,{className:`px-3 pt-2 text-xs text-muted-foreground`,children:n}),e.written?(0,J.jsx)(L5,{hits:[e.memory],defaultOpen:!0}):(0,J.jsx)(L5,{hits:e.candidates})]})}function Koe({hit:e,defaultOpen:t}){let{t:n}=Ro(),[r,i]=(0,G.useState)(t);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:e=>{let t=window.getSelection();t?.toString()&&e.currentTarget.contains(t.anchorNode)||i(e=>!e)},className:`block w-full cursor-pointer px-3 py-2 text-left transition-colors hover:bg-muted/40`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:q(`min-w-0 flex-1 font-medium text-foreground text-xs`,r?`break-words`:`truncate`),children:e.title}),e.unitType&&(0,J.jsx)(cO,{variant:`secondary`,size:`sm`,children:e.unitType}),e.space&&(0,J.jsx)(cO,{variant:`outline`,size:`sm`,children:n(e.space===`global`?`Global`:`Project`)}),e.score!==null&&(0,J.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums`,children:e.score.toFixed(2)})]}),(0,J.jsx)(`span`,{className:q(`mt-0.5 whitespace-pre-wrap break-words text-muted-foreground text-xs leading-relaxed`,r?`block`:`line-clamp-2`),children:e.content})]})})}var R5=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function z5(e){if(!e)return null;try{let t=JSON.parse(e);return R5(t)?t:null}catch{return null}}function B5(e,t){if(!Array.isArray(e))return null;let n=[];for(let r of e){if(!R5(r)||typeof r.id!=`string`||!r.id||typeof r.title!=`string`||typeof r.content!=`string`)return null;let{spaceId:e,[t]:i}=r;n.push({id:r.id,title:r.title,content:r.content,unitType:typeof r.unitType==`string`&&r.unitType?r.unitType:null,space:e===`global`?`global`:typeof e==`string`&&e.startsWith(`proj:`)?`project`:null,score:typeof i==`number`&&Number.isFinite(i)?i:null})}return n}function qoe(e){let t=z5(e);return t?B5(t.results,`score`):null}function Joe(e,t){let n=z5(e);if(n?.status===`candidates_found`){let e=B5(n.candidates,`similarity`);return e?{written:!1,candidates:e}:null}if(n?.status!==`inserted`||!R5(n.memory)||!t)return null;let r=B5([{...n.memory,content:t}],`score`)?.[0];return r?{written:!0,deduplicated:n.deduplicated===!0,memory:r}:null}var V5=G.createContext(void 0);function H5(e){let t=G.useContext(V5);if(t===void 0&&!e)throw Error(En(50));return t}var Yoe={...$C,instantType:e=>e.instantType,adaptiveOrigin:e=>e.adaptiveOrigin,closeDelay:e=>e.closeDelay},Xoe=class extends wC{constructor(e,t,n){let r=new WC;super(Zoe(e,r,t,n),Qoe(r),Yoe)}setOpen=(e,t)=>{let{inlineRectCoordsRef:n}=this.context;RC(this,e,t,{onBeforeDispatch(){let r=t.event;e&&t.reason===`trigger-hover`&&t.trigger&&`clientX`in r&&`clientY`in r&&n.current?.element!==t.trigger&&rC(n,t.trigger,r.clientX,r.clientY)}})}};function Zoe(e,t,n,r=!1){let i={...KC(),instantType:void 0,adaptiveOrigin:void 0,closeDelay:300,...e};return i.floatingRootContext=qC(t,n,r),i}function Qoe(e){return{popupRef:G.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e,inlineRectCoordsRef:{current:void 0}}}function U5(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,onOpenChangeComplete:i,actionsRef:a,handle:o,triggerId:s,defaultTriggerId:c=null,children:l}=e,u=NC((e,r)=>new Xoe({open:n,openProp:t,activeTriggerId:c,triggerIdProp:s},e,r));u.useControlledProp(`openProp`,t),u.useControlledProp(`triggerIdProp`,s),u.useContextCallback(`onOpenChange`,r),u.useContextCallback(`onOpenChangeComplete`,i);let d=u.useState(`open`),f=u.useState(`activeTriggerId`),p=u.useState(`mounted`),m=u.useState(`payload`);BC(u,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:h}=VC(d,u,()=>{u.context.inlineRectCoordsRef.current=void 0});Z(()=>{d&&(f??u.set(`payload`,void 0))},[u,f,d]),G.useImperativeHandle(a,()=>({unmount:h,close:()=>u.setOpen(!1,Kv(Wv))}),[h,u]);let g=d||p;return(0,J.jsxs)(V5.Provider,{value:u,children:[o&&(0,J.jsx)(PC,{handle:o,store:u}),g&&(0,J.jsx)($oe,{store:u}),typeof l==`function`?l({payload:m}):l]})}function $oe({store:e}){let t=Wx(e.useState(`floatingRootContext`));return HC(e,{activeTriggerProps:t.reference,inactiveTriggerProps:t.trigger,popupProps:t.floating}),null}var ese=pC(function(e){return H5(!0)?(0,J.jsx)(U5,{...e}):(0,J.jsx)(Ax,{children:(0,J.jsx)(U5,{...e})})}),W5=G.createContext(void 0);function tse(){let e=G.useContext(W5);if(e===void 0)throw Error(En(48));return e}var nse=G.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return H5().useState(`mounted`)||n?(0,J.jsx)(W5.Provider,{value:n,children:(0,J.jsx)(wte,{ref:t,...r})}):null}),rse=mC(function(e,t){let{render:n,className:r,delay:i,closeDelay:a,id:o,payload:s,handle:c,style:l,...u}=e,d=H5(!0),f=ew(c)??d;if(!f)throw Error(En(89));let p=Qv(o),m=f.useState(`isTriggerActive`,p),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`floatingRootContext`),_=f.context.inlineRectCoordsRef,v=G.useRef(null),y=i??600,b=a??300,{registerTrigger:x,isMountedByThisTrigger:S}=zC(p,v,f,{payload:s,closeDelay:b}),C=pw(g,{mouseOnly:!0,move:!1,handleClose:Aw(),delay:()=>({open:y,close:b}),triggerElementRef:v,isActiveTrigger:m,isClosing:()=>f.select(`transitionStatus`)===`ending`}),w=aw(g,{delay:y}),T={open:h},E=f.useState(`triggerProps`,S),D=nC(_,h);return Wn(`a`,e,{state:T,ref:[t,x,v],props:[C,w.reference,E,D,{id:p},u],stateAttributesMapping:K_})}),G5=G.createContext(void 0);function ise(){let e=G.useContext(G5);if(e===void 0)throw Error(En(49));return e}var ase=G.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=hx,style:g,..._}=e,v=H5(),y=tse(),b=Ox(),x=v.useState(`open`),S=v.useState(`mounted`),C=v.useState(`floatingRootContext`),w=v.useState(`instantType`),T=v.useState(`transitionStatus`),E=v.useState(`adaptiveOrigin`),D=v.context.inlineRectCoordsRef,O=TE({anchor:i,floatingRootContext:C,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:y,nodeId:b,collisionAvoidance:h,adaptiveOrigin:E,inline:iC(D)}),k=O.update;Z(()=>{x&&S&&k()},[x,S,k]);let A=OE(e,{open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:w},{styles:O.positionerStyles,transitionStatus:T,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!S,inert:!x});return(0,J.jsx)(G5.Provider,{value:O,children:(0,J.jsx)(kx,{id:b,children:A})})}),ose=G.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,o=H5(),{side:s,align:c}=ise(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`closeDelay`);return AC({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),dw(p,{closeDelay:m}),Wn(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,o.useStateSetter(`popupElement`)],props:[jC,f,DE(d),a],stateAttributesMapping:Y_})}),sse=ese;function cse({...e}){return(0,J.jsx)(rse,{"data-slot":`preview-card-trigger`,...e})}function lse({className:e,children:t,align:n=`center`,sideOffset:r=4,...i}){return(0,J.jsx)(nse,{children:(0,J.jsx)(ase,{align:n,className:`z-50`,"data-slot":`preview-card-positioner`,sideOffset:r,children:(0,J.jsx)(ose,{className:q(`relative flex w-64 origin-(--transform-origin) text-balance rounded-lg border bg-popover bg-clip-padding p-4 text-popover-foreground text-sm shadow-lg transition-[scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,e),"data-slot":`preview-card-content`,...i,children:t})})})}var K5={mask:`text-sky-600 dark:text-sky-400`,warn:`text-amber-600 dark:text-amber-400`,block:`text-red-600 dark:text-red-400`},use={mask:Ht,warn:Bt,block:Vt},dse={mask:`Mask`,warn:`Warn only`,block:`Block`},fse={system:`System prompt`,user:`Your message`,tool_result:`Tool output`,tool_args:`Tool arguments`,assistant:`Earlier replies`,tools:`Tool descriptions`};function pse({report:e}){let{t}=Ro(),n=s(e);if(!n)return null;let r=use[n],i=new Set(e.hits.map(e=>e.token)).size;return(0,J.jsxs)(sse,{children:[(0,J.jsxs)(cse,{render:(0,J.jsx)(`span`,{className:q(`inline-flex shrink-0 items-center gap-0.5 text-[11px]`,K5[n]),"data-privacy-mask":n}),children:[(0,J.jsx)(r,{className:`size-3.5`}),(0,J.jsx)(`span`,{className:`tabular-nums`,children:i})]}),(0,J.jsxs)(lse,{className:`w-72 text-xs`,children:[(0,J.jsx)(`p`,{className:`mb-1.5 font-medium`,children:t(`Privacy masking`)}),(0,J.jsx)(`ul`,{className:`space-y-1`,children:e.hits.map(e=>(0,J.jsxs)(`li`,{className:`flex flex-wrap gap-x-2`,children:[(0,J.jsx)(`span`,{className:K5[e.action],children:t(dse[e.action])}),(0,J.jsx)(`span`,{children:e.kind}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:t(fse[e.where]??e.where)}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e.preview}),e.count>1&&(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[`×`,e.count]})]},`${e.token}-${e.action}-${e.where}`))}),e.restored>0&&(0,J.jsx)(`p`,{className:`mt-1.5 text-muted-foreground`,children:t(`Restored {{count}} in the reply`,{count:e.restored})})]})]})}var mse=/^\[.+#[0-9A-Fa-f]{4}\]$/;function hse(e){let t=e.indexOf(`
|
|
1617
1617
|
`),n=t===-1?e:e.slice(0,t);return mse.test(n)?t===-1?``:e.slice(t+1).split(`
|
|
1618
1618
|
`).map(e=>e.replace(/^\d+:/,``)).join(`
|
|
1619
1619
|
`):e}var gse={theme:j1,disableFileHeader:!0,overflow:`wrap`,preferredHighlighter:`shiki-js`};function q5({path:e,contents:t}){let{t:n}=Ro(),[r,i]=(0,G.useState)(!1),a=k1(gse);(0,G.useEffect)(()=>{let e=!0;return P1().then(()=>{e&&i(!0)}),()=>{e=!1}},[]);let o=(0,G.useMemo)(()=>({name:e.split(`/`).pop()||`file`,contents:hse(t)}),[e,t]);return r?(0,J.jsx)(x1,{file:o,disableWorkerPool:!0,options:a}):(0,J.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n(`Loading...`)})}function _se(e){let{inputTokens:t,outputTokens:n}=e;if(typeof t!=`number`||!Number.isFinite(t)||t<0||typeof n!=`number`||!Number.isFinite(n)||n<0)return null;let r=Math.max(0,t-n);return{tokens:r,percent:t>0?Math.round(r/t*100):null}}var vse={compressed:`Compressed`,unchanged:`Unchanged`,pending:`Background task started`,bypassed:`Bypassed`,unavailable:`Unavailable`};function yse({value:e}){let t=Qa(e),{t:n}=Ro();if(!t)return null;let r=_se(t);return(0,J.jsxs)(`div`,{className:`border-border/60 border-t text-[10px] text-muted-foreground`,"data-rtk-status":t.status,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 px-3 py-1`,children:[(0,J.jsx)(`span`,{className:`font-semibold tracking-wide text-foreground/75`,children:`RTK`}),(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,J.jsx)(`span`,{children:n(vse[t.status])}),r&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,J.jsx)(`span`,{children:n(`~{{count}} tokens saved`,{count:_A(r.tokens)})}),r.percent!==null&&(0,J.jsxs)(`span`,{children:[`(`,r.percent,`%)`]})]})]}),(0,J.jsxs)(`div`,{className:`space-y-2 px-3 pb-2`,children:[t.status===`pending`&&(0,J.jsx)(`p`,{className:`rounded bg-muted/40 px-2 py-1 text-foreground/80`,children:n(`This is the startup receipt; see the task_output result for final statistics.`)}),(t.inputTokens!==void 0||t.reason)&&(0,J.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:[t.inputTokens!==void 0&&t.outputTokens!==void 0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`dt`,{children:n(`Input estimate`)}),(0,J.jsx)(`dd`,{className:`font-mono text-foreground/80`,children:n(`{{count}} tokens`,{count:_A(t.inputTokens)})}),(0,J.jsx)(`dt`,{children:n(`Output estimate`)}),(0,J.jsx)(`dd`,{className:`font-mono text-foreground/80`,children:n(`{{count}} tokens`,{count:_A(t.outputTokens)})})]}),t.reason&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`dt`,{children:n(`Reason`)}),(0,J.jsx)(`dd`,{className:`min-w-0 whitespace-pre-wrap text-foreground/80`,children:t.reason})]})]})]})]})}function J5({icon:e,state:t}){let n=t===`running`||t===`reviewing`;return(0,J.jsxs)(`span`,{className:q(`relative flex size-[22px] shrink-0 items-center justify-center rounded-full border text-muted-foreground`,n&&`border-transparent text-brand`,t===`error`&&`border-destructive/40 text-destructive`),children:[(0,J.jsx)(e,{className:`size-3`}),n&&(0,J.jsx)(`span`,{className:`absolute -inset-px animate-spin rounded-full border-[1.5px] border-brand/20 border-t-brand`})]})}var bse={queued:[`Queued`,`bg-muted-foreground`],running:[`running`,`bg-amber-500`],awaiting_input:[`awaiting input`,`bg-amber-500`],validating:[`validating`,`bg-amber-500`],succeeded:[`succeeded`,`bg-emerald-500`],failed:[`failed`,`bg-destructive`],cancelled:[`cancelled`,`bg-muted-foreground`],interrupted:[`interrupted`,`bg-muted-foreground`],creating:[`creating`,`bg-amber-500`],ready:[`idle`,`bg-muted-foreground`],active:[`running`,`bg-amber-500`],parked:[`parked`,`bg-muted-foreground`],closed:[`closed`,`bg-muted-foreground`]};function xse({view:e,titles:t}){let{t:n}=Ro();return(0,J.jsxs)(`div`,{className:`space-y-2 px-3 py-2 text-sm`,children:[e.kind===`report`&&e.text&&(0,J.jsx)(I5,{text:e.text}),e.kind===`report`&&e.value&&(0,J.jsx)(I5,{text:`\`\`\`json\n${e.value}\n\`\`\``}),e.kind===`report`&&e.error&&(0,J.jsx)(`p`,{className:`whitespace-pre-wrap text-destructive`,children:e.error}),e.runs.length>0&&(0,J.jsx)(`ul`,{className:`space-y-0.5 text-xs text-muted-foreground`,children:e.runs.map(e=>(0,J.jsx)(Sse,{run:e,title:t?.[e.agentId]},e.runId||e.agentId))}),e.kind===`list`&&e.runs.length===0&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`No agents`)}),e.kind===`wait`&&e.timedOut&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`Timed out; unfinished agents keep running`)}),e.kind===`wait`&&e.interrupted&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`Wait was interrupted`)}),(0,J.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer hover:text-foreground`,children:n(`Run info`)}),(0,J.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap font-mono`,children:e.info})]}),e.head&&(0,J.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-muted-foreground`,children:e.head})]})}function Sse({run:e,title:t}){let{t:n}=Ro(),[r,i]=bse[e.status]??[null,`bg-muted-foreground`],a=e.durationMs===null?``:n(`took {{duration}}`,{duration:vA(e.durationMs)});return(0,J.jsxs)(`li`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:q(`h-1.5 w-1.5 shrink-0 rounded-full`,i)}),t&&(0,J.jsx)(`span`,{className:`truncate text-foreground`,children:t}),(0,J.jsx)(`span`,{className:`shrink-0`,children:[r?n(r):e.status,a].filter(Boolean).join(` · `)})]})}var Y5=e=>!!e&&typeof e==`object`&&!Array.isArray(e),X5=e=>typeof e==`string`&&e.trim()?e:null;function Z5(e){if(!Y5(e))return null;let{agentId:t,runId:n,status:r,createdAt:i,startedAt:a,finishedAt:o}=e;if(typeof t!=`string`||typeof n!=`string`||typeof r!=`string`)return null;let s=typeof a==`number`?a:i;return{agentId:t,runId:n,status:r,durationMs:typeof o==`number`&&typeof s==`number`?Math.max(0,o-s):null}}var Cse=new Set([`closed`,`parked`,`creating`]);function wse(e){if(!Y5(e))return null;let{agentId:t,status:n,latestRun:r}=e;return typeof t!=`string`||typeof n!=`string`?null:(Cse.has(n)?null:Z5(r))??{agentId:t,runId:``,status:n,durationMs:null}}function Tse(e,t){let n=BF(t);if(!n)return null;let{head:r,value:i}=n;if(e===`report`){let e=Z5(i.run);if(!e)return null;let{text:t,value:n,error:a,...o}=i;return{kind:`report`,head:r,runs:[e],text:X5(t),value:n==null?null:JSON.stringify(n,null,2),error:X5(a),info:JSON.stringify(o,null,2)}}if(e===`list`){if(!Array.isArray(i.agents))return null;let e=i.agents.flatMap(e=>wse(e)??[]);return e.length===i.agents.length?{kind:`list`,head:r,runs:e,info:JSON.stringify(i,null,2)}:null}let a=e===`wait`?i:e===void 0?i.report:null;if(!Y5(a)||!Array.isArray(a.runs))return e===void 0&&i.report===void 0&&typeof i.agentId==`string`&&typeof i.runId==`string`?{kind:`receipt`,head:r,runs:[],info:JSON.stringify(i,null,2)}:null;let o=a.runs.flatMap(e=>Z5(e)??[]);return o.length===a.runs.length?{kind:`wait`,head:r,runs:o,timedOut:a.timedOut===!0,interrupted:a.interrupted===!0,info:JSON.stringify(i,null,2)}:null}function Ese({command:e,output:t}){let n=u(e=>e.terminalTheme),r=u(e=>e.terminalFontFamily),i=f(n)??a;return(0,J.jsxs)(`div`,{"data-slot":`terminal-output`,className:`px-3 py-2 text-xs leading-relaxed`,style:{backgroundColor:i.background,"--terminal-bg":i.background,color:i.foreground,fontFamily:r},children:[(0,J.jsxs)(`div`,{className:`whitespace-pre-wrap [overflow-wrap:anywhere]`,children:[(0,J.jsx)(`span`,{style:{color:i.green},children:`$ `}),e]}),t&&(0,J.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap [overflow-wrap:anywhere]`,style:{fontFamily:`inherit`},children:mG(t)})]})}function Dse(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(!(n.role!==`toolResult`||n.toolName!==`todo`||!n.todos))return n.todos.some(e=>e.status!==`completed`)?{id:n.toolCallId??String(t),todos:n.todos}:null}return null}function Q5({todos:e}){return(0,J.jsx)(`ul`,{className:`space-y-0.5 text-xs`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`flex items-start gap-1.5`,children:[e.status===`completed`?(0,J.jsx)(De,{className:`mt-0.5 h-3 w-3 shrink-0 text-green-600 dark:text-green-500`}):e.status===`in_progress`?(0,J.jsx)(Fe,{className:`mt-0.5 h-3 w-3 shrink-0 text-blue-500`}):(0,J.jsx)(Re,{className:`mt-0.5 h-3 w-3 shrink-0 text-muted-foreground/50`}),(0,J.jsx)(`span`,{className:q(e.status===`completed`?`text-muted-foreground line-through`:e.status===`in_progress`?`font-medium`:`text-muted-foreground`),children:e.content})]},e.content))})}var $5=new Set;function Ose({conversationId:e}){let{t}=Ro(),n=u(e=>e.pinUnfinishedTodos),r=OA(t=>t.conversations[e]?.messages),i=(0,G.useMemo)(()=>n&&r?Dse(r):null,[n,r]),[a,o]=(0,G.useState)(!1),[,s]=(0,G.useState)(0);if(!i||$5.has(i.id))return null;let c=i.todos.filter(e=>e.status===`completed`).length,l=i.todos.find(e=>e.status===`in_progress`)??i.todos.find(e=>e.status===`pending`);return(0,J.jsxs)(`div`,{className:`mb-1 rounded-lg border border-border/60 bg-muted/20 px-2.5 py-1.5 text-xs`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(e=>!e),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,J.jsx)(dt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`shrink-0 font-medium`,children:t(`Todos`)}),(0,J.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums`,children:[c,`/`,i.todos.length]}),!a&&l&&(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,title:l.content,children:l.content}),a?(0,J.jsx)(Oe,{className:`ml-auto h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,J.jsx)(ke,{className:`ml-auto h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,J.jsx)(`button`,{type:`button`,title:t(`Hide until the todo list updates`),onClick:()=>{$5.add(i.id),s(e=>e+1)},className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground`,children:(0,J.jsx)(sn,{className:`h-3.5 w-3.5`})})]}),a&&(0,J.jsx)(`div`,{className:`mt-1.5 max-h-48 overflow-y-auto`,children:(0,J.jsx)(Q5,{todos:i.todos})})]})}function e7({src:e,className:t,frameClassName:n,onError:r}){let[i,a]=(0,G.useState)(!1);return QT(i),(0,G.useEffect)(()=>{if(!i)return;let e=e=>{e.key===`Escape`&&a(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:q(`cursor-zoom-in`,n),children:(0,J.jsx)(`img`,{src:e,alt:``,className:t,onError:r})}),i&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:q(`fixed inset-0 flex cursor-zoom-out items-center justify-center bg-black/75`),style:{zIndex:lE.NESTED_MODAL_BACKDROP},"data-enso-float":``,children:(0,J.jsx)(`img`,{src:e,alt:``,className:`max-h-[92vh] max-w-[92vw] rounded-lg object-contain`})})]})}var kse=(e,t)=>e===t||!!e&&!!t&&e.runMs===t.runMs&&e.turnMs===t.turnMs&&e.ttftMs===t.ttftMs&&e.tps===t.tps;function Ase(e,t){let n=e.item,r=t.item;if(n===r)return!0;if(n.kind!==r.kind||n.key!==r.key)return!1;switch(n.kind){case`user`:return r.kind!==`user`||n.text!==r.text||n.images.length!==r.images.length||n.timestamp!==r.timestamp||n.deliveryState!==r.deliveryState||n.turnDurationMs!==r.turnDurationMs||n.collapsed!==r.collapsed||n.canCollapse!==r.canCollapse?!1:n.images.every((e,t)=>e===r.images[t]);case`text`:case`thinking`:return r.kind===n.kind&&n.text===r.text&&n.streaming===r.streaming&&(n.kind!==`text`||r.kind===`text`&&kse(n.perf,r.perf)&&n.timestamp===r.timestamp&&n.turnDurationMs===r.turnDurationMs)&&(n.kind!==`thinking`||r.kind===`thinking`&&n.durationMs===r.durationMs);case`tool`:return r.kind===`tool`&&n.state===r.state&&n.name===r.name&&n.summary===r.summary&&n.output===r.output&&n.edits===r.edits&&n.writeContent===r.writeContent&&n.fileChanges===r.fileChanges&&n.imagePath===r.imagePath&&n.todos===r.todos&&n.durationMs===r.durationMs&&n.startedAt===r.startedAt&&n.agentMeta===r.agentMeta&&n.source===r.source&&n.nestedPending===r.nestedPending&&JSON.stringify(n.sandbox)===JSON.stringify(r.sandbox)&&n.rtk===r.rtk&&n.plan?.title===r.plan?.title&&n.plan?.text===r.plan?.text&&n.sentMessage===r.sentMessage&&n.memoryContent===r.memoryContent&&n.ask?.question===r.ask?.question&&n.ask?.options.join(`
|
|
@@ -1623,4 +1623,4 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
1623
1623
|
`,1)[0]??``);function yce(e,t,n,r,i=100){if(r||!n)return{hiddenSince:t,delayMs:null};let a=t??e;return{hiddenSince:a,delayMs:Math.max(0,i-(e-a))}}var bce=1e6;function xce(e,t,n=bce){if(t.length===0)return{anchor:null,firstItemIndex:n,remount:!1};if(!e)return{anchor:{keys:t,index:n},firstItemIndex:n,remount:!1};let r=new Map(t.map((e,t)=>[e,t]));for(let n=0;n<e.keys.length;n++){let i=r.get(e.keys[n]);if(i===void 0)continue;let a=e.index+n-i;return{anchor:{keys:t,index:a},firstItemIndex:a,remount:!1}}return{anchor:{keys:t,index:n},firstItemIndex:n,remount:!0}}function Sce(e,t){return t}var Cce=[{icon:Ue,title:`Map the project`,hint:`Entry points, modules and key dependencies`,prompt:`Walk me through this project's structure: entry points, module layout and key dependencies.`},{icon:Te,title:`Find potential issues`,hint:`Suspicious logic and unhandled edge cases`,prompt:`Review this project for potential bugs, suspicious logic and unhandled edge cases, and list them by severity.`},{icon:Xe,title:`Add unit tests`,hint:`Cover the core modules with tests`,prompt:`Find the core modules that lack tests and add unit tests for them.`},{icon:Ft,title:`Summarize recent changes`,hint:`A digest based on git log`,prompt:`Summarize the recent changes in this repository based on git log.`}];function wce({onPick:e}){let{t}=Ro();return(0,J.jsx)(`div`,{className:`mx-auto grid w-full max-w-[560px] grid-cols-1 gap-2.5 text-left @min-[36rem]:grid-cols-2`,children:Cce.map(({icon:n,title:r,hint:i,prompt:a})=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>e(t(a)),"data-slot":`welcome-suggestion`,className:`group flex items-start gap-3 rounded-xl border bg-card px-3.5 py-3 text-left shadow-xs transition-[border-color,box-shadow,transform] duration-200 hover:-translate-y-px hover:border-brand/25 hover:shadow-float`,children:[(0,J.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-lg bg-brand/8 text-brand dark:bg-brand/14`,children:(0,J.jsx)(n,{className:`size-3.5`})}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block text-[13px] font-medium`,children:t(r)}),(0,J.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t(i)})]})]},r))})}var C7=`enso-chat-col mx-auto w-full max-w-2xl px-4 @min-[56rem]:max-w-3xl @min-[72rem]:max-w-4xl @min-[84rem]:max-w-5xl @min-[96rem]:max-w-6xl @min-[112rem]:max-w-7xl`,Tce=new Set([`text`,`thinking`,`tool`,`tool-group`]),w7=1e3;function T7({className:e,children:t}){let[n,r]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{let e=requestAnimationFrame(()=>r(!0));return()=>cancelAnimationFrame(e)},[]),(0,J.jsx)(`div`,{className:q(`t-stagger`,n&&`is-shown`,e),children:t})}var E7=40,Ece={index:`LAST`,align:`end`},Dce={top:600,bottom:600},Oce=e=>e?`auto`:!1;function kce({style:e,...t}){let n=e?.visibility===`hidden`,[r,i]=(0,G.useState)(!1),a=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=yce(Date.now(),a.current,n,r);if(a.current=e.hiddenSince,e.delayMs===null)return;let t=window.setTimeout(()=>i(!0),e.delayMs);return()=>window.clearTimeout(t)},[n,r]),(0,J.jsx)(`div`,{...t,style:n&&r?{...e,visibility:`visible`}:e})}function Ace({ref:e,items:t,busy:n,loading:r=!1,running:i,runStartedAt:a,lastOutputAt:o,error:s,emptyTitle:c,emptyDescription:l,onSuggestion:d,onRetryResume:f,virtualize:p=!0,onStartReached:m,historyLoading:h=!1,hasOlder:g,olderCursor:_,searchQuery:v=``,activeHit:y=null}){let{t:b}=Ro(),x=(0,G.useRef)(null),[S,C]=(0,G.useState)(!0),[w,T]=(0,G.useState)(!1),E=(0,G.useRef)(!0),D=(0,G.useRef)(null),O=(0,G.useRef)(0),k=(0,G.useRef)(0),A=(0,G.useRef)(null),j=(0,G.useRef)(!1),M=(0,G.useRef)(!1),N=(0,G.useRef)(0),[P,F]=(0,G.useState)(null),I=(0,G.useRef)(0),L=(0,G.useCallback)(e=>{cancelAnimationFrame(I.current),I.current=requestAnimationFrame(()=>F(e()))},[]);(0,G.useEffect)(()=>()=>cancelAnimationFrame(I.current),[]);let[R,z]=(0,G.useState)(new Set),B=(0,G.useCallback)(e=>{z(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),[V,ee]=(0,G.useState)(new Map),H=u(e=>e.autoCollapseTurns),U=u(e=>e.collapseCompletedActivity),W=u(e=>e.compactReadOnlyTools),te=(0,G.useMemo)(()=>NI(t,i,R,{compact:W,autoCollapseCompletedTurns:H,collapseCompletedActivity:U,turnOverrides:V}),[t,i,R,W,H,U,V]),ne=(0,G.useRef)({state:PI,collapse:new Map,reveal:new Map}),re=(0,G.useMemo)(()=>{let e=ne.current,t=e=>D.current?.querySelector(`[data-nav-key="${CSS.escape(e)}"]`),n=FI(e.state,te,(e,n)=>{let r=t(e)?.getBoundingClientRect().top,i=t(n)?.getBoundingClientRect().bottom;return r===void 0||i===void 0?0:i-r}),r=Date.now();e.state=n.next;for(let{key:t,...i}of n.collapses)e.collapse.set(t,{at:r,...i});for(let t of n.expands)e.reveal.set(t,r);return n.children},[te]),ie=(0,G.useRef)(null),ae=(0,G.useRef)(0),oe=(0,G.useRef)(null),se=xce(ie.current,te.map(e=>e.key));ie.current=se.anchor,se.remount&&(ae.current+=1,oe.current=null);let ce=se.firstItemIndex,le=(0,G.useCallback)((e,t)=>{ee(n=>n.get(e)===t?n:new Map(n).set(e,t))},[]),ue=(0,G.useMemo)(()=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(r.kind!==`user`)continue;let i=``;for(let e=n+1;e<t.length;e++){let n=t[e];if(n.kind===`user`)break;if(n.kind===`text`){i=n.text;break}}e.push({key:r.key,question:r.text||`[image]`,answer:i})}return e},[t]),de=(0,G.useCallback)(()=>{let e=D.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight>2&&(j.current=!0,e.scrollTop=e.scrollHeight)},[]),fe=(0,G.useCallback)(()=>{cancelAnimationFrame(O.current);let e=Date.now()+1200,t=null,n=()=>{cancelAnimationFrame(O.current),j.current=!1,t?.removeEventListener(`touchstart`,n),t?.removeEventListener(`wheel`,n)},r=()=>{!t&&D.current&&(t=D.current,t.addEventListener(`touchstart`,n,{passive:!0,once:!0}),t.addEventListener(`wheel`,n,{passive:!0,once:!0})),de(),E.current=!0,C(!0),Date.now()<e?O.current=requestAnimationFrame(r):n()};r(),C(!0),E.current=!0},[de]);(0,G.useEffect)(()=>()=>{cancelAnimationFrame(O.current),cancelAnimationFrame(k.current),window.clearTimeout(N.current)},[]);let pe=(0,G.useCallback)(e=>{if(A.current?.disconnect(),A.current=null,!e)return;let t=new ResizeObserver(()=>{if(!E.current&&!j.current)return;cancelAnimationFrame(k.current);let e=8,t=()=>{de();let n=D.current;(n?n.scrollHeight-n.scrollTop-n.clientHeight:0)<=2||(--e>0?k.current=requestAnimationFrame(t):fe())};t()});t.observe(e),A.current=t,fe()},[de,fe]);(0,G.useEffect)(()=>()=>A.current?.disconnect(),[]);let me=e=>te.findIndex(t=>t.key===e||t.kind===`tool-group`&&D7(t,e)),he=e=>{if(!p){D.current?.querySelector(`[data-nav-key="${CSS.escape(e)}"]`)?.scrollIntoView({block:`center`});return}let t=me(e);t>=0&&x.current?.scrollToIndex({index:Sce(ce,t),align:`center`})},ge=(0,G.useRef)(null),K=e=>{if(me(e)>=0){ge.current=null,he(e);return}let n=null,r=!1;for(let i of t)if(i.kind===`user`&&(n=i.key),i.key===e){r=!0;break}!r||!n||(ge.current=e,le(n,!1))};(0,G.useLayoutEffect)(()=>{let e=ge.current;!e||me(e)<0||(ge.current=null,he(e))},[te]),(0,G.useImperativeHandle)(e,()=>({scrollToBottom:fe,pinToBottom:de,isAtBottom:()=>E.current,getScroller:()=>p?null:D.current,scrollToKey:K}));let _e=(0,G.useRef)(!1),ve=`${_}:${ce}`,be=(0,G.useRef)(ve);be.current!==ve&&(be.current=ve,_e.current=!1);let xe=()=>{!m||_e.current||(_e.current=!0,m())};(0,G.useEffect)(()=>{p&&!h&&oe.current===ce&&xe()},[_,h]);let Se=(0,G.useMemo)(()=>({query:v,activeKey:y?.key??``,activeNth:y?.nth??-1}),[v,y?.key,y?.nth]),Ce=(e,t)=>{let n=te[t+1];if(n!==void 0&&x7(e)&&x7(n))return`pb-1`;if(!W)return`pb-4`;let r=n!==void 0&&l7(n);return l7(e)?r?`pb-1`:`pb-2`:e.kind===`text`&&r?`pb-1`:`pb-4`},we=(e,t)=>{let n=te[t-1],r=te[t+1],i=n?.kind===`user`&&!n.collapsed&&Tce.has(e.kind)?n:void 0,a=x7(e),o=Date.now(),s=ne.current.collapse.get(e.key),c=s&&o-s.at<w7?s:void 0,l=re.get(e.key),u=l&&ne.current.reveal.get(l.group),d=l&&u!==void 0&&o-u<w7;return(0,J.jsxs)(`div`,{"data-nav-key":e.key,"data-reply-head":i?``:void 0,"data-step-prev":a&&n&&x7(n)?``:void 0,"data-step-next":a&&r&&x7(r)?``:void 0,"data-fold-collapse":c?c.pair?`pair`:`toggle`:void 0,style:c?{"--fold-from":`${c.height}px`}:d?{"--fold-i":l.index}:void 0,className:q(C7,Ce(e,t),a&&`enso-step-row`,d&&`t-fold-reveal`,`[overflow-wrap:anywhere]`),children:[i&&(0,J.jsx)(Vse,{model:i.replyModel,at:i.replyAt,privacyMask:i.replyPrivacyMask}),(0,J.jsx)(Fce,{itemKey:e.key,children:(0,J.jsx)(Hse,{item:e,onToggleGroup:B,onToggleTurn:le})})]},e.key)},Te=(0,G.useRef)(!1);g===!0&&(Te.current=!0);let Ee=CF(t.length>0,h,g,Te.current,!p&&w);(0,G.useLayoutEffect)(()=>{if(p){T(!1);return}let e=D.current;T(!!e&&wF(g===!0,h,e.scrollHeight,e.clientHeight))},[p,g,h,ce,te.length,t.length]);let De=()=>(0,J.jsx)(jce,{chrome:Ee,onLoadMore:Ee===`more`?xe:void 0}),Oe=()=>(0,J.jsxs)(`div`,{className:q(C7,`pb-6 [overflow-wrap:anywhere]`),children:[n&&(0,J.jsxs)(`div`,{className:`flex min-h-[26px] items-center gap-2 text-[13px]`,children:[(0,J.jsx)(Mce,{}),(0,J.jsx)(`span`,{className:`t-shimmer`,"data-text":b(r?`Loading…`:`Working…`),children:b(r?`Loading…`:`Working…`)}),!r&&(o??a)!==void 0&&(0,J.jsx)(Pce,{since:o??a})]}),s&&(0,J.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,J.jsx)(`p`,{className:`min-w-0 flex-1 text-sm text-destructive whitespace-pre-wrap`,children:b(s)}),(0,J.jsx)(p7,{}),f&&(0,J.jsx)(ji,{size:`sm`,variant:`outline`,onClick:f,children:b(`Retry resume`)})]})]});return(0,J.jsx)(II.Provider,{value:Se,children:(0,J.jsxs)(`div`,{className:`@container relative min-h-0 flex-1`,children:[(0,J.jsx)(GI,{items:ue,activeKey:P,onJump:K}),t.length===0&&!n?(0,J.jsxs)(T7,{className:`flex h-full flex-col items-center justify-center gap-2 overflow-y-auto px-4 text-center`,children:[(0,J.jsx)(`span`,{className:`t-stagger-line t-stagger-line--1 mb-3`,children:(0,J.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14`,children:(0,J.jsx)(EA,{className:`size-6`})})}),(0,J.jsx)(`p`,{className:`t-stagger-line t-stagger-line--1 text-[22px] font-semibold tracking-tight`,children:c}),s?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`t-stagger-line t-stagger-line--2 max-w-md text-sm text-destructive whitespace-pre-wrap`,children:b(s)}),f&&(0,J.jsx)(ji,{size:`sm`,variant:`outline`,onClick:f,children:b(`Retry resume`)})]}):(0,J.jsxs)(J.Fragment,{children:[l!==``&&(0,J.jsx)(`p`,{className:`t-stagger-line t-stagger-line--2 text-sm text-muted-foreground`,children:l??b(`Ask the agent…`)}),d&&(0,J.jsx)(`div`,{className:`t-stagger-line t-stagger-line--3 mt-5 w-full`,children:(0,J.jsx)(wce,{onPick:d})})]})]}):t.length===0&&s?(0,J.jsxs)(T7,{className:`flex h-full flex-col items-center justify-center gap-2 text-center`,children:[(0,J.jsx)(`p`,{className:`t-stagger-line t-stagger-line--1 max-w-md text-sm text-destructive whitespace-pre-wrap`,children:b(s)}),f&&(0,J.jsx)(ji,{size:`sm`,variant:`outline`,onClick:f,children:b(`Retry resume`)})]}):t.length===0?(0,J.jsxs)(`div`,{"data-timeline-loading":``,className:`flex h-full flex-col items-center justify-center gap-2.5 text-center`,children:[(0,J.jsx)(pt,{className:`h-5 w-5 animate-spin text-muted-foreground`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:b(`Preparing session…`)})]}):p?(0,J.jsx)(KN,{ref:x,data:te,defaultItemHeight:80,computeItemKey:(e,t)=>t.key,firstItemIndex:ce,startReached:xe,followOutput:Oce,atBottomThreshold:E7,atBottomStateChange:e=>{C(e),E.current=e},increaseViewportBy:Dce,initialTopMostItemIndex:Ece,rangeChanged:({startIndex:e})=>{oe.current=e,e>ce+4&&(_e.current=!1),L(()=>{let t=Math.max(0,e-ce),n=null;for(let e=0;e<=Math.min(t+1,te.length-1);e++)te[e]?.kind===`user`&&(n=te[e].key);return n})},scrollerRef:e=>{D.current=e instanceof HTMLElement?e:null},className:`h-full select-text`,components:{List:kce,Header:De,Footer:Oe},itemContent:(e,t)=>we(t,e-ce)},ae.current):(0,J.jsx)(`div`,{ref:e=>{D.current=e},onTouchStart:()=>{M.current=!0,window.clearTimeout(N.current)},onTouchEnd:()=>{window.clearTimeout(N.current),N.current=window.setTimeout(()=>{M.current=!1},400)},onWheel:()=>{M.current=!0,window.clearTimeout(N.current),N.current=window.setTimeout(()=>{M.current=!1},400)},onScroll:e=>{let t=e.currentTarget;if(j.current){j.current=!1,E.current=!0,C(!0);return}if(!M.current){E.current&&de();return}let n=t.scrollHeight-t.scrollTop-t.clientHeight<=E7;n!==E.current&&(E.current=n,C(n)),m&&(t.scrollTop<80&&!_e.current?(_e.current=!0,m()):t.scrollTop>240&&(_e.current=!1))},className:`h-full select-text overflow-y-auto [overflow-anchor:none]`,children:(0,J.jsxs)(`div`,{ref:pe,children:[De(),te.map((e,t)=>we(e,t)),Oe()]})}),!S&&t.length>0&&(0,J.jsxs)(`button`,{type:`button`,onClick:fe,className:`absolute bottom-4 left-1/2 z-10 inline-flex h-7 -translate-x-1/2 items-center gap-1.5 rounded-full border bg-card px-3 text-xs text-muted-foreground shadow-float transition-colors hover:text-foreground`,children:[(0,J.jsx)(ye,{className:`h-3 w-3`}),b(`Scroll to bottom`)]})]})})}function D7(e,t){return e.children.some(e=>e.key===t||e.kind===`tool-group`&&D7(e,t))}function jce({chrome:e,onLoadMore:t}){let{t:n}=Ro();return e===`none`?(0,J.jsx)(`div`,{className:`h-6`}):(0,J.jsx)(`div`,{className:q(C7,`flex items-center justify-center gap-2 py-3`),children:e===`loading`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(pt,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`Loading earlier messages…`)})]}):e===`more`?(0,J.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline-offset-2 hover:underline`,onClick:t,children:n(`Load earlier messages`)}):(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`Beginning of conversation`)})})}function Mce(){return(0,J.jsxs)(`span`,{className:`relative flex size-[22px] shrink-0 items-center justify-center`,children:[(0,J.jsx)(`span`,{className:`absolute size-2 animate-ping rounded-full bg-brand/50`}),(0,J.jsx)(`span`,{className:`relative size-2 rounded-full bg-brand`})]})}var Nce=e=>{let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m${t%60}s`},Pce=(0,G.memo)(function({since:e}){let[,t]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,J.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:Nce(Date.now()-e)})}),Fce=class extends G.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidUpdate(e){e.itemKey!==this.props.itemKey&&this.state.failed&&this.setState({failed:!1})}render(){return this.state.failed?(0,J.jsxs)(`p`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-1.5 text-xs text-destructive`,children:[`message render failed · `,this.props.itemKey]}):this.props.children}};function Ice({retry:e,onCancel:t}){let{t:n}=Ro(),[r,i]=(0,G.useState)(()=>Date.now());(0,G.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),500);return()=>clearInterval(e)},[]);let a=Math.max(0,Math.ceil((e.at+e.delayMs-r)/1e3));return(0,J.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-2.5 py-1.5 text-xs`,children:[(0,J.jsx)(Pt,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-amber-500 [animation-duration:2s]`}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.error,children:[e.maxAttempts>0?n(`Auto-retrying ({{attempt}}/{{max}})`,{attempt:e.attempt,max:e.maxAttempts}):n(`Auto-retrying ({{attempt}})`,{attempt:e.attempt}),(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,a>0?n(`retrying in {{seconds}}s`,{seconds:a}):n(`retrying…`),` — `,e.error]})]}),t&&(0,J.jsx)(`button`,{type:`button`,title:n(`Cancel auto-retry`),onClick:t,className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground`,children:(0,J.jsx)(sn,{className:`h-3.5 w-3.5`})})]})}var Lce=[`pattern`,`query`,`path`,`file_path`],Rce=[`path`,`file_path`,`query`,`pattern`],zce=[`command`,`cmd`,`script`],Bce=[`path`,`file_path`,`pattern`,`query`,`command`,`url`,`description`,`summary`],Vce=120;function O7(e){let t=e.replace(/\s+/g,` `).trim();return t.length>Vce?`${t.slice(0,119)}…`:t}function Hce(e){let t=e.toLowerCase();return t.includes(`search`)||t.includes(`grep`)||t===`find`?Lce:t===`read`||t.endsWith(`_read`)?Rce:t===`bash`||t.includes(`shell`)||t.includes(`terminal`)?zce:Bce}function Uce(e,t){let n=t.trim();if(!n)return``;let r;try{r=JSON.parse(n)}catch{return O7(n)}if(r===null)return``;if(typeof r!=`object`||Array.isArray(r))return O7(JSON.stringify(r)??String(r));let i=oF(e,r);if(i.summary!==void 0)return O7(i.summary);if(!i.args||typeof i.args!=`object`)return``;let a=i.args;for(let e of Hce(i.name)){let t=a[e];if(typeof t==`string`&&t.trim())return O7(t)}let o=JSON.stringify(a);return o===`{}`?``:O7(o)}function Wce(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=24}var k7=new Map,Gce=e=>{let t=k7.get(e);return t?new Set(t):new Set},A7=(e,t)=>(k7.set(e,t),t),j7=new Map,Kce=(e,t)=>{let n=j7.get(e)??new Set;j7.set(e,n);for(let e of t)n.add(e);return n};function qce({sessionId:e,tasks:t,subagents:n,readOnly:r}){let i=u(e=>e.virtualModels),{t:a}=Ro(),[o,s]=(0,G.useState)(()=>Gce(e)),[c,l]=(0,G.useState)(null),d=Kce(e,[...t.filter(e=>e.status===`running`).map(e=>e.taskId),...n.filter(e=>e.status===`running`).map(e=>e.id)]),f=(e,t)=>!o.has(e)&&(t===`running`||d.has(e)),p=t.filter(e=>f(e.taskId,e.status)),m=n.filter(e=>f(e.id,e.status));if((0,G.useEffect)(()=>{let r=j7.get(e),i=[...t.filter(e=>e.status!==`running`).map(e=>e.taskId),...n.filter(e=>e.status!==`running`).map(e=>e.id)].filter(e=>r?.has(e)&&!o.has(e)&&e!==c);if(i.length===0)return;let a=setTimeout(()=>{s(t=>{let n=new Set(t);for(let e of i)n.add(e);return A7(e,n)})},5e3);return()=>clearTimeout(a)},[e,t,n,o,c]),p.length===0&&m.length===0)return null;let h=t=>{s(n=>A7(e,new Set(n).add(t))),c===t&&l(null)},g=p.find(e=>e.taskId===c)??null,_=m.find(e=>e.id===c)??null;return(0,J.jsxs)(`div`,{className:`relative mb-1.5`,children:[(g||_)&&(0,J.jsxs)(`div`,{className:`absolute bottom-full left-0 right-0 z-30 mb-1.5 rounded-xl border bg-card shadow-float`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1.5 text-xs`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-muted-foreground`,children:[g?g.command:_?.description,_?.modelId?` · ${pO(i,_.modelId)}`:``]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,J.jsx)(sn,{className:`h-3.5 w-3.5`})})]}),g&&(0,J.jsx)(tle,{tail:g.tail}),_&&(0,J.jsx)(Jce,{agent:_},_.id)]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-xl border bg-card p-1 shadow-xs`,children:[p.map(t=>(0,J.jsx)(M7,{icon:Xt,status:t.status,meta:(0,J.jsx)(ele,{task:t}),open:c===t.taskId,onToggle:()=>l(c===t.taskId?null:t.taskId),stopTitle:a(`Stop task`),onStop:r?void 0:()=>void window.electronAPI.agent.stopTask(e,t.taskId),onDismiss:()=>h(t.taskId),children:(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,title:t.command,children:t.command})},t.taskId)),m.map(t=>(0,J.jsxs)(M7,{icon:Ce,status:t.status,meta:(0,J.jsx)($ce,{agent:t}),open:c===t.id,onToggle:()=>l(c===t.id?null:t.id),stopTitle:a(`Stop subagent`),onStop:r?void 0:()=>void window.electronAPI.agent.stopSubagent(e,t.id),onDismiss:()=>h(t.id),children:[t.agentType&&(0,J.jsx)(`span`,{className:`shrink-0 font-medium`,children:t.agentType}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:[t.description,t.modelId&&(0,J.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[` `,`· `,pO(i,t.modelId)]}),t.status===`running`&&t.currentActivity&&(0,J.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[` · `,t.currentActivity]})]})]},t.id))]})]})}function M7({icon:e,status:t,meta:n,open:r,onToggle:i,stopTitle:a,onStop:o,onDismiss:s,children:c}){let{t:l}=Ro();return(0,J.jsxs)(`div`,{className:`flex min-h-[30px] min-w-0 items-center gap-2 px-1 text-[13px]`,children:[(0,J.jsx)(J5,{icon:e,state:t===`running`?`running`:t===`failed`?`error`:`ok`}),c,n,(0,J.jsxs)(`button`,{type:`button`,onClick:i,"aria-expanded":r,className:`flex h-6 shrink-0 items-center gap-0.5 rounded-md px-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[l(`Output`),(0,J.jsx)(Oe,{className:q(`h-3 w-3 transition-transform`,r&&`rotate-180`)})]}),t===`running`?o&&(0,J.jsx)(`button`,{type:`button`,onClick:o,title:a,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,J.jsx)(Qt,{className:`h-3 w-3`})}):(0,J.jsx)(`button`,{type:`button`,onClick:s,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(sn,{className:`h-3 w-3`})})]})}function Jce({agent:e}){let{t}=Ro(),n=e.activities??[],r=(0,G.useRef)(null),i=(0,G.useRef)(!0);return(0,G.useEffect)(()=>{let e=r.current;e&&i.current&&(e.scrollTop=e.scrollHeight)},[n,e.resultText]),(0,J.jsxs)(`div`,{ref:r,className:`max-h-96 space-y-2 overflow-auto px-3 py-2 text-sm`,onScroll:e=>{i.current=Wce(e.currentTarget)},children:[n.map(e=>(0,J.jsx)(Yce,{activity:e},e.id)),n.length===0&&!e.resultText&&(0,J.jsx)(`pre`,{className:`font-mono text-xs whitespace-pre-wrap text-muted-foreground`,children:(e.activityLog??[]).join(`
|
|
1624
1624
|
`)||t(`(no output yet)`)}),e.detailsPruned&&(0,J.jsx)(`div`,{className:`rounded-md border border-dashed px-2.5 py-2 text-xs text-muted-foreground`,children:t(`Earlier activity details were cleared; the final report is still available.`)}),e.resultText&&e.status!==`running`&&(0,J.jsxs)(`section`,{className:q(`rounded-lg border px-3 py-2`,e.status===`failed`?`border-destructive/30 bg-destructive/5`:`border-blue-500/30 bg-blue-500/5`),children:[(0,J.jsx)(`div`,{className:`mb-1.5 font-medium text-xs text-foreground`,children:t(`Final report`)}),(0,J.jsx)(I5,{text:e.resultText})]})]})}function Yce({activity:e}){let{t}=Ro(),[n,r]=(0,G.useState)(!1);if(e.type===`assistant`)return(0,J.jsxs)(`section`,{className:`rounded-md bg-muted/30 px-2.5 py-2`,children:[(0,J.jsx)(`div`,{className:`mb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:t(`Assistant`)}),(0,J.jsx)(Qce,{text:e.text,markdown:!0})]});let i=Uce(e.toolName,e.argumentsText),a=oF(e.toolName,e.argumentsText).name,o=rF(a),s=`subagent-tool-${e.id.replace(/[^A-Za-z0-9_-]/g,`-`)}`;return(0,J.jsxs)(`section`,{className:`border-b border-border/40 last:border-b-0`,children:[(0,J.jsxs)(`button`,{type:`button`,"aria-controls":s,"aria-expanded":n,onClick:()=>r(e=>!e),className:`flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 text-left text-xs transition-colors hover:bg-muted/50`,children:[(0,J.jsx)(Xce,{toolName:a}),(0,J.jsx)(`span`,{className:`shrink-0 font-medium text-foreground/80`,children:o?.tool??a}),i&&(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground`,title:i,children:i}),!i&&(0,J.jsx)(`span`,{className:`min-w-0 flex-1`}),(0,J.jsx)(Zce,{status:e.status,label:t(e.status)}),(0,J.jsx)(ke,{"aria-hidden":`true`,className:q(`h-3 w-3 shrink-0 text-muted-foreground transition-transform`,n&&`rotate-90`)})]}),n&&(0,J.jsxs)(`div`,{id:s,className:`ml-5 border-border/50 border-l pb-2 pl-2.5`,children:[o&&(0,J.jsxs)(`div`,{className:`mb-1 truncate font-mono text-[10px] text-muted-foreground/70`,children:[o.server,`.`,o.tool]}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70`,children:t(`Arguments`)}),(0,J.jsx)(`pre`,{className:`max-h-28 overflow-auto font-mono text-[10px] leading-relaxed whitespace-pre-wrap text-muted-foreground/80`,children:mG(e.argumentsText)}),e.outputText&&(0,J.jsxs)(`div`,{className:`mt-1.5 border-border/40 border-t pt-1.5`,children:[(0,J.jsx)(`div`,{className:`mb-0.5 text-[10px] text-muted-foreground`,children:t(`Result`)}),(0,J.jsx)(`pre`,{className:`overflow-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap text-foreground/80`,children:mG(e.outputText)})]})]})]})}function Xce({toolName:e}){let t=e.toLowerCase(),n=`h-3.5 w-3.5 shrink-0 text-muted-foreground`;return t.includes(`search`)||t.includes(`grep`)||t===`find`?(0,J.jsx)(Rt,{"aria-hidden":`true`,className:n}):t===`read`||t===`write`||t===`edit`||t===`apply_patch`||t.endsWith(`_read`)?(0,J.jsx)(Ye,{"aria-hidden":`true`,className:n}):t===`bash`||t===`exec`||t===`codemode`||t.includes(`shell`)||t.includes(`terminal`)?(0,J.jsx)(en,{"aria-hidden":`true`,className:n}):(0,J.jsx)(on,{"aria-hidden":`true`,className:n})}function Zce({status:e,label:t}){let n=`h-3.5 w-3.5`;return(0,J.jsx)(`span`,{role:`status`,"aria-label":t,title:t,className:q(`shrink-0`,e===`failed`?`text-destructive`:`text-muted-foreground`),children:e===`running`?(0,J.jsx)(pt,{"aria-hidden":`true`,className:q(n,`animate-spin`)}):e===`done`?(0,J.jsx)(De,{"aria-hidden":`true`,className:n}):e===`failed`?(0,J.jsx)(Ne,{"aria-hidden":`true`,className:n}):(0,J.jsx)(xe,{"aria-hidden":`true`,className:n})})}function Qce({text:e,label:t,markdown:n=!1}){let{t:r}=Ro(),i=e.length>800||e.split(`
|
|
1625
1625
|
`).length>16,a=n?(0,J.jsx)(I5,{text:e}):(0,J.jsx)(`pre`,{className:`overflow-x-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap text-muted-foreground`,children:mG(e)});return i?(0,J.jsxs)(`details`,{className:`group/details`,children:[(0,J.jsxs)(`summary`,{className:`cursor-pointer text-[10px] text-muted-foreground hover:text-foreground`,children:[t?`${t} · `:``,r(`{{count}} chars`,{count:e.length})]}),(0,J.jsx)(`div`,{className:`mt-1.5`,children:a})]}):(0,J.jsxs)(`div`,{children:[t&&(0,J.jsx)(`div`,{className:`mb-0.5 text-[10px] text-muted-foreground`,children:t}),a]})}function $ce({agent:e}){let[,t]=(0,G.useState)(0);return(0,G.useEffect)(()=>{if(e.status!==`running`)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e.status]),(0,J.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums`,children:[e.steps>0?`${e.steps} steps · `:``,e.outputTokens?`${e.outputTokens} tok · `:``,e.status===`running`?vA(Date.now()-e.startedAt):e.status]})}function ele({task:e}){let[,t]=(0,G.useState)(0);return(0,G.useEffect)(()=>{if(e.status!==`running`)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e.status]),(0,J.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums`,children:e.status===`running`?vA(Date.now()-e.startedAt):e.exitCode===void 0?e.status:`exit ${e.exitCode}`})}function tle({tail:e}){let{t}=Ro(),n=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=n.current;e&&(e.scrollTop=e.scrollHeight)},[e]),(0,J.jsx)(`pre`,{ref:n,className:`max-h-56 overflow-auto border-t border-border/60 px-2.5 py-2 font-mono text-xs leading-relaxed whitespace-pre-wrap text-muted-foreground`,children:mG(e)||t(`(no output yet)`)})}function nle(e){return{sessionId:e.sessionId,canRewind:!e.bot&&!e.deviceReadOnly,canRetry:!e.bot&&!e.deviceReadOnly,canFork:!1,...e.bot?{botSession:!0}:{}}}var N7=7e5,rle=1600;async function P7(e,t=N7,n=rle){let r=await createImageBitmap(e),i=Math.min(1,n/Math.max(r.width,r.height)),a=document.createElement(`canvas`);a.width=Math.round(r.width*i),a.height=Math.round(r.height*i);let o=a.getContext(`2d`);if(!o)throw Error(`画布不可用`);o.drawImage(r,0,0,a.width,a.height),r.close();for(let e of[.85,.7,.55,.4]){let n=a.toDataURL(`image/jpeg`,e),r=n.slice(n.indexOf(`,`)+1);if(r.length*.75<=t)return{data:r,mimeType:`image/jpeg`}}throw Error(`图片太大,请换一张更小的图`)}var F7=e=>Math.floor(N7/Math.max(1,e));async function I7(e,t){try{return await P7(e,t)}catch{return P7(e,t,1024)}}async function ile(e){let t=F7(e.length),n=[];for(let r of e)n.push(await I7(r,t));return n}function ale(e,t,n,r){let i=e?.find(e=>e.id===n);if(!i)return null;let a=i.text;return{sessionId:t,messageId:n,text:a,...i.hasImages?{hasImages:!0}:{},priorMatches:r.filter(e=>L7(a,e)).length,priorUserCount:r.length}}function L7(e,t){if(t===e)return!0;let n=wG(t);return n!==null&&e.trimStart().startsWith(n)}function ole(e,t,n){let r=new Set(t.filter(e=>e.sessionId===n).map(e=>e.messageId));return(e??[]).filter(e=>!r.has(e.id))}function sle(e,t,n){let r=t.filter(e=>e.sessionId===n).map(e=>lle(e));return r.length===0?[...e]:[...e,...r]}function cle(e,t,n,r){return e.filter(e=>e.sessionId===t?r?.turnSettled&&n.length>e.priorUserCount?!1:e.text?n.filter(t=>L7(e.text,t)).length<=e.priorMatches:n.length<=e.priorUserCount:!0)}function R7(e){return e.filter(e=>e.role===`user`).map(ule)}function lle(e){let t=e.text||(e.hasImages?`[image]`:``);return{role:`user`,content:t?[{type:`text`,text:t}]:[]}}function ule(e){return e.content.map(e=>e.type===`text`?e.text:``).join(`
|
|
1626
|
-
`).trim()}var dle=e=>e===`outbox-discarding`?`正在移除…`:e===`outbox-discard`?`移除未保存,请勿关闭页面;请再次移除,重启后可能重新入队`:e===`outbox-storage`?`无法保存离线消息,请勿关闭页面;可重试或复制消息`:e===`delivery-unconfirmed`?`未收到回执,发送结果未确认;可重试确认`:e===`read-only`?`此设备为只读`:e&&Po(`zh`,Fi(e)??e),z7=(e=!1)=>e?`此设备为只读,刚才的操作未执行;可在桌面「设置 → 设备」切换为可操作`:`此设备为只读,只能查看;可在桌面「设置 → 设备」切换为可操作`,fle=70;function ple({percent:e,critical:t}){return(0,J.jsx)(`span`,{"aria-hidden":!0,className:`h-1 w-7 shrink-0 overflow-hidden rounded-full bg-muted-foreground/20`,children:(0,J.jsx)(`span`,{className:q(`block h-full rounded-full`,t?`bg-destructive`:e>=fle?`bg-warning`:`bg-muted-foreground/70`),style:{width:`${e}%`}})})}function mle(e,t){let n={inputTokens:0,outputTokens:0,...e};return t&&(n.contextUsed=t.used,t.window!==void 0&&(n.contextWindow=t.window)),n.inputTokens===0&&n.outputTokens===0&&n.cacheHitPercent===void 0&&n.ttftAvgMs===void 0&&n.tokensPerSecond===void 0&&n.contextUsed===void 0?void 0:n}function hle(e,t){let n={tokens:void 0,cache:void 0,context:void 0,speed:void 0};if(!t)return n;if(t.contextUsed!==void 0){let e=t.contextUsed,r=t.contextWindow??0;if(r>0){let t=Math.min(100,Math.round(e/r*100));n.context={compact:`${t}%`,full:`${_A(r)} · ${t}%`,percent:t,critical:t>=90}}else n.context={compact:`${_A(e)}·?`,full:`${_A(e)} · ?`}}let r=[],i=[];return t.ttftAvgMs!==void 0&&(r.push(vA(t.ttftAvgMs)),i.push(e(`First token avg {{duration}}`,{duration:vA(t.ttftAvgMs)}))),t.tokensPerSecond!==void 0&&(r.push(`${t.tokensPerSecond} tok/s`),i.push(e(`{{speed}} tok/s`,{speed:t.tokensPerSecond}))),r.length>0&&(n.speed={compact:r.join(` · `),full:i.join(` · `)}),(t.inputTokens>0||t.outputTokens>0)&&(n.tokens={compact:`↑${_A(t.inputTokens)} ↓${_A(t.outputTokens)}`,full:e(`Input {{input}} tok · Output {{output}} tok`,{input:_A(t.inputTokens),output:_A(t.outputTokens)})}),t.cacheHitPercent!==void 0&&(n.cache={compact:`${t.cacheHitPercent}%`,full:e(`Cache hit {{percent}}%`,{percent:t.cacheHitPercent})}),n}var gle=[[`tokens`,He],[`cache`,Ke],[`context`,tt],[`speed`,cn]];function _le({usageTotals:e,context:t}){let{t:n}=Ro(),r=hle(n,mle(e,t));return(0,J.jsx)(`div`,{"data-slot":`stats-line`,className:`flex min-h-6 flex-wrap items-center justify-center gap-x-3 px-1`,children:gle.map(([e,t])=>{let n=r[e];return n?(0,J.jsxs)(`span`,{className:q(`flex items-center gap-1 text-[11px] tabular-nums`,n.critical?`text-destructive`:`text-muted-foreground/80`),children:[n.percent===void 0?(0,J.jsx)(t,{className:`h-3 w-3 shrink-0 opacity-75`}):(0,J.jsx)(ple,{percent:n.percent,critical:!!n.critical}),n.compact]},e):null})})}function B7(e){let{view:t,sessionId:n}=e,r=(0,G.useRef)(null),[i,a]=(0,G.useState)(!1),o=(0,G.useRef)(null),s=(0,G.useRef)(null),c=(0,G.useRef)(!1);(0,G.useLayoutEffect)(()=>{let e=o.current,t=s.current,n=e?.querySelector(`[aria-selected="true"]`);!e||!t||!n||(c.current||(t.style.transition=`none`),t.style.transform=`translate(${n.offsetLeft}px, ${n.offsetTop}px)`,t.style.width=`${n.offsetWidth}px`,t.style.height=`${n.offsetHeight}px`,c.current||=(t.offsetWidth,t.style.transition=``,!0))},[n,e.tabGroup]);let l=t?.status===`running`,u=e.bot,d=!!(u?.readOnly||e.deviceReadOnly),f=e.artifacts?.chatId,p=e.artifacts?.conversationId,h=(0,G.useMemo)(()=>({...nle({sessionId:n,bot:u,deviceReadOnly:e.deviceReadOnly}),...f&&p?{turnFooter:e=>(0,J.jsx)(Qi,{target:{chatId:f,conversationId:p,messageIndex:e}})}:{}}),[n,u,e.deviceReadOnly,f,p]),g=(0,G.useMemo)(()=>{if(u)return[];let t=[{name:`/goal`,description:`Set a session goal (/goal <objective> · pause · resume · clear)`},{name:`/compact`,description:`Compact the context now (/compact [summary focus])`}],n=(e.slashCommands??[]).filter(e=>e.name!==`/goal`&&e.name!==`/compact`);return[...t,...n]},[e.slashCommands,u]),_=(0,G.useMemo)(()=>t?[...t.messages.entries()].sort((e,t)=>e[0]-t[0]):[],[t]),v=(0,G.useMemo)(()=>sle(_.map(([,e])=>e),e.echoes??[],n??``),[_,e.echoes,n]),y=v.length>0||t?.status===`running`||t?.status===`failed`;Sne(n?{id:n,projectId:``,status:t?.status??`idle`,started:y,spawning:!1,messages:v,queuedMessages:e.queued?.map(e=>({id:e.id,text:e.text}))}:null);let b=(0,G.useMemo)(()=>gI(v,l,[],e.cwd,{pendingApprovals:t?.approvals,compaction:t?.compaction,compactionNoticeAt:m(_.map(([e])=>e),t?.compactionNoticeAt)}),[v,_,l,e.cwd,t?.approvals,t?.compaction,t?.compactionNoticeAt]),x=t?.messages.size?Math.min(...t.messages.keys()):null,S=(0,G.useRef)(null),C=(0,G.useCallback)(()=>{if(!e.hasOlder||!e.onLoadOlder)return;let t=r.current?.getScroller();S.current=t?{height:t.scrollHeight,top:t.scrollTop}:null,e.onLoadOlder()},[e.hasOlder,e.onLoadOlder]);(0,G.useLayoutEffect)(()=>{let e=r.current?.getScroller(),t=S.current;!e||!t||(S.current=null,e.scrollTop=t.top+(e.scrollHeight-t.height))},[x]),(0,G.useEffect)(()=>{r.current?.isAtBottom()&&r.current.pinToBottom()},[b]);let w=async(t,n)=>{a(!0);try{let i=F7(n.length),a=[];for(let e of n)a.push(await vle(e,i));e.onSend(t,a),r.current?.scrollToBottom()}finally{a(!1)}};return(0,J.jsx)(wA.Provider,{value:h,children:(0,J.jsxs)(`div`,{className:`phone-chat-root flex h-full min-h-0 flex-col`,children:[(0,J.jsxs)(`header`,{className:`flex shrink-0 items-center gap-1 border-b bg-background px-2 py-2 pt-safe`,children:[u?.onBack||!e.drawerDocked?(0,J.jsx)(`button`,{type:`button`,onClick:u?.onBack??e.onOpenDrawer,"aria-label":u?.onBack?`返回群聊`:`打开会话列表`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:u?.onBack?(0,J.jsx)(Ae,{className:`h-4.5 w-4.5`}):(0,J.jsx)(Dt,{className:`h-4.5 w-4.5`})}):(0,J.jsx)(`span`,{className:`h-9 w-9 shrink-0`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 text-center`,children:[(0,J.jsxs)(`p`,{className:`flex min-w-0 items-center justify-center gap-1.5`,children:[e.connState!==`host-offline`&&e.connState!==`unauthorized`&&(0,J.jsx)(`span`,{className:q(`h-1.5 w-1.5 shrink-0 rounded-full`,e.connState===`online`&&!e.syncing?`bg-emerald-500`:`animate-pulse bg-amber-500`),title:e.connState===`online`&&e.syncing?`同步中…`:e.stateLabel}),(0,J.jsx)(`span`,{className:`truncate font-medium text-sm`,children:e.title})]}),(0,J.jsx)(`p`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:e.projectName||e.stateLabel})]}),u?.readOnly?(0,J.jsx)(`span`,{className:`h-9 w-9 shrink-0`}):(0,J.jsx)(`button`,{type:`button`,onClick:e.onNewSession,disabled:!e.canCreate||d||!!u&&i||e.connState!==`online`,"aria-label":`新建会话`,title:e.newSessionHint??`新建会话`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,children:(0,J.jsx)(Jt,{className:`h-4.5 w-4.5`})})]}),e.connState===`host-offline`&&(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-center gap-1.5 bg-amber-500/10 py-1 text-amber-700 text-xs dark:text-amber-400`,children:[(0,J.jsx)(pt,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:e.stateLabel})]}),e.tabGroup&&e.tabGroup.children.length>0&&(0,J.jsxs)(`div`,{ref:o,role:`tablist`,className:`t-tabs relative flex shrink-0 items-center justify-start gap-1 overflow-x-auto border-b px-2 py-1`,children:[(0,J.jsx)(`span`,{ref:s,"aria-hidden":`true`,className:`t-tabs-pill pointer-events-none absolute top-0 left-0 z-0 rounded-md bg-muted`}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===e.tabGroup.parent.id,className:V7(n===e.tabGroup.parent.id),onClick:()=>e.onSelectTab?.(e.tabGroup?.parent.id??``),children:[(0,J.jsx)(gt,{className:`h-3 w-3 shrink-0`}),(0,J.jsx)(`span`,{className:`max-w-40 truncate`,children:e.tabGroup.parent.title||`新对话`})]}),e.tabGroup.children.map(t=>(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===t.id,className:V7(n===t.id),onClick:()=>e.onSelectTab?.(t.id),children:[(0,J.jsx)(Ce,{className:`h-3 w-3 shrink-0`}),(0,J.jsx)(`span`,{className:`max-w-28 truncate`,children:t.title||`coworker`}),(0,J.jsx)(`span`,{className:q(`h-1.5 w-1.5 shrink-0 rounded-full`,t.status===`running`?`animate-pulse bg-brand`:t.status===`failed`?`bg-destructive`:`bg-muted-foreground/30`)})]},t.id))]}),n===null?(0,J.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,J.jsx)(`span`,{className:`mb-3 flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14`,children:(0,J.jsx)(EA,{className:`size-6`})}),(0,J.jsx)(`p`,{className:`font-semibold text-[22px] tracking-tight`,children:`EnsoCode`}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e.connState===`online`?`从左上角选择会话,或新建一个`:e.stateLabel})]}):(0,J.jsx)(Ace,{ref:r,items:b,busy:t===null?!!e.syncing:l,loading:t===null,running:l,error:void 0,emptyTitle:e.projectName||`EnsoCode`,virtualize:!1,historyLoading:e.historyLoading,hasOlder:e.hasOlder,firstItemIndex:x??0,onStartReached:e.hasOlder?C:void 0},n),n!==null&&(0,J.jsx)(`div`,{className:`phone-dock @container shrink-0 pt-1 pb-safe`,children:(0,J.jsxs)(`div`,{className:`enso-chat-col mx-auto w-full max-w-2xl px-4 @min-[56rem]:max-w-3xl @min-[72rem]:max-w-4xl @min-[84rem]:max-w-5xl @min-[96rem]:max-w-6xl @min-[112rem]:max-w-7xl`,children:[t?.retry&&(0,J.jsx)(Ice,{retry:t.retry}),!d&&(0,J.jsx)(Ene,{conversationId:n,queued:(e.queued??[]).map(e=>({id:e.id,text:e.text}))}),e.goal&&!d&&(0,J.jsx)(wne,{conversationId:n,goal:{...e.goal,noProgressRuns:0}}),(0,J.jsx)(Ose,{conversationId:n},n),(0,J.jsx)(qce,{sessionId:n,tasks:t?.tasks??[],subagents:t?.subagents??[],readOnly:e.deviceReadOnly}),u?.outbox,u?.notice&&(0,J.jsx)(`p`,{className:`mb-1 rounded-md bg-destructive/10 px-2 py-1 text-destructive text-xs`,children:u.notice}),e.deviceReadOnly?(0,J.jsx)(`p`,{className:`mb-1 rounded-md bg-muted px-2 py-1 text-center text-muted-foreground text-xs`,children:z7(e.readOnlyRejected)}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Eg,{approvals:t?.approvals??[],onRespond:e.onApproval,clockOffset:e.clockOffset}),(0,J.jsx)(Dg,{asks:t?.asks??[],onAnswer:e.onAsk,clockOffset:e.clockOffset,autoFocus:!1})]}),!d&&(0,J.jsx)(CA,{commands:g,running:l,busy:l,locked:e.newSessionBusy||!!u&&i||(t?.approvals??[]).length>0,focusKey:u?.chatId?`bot-chat:${u.chatId}`:n,autoFocus:!1,enterToSend:!1,toolbar:e.modelLabel&&e.onOpenConfig?(0,J.jsxs)(`button`,{type:`button`,onClick:e.onOpenConfig,className:`flex min-w-0 items-center gap-0.5 rounded-md px-1.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[(0,J.jsx)(`span`,{className:`truncate`,children:e.modelLabel}),(0,J.jsx)(Oe,{className:`h-3 w-3 shrink-0`})]}):void 0,onSend:e=>{w(e.text,e.images)},onAbort:e.onAbort,voice:e.voice,voiceMode:`hold`}),!d&&(0,J.jsx)(_le,{usageTotals:e.usageTotals,context:e.context})]})})]})})}function V7(e){return q(`t-tab flex min-w-0 shrink-0 items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors`,e?`font-medium`:`text-muted-foreground`)}async function vle(e,t){if(e.data.length*.75<=t)return e;let n=await(await fetch(`data:${e.mimeType};base64,${e.data}`)).blob();return I7(new File([n],`image`,{type:e.mimeType}),t)}function yle(e){if(e==null||!Number.isFinite(e)||e<0)return null;let t=Math.round(e);return t<1?`<1ms`:`${t}ms`}function ble(e,t){let n=e===`direct`?`直连`:`中继`,r=yle(t);return r?`已连接 · ${n} · ${r}`:`已连接 · ${n}`}var H7=`enso-phone-drawer-segment`;function xle(){let e=localStorage.getItem(H7);return e===`bot`||e===`code`?e:null}function Sle(e){localStorage.setItem(H7,e)}function U7(e,t){if(!e)return!1;let n=xle();return n?n===`bot`:t!==null}function Cle(e,t=0){let n=new Map;for(let r of e)if(!(r.seq<=t)&&((r.kind===`human`||r.newConversation)&&n.clear(),r.kind===`bot`&&r.botId&&n.delete(r.botId),r.failure&&n.set(r.failure.botId,r.id),r.retryOf))for(let[e,t]of n)t===r.retryOf&&n.delete(e);return new Set(n.values())}function wle(e,t){let n=RegExp(`#${t}(?!\\d)`).exec(e);if(!n)return;let r=n.index+n[0].length;return[e.slice(0,n.index),n[0],e.slice(r)]}function Tle({status:e}){return e===`running`?(0,J.jsx)(pt,{className:`h-3 w-3 shrink-0 animate-spin text-brand`}):e===`done`?(0,J.jsx)(De,{className:`h-3 w-3 shrink-0 text-muted-foreground`}):e===`denied`?(0,J.jsx)(Wt,{className:`h-3 w-3 shrink-0 text-muted-foreground`}):e===`timeout`?(0,J.jsx)(Ve,{className:`h-3 w-3 shrink-0 text-warning`}):(0,J.jsx)(sn,{className:`h-3 w-3 shrink-0 text-destructive`})}function Ele({item:e,bots:t,clockOffset:n,onOpen:r}){let i=t.get(e.botId),a=e.ownerBotId?t.get(e.ownerBotId):void 0,o=e.state!==`queued`,[s,c]=(0,G.useState)(()=>Date.now());(0,G.useEffect)(()=>{if(!o)return;let e=window.setInterval(()=>c(Date.now()),1e3);return()=>window.clearInterval(e)},[o]);let l=s-n,u=o&&r?()=>r(e.conversationId):void 0;return(0,J.jsxs)(`button`,{type:`button`,disabled:!u,onClick:u,className:`flex w-full gap-2 rounded-lg border bg-muted/30 px-2.5 py-2 text-left disabled:cursor-default`,children:[(0,J.jsx)(La,{bot:i,size:`sm`,busy:o}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,J.jsxs)(`span`,{className:`truncate font-medium`,children:[i?.name??`成员`,a?(0,J.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` 替 `,a.name]}):null]}),(0,J.jsx)(`span`,{className:q(`shrink-0`,o?`text-brand`:`text-muted-foreground`),children:bo(e)}),o&&e.startedAt!==void 0&&(0,J.jsx)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:Co(l-e.startedAt)}),u&&(0,J.jsx)(ke,{className:`ml-auto h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),e.more>0&&(0,J.jsxs)(`span`,{className:`mt-1 block text-[11px] text-muted-foreground`,children:[`+`,e.more,` 个更早的步骤`]}),e.steps.map((e,t)=>(0,J.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-[11px]`,children:[(0,J.jsx)(Tle,{status:e.status}),(0,J.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.name}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-muted-foreground`,children:e.detail}),e.status===`timeout`&&(0,J.jsx)(`span`,{className:`shrink-0 text-warning`,children:e.name===`ask_user`?`已超时未回答`:`已超时拒绝`}),(0,J.jsx)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:e.durationMs===void 0?e.startedAt===void 0?``:Co(l-e.startedAt):Co(e.durationMs)})]},t))]})]})}var W7=e=>[...e].sort((e,t)=>t.activityAt-e.activityAt);function Dle(e,t,n=10){let r=W7(e),i=e=>e.id===t.currentId||e.id===t.rootId?0:e.unread||e.running?1:2,a=new Set([...r].sort((e,t)=>i(e)-i(t)).slice(0,n).map(e=>e.id));return r.filter(e=>a.has(e.id)).sort((e,n)=>Number(n.id===t.rootId)-Number(e.id===t.rootId))}function Ole(e,t,n){let r=t.trim().toLowerCase();return W7(e).filter(e=>(n===`all`||(n===`unread`?e.unread:e.running))&&(!r||`${e.title}\n${e.preview??``}`.toLowerCase().includes(r)))}var kle=G.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=Jk(),{clearErrors:C}=Zk(),w=h||s,T=m??a,E={...p,disabled:w},{labelId:D}=$k(),O=tA({id:i});Z(()=>{let e=o!=null;S.inputRef.current?.value||e&&o!==``?b(!0):e&&o===``&&b(!1)},[S.inputRef,b,o]);let k=G.useRef(null);Z(()=>{u&&k.current===Ay(Dv(k.current))&&y(!0)},[u,y]);let[A]=xO({controlled:o,default:l,name:`FieldControl`,state:`value`}),j=o!==void 0,M=j?A:void 0,N=xv(()=>S.inputRef.current?.value);return Yk(S.inputRef,O,M,N,!w,a),Wn(`input`,e,{ref:[t,k],state:E,props:[{id:O,disabled:w,name:T,ref:S.inputRef,"aria-labelledby":D,autoFocus:u,...j?{value:M}:{defaultValue:l},onChange(e){let t=e.currentTarget.value;c?.(t,Kv(Mv,e.nativeEvent)),_(t!==(v.initialValue??``)),b(t!==``),e.nativeEvent.defaultPrevented||(C(T),S.change(t))},onFocus(){y(!0)},onBlur(e){g(!0),y(!1),x===`onBlur`&&S.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(g(!0),S.commit(e.currentTarget.value))}},f,e=>S.getValidationProps(w,e)],stateAttributesMapping:Gk})}),Ale=G.forwardRef(function(e,t){return(0,J.jsx)(kle,{ref:t,...e})});function G7({className:e,size:t=`default`,unstyled:n=!1,...r}){return(0,J.jsx)(`span`,{className:q(!n&&`relative inline-flex w-full rounded-lg border border-input bg-background bg-clip-padding text-base shadow-xs ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none has-focus-visible:ring-[3px] sm:text-sm dark:bg-input/32 dark:not-in-data-[slot=group]:bg-clip-border dark:has-aria-invalid:ring-destructive/24 dark:not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/8%)]`,e)||void 0,"data-size":t,"data-slot":`input-control`,children:(0,J.jsx)(Ale,{className:q(`h-8.5 w-full min-w-0 rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-8.5 outline-none placeholder:text-muted-foreground/72 sm:h-7.5 sm:leading-7.5`,t===`sm`&&`h-7.5 px-[calc(--spacing(2.5)-1px)] leading-7.5 sm:h-6.5 sm:leading-6.5`,t===`lg`&&`h-9.5 leading-9.5 sm:h-8.5 sm:leading-8.5`,r.type===`search`&&`[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none`,r.type===`file`&&`text-muted-foreground file:me-3 file:bg-transparent file:font-medium file:text-foreground file:text-sm`),"data-slot":`input`,size:typeof t==`number`?t:void 0,...r})})}var K7=nT,jle=Rw;function Mle({className:e,...t}){return(0,J.jsx)(X_,{className:q(`fixed inset-0 z-50 bg-black/32 backdrop-blur-sm transition-opacity duration-150 ease-out data-ending-style:opacity-0 data-starting-style:opacity-0`,e),"data-slot":`sheet-backdrop`,...t})}function Nle({className:e,side:t,inset:n=!1,...r}){return(0,J.jsx)(rT,{className:q(`fixed inset-0 z-50 grid`,t===`bottom`&&`grid grid-rows-[1fr_auto] pt-12`,t===`top`&&`grid grid-rows-[auto_1fr] pb-12`,t===`left`&&`flex justify-start`,t===`right`&&`flex justify-end`,n&&`sm:p-4`),"data-slot":`sheet-viewport`,...r})}function q7({className:e,children:t,showCloseButton:n=!0,side:r=`right`,inset:i=!1,...a}){return(0,J.jsxs)(jle,{children:[(0,J.jsx)($T,{}),(0,J.jsx)(Mle,{}),(0,J.jsx)(Nle,{inset:i,side:r,children:(0,J.jsxs)(Fw,{className:q(`relative flex max-h-full min-h-0 w-full min-w-0 flex-col bg-popover bg-clip-padding text-popover-foreground shadow-lg transition-[opacity,translate] duration-150 [transition-timing-function:cubic-bezier(0.34,1.56,0.64,1)] will-change-transform before:pointer-events-none before:absolute before:inset-0 before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:opacity-0 data-starting-style:opacity-0 max-sm:before:hidden dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,r===`bottom`&&`row-start-2 border-t data-ending-style:translate-y-8 data-starting-style:translate-y-8`,r===`top`&&`data-ending-style:-translate-y-8 data-starting-style:-translate-y-8 border-b`,r===`left`&&`data-ending-style:-translate-x-8 data-starting-style:-translate-x-8 w-[calc(100%-(--spacing(12)))] max-w-md border-e`,r===`right`&&`col-start-2 w-[calc(100%-(--spacing(12)))] max-w-md border-s data-ending-style:translate-x-8 data-starting-style:translate-x-8`,i&&`before:hidden sm:rounded-2xl sm:border sm:before:rounded-[calc(var(--radius-2xl)-1px)] sm:**:data-[slot=sheet-footer]:rounded-b-[calc(var(--radius-2xl)-1px)]`,e),"data-slot":`sheet-popup`,...a,children:[t,n&&(0,J.jsx)(qv,{"aria-label":`Close`,className:`absolute end-2 top-2`,render:(0,J.jsx)(ji,{size:`icon`,variant:`ghost`}),children:(0,J.jsx)(sn,{})})]})})]})}function J7({className:e,...t}){return(0,J.jsx)(`div`,{className:q(`flex flex-col gap-2 p-6 in-[[data-slot=sheet-popup]:has([data-slot=sheet-panel])]:pb-3 max-sm:pb-4`,e),"data-slot":`sheet-header`,...t})}function Y7({className:e,...t}){return(0,J.jsx)(iT,{className:q(`font-heading text-xl leading-none`,e),"data-slot":`sheet-title`,...t})}function X7(e,t,n=Date.now()){let r=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),i=e-n,a=Math.abs(i);return a<6e4?r.format(0,`second`):a<36e5?r.format(Math.trunc(i/6e4),`minute`):a<864e5?r.format(Math.trunc(i/36e5),`hour`):a<2592e6?r.format(Math.trunc(i/864e5),`day`):a<31536e6?r.format(Math.trunc(i/2592e6),`month`):r.format(Math.trunc(i/31536e6),`year`)}function Z7({entry:e}){return(0,J.jsxs)(J.Fragment,{children:[e.running&&(0,J.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-warning`}),(0,J.jsx)(`span`,{className:`shrink-0 text-muted-foreground text-xs`,children:X7(e.activityAt,`zh`)})]})}function Ple({threads:e,status:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(``),{entries:o,currentId:s,rootId:c,disabledHint:l}=e,u=o.find(e=>e.id===s),d=Dle(o,{currentId:s,rootId:c}),f=o.length-d.length,p=Ole(o,i,`all`),m=t=>{!l&&t!==s&&e.onSelect(t)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Nk,{children:[(0,J.jsxs)(Fk,{"aria-label":`切换话题`,className:`mx-auto flex max-w-full items-center justify-center gap-0.5 text-[11px] text-muted-foreground`,children:[(0,J.jsxs)(`span`,{className:`truncate`,children:[u?.title??`主话题`,t&&` · ${t}`]}),(0,J.jsx)(Oe,{className:`h-3 w-3 shrink-0`})]}),(0,J.jsxs)(Ik,{className:`w-72 max-w-[calc(100vw-1rem)]`,children:[(0,J.jsxs)(Rk,{children:[(0,J.jsx)(Bk,{children:`话题`}),d.map(e=>(0,J.jsxs)(zk,{disabled:!!l&&e.id!==s,onClick:()=>m(e.id),children:[(0,J.jsx)(De,{className:q(e.id!==s&&`invisible`)}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,J.jsx)(Z7,{entry:e})]},e.id))]}),(0,J.jsx)(Vk,{}),f>0&&(0,J.jsxs)(zk,{onClick:()=>{a(``),r(!0)},children:[(0,J.jsx)(ft,{}),`全部话题(`,o.length,`)`]}),(0,J.jsxs)(zk,{disabled:!!l,onClick:e.onCreate,children:[(0,J.jsx)(_t,{}),`新话题`]}),l&&(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-muted-foreground text-xs`,children:l})]})]}),(0,J.jsx)(K7,{open:n,onOpenChange:r,children:(0,J.jsxs)(q7,{side:`bottom`,className:`max-h-[80vh] pb-safe`,children:[(0,J.jsx)(J7,{children:(0,J.jsxs)(Y7,{children:[`全部话题(`,o.length,`)`]})}),(0,J.jsx)(`div`,{className:`px-4 pb-2`,children:(0,J.jsx)(G7,{value:i,placeholder:`搜索话题…`,onChange:e=>a(e.target.value)})}),l&&(0,J.jsx)(`p`,{className:`px-4 pb-2 text-muted-foreground text-xs`,children:l}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-3`,children:[p.map(e=>(0,J.jsxs)(`button`,{type:`button`,disabled:!!l&&e.id!==s,onClick:()=>{m(e.id),r(!1)},className:`flex w-full items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-accent disabled:opacity-60`,children:[(0,J.jsx)(De,{className:q(`h-4 w-4 shrink-0`,e.id!==s&&`invisible`)}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`block truncate text-sm`,children:e.title}),e.preview&&(0,J.jsx)(`span`,{className:`block truncate text-muted-foreground text-xs`,children:e.preview})]}),(0,J.jsx)(Z7,{entry:e})]},e.id)),p.length===0&&(0,J.jsx)(`p`,{className:`py-8 text-center text-muted-foreground text-sm`,children:`没有匹配的话题`})]})]})})]})}var Fle={queued:`排队中`,running:`进行中`,completed:`已完成`,failed:`失败`,canceled:`已取消`,blocked:`卡住了`},Q7=4,Ile=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),Lle={started:{icon:Ie,className:`border-brand/50 text-brand`},blocked:{icon:Ne,className:`border-warning/60 text-warning`},delivered:{icon:Pe,className:`border-success/60 text-success`}};function Rle({entry:e,bots:t}){let n=!!e.taskId,[r,i]=(0,G.useState)(!n),a=(0,J.jsxs)(J.Fragment,{children:[n&&(0,J.jsx)(ke,{"aria-hidden":!0,className:q(`h-3 w-3 shrink-0 transition-transform`,r&&`rotate-90`)}),(0,J.jsxs)(`span`,{className:`font-medium`,children:[t.get(e.from)?.name??`成员`,` → `,t.get(e.to)?.name??`成员`]}),(0,J.jsx)(`span`,{className:q(`rounded px-1.5 py-0.5`,e.state===`running`||e.state===`queued`?`bg-brand/10 text-brand`:e.state===`failed`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`),children:Fle[e.state]})]});return(0,J.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2 text-xs`,children:[n?(0,J.jsx)(`button`,{type:`button`,"aria-expanded":r,"aria-label":r?`收起委派结果`:`展开委派结果`,className:`flex w-full items-center gap-1.5 text-left`,onClick:()=>i(e=>!e),children:a}):(0,J.jsx)(`p`,{className:`flex items-center gap-1.5`,children:a}),r&&e.summary&&(0,J.jsx)(`p`,{className:`mt-1 line-clamp-3 text-muted-foreground`,children:e.summary})]})}function $7(e,t){let n=[...t].sort((e,t)=>t.length-e.length),r=[],i=e,a=0;for(;i;){let e=i.indexOf(`@`),t=e<0?void 0:n.find(t=>i.startsWith(t,e+1));if(e<0||!t){r.push(i);break}e>0&&r.push(i.slice(0,e)),r.push((0,J.jsxs)(`span`,{className:`font-medium text-brand`,children:[`@`,t]},a++)),i=i.slice(e+1+t.length)}return r}function zle(e){let{chat:t,bots:n,timeline:r,state:i}=e,a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useRef)(null),c=(0,G.useRef)(!0),l=(0,G.useRef)(null),u=(0,G.useRef)(null),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(0),[h,g]=(0,G.useState)([]),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(null),x=r?.entries??[],S=t.epochSeq??x.findLast(e=>e.kind===`system`&&e.newConversation)?.seq??0,[C,w]=(0,G.useState)(!1);(0,G.useEffect)(()=>w(!1),[t.id,S]);let T=S>0&&!C,E=co(x,S,C),D=Cle(x,S),O=t.members.map(e=>n.get(e)).filter(e=>!!(e&&!e.archived)),k=O.map(e=>e.name),A=!!i?.current||t.status!==`idle`,j=fo(d,p),M=j?mo(j.query,O):[],N=E[0]?.seq,P=E.at(-1)?.seq;(0,G.useLayoutEffect)(()=>{let e=a.current;if(!e)return;let t=s.current;t?(s.current=null,e.scrollTop=t.top+(e.scrollHeight-t.height)):c.current&&(e.scrollTop=e.scrollHeight)},[N,P,i?.current,e.activities.length]);let F=()=>{let t=a.current;!r?.hasOlder||!t||e.historyLoading||e.connState!==`online`||T&&(x[0]?.seq??S)<=S||(s.current={height:t.scrollHeight,top:t.scrollTop},e.onLoadOlder())},I=e=>{if(!j)return;let t=ho(d,j,p,e.name);f(t.text),m(t.caret),requestAnimationFrame(()=>{o.current?.focus(),o.current?.setSelectionRange(t.caret,t.caret)})},L=(0,G.useRef)(h);L.current=h,(0,G.useEffect)(()=>()=>{for(let e of L.current)URL.revokeObjectURL(e.url)},[]);let R=e=>{let t=[...e??[]].filter(e=>e.type.startsWith(`image/`)).slice(0,Q7-h.length).map(e=>({file:e,url:URL.createObjectURL(e)}));g(e=>[...e,...t]),b(null)},z=e=>{URL.revokeObjectURL(e),g(t=>t.filter(t=>t.url!==e))},B=async()=>{if(!d.trim()&&h.length===0||_||e.newSessionBusy)return;let t=[];if(h.length){v(!0);try{t=await ile(h.map(e=>e.file))}catch(e){b(e instanceof Error?e.message:`图片处理失败`);return}finally{v(!1)}}e.onSend(d,t);for(let e of h)URL.revokeObjectURL(e.url);g([]),b(null),f(``),m(0),c.current=!0},V=e=>{let t=o.current,n=t?.selectionStart??d.length,r=t?.selectionEnd??d.length,i=d.slice(0,n)+e+d.slice(r);f(i),m(n+e.length),requestAnimationFrame(()=>{t?.focus(),t?.setSelectionRange(n+e.length,n+e.length)})},ee=t=>{switch(t.kind){case`human`:return(0,J.jsxs)(`div`,{className:`flex flex-col items-end`,children:[t.text&&(0,J.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-brand/10 px-3 py-2 text-sm`,children:[$7(t.text,k),t.truncated&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`消息过长,仅显示部分内容`})]}),t.images?.length?(0,J.jsx)(Qi,{target:{chatId:e.chat.id,entryId:t.id}}):null]},t.seq);case`bot`:{let r=n.get(t.botId);return(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(La,{bot:r,size:`sm`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`p`,{className:`flex items-baseline gap-1.5 text-xs`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:r?.name??`成员`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:Ile(t.at)})]}),(0,J.jsxs)(`div`,{className:`mt-0.5 min-w-0 text-sm`,children:[(0,J.jsx)(I5,{text:t.text}),t.truncated&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`消息过长,仅显示部分内容`})]}),(0,J.jsx)(Qi,{target:{chatId:e.chat.id,entryId:t.id}}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>e.onOpenProcess(t.conversationId),className:`mt-0.5 flex items-center gap-0.5 text-muted-foreground text-xs hover:text-foreground`,children:[(0,J.jsx)(ke,{className:`h-3 w-3`}),`查看过程`]})]})]},t.seq)}case`delegation`:return(0,J.jsx)(Rle,{entry:t,bots:n},t.seq);case`progress`:{let e=n.get(t.botId),r=Lle[t.phase],i=r.icon,a=wle(t.text,t.taskSeq);return(0,J.jsxs)(`div`,{"data-phase":t.phase,className:`flex gap-2 text-xs`,children:[(0,J.jsx)(La,{bot:e,size:`sm`}),(0,J.jsxs)(`div`,{className:q(`flex min-w-0 items-start gap-1.5 rounded-md border-l-2 bg-muted/50 px-2 py-1`,r.className),children:[(0,J.jsx)(i,{"aria-hidden":!0,className:`mt-px h-3.5 w-3.5 shrink-0`}),(0,J.jsxs)(`p`,{className:`line-clamp-2 min-w-0 break-words text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.name??`成员`}),` `,a?(0,J.jsxs)(J.Fragment,{children:[$7(a[0],k),(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:a[1]}),$7(a[2],k)]}):$7(t.text,k)]})]})]},t.seq)}case`system`:return(0,J.jsxs)(`p`,{className:`text-center text-muted-foreground text-xs`,children:[t.text,D.has(t.id)&&e.onRetry&&!e.deviceReadOnly&&(0,J.jsx)(`button`,{type:`button`,className:`ml-2 underline disabled:opacity-50`,disabled:A||e.connState!==`online`,onClick:()=>e.onRetry?.(t.id),children:`重试`})]},t.seq)}},H=i?.current?n.get(i.current):void 0;return(0,J.jsxs)(`div`,{className:`phone-chat-root flex h-full min-h-0 flex-col`,children:[(0,J.jsxs)(`header`,{className:`flex shrink-0 items-center gap-1 border-b bg-background px-2 py-2 pt-safe`,children:[e.drawerDocked?(0,J.jsx)(`span`,{className:`h-9 w-9 shrink-0`}):(0,J.jsx)(`button`,{type:`button`,onClick:e.onOpenDrawer,"aria-label":`打开会话列表`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,J.jsx)(Dt,{className:`h-4.5 w-4.5`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 text-center`,children:[(0,J.jsx)(`p`,{className:`truncate font-medium text-sm`,children:t.title||`群聊`}),e.threads?(0,J.jsx)(Ple,{threads:e.threads,status:e.connState===`online`?void 0:e.stateLabel}):(0,J.jsx)(`p`,{className:`truncate text-[11px] text-muted-foreground`,children:e.connState===`online`?`${t.members.length} 位成员`:e.stateLabel})]}),e.threads?(0,J.jsx)(`button`,{type:`button`,onClick:e.threads.onCreate,disabled:!!e.threads.disabledHint,"aria-label":`新话题`,title:e.threads.disabledHint??`新话题`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,children:(0,J.jsx)(Jt,{className:`h-4.5 w-4.5`})}):(0,J.jsx)(`button`,{type:`button`,onClick:e.onNewSession,disabled:!e.canCreate||e.deviceReadOnly||_||e.connState!==`online`,"aria-label":`新建会话`,title:e.newSessionHint??`新建会话`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,children:(0,J.jsx)(Jt,{className:`h-4.5 w-4.5`})})]}),(0,J.jsxs)(`div`,{ref:a,onScroll:e=>{let t=e.currentTarget;c.current=t.scrollHeight-t.scrollTop-t.clientHeight<40,t.scrollTop<60&&F()},className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-3 py-3`,children:[r===void 0?(0,J.jsxs)(`p`,{className:`flex items-center justify-center gap-1.5 py-8 text-muted-foreground text-sm`,children:[(0,J.jsx)(pt,{className:`h-4 w-4 animate-spin`}),`读取中…`]}):r.hasOlder&&(!T||(x[0]?.seq??S)>S)?(0,J.jsx)(`button`,{type:`button`,onClick:F,disabled:e.historyLoading||e.connState!==`online`,className:`w-full py-1 text-center text-muted-foreground text-xs`,children:e.historyLoading?`加载中…`:`加载更早的消息`}):E.length===0?(0,J.jsx)(`p`,{className:`py-8 text-center text-muted-foreground text-sm`,children:`@ 成员开始对话,未 @ 时由群主回复`}):null,S>0&&(0,J.jsx)(`button`,{type:`button`,className:`w-full py-1 text-center text-muted-foreground text-xs`,onClick:()=>{w(!C),C&&r?.history?e.onJumpLatest?.():!C&&r?.hasOlder&&!x.some(e=>e.seq<S)&&e.onLoadOlder()},children:T?`更早的对话 · ${S-1} 条`:`收起更早的对话`}),r?.history&&(0,J.jsx)(`button`,{type:`button`,className:`w-full py-1 text-center text-brand text-xs`,onClick:()=>{c.current=!0,e.onJumpLatest?.()},children:`回到最新消息`}),E.map(ee),e.activities.map(t=>(0,J.jsx)(Ele,{item:t,bots:n,clockOffset:e.clockOffset,onOpen:e.onOpenProcess},t.conversationId)),H&&e.activities.length===0&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(La,{bot:H,size:`sm`,busy:!0}),(0,J.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[H.name,` 正在回复…`]})]})]}),(0,J.jsxs)(`div`,{className:`phone-dock shrink-0 space-y-2 px-3 pt-1 pb-safe`,children:[e.outbox,e.notice&&(0,J.jsx)(`p`,{className:`rounded-md bg-destructive/10 px-2 py-1 text-destructive text-xs`,children:e.notice}),e.deviceReadOnly&&(0,J.jsx)(`p`,{className:`rounded-md bg-muted px-2 py-1 text-center text-muted-foreground text-xs`,children:z7(e.readOnlyRejected)}),!e.deviceReadOnly&&e.pending.map(({sessionId:t,botId:r,view:i})=>i.approvals.length>0||i.asks.length>0?(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n.get(r)?.name??`成员`}),(0,J.jsx)(Eg,{approvals:i.approvals,clockOffset:e.clockOffset,onRespond:(n,r)=>e.onApproval(t,n,r)}),(0,J.jsx)(Dg,{asks:i.asks,clockOffset:e.clockOffset,onAnswer:(n,r)=>e.onAsk(t,n,r),autoFocus:!1})]},t):null),(0,J.jsxs)(`div`,{className:q(`relative`,e.deviceReadOnly&&`hidden`),children:[M.length>0&&(0,J.jsx)(`div`,{className:`absolute right-0 bottom-full left-0 mb-1 max-h-48 overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`,children:M.map(e=>{let t=n.get(e.id);return(0,J.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>I(e),className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-accent`,children:[t?(0,J.jsx)(La,{bot:t,size:`sm`}):(0,J.jsx)(`span`,{className:`flex h-7 w-7 items-center justify-center rounded-full bg-muted text-xs`,children:`@`}),(0,J.jsx)(`span`,{className:`font-medium`,children:e.name}),t?.title&&(0,J.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:t.title})]},e.id)})}),y&&(0,J.jsx)(`p`,{className:`mb-1 text-destructive text-xs`,children:y}),h.length>0&&(0,J.jsx)(`div`,{className:`mb-1.5 flex gap-1.5`,children:h.map(e=>(0,J.jsxs)(`div`,{className:`relative h-14 w-14 overflow-hidden rounded-lg border`,children:[(0,J.jsx)(`img`,{src:e.url,alt:``,className:`h-full w-full object-cover`}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`移除图片`,onClick:()=>z(e.url),className:`absolute top-0.5 right-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-black/60 text-white`,children:(0,J.jsx)(sn,{className:`h-3 w-3`})})]},e.url))}),(0,J.jsxs)(`div`,{ref:u,className:`flex items-end gap-2 rounded-2xl border bg-background px-3 py-2`,children:[(0,J.jsx)(`input`,{ref:l,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,onChange:e=>{R(e.target.files),e.target.value=``}}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`添加图片`,disabled:h.length>=Q7,onClick:()=>l.current?.click(),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-muted-foreground disabled:opacity-40`,children:(0,J.jsx)(ot,{className:`h-4.5 w-4.5`})}),e.voice&&(0,J.jsx)(`span`,{className:`flex h-8 shrink-0 items-center justify-center [&>div>button]:h-8 [&>div>button]:min-w-8 [&>div>button]:rounded-full`,children:(0,J.jsx)(lD,{startSession:e.voice,disabled:_,holdScope:u,onText:V})}),(0,J.jsx)(`textarea`,{ref:o,rows:1,value:d,placeholder:`@ 成员,或直接说…`,onChange:e=>{f(e.target.value),m(e.target.selectionStart??e.target.value.length)},onSelect:e=>m(e.currentTarget.selectionStart??0),className:`max-h-32 min-h-6 flex-1 resize-none bg-transparent text-sm outline-none field-sizing-content`}),A&&(0,J.jsx)(`button`,{type:`button`,"aria-label":`停止`,onClick:e.onStop,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-foreground`,children:(0,J.jsx)(Qt,{className:`h-3.5 w-3.5 fill-current`})}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`发送`,disabled:!d.trim()&&h.length===0||_||e.newSessionBusy||!e.outbox&&e.connState!==`online`,onClick:()=>void B(),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-brand text-brand-foreground disabled:opacity-40`,children:(0,J.jsx)(be,{className:`h-4 w-4`})})]})]})]})]})}var e9=e=>typeof window.matchMedia==`function`&&window.matchMedia(e).matches;function Ble(e){return(0,G.useSyncExternalStore)(t=>{if(typeof window.matchMedia!=`function`)return()=>{};let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},()=>e9(e),()=>e9(e))}var Vle=`(min-width: 900px)`;function Hle(e){let t=G.useRef(!0);t.current&&(t.current=!1,e())}var t9=G.createContext(null);function n9(){let e=G.useContext(t9);if(e===null)throw Error(En(60));return e}var Ule=(e,t)=>Object.is(e,t);function r9(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function i9(e,t,n){return!e||e.length===0?-1:e.findIndex(e=>e!==void 0&&r9(e,t,n))}function Wle(e,t,n){return e.filter(e=>!r9(t,e,n))}function a9(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function o9(e){return e!=null&&e.length>0&&typeof e[0]==`object`&&e[0]!=null&&`items`in e[0]}function Gle(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(o9(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function s9(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return a9(e)}function c9(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?a9(e.value):a9(e)}function l9(e,t,n){function r(){return s9(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){let n=t,i=o9(n)?n.flatMap(e=>e.items):n;if(typeof e!=`object`||!e){let t=i.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=i.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function Kle(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,J.jsx)(G.Fragment,{children:l9(r,t,n)},i)),e),[])}var u9={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:c9(t,r)!==``},hasNullItemLabel:(e,t)=>t?Gle(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>r9(t,e,n)):r9(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function qle(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:y=!1,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S=Ule,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=Zk(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=Jk(),F=tA({id:t}),I=M||d,L=j??c,[R,z]=xO({controlled:n,default:y?r??zn:r,name:`Select`,state:`value`}),[B,V]=xO({controlled:a,default:o,name:`Select`,state:`open`}),ee=G.useRef([]),H=G.useRef([]),U=G.useRef(null),W=G.useRef(null),te=G.useRef(0),ne=G.useRef(null),re=G.useRef([]),ie=G.useRef(!1),ae=G.useRef(null),oe=G.useRef(null),se=G.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ce=G.useRef(!1),{mounted:le,setMounted:ue,transitionStatus:de}=OC(B),{openMethod:fe,triggerProps:pe}=cT(B),me=On(()=>new wC({id:F,labelId:void 0,modal:m,multiple:y,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,value:R,open:B,mounted:le,transitionStatus:de,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,he=yC(me,u9.activeIndex),ge=yC(me,u9.selectedIndex),K=yC(me,u9.triggerElement),_e=yC(me,u9.positionerElement),ve=gk(fe),ye=fe??ve,be=G.useMemo(()=>y?``:c9(R,x),[y,R,x]),xe=G.useMemo(()=>y&&Array.isArray(R)?R.map(e=>c9(e,x)):c9(R,x),[y,R,x]);Yk(Jy(K),F,R,xv(()=>xe),!I,c);let Se=G.useRef(R),Ce=y?Array.isArray(R)&&R.length>0:R!=null&&be!==``;Z(()=>{A(Ce)},[Ce,A]),Z(function(){let e=R,t=!1;if(y){let n=Array.isArray(R)?R:[];t=n.length===0,e=n[n.length-1]}let n=t?-1:i9(re.current,e,S),r=n===-1?null:n;r===null&&(oe.current=null),!B&&me.set(`selectedIndex`,r)},[y,B,R,S,me]);function we(e){let t=k.initialValue;return Array.isArray(e)&&Array.isArray(t)?!Hk(e,t,(e,t)=>r9(e,t,S)):e!==t}oT(R,()=>{T(L),E(we(R)),N.change(R)});let Te=xv((e,t)=>{s?.(e,t),!t.isCanceled&&(V(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(D(!0),O(!1),P===`onBlur`&&N.commit(R)))}),Ee=xv(()=>{ue(!1),me.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)});AC({enabled:!h,open:B,ref:U,onComplete(){B||Ee()}}),G.useImperativeHandle(h,()=>({unmount:Ee}),[Ee]);let De=xv((e,t)=>{i?.(e,t),!t.isCanceled&&z(e)}),Oe=xv(e=>{let t=AT(e.scrollHeight,e.clientHeight),n=jT(e.scrollTop,t),r=n>0,i=n<t;me.set(`scrollUpArrowVisible`,r),me.set(`scrollDownArrowVisible`,i)}),ke=tw({open:B,onOpenChange:Te,elements:{reference:K,floating:_e}}),Ae=Vx(ke,{enabled:!f&&!I,event:`mousedown`}),je=Wx(ke),Me=xw(ke,{enabled:!f&&!I,listRef:ee,activeIndex:he,selectedIndex:ge,disabledIndices:zn,onNavigate(e){e===null&&!B||me.set(`activeIndex`,e)},focusItemOnHover:C}),Ne=Sw(ke,{enabled:!f&&!I&&(B||!y),listRef:H,activeIndex:he,selectedIndex:ge,disabledIndices:e=>Mk(ee.current[e]),onMatch(e){B?me.set(`activeIndex`,e):De(re.current[e],Kv(Mv))},onTyping(e){ie.current=e}}),Pe=G.useMemo(()=>dn(Ne.reference,Me.reference,je.reference,Ae.reference,pe),[Ae.reference,Ne.reference,Me.reference,je.reference,pe]),Fe=G.useMemo(()=>dn(jC,Ne.floating,Me.floating,je.floating),[Ne.floating,Me.floating,je.floating]),Ie=Me.item??Bn;Hle(()=>{me.update({popupProps:Fe,triggerProps:Pe})}),me.useSyncedValues({id:F,modal:m,multiple:y,value:R,open:B,mounted:le,transitionStatus:de,popupProps:Fe,triggerProps:Pe,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:ye});let Le=G.useMemo(()=>({store:me,floatingContext:ke,required:p,disabled:I,readOnly:f,multiple:y,highlightItemOnHover:C,setValue:De,setOpen:Te,listRef:ee,popupRef:U,scrollHandlerRef:W,handleScrollArrowVisibility:Oe,scrollArrowsMountedCountRef:te,itemProps:Ie,valueRef:ne,valuesRef:re,labelsRef:H,typingRef:ie,selectionRef:se,firstItemTextRef:ae,selectedItemTextRef:oe,validation:N,onOpenChangeComplete:_,alignItemWithTriggerActiveRef:ce,initialValueRef:Se}),[me,ke,p,I,f,y,C,De,Te,Ie,N,_,Oe]),Re=kn(g,N.inputRef),ze=y?void 0:L,Be=G.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=c9(e,x);return(0,J.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,J.jsxs)(t9.Provider,{value:Le,children:[w,(0,J.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){me.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=Kv(Mv,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=re.current.findIndex(t=>c9(t,x).toLowerCase()===e||s9(t,b).toLowerCase()===e);r===-1&&(r=re.current.findIndex((t,n)=>{let r=H.current[n];return r!=null&&r.toLowerCase()===e}));let i=re.current[r];i!=null&&De(i,n)}me.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&ze==null?`${F}-hidden-input`:void 0,form:l,name:ze,autoComplete:u,value:be,disabled:I,required:p&&!(y&&Ce),readOnly:f,ref:Re,style:L?nb:tb,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Be]})}var Jle=400,Yle={...q_,...Gk,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},Xle=G.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,setFocused:u,validationMode:d,state:f,disabled:p}=Jk(),{labelId:m}=$k(),{store:h,setOpen:g,selectionRef:_,validation:v,readOnly:y,required:b,alignItemWithTriggerActiveRef:x,disabled:S}=n9(),C=p||S||a,w=yC(h,u9.open),T=yC(h,u9.mounted),E=yC(h,u9.value),D=yC(h,u9.triggerProps),O=yC(h,u9.positionerElement),k=yC(h,u9.listElement),A=yC(h,u9.popupSide),j=yC(h,u9.id),M=yC(h,u9.labelId),N=yC(h,u9.hasSelectedValue),P=T&&O?A:null,F=i??j,I=eA(m,M);tA({id:F});let L=Jy(O),R=G.useRef(null),{getButtonProps:z,buttonRef:B}=kv({disabled:C,native:o}),V=h.useStateSetter(`triggerElement`),ee=ry(),H=ry(),U=ry();G.useEffect(()=>{if(w)return U.start(Jle,()=>{_.current.allowUnselectedMouseUp=!0,_.current.allowSelectedMouseUp=!0}),()=>{U.clear()};_.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},H.clear()},[w,_,H,U]);let W=dn(D,{id:F,role:`combobox`,"aria-expanded":w,"aria-haspopup":`listbox`,"aria-controls":w?k?.id??By(O)?.id:void 0,"aria-labelledby":I,"aria-readonly":y||void 0,"aria-required":b||void 0,tabIndex:C?-1:0,onFocus(e){u(!0),w&&x.current&&g(!1,Kv(Mv,e.nativeEvent)),ee.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){jy(O,e.relatedTarget)||(l(!0),u(!1),d===`onBlur`&&v.commit(E))},onMouseDown(e){if(w)return;let t=Dv(e.currentTarget);function n(e){if(!R.current)return;let t=e.target;jy(R.current,t)||jy(L.current,t)||ok(e,R.current)||g(!1,Kv(Hv,e))}H.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,z),te=v.getValidationProps(C,W);te.role=`combobox`;let ne={...f,open:w,disabled:C,value:E,readOnly:y,popupSide:P,placeholder:!N};return Wn(`button`,e,{ref:[t,R,B,V],state:ne,stateAttributesMapping:Yle,props:te})}),Zle={value:()=>null},Qle=G.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,{store:c,valueRef:l}=n9(),u=yC(c,u9.value),d=yC(c,u9.items),f=yC(c,u9.itemToStringLabel),p=yC(c,u9.hasSelectedValue),m=!p&&a!=null&&i==null,h=yC(c,u9.hasNullItemLabel,m),g={value:u,placeholder:!p},_=null;return _=typeof i==`function`?i(u):i??(m&&!h?a:Array.isArray(u)?Kle(u,d,f):l9(u,d,f)),Wn(`span`,e,{state:g,ref:[t,l],props:[{children:_},s],stateAttributesMapping:Zle})}),$le=G.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{store:o}=n9();return Wn(`span`,e,{state:{open:yC(o,u9.open)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:K_})}),eue=G.forwardRef(function(e,t){let{store:n}=n9(),r=yC(n,u9.mounted),i=yC(n,u9.forceMount);return r||i?(0,J.jsx)(xx,{ref:t,...e}):null}),d9=G.createContext(void 0);function f9(){let e=G.useContext(d9);if(!e)throw Error(En(59));return e}function p9(e,t){e&&Object.assign(e.style,t)}var m9={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},tue={position:`fixed`},nue=G.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=mx,style:_,...v}=e,{store:y,listRef:b,labelsRef:x,alignItemWithTriggerActiveRef:S,selectedItemTextRef:C,valuesRef:w,initialValueRef:T,popupRef:E,setValue:D,floatingContext:O}=n9(),k=yC(y,u9.open),A=yC(y,u9.mounted),j=yC(y,u9.modal),M=yC(y,u9.value),N=yC(y,u9.openMethod),P=yC(y,u9.positionerElement),F=yC(y,u9.triggerElement),I=yC(y,u9.isItemEqualToValue),L=yC(y,u9.transitionStatus),R=G.useRef(null),z=G.useRef(null),[B,V]=G.useState(h),ee=A&&B&&N!==`touch`;!A&&B!==h&&V(h),G.useImperativeHandle(S,()=>ee),qO((ee||j)&&k,N===`touch`,P,F);let H=TE({anchor:n,floatingRootContext:O,positionMethod:a,mounted:A,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??ee,collisionAvoidance:g,keepMounted:!0}),U=ee?`none`:H.side,W=ee?tue:H.positionerStyles,te={open:k,side:U,align:H.align,anchorHidden:H.anchorHidden};Z(()=>{y.set(`popupSide`,H.side)},[y,H.side]);let ne=OE(e,te,{styles:W,transitionStatus:L,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!A,inert:!k}),re=G.useRef(0),ie=xv(e=>{if(w.current.length===0)return;let t=re.current;if(re.current=e.size,e.size===t)return;let n=Kv(Mv);if(t!==0&&!y.state.multiple&&M!==null&&i9(w.current,M,I)===-1){let e=T.current,t=e!=null&&i9(w.current,e,I)!==-1?e:null;D(t,n),t===null&&(y.set(`selectedIndex`,null),C.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(M)){let e=M.filter(e=>i9(w.current,e,I)!==-1);e.length!==M.length&&(D(e,n),e.length===0&&(y.set(`selectedIndex`,null),C.current=null))}if(k&&ee){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};p9(P,e),p9(E.current,e)}}),ae=G.useMemo(()=>({...H,side:U,alignItemWithTriggerActive:ee,setControlledAlignItemWithTrigger:V,scrollUpArrowRef:R,scrollDownArrowRef:z}),[H,U,ee,V]);return(0,J.jsx)(zO,{elementsRef:b,labelsRef:x,onMapChange:ie,children:(0,J.jsxs)(d9.Provider,{value:ae,children:[A&&j&&(0,J.jsx)(Lw,{inert:Iw(!k),cutout:F}),ne]})})}),rue={...J_,...G_},iue=G.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s,popupRef:c,onOpenChangeComplete:l,setOpen:u,valueRef:d,firstItemTextRef:f,selectedItemTextRef:p,multiple:m,handleScrollArrowVisibility:h,scrollHandlerRef:g,listRef:_,highlightItemOnHover:v,floatingContext:y}=n9(),{side:b,align:x,alignItemWithTriggerActive:S,isPositioned:C,setControlledAlignItemWithTrigger:w}=f9(),T=PO(!0)!=null,E=OT(),{nonce:D,disableStyleElements:O}=yT(),k=yC(s,u9.id),A=yC(s,u9.open),j=yC(s,u9.openMethod),M=yC(s,u9.mounted),N=yC(s,u9.popupProps),P=yC(s,u9.transitionStatus),F=yC(s,u9.triggerElement),I=yC(s,u9.positionerElement),L=yC(s,u9.listElement),R=G.useRef(!1),z=G.useRef(!1),B=G.useRef({}),V=$y(),ee=xv(e=>{if(!I||!c.current||!z.current)return;let t=I.style.top===`0px`,n=I.style.bottom===`0px`;if(R.current||!S||!t&&!n){h(e);return}let r=_9(I),i=v9(I.getBoundingClientRect().height,`y`,r),a=Dv(I),o=$_(I),s=o.getComputedStyle(I),l=parseFloat(s.marginTop),u=parseFloat(s.marginBottom),d=h9(o.getComputedStyle(c.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,m=g9(e),g=null,_=e=>{I.style.height=`${e}px`},v=t?m-p:p,y=Math.min(i+v,f);if(v<=1){let n=kT(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?m:0,f-(i+n)<=1&&(R.current=!0),h(e);return}f-y>1?g=t?1/0:0:n&&p<m&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=kT(g,0,g9(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(R.current=!0),h(e)});G.useImperativeHandle(g,()=>ee,[ee]),AC({open:A,ref:c,onComplete(){A&&l?.(!0)}});let H={open:A,transitionStatus:P,side:b,align:x};Z(()=>{!I||!c.current||Object.keys(B.current).length||(B.current={top:I.style.top||`0`,left:I.style.left||`0`,right:I.style.right,height:I.style.height,bottom:I.style.bottom,minHeight:I.style.minHeight,maxHeight:I.style.maxHeight,marginTop:I.style.marginTop,marginBottom:I.style.marginBottom})},[c,I]),Z(()=>{A||S||(z.current=!1,R.current=!1,p9(I,B.current))},[A,S,I,c]),Z(()=>{let e=c.current;if(!A||!F||!I||!e||S&&!C||s.state.transitionStatus===`ending`)return;if(z.current=!0,e.style.removeProperty(`--transform-origin`),!S){V.request(()=>h(L||e));return}let t=aue(e);try{let t=p.current;t?.isConnected||(t=!u9.hasSelectedValue(s.state)&&f.current?.isConnected?f.current:null);let n=d.current,r=$_(I),i=r.getComputedStyle(I),a=r.getComputedStyle(e),o=Dv(F),c=_9(F),l=y9(F.getBoundingClientRect(),c),u=y9(I.getBoundingClientRect(),c),m=l.height,g=L||e,y=g.scrollHeight,b=parseFloat(a.borderBottomWidth),x=parseFloat(i.marginTop)||10,S=parseFloat(i.marginBottom)||10,C=parseFloat(i.minHeight)||100,T=h9(a),D=o.documentElement.clientHeight-x-S,O=o.documentElement.clientWidth,k=D-l.bottom+m,A,j=E===`rtl`?l.right-u.width:l.left,M=0;if(t&&n){let e=y9(n.getBoundingClientRect(),c);A=y9(t.getBoundingClientRect(),c),j=u.left+(E===`rtl`?e.right-A.right:e.left-A.left);let r=e.top-l.top+e.height/2;M=A.top-u.top+A.height/2-r}let N=k+M+S+b,P=Math.min(D,N),z=D-x-S,V=N-P,ee=O-5;I.style.left=`${kT(j,5,ee-u.width)}px`,I.style.height=`${P}px`,I.style.maxHeight=`none`,I.style.marginTop=`${x}px`,I.style.marginBottom=`${S}px`,e.style.height=`100%`;let H=g9(g),U=V>=H-1;U&&(P=Math.min(D,u.height)-(V-H));let W=l.top<20||l.bottom>D-20||Math.ceil(P)+1<Math.min(y,C),te=(r.visualViewport?.scale??1)!==1&&hy;if(W||te){p9(I,B.current),w(!1);return}let ne=Math.max(C,P);if(U){let e=Math.max(0,D-N);I.style.top=u.height>=z?`0`:`${e}px`,I.style.height=`${P}px`,g.scrollTop=g9(g)}else I.style.bottom=`0`,g.scrollTop=V;if(A){let t=u.top,n=u.height,r=A.top+A.height/2,i=kT(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(`--transform-origin`,`50% ${i}%`)}(ne===D||P>=T)&&(R.current=!0),h(g),v&&s.state.selectedIndex===null&&s.state.activeIndex===null&&_.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,A,I,F,d,f,p,c,h,S,w,V,L,_,v,E,C]),G.useEffect(()=>{if(!S||!I||!A)return;let e=$_(I);function t(e){u(!1,Kv(Gv,e))}return Ky(e,`resize`,t)},[u,S,I,A]);let U={...L?{role:`presentation`,"aria-orientation":void 0}:{role:`listbox`,"aria-multiselectable":m||void 0,id:`${k}-list`},onKeyDown(e){T&&Nw.has(e.key)&&e.stopPropagation()},onScroll(e){L||ee(e.currentTarget)},...S&&{style:L?{height:`100%`}:m9},className:!L&&S?mT.className:void 0},W=Wn(`div`,e,{ref:[t,c],state:H,stateAttributesMapping:rue,props:[N,U,DE(P),o]});return(0,J.jsxs)(G.Fragment,{children:[!O&&mT.getElement(D),(0,J.jsx)(Bx,{context:y,modal:!1,disabled:!M,openInteractionType:j,returnFocus:a,restoreFocus:!0,children:W})]})});function h9(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function g9(e){return AT(e.scrollHeight,e.clientHeight)}function _9(e){return DS.getScale(e)}function v9(e,t,n){return e/n[t]}function y9(e,t){return Sb({x:v9(e.x,`x`,t),y:v9(e.y,`y`,t),width:v9(e.width,`x`,t),height:v9(e.height,`y`,t)})}var b9=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function aue(e){let{style:t}=e,n={};for(let[e,r]of b9)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of b9){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var oue=G.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{store:o,scrollHandlerRef:s,multiple:c}=n9(),{alignItemWithTriggerActive:l}=f9(),u=yC(o,u9.hasScrollArrows),d=yC(o,u9.openMethod),f={id:`${yC(o,u9.id)}-list`,role:`listbox`,"aria-multiselectable":c||void 0,onScroll(e){s.current?.(e.currentTarget)},...l&&{style:m9},className:u&&d!==`touch`?mT.className:void 0};return Wn(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),x9=G.createContext(void 0);function S9(){let e=G.useContext(x9);if(!e)throw Error(En(57));return e}var sue=G.memo(G.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=G.useRef(null),d=DO({guess:!0,label:o,textRef:u}),{store:f,itemProps:p,setOpen:m,setValue:h,selectionRef:g,typingRef:_,valuesRef:v,multiple:y,selectedItemTextRef:b,disabled:x,readOnly:S}=n9(),C=x||s,w=yC(f,u9.isActive,d.index),T=yC(f,u9.open),E=yC(f,u9.isSelected,a),D=yC(f,u9.isSelectedByFocus,d.index),O=yC(f,u9.isItemEqualToValue),k=d.index,A=G.useRef(null);Z(()=>{let e=v.current;return e[k]=a,()=>{delete e[k]}},[k,a,v]),Z(()=>{let e=f.state.value,t=e;y&&Array.isArray(e)&&(t=e.length>0?e[e.length-1]:void 0),t!==void 0&&r9(a,t,O)&&(f.set(`selectedIndex`,k),u.current&&(b.current=u.current))},[k,y,O,f,a,b]);let j=G.useRef(`mouse`),M=G.useRef(!1),{getButtonProps:N,buttonRef:P}=kv({disabled:C,focusableWhenDisabled:!0,native:c,composite:!0}),F={disabled:C,selected:E,highlighted:w};function I(e){if(x||S)return;let t=f.state.value;if(y){let n=Array.isArray(t)?t:[],r=E?Wle(n,a,O):[...n,a];h(r,Kv(Lv,e))}else h(a,Kv(Lv,e)),m(!1,Kv(Lv,e))}function L(){g.current.dragY=0}let R={role:`option`,"aria-selected":E,tabIndex:T&&w?0:-1,onKeyDown(e){f.set(`activeIndex`,k),e.key===` `&&_.current&&e.preventDefault()},onClick(e){let t=j.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&by(e.nativeEvent)&&(n!==void 0||w),i=t&&!r&&!M.current;M.current=!1,!(C||i)&&I(e.nativeEvent)},onPointerEnter(e){j.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=g.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){j.current=e.pointerType,M.current=!0,L()},onMouseUp(){if(L(),C||j.current===`touch`||M.current)return;let e=!g.current.allowSelectedMouseUp&&E,t=!g.current.allowUnselectedMouseUp&&!E;e||t||(M.current=!0,A.current?.click(),M.current=!1)}},z=Wn(`div`,e,{ref:[P,t,d.ref,A],state:F,props:[p,R,l,N]}),B=G.useMemo(()=>({selected:E,index:k,textRef:u,selectedByFocus:D}),[E,k,u,D]);return(0,J.jsx)(x9.Provider,{value:B,children:z})})),cue=G.forwardRef(function(e,t){let{selected:n}=S9();return e.keepMounted||n?(0,J.jsx)(lue,{...e,ref:t}):null}),lue=G.memo(G.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=S9(),c=G.useRef(null),{transitionStatus:l,setMounted:u}=OC(s),d=Wn(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:G_});return AC({open:s,ref:c,onComplete(){s||u(!1)}}),d})),uue=G.memo(G.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=S9(),{firstItemTextRef:a,selectedItemTextRef:o}=n9(),{render:s,className:c,style:l,...u}=e;return Wn(`div`,e,{ref:[G.useCallback(e=>{e&&(n===0&&(a.current=e),i&&(o.current=e))},[a,o,n,i]),t,r],props:u})})),C9=G.forwardRef(function(e,t){let{render:n,className:r,style:i,direction:a,keepMounted:o,...s}=e,c=a===`up`,{store:l,popupRef:u,listRef:d,handleScrollArrowVisibility:f,scrollArrowsMountedCountRef:p}=n9(),{side:m,scrollDownArrowRef:h,scrollUpArrowRef:g}=f9(),_=yC(l,c?u9.scrollUpArrowVisible:u9.scrollDownArrowVisible),v=yC(l,u9.openMethod),y=_&&v!==`touch`,b=ry(),x=c?g:h,{mounted:S,transitionStatus:C,setMounted:w}=OC(y);Z(()=>(p.current+=1,l.set(`hasScrollArrows`,!0),()=>{p.current=Math.max(0,p.current-1),p.current===0&&l.set(`hasScrollArrows`,!1)}),[l,p]),AC({open:y,ref:x,onComplete(){y||w(!1)}});let T=Wn(`div`,e,{ref:[t,x],state:{direction:a,visible:y,side:m,transitionStatus:C},props:[{"aria-hidden":!0,children:c?`▲`:`▼`,style:{position:`absolute`},onMouseMove(e){if(e.movementX===0&&e.movementY===0||b.isStarted())return;l.set(`activeIndex`,null);function t(){let e=l.state.listElement??u.current;if(!e)return;l.set(`activeIndex`,null),f(e);let n=AT(e.scrollHeight,e.clientHeight),r=jT(e.scrollTop,n),i=r===(c?0:n),a=d.current;if(r!==e.scrollTop&&(e.scrollTop=r),i){b.clear();return}if(a.length>0){let t=x.current?.offsetHeight||0;e.scrollTop=due(a,c,r,e.clientHeight,t,n)}b.start(40,t)}b.start(40,t)},onMouseLeave(){b.clear()}},s],stateAttributesMapping:G_});return S||o?T:null});function due(e,t,n,r,i,a){if(t){let t=0,r=n+i-1;for(let n=0;n<e.length;n+=1){let i=e[n];if(i&&i.offsetTop>=r){t=n;break}}let o=Math.max(0,t-1),s=e[o];return o<t&&s?jT(s.offsetTop-i,a):0}let o=e.length-1,s=n+r-i+1;for(let t=0;t<e.length;t+=1){let n=e[t];if(n&&n.offsetTop+n.offsetHeight>s){o=Math.max(0,t-1);break}}let c=Math.min(e.length-1,o+1),l=e[c];return c>o&&l?jT(l.offsetTop+l.offsetHeight-r+i,a):a}var fue=G.forwardRef(function(e,t){return(0,J.jsx)(C9,{...e,ref:t,direction:`down`})}),pue=G.forwardRef(function(e,t){return(0,J.jsx)(C9,{...e,ref:t,direction:`up`})}),w9=qle;function T9({className:e,size:t=`default`,children:n,...r}){return(0,J.jsxs)(Xle,{className:q(`relative inline-flex min-h-9 w-full min-w-36 select-none items-center justify-between gap-2 rounded-lg border border-input bg-background bg-clip-padding px-[calc(--spacing(3)-1px)] text-left text-base shadow-xs outline-none ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-data-disabled:not-focus-visible:not-aria-invalid:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 focus-visible:border-ring focus-visible:ring-[3px] aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/16 data-disabled:pointer-events-none data-disabled:opacity-64 sm:min-h-8 sm:text-sm dark:bg-input/32 dark:not-in-data-[slot=group]:bg-clip-border dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-focus-visible:not-aria-invalid:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/8%)] [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0 [[data-disabled],:focus-visible,[aria-invalid],[data-pressed]]:shadow-none`,t===`sm`&&`min-h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] sm:min-h-7`,t===`lg`&&`min-h-10 sm:min-h-9`,e),"data-slot":`select-trigger`,...r,children:[n,(0,J.jsx)($le,{"data-slot":`select-icon`,children:(0,J.jsx)(Me,{className:`-me-1 size-4.5 opacity-80 sm:size-4`})})]})}function E9({className:e,...t}){return(0,J.jsx)(Qle,{className:q(`flex-1 truncate data-placeholder:text-muted-foreground`,e),"data-slot":`select-value`,...t})}function D9({className:e,children:t,sideOffset:n=4,alignItemWithTrigger:r=!0,zIndex:i,...a}){return(0,J.jsx)(eue,{children:(0,J.jsx)(nue,{alignItemWithTrigger:r,className:`select-none`,style:{zIndex:i??lE.DROPDOWN},"data-slot":`select-positioner`,sideOffset:n,children:(0,J.jsxs)(iue,{className:`origin-(--transform-origin) transition-[scale,opacity] has-data-[side=none]:scale-100 has-data-starting-style:scale-98 has-data-starting-style:opacity-0 has-data-[side=none]:transition-none`,"data-slot":`select-popup`,...a,children:[(0,J.jsx)(pue,{className:`top-0 z-50 flex h-6 w-full cursor-default items-center justify-center before:pointer-events-none before:absolute before:inset-x-px before:top-px before:h-[200%] before:rounded-t-[calc(var(--radius-lg)-1px)] before:bg-linear-to-b before:from-50% before:from-popover`,"data-slot":`select-scroll-up-arrow`,children:(0,J.jsx)(je,{className:`relative size-4.5 sm:size-4`})}),(0,J.jsx)(`span`,{className:`relative block h-full rounded-lg border bg-popover bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-lg dark:not-in-data-[slot=group]:bg-clip-border`,children:(0,J.jsx)(oue,{className:q(`max-h-(--available-height) min-w-(--anchor-width) overflow-y-auto p-1`,e),"data-slot":`select-list`,children:t})}),(0,J.jsx)(fue,{className:`bottom-0 z-50 flex h-6 w-full cursor-default items-center justify-center before:pointer-events-none before:absolute before:inset-x-px before:bottom-px before:h-[200%] before:rounded-b-[calc(var(--radius-lg)-1px)] before:bg-linear-to-t before:from-50% before:from-popover`,"data-slot":`select-scroll-down-arrow`,children:(0,J.jsx)(Oe,{className:`relative size-4.5 sm:size-4`})})]})})})}function O9({className:e,children:t,...n}){return(0,J.jsxs)(sue,{className:q(`grid min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default grid-cols-[1rem_1fr] items-center gap-2 rounded-sm py-1 ps-2 pe-4 text-base outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),"data-slot":`select-item`,...n,children:[(0,J.jsx)(cue,{className:`col-start-1`,children:(0,J.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,height:`24`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:`24`,xmlns:`http://www.w3.org/1500/svg`,children:(0,J.jsx)(`path`,{d:`M5.252 12.7 10.2 18.63 18.748 5.37`})})}),(0,J.jsx)(uue,{className:`col-start-2 min-w-0`,children:t})]})}function mue(e,t,n){return e.find(e=>e.id===t)?.id??e.find(e=>e.id===n)?.id??e[0]?.id??``}var k9={supervised:`受监督(每步确认)`,"auto-edits":`自动接受编辑`,full:`完全放行`,assistant:`助手代审`},A9={minimal:`极低`,low:`低`,medium:`中`,high:`高`,xhigh:`极高`,max:`最高`};function hue({projects:e,providers:t,open:n,preferredProjectId:r,onClose:i,onCreate:a}){let[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(`full`),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(`medium`),[v,y]=(0,G.useState)(n);n!==v&&(y(n),n&&s(null));let b=mue(e,o,r),x=t.find(e=>e.id===c)??t[0]??{id:``,models:[]},S=x.id,C=x.models.find(e=>e.id===u)?.id??x.models[0]?.id??``,w=!!(b&&S&&C);return(0,J.jsx)(K7,{open:n,onOpenChange:e=>!e&&i(),children:(0,J.jsxs)(q7,{side:`bottom`,className:`pb-safe`,children:[(0,J.jsx)(J7,{children:(0,J.jsx)(Y7,{children:`新建会话`})}),(0,J.jsxs)(`div`,{className:`space-y-4 p-4 pt-0`,children:[(0,J.jsx)(j9,{label:`项目`,children:(0,J.jsxs)(w9,{items:e.map(e=>({value:e.id,label:ie(e)})),value:b,onValueChange:e=>s(e),children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:e.map(e=>(0,J.jsx)(O9,{value:e.id,children:ie(e)},e.id))})]})}),(0,J.jsx)(j9,{label:`模型服务`,children:(0,J.jsxs)(w9,{items:t.map(e=>({value:e.id,label:e.name})),value:S,onValueChange:e=>{l(e),d(null)},children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:t.map(e=>(0,J.jsx)(O9,{value:e.id,children:e.name},e.id))})]})}),(0,J.jsx)(j9,{label:`模型`,children:(0,J.jsxs)(w9,{items:x.models.map(e=>({value:e.id,label:e.label??e.id})),value:C,onValueChange:e=>d(e),children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:x.models.map(e=>(0,J.jsx)(O9,{value:e.id,children:e.label??e.id},e.id))})]})}),(0,J.jsx)(j9,{label:`审批模式`,children:(0,J.jsxs)(w9,{items:Object.keys(k9).map(e=>({value:e,label:k9[e]})),value:f,onValueChange:e=>p(e),children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:Object.keys(k9).map(e=>(0,J.jsx)(O9,{value:e,children:k9[e]},e))})]})}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`推理`}),(0,J.jsx)(uA,{checked:m,onCheckedChange:h})]}),m&&(0,J.jsx)(j9,{label:`推理档位`,children:(0,J.jsxs)(w9,{items:Object.keys(A9).map(e=>({value:e,label:A9[e]})),value:g,onValueChange:e=>_(e),children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:Object.keys(A9).map(e=>(0,J.jsx)(O9,{value:e,children:A9[e]},e))})]})}),e.length===0&&(0,J.jsx)(`p`,{className:`text-destructive text-xs`,children:`桌面端还没有项目,请先在桌面添加。`}),e.length>0&&t.length===0&&(0,J.jsx)(`p`,{className:`text-destructive text-xs`,children:`桌面端没有可用的模型服务。`}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,J.jsx)(ji,{variant:`outline`,onClick:i,children:`取消`}),(0,J.jsx)(ji,{disabled:!w,onClick:()=>a({projectId:b,providerId:S,modelId:C,approvalMode:f,...m?{reasoningEnabled:m,thinkingLevel:g}:{}}),children:`创建`})]})]})]})})}function j9({label:e,children:t}){return(0,J.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e}),t]})}var gue={pending:`待发送`,sending:`发送中…`,failed:`发送失败`};function _ue({items:e,readOnly:t,onRetry:n,onDiscard:r}){return e.length===0?null:(0,J.jsx)(`div`,{className:`mb-1 space-y-1`,children:e.map(e=>(0,J.jsxs)(`div`,{className:q(`flex flex-wrap items-center gap-2 rounded-xl border px-2.5 py-1.5 text-xs`,e.status===`failed`?`border-destructive/40 bg-destructive/5`:`bg-muted/40`),children:[(0,J.jsx)(`span`,{className:q(`min-w-0 flex-1`,e.status===`failed`?`whitespace-pre-wrap break-words select-text`:`truncate`),children:e.text||(e.images?.length?`[${e.images.length} 张图片]`:``)}),(0,J.jsxs)(`span`,{className:q(`min-w-0 break-words`,e.status===`failed`?`text-destructive`:`text-muted-foreground`),children:[e.error?.startsWith(`outbox-discard`)?`移除消息`:e.error===`delivery-unconfirmed`?`结果未确认`:gue[e.status],e.status===`failed`&&e.error?`:${dle(e.error)}`:``]}),e.status===`failed`&&!e.error?.startsWith(`outbox-discard`)&&!t&&(0,J.jsx)(`button`,{type:`button`,"aria-label":`重试`,onClick:()=>n(e.deliveryId),className:`shrink-0 rounded p-0.5 text-foreground hover:bg-accent`,children:(0,J.jsx)(Lt,{className:`h-3.5 w-3.5`})}),e.status!==`sending`&&(0,J.jsx)(`button`,{type:`button`,"aria-label":`删除`,disabled:e.error===`outbox-discarding`,onClick:()=>r(e.deliveryId),className:`shrink-0 rounded p-0.5 text-muted-foreground hover:bg-accent`,children:(0,J.jsx)(sn,{className:`h-3.5 w-3.5`})})]},e.deliveryId))})}function vue(){let e=globalThis.BarcodeDetector;if(!e)return null;let t=new e({formats:[`qr_code`]});return{async scan(e){return(await t.detect(e))[0]?.rawValue??null}}}async function yue(){let{default:t}=await Y(async()=>{let{default:t}=await import(`./jsQR-B1eQcpQl.js`).then(t=>e(t.default,1));return{default:t}},__vite__mapDeps([144,1])),n=document.createElement(`canvas`),r=n.getContext(`2d`,{willReadFrequently:!0});return{async scan(e){if(!r||!e.videoWidth)return null;let i=Math.min(1,640/Math.max(e.videoWidth,e.videoHeight));n.width=Math.round(e.videoWidth*i),n.height=Math.round(e.videoHeight*i),r.drawImage(e,0,0,n.width,n.height);let{data:a,width:o,height:s}=r.getImageData(0,0,n.width,n.height);return t(a,o,s,{inversionAttempts:`dontInvert`})?.data??null}}}async function bue(){return vue()??await yue()}function xue(e){try{return _(e),!0}catch{return!1}}function Sue({onPaired:e,autoInvite:t,onCancel:n}){let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(!1),[s,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(!1),f=(0,G.useRef)(null),p=(0,G.useRef)(null),m=()=>{for(let e of p.current?.getTracks()??[])e.stop();p.current=null,d(!1)},h=async t=>{o(!0),l(null);try{let n=_(t),r=/iPhone|iPad|Android/i.exec(navigator.userAgent)?.[0]??`Phone`,i=await c(n.relay,n.publicKey,r);e({pairId:i.pairId,token:i.deviceToken,contentKey:btoa(String.fromCharCode(...i.contentKey)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``),deviceName:r,relayUrl:n.relay,pairedAt:Date.now()})}catch(e){l(e instanceof Error?e.message:String(e))}finally{o(!1)}},g=(0,G.useRef)(!1);(0,G.useEffect)(()=>{!t||g.current||(g.current=!0,h(t))},[t]);let v=(0,G.useRef)(()=>{});v.current=e=>{m(),h(e)};let y=async()=>{l(null);try{p.current=await navigator.mediaDevices.getUserMedia({video:{facingMode:`environment`}}),d(!0)}catch(e){l(window.isSecureContext?e instanceof DOMException&&e.name===`NotAllowedError`?`摄像头权限被拒绝,请在浏览器设置中允许后重试`:`无法访问摄像头,请粘贴配对码`:`扫码需要 HTTPS 环境,请改用粘贴配对码`),d(!1)}};return(0,G.useEffect)(()=>{if(!u)return;let e=f.current,t=p.current;if(!e||!t)return;let n=!1,r=0;return e.srcObject=t,e.muted=!0,(async()=>{try{await e.play();let t=await bue(),i=async()=>{if(!(n||!p.current)){try{let n=await t.scan(e);if(n&&xue(n)){v.current(n);return}}catch{}r=requestAnimationFrame(()=>void i())}};await i()}catch{n||l(`无法开始预览,请粘贴配对码`)}})(),()=>{n=!0,cancelAnimationFrame(r)}},[u]),(0,J.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-5 px-6 pt-safe pb-safe`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 text-center`,children:[(0,J.jsx)(`span`,{className:`mb-2 flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14`,children:(0,J.jsx)(EA,{className:`size-6`})}),(0,J.jsx)(`h1`,{className:`font-medium text-lg`,children:`连接到 EnsoCode`}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`在桌面端「设置 → 手机」生成配对码,扫码或粘贴。`})]}),u?(0,J.jsxs)(`div`,{className:`w-full max-w-sm space-y-2`,children:[(0,J.jsx)(`video`,{ref:f,playsInline:!0,muted:!0,className:`aspect-square w-full rounded-lg bg-black object-cover`}),(0,J.jsx)(ji,{variant:`outline`,className:`w-full`,onClick:m,children:`取消扫码`})]}):(0,J.jsxs)(ji,{className:`w-full max-w-sm`,onClick:()=>void y(),children:[(0,J.jsx)(Ee,{className:`mr-1.5 h-4 w-4`}),`扫描二维码`]}),(0,J.jsxs)(`div`,{className:`flex w-full max-w-sm items-center gap-2`,children:[(0,J.jsx)(G7,{value:r,onChange:e=>i(e.target.value),placeholder:`enso://pair?relay=…`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,className:`font-mono text-xs`}),(0,J.jsx)(ji,{variant:`outline`,className:`shrink-0`,disabled:a||!r.trim(),onClick:()=>void h(r.trim()),children:a?(0,J.jsx)(pt,{className:`h-4 w-4 animate-spin`}):`配对`})]}),s&&(0,J.jsx)(`p`,{className:`max-w-sm text-center text-destructive text-xs`,children:s}),n&&(0,J.jsx)(ji,{variant:`ghost`,className:`w-full max-w-sm`,onClick:n,children:`返回`})]})}function M9(){return window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0}function N9(){return`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window}async function Cue(){if(!(`serviceWorker`in navigator))return null;try{return await navigator.serviceWorker.register(`/sw.js`)}catch{return null}}function wue(e){let t=e+`=`.repeat((4-e.length%4)%4),n=atob(t.replace(/-/g,`+`).replace(/_/g,`/`));return Uint8Array.from(n,e=>e.charCodeAt(0))}function Tue(e){return e===`AbortError`?`service-unreachable`:e===`NotAllowedError`?`permission-denied`:`subscribe-failed`}async function P9(e){if(!N9())return{ok:!1,reason:`unsupported`};if(await Notification.requestPermission()!==`granted`)return{ok:!1,reason:`permission-denied`};let t=await navigator.serviceWorker.ready;try{let n=(await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:wue(e)})).toJSON();return!n.endpoint||!n.keys?.p256dh||!n.keys?.auth?{ok:!1,reason:`subscribe-failed`}:{ok:!0,subscription:{endpoint:n.endpoint,keys:{p256dh:n.keys.p256dh,auth:n.keys.auth}}}}catch(e){return{ok:!1,reason:Tue(e instanceof Error?e.name:``)}}}async function Eue(){if(`serviceWorker`in navigator)try{await(await(await navigator.serviceWorker.ready).pushManager.getSubscription())?.unsubscribe()}catch{}}var F9={minimal:`极低`,low:`低`,medium:`中`,high:`高`,xhigh:`极高`,max:`最高`};function Due({providers:e,config:t,open:n,onClose:r,onSetModel:i,onSetReasoning:a,onSetThinking:o}){let s=e.find(e=>e.id===t.providerId),c=t.reasoningEnabled??!1,l=t.thinkingLevel??`medium`;return(0,J.jsx)(K7,{open:n,onOpenChange:e=>!e&&r(),children:(0,J.jsxs)(q7,{side:`bottom`,className:`pb-safe`,children:[(0,J.jsx)(J7,{children:(0,J.jsx)(Y7,{children:`会话设置`})}),(0,J.jsxs)(`div`,{className:`space-y-4 p-4 pt-0`,children:[(0,J.jsx)(I9,{label:`模型服务`,children:(0,J.jsxs)(w9,{items:e.map(e=>({value:e.id,label:e.name})),value:t.providerId??``,onValueChange:t=>{let n=e.find(e=>e.id===t),r=n?.models[0]?.id;n&&r&&i(n.id,r)},children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:e.map(e=>(0,J.jsx)(O9,{value:e.id,children:e.name},e.id))})]})}),(0,J.jsx)(I9,{label:`模型`,children:(0,J.jsxs)(w9,{items:(s?.models??[]).map(e=>({value:e.id,label:e.label??e.id})),value:t.modelId??``,onValueChange:e=>{t.providerId&&i(t.providerId,e)},children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:(s?.models??[]).map(e=>(0,J.jsx)(O9,{value:e.id,children:e.label??e.id},e.id))})]})}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`推理`}),(0,J.jsx)(uA,{checked:c,onCheckedChange:a})]}),c&&(0,J.jsx)(I9,{label:`推理档位`,children:(0,J.jsxs)(w9,{items:Object.keys(F9).map(e=>({value:e,label:F9[e]})),value:l,onValueChange:e=>o(e),children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:Object.keys(F9).map(e=>(0,J.jsx)(O9,{value:e,children:F9[e]},e))})]})}),(0,J.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`模型切换对运行中的会话在下次启动时生效;推理档位即时生效。`})]})]})})}function I9({label:e,children:t}){return(0,J.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e}),t]})}function Oue(e){return e.status===`failed`&&!e.spawning?`failed`:(e.pendingAskCount??0)>0?`waiting`:e.status===`running`||e.spawning||e.hasRunningChild?`running`:e.unread?`unread`:`idle`}function L9(e){return[...e].sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0))}function R9(e){let t=e=>(e.pendingAskCount??0)>0||(e.pendingApprovalCount??0)>0;return[...e.filter(t),...e.filter(e=>!t(e))]}function kue(e,t){let n=L9(e),r=new Map(n.map(e=>[e.id,e])),i=[];for(let e of t){let t=r.get(e);t&&(i.push(t),r.delete(e))}return[...i,...R9([...r.values()])]}function z9(e){return R9([...L9(e.filter(e=>e.pinned)),...L9(e.filter(e=>!e.pinned))])}function Aue(e,t){return Oue({status:e.status,unread:e.unread,pendingAskCount:e.pendingAskCount,hasRunningChild:t})!==`idle`}var B9=`__all__`,V9=`__ungrouped__`;function H9(e){return new Set(e.map(e=>e.id))}function U9(e,t){return t.includes(e)}function jue(e,t){let n=e.groupId;return!n||!H9(t).has(n)}function Mue(e,t,n,r){let i=e.filter(e=>!U9(e.id,n));return r===`__all__`||r===`__recent__`?i:r===`__ungrouped__`?i.filter(e=>jue(e,t)):i.filter(e=>e.groupId===r)}function Nue(e,t,n){let r=e.filter(e=>!U9(e.id,n)),i=[...t].sort((e,t)=>e.order-t.order),a=H9(t),o=i.map(e=>({groupId:e.id,group:e,projects:r.filter(t=>t.groupId===e.id)})),s=r.filter(e=>!e.groupId||!a.has(e.groupId));return s.length>0&&o.push({groupId:V9,projects:s}),o}function W9(e,t){return e<=0?0:Math.min(e,5+Math.max(0,t))}function Pue(e,t){return W9(e,t)>=e?0:Math.min(Math.max(0,e-5),t+15)}function Fue(e){return Math.max(0,e-15)}var Iue=[{value:`auto`,label:`跟随桌面`},{value:`light`,label:`浅`},{value:`dark`,label:`深`}],Lue={unsupported:`当前浏览器不支持推送。`,"permission-denied":`通知权限被拒绝,请在浏览器站点设置中允许后重试。`,"service-unreachable":`无法连接 Google 推送服务(FCM),请检查网络或代理后重试。`,"subscribe-failed":`订阅失败,请稍后重试。`};function Rue({open:e,docked:t=!1,pinnable:n=!1,onTogglePinned:r,projects:a,groups:o=[],catalog:s,pinnedOrder:c=[],activeId:l,canCreate:u,devices:d,activeDevicePairId:f,remoteDesktop:p,connected:m,connectionLabel:h,pushEnabled:g,pushBusy:_,pushError:v,pushAvailability:y,pushConfigReady:b,onTogglePush:x,onClose:S,onSelect:C,onNewConversation:w,onSwitchDevice:T,onAddDevice:E,onRenameDevice:O,onUnpairDevice:k,botSegment:A}){let j=A?.active===!0,[M,N]=(0,G.useState)({}),[P,F]=(0,G.useState)({}),[I,L]=(0,G.useState)(!1),[B,V]=(0,G.useState)(null),ee=p?d.find(e=>e.pairId===f&&e.scope!==`read`):void 0,[H,U]=(0,G.useState)(z),[W,te]=(0,G.useState)(()=>{try{return localStorage.getItem(`enso-phone-selected-project-group`)??`__all__`}catch{return B9}}),[ie,ae]=(0,G.useState)({}),oe=W===`__all__`||W===`__ungrouped__`||o.some(e=>e.id===W)?W:B9;(0,G.useEffect)(()=>R(()=>U(z())),[]),(0,G.useEffect)(()=>{e||V(null)},[e]);let[se,ce]=(0,G.useState)(()=>Date.now());(0,G.useEffect)(()=>{if(!e)return;ce(Date.now());let t=setInterval(()=>ce(Date.now()),6e4);return()=>clearInterval(t)},[e]);let le=new Set(a.filter(e=>e.archived).map(e=>e.id)),ue=[...le],de=e=>e.archived||le.has(e.projectId),fe=Mue(a,o,ue,oe),pe=Nue(a,o,ue),me=new Set(fe.map(e=>e.id)),he=s.filter(e=>!e.parentId),ge=e=>!e.projectId||me.has(e.projectId),K=e=>s.some(t=>t.parentId===e&&t.status===`running`),ve=L9(he.filter(e=>!de(e)&&ge(e)&&Aue(e,K(e.id)))),ye=kue(he.filter(e=>e.pinned&&!de(e)&&ge(e)),c),be=L9(he.filter(e=>{if(!de(e))return!1;if(oe===`__all__`)return!0;let t=a.find(t=>t.id===e.projectId);return t?oe===`__ungrouped__`?!t.groupId||!o.some(e=>e.id===t.groupId):t.groupId===oe:oe===V9})),xe=he.filter(e=>!de(e)),Ce=new Set(a.map(e=>e.id)),we=z9(xe.filter(e=>!Ce.has(e.projectId)));return(0,J.jsxs)(J.Fragment,{children:[!t&&(0,J.jsx)(`button`,{type:`button`,"aria-label":`关闭侧栏`,onClick:S,className:q(`fixed inset-0 z-40 bg-black/40 transition-[opacity,visibility] duration-200`,e?`visible opacity-100`:`invisible pointer-events-none opacity-0`)}),(0,J.jsxs)(`aside`,{className:q(`flex shrink-0 flex-col border-r bg-background`,t?`relative h-full w-72`:q(`fixed inset-y-0 left-0 z-50 w-[82vw] max-w-xs transition-transform duration-200`,e?`translate-x-0`:`-translate-x-full`)),children:[(0,J.jsxs)(`div`,{className:q(`flex h-12 shrink-0 items-center justify-between px-3 pt-safe`,o.length===0&&`border-b`),children:[A?(0,J.jsx)(`span`,{className:`flex rounded-lg bg-muted p-0.5 text-sm`,children:[`项目`,`Bot`].map(e=>{let t=e===`Bot`===A.active;return(0,J.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>A.onChange(e===`Bot`),className:q(`rounded-md px-3 py-0.5 transition-colors`,t?`bg-background font-medium shadow-xs`:`text-muted-foreground`),children:e},e)})}):(0,J.jsx)(`span`,{className:`font-medium text-sm`,children:`项目`}),t?n&&r?(0,J.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`收起侧栏`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(Tt,{className:`h-4 w-4`})}):null:(0,J.jsxs)(`span`,{className:`flex items-center`,children:[n&&r&&(0,J.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`固定侧栏`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(Et,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{type:`button`,onClick:S,"aria-label":`关闭侧栏`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(sn,{className:`h-4 w-4`})})]})]}),!j&&o.length>0&&(0,J.jsx)(`div`,{className:`shrink-0 border-b px-3 pb-2`,children:(0,J.jsxs)(w9,{items:[{value:`__all__`,label:`全部`},...o.slice().sort((e,t)=>e.order-t.order).map(e=>({value:e.id,label:`${e.emoji?`${e.emoji} `:``}${e.name}`})),{value:`__ungrouped__`,label:`未分组`}],value:oe,onValueChange:e=>{if(e){te(e);try{localStorage.setItem(`enso-phone-selected-project-group`,e)}catch{}}},children:[(0,J.jsx)(T9,{className:`w-full`,size:`sm`,children:(0,J.jsx)(E9,{})}),(0,J.jsxs)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:[(0,J.jsx)(O9,{value:`__all__`,children:`全部`}),o.slice().sort((e,t)=>e.order-t.order).map(e=>(0,J.jsxs)(O9,{value:e.id,children:[e.emoji?`${e.emoji} `:``,e.name]},e.id)),(0,J.jsx)(O9,{value:`__ungrouped__`,children:`未分组`})]})]})}),j?A?.panel:(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2`,children:[a.length===0&&(0,J.jsx)(`p`,{className:`rounded-lg border border-dashed px-3 py-6 text-center text-muted-foreground text-sm`,children:`桌面端还没有项目`}),ve.length>0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`flex items-center gap-1.5 px-2 py-2`,children:(0,J.jsx)(`span`,{className:`font-medium text-sm`,children:`活跃中`})}),(0,J.jsx)(`div`,{className:`flex flex-col gap-y-0.5`,children:ve.map(e=>(0,J.jsx)(G9,{session:e,active:l===e.id,nowTick:se,onSelect:C},e.id))})]}),ye.length>0&&(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-2`,children:[(0,J.jsx)(At,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`font-medium text-sm`,children:`置顶`})]}),(0,J.jsx)(`div`,{className:`flex flex-col gap-y-0.5`,children:ye.map(e=>(0,J.jsx)(G9,{session:e,active:l===e.id,nowTick:se,onSelect:C},e.id))})]}),(oe===`__all__`&&o.length>0?pe.flatMap(e=>{let t=ie[e.groupId]===!0;return[{kind:`header`,section:e,folded:t},...t?[]:e.projects.map(e=>({kind:`project`,project:e}))]}):fe.map(e=>({kind:`project`,project:e}))).map(e=>e.kind===`header`?(0,J.jsxs)(`button`,{type:`button`,onClick:()=>ae(t=>({...t,[e.section.groupId]:!t[e.section.groupId]})),className:`flex h-7 w-full items-center gap-1 rounded-md px-2 text-left text-xs font-medium text-muted-foreground`,children:[(0,J.jsx)(ke,{className:q(`h-3.5 w-3.5 shrink-0 transition-transform duration-150`,!e.folded&&`rotate-90`)}),e.section.group?.emoji&&(0,J.jsx)(`span`,{className:`shrink-0 text-sm`,children:e.section.group.emoji}),e.section.group?.color&&(0,J.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.section.group.color}}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.section.group?.name??`未分组`}),(0,J.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/70`,children:e.section.projects.length})]},`hdr-${e.section.groupId}`):(0,J.jsx)(K9,{name:re(e.project),badge:ne(e.project),sessions:z9(xe.filter(t=>t.projectId===e.project.id)),folded:M[e.project.id]===!0,revealedExtra:P[e.project.id]??0,activeId:l,nowTick:se,canCreate:u,onToggleFold:()=>N(t=>({...t,[e.project.id]:!t[e.project.id]})),onRevealMore:t=>F(n=>({...n,[e.project.id]:t})),onSelect:C,onNew:()=>w(e.project.id)},e.project.id)),we.length>0&&(0,J.jsx)(K9,{name:`其他`,sessions:we,folded:M.__orphan===!0,revealedExtra:P.__orphan??0,activeId:l,nowTick:se,canCreate:!1,onToggleFold:()=>N(e=>({...e,__orphan:!e.__orphan})),onRevealMore:e=>F(t=>({...t,__orphan:e})),onSelect:C})]}),!j&&be.length>0&&(0,J.jsxs)(`div`,{className:`shrink-0 border-t p-2`,children:[I&&(0,J.jsx)(`div`,{className:`mb-0.5 flex max-h-64 flex-col gap-y-0.5 overflow-y-auto`,children:be.map(e=>(0,J.jsx)(G9,{session:e,active:l===e.id,nowTick:se,subtitle:(()=>{let t=a.find(t=>t.id===e.projectId);return t?re(t):void 0})(),onSelect:C},e.id))}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>L(e=>!e),className:`flex w-full items-center gap-1 rounded-lg px-2 py-2 text-left transition-colors hover:bg-muted/60`,children:[(0,J.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,J.jsx)(ke,{className:q(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,I?`-rotate-90`:`rotate-0`)})}),(0,J.jsx)(_e,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground text-sm`,children:`已归档`}),(0,J.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums`,children:be.length})]})]}),(0,J.jsxs)(`div`,{className:`shrink-0 space-y-1 border-t p-2 pb-safe`,children:[!B&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,J.jsx)(wt,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground text-sm`,children:`主题`}),(0,J.jsx)(`div`,{className:`flex shrink-0 gap-0.5 rounded-md border p-0.5`,children:Iue.map(e=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>i(e.value),className:q(`rounded px-2 py-1 text-[11px] transition-colors`,H===e.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-accent`),children:e.label},e.value))})]}),!B&&ee&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,J.jsx)(St,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground text-sm`,children:`界面`}),(0,J.jsxs)(`div`,{className:`flex shrink-0 gap-0.5 rounded-md border p-0.5`,children:[(0,J.jsx)(`span`,{className:`rounded bg-primary px-2 py-1 text-[11px] text-primary-foreground`,children:`精简`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{window.location.href=D(ee.pairId)},className:`rounded px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-accent`,children:`完整`})]})]}),!B&&(0,J.jsxs)(`div`,{className:`px-2 py-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Se,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground text-sm`,children:`推送通知`}),(0,J.jsx)(uA,{checked:g,disabled:_||y!==`ok`||!m||!b,onCheckedChange:x})]}),_&&(0,J.jsx)(`p`,{className:`mt-1 pl-6 text-[11px] text-muted-foreground`,children:`正在开启…`}),v&&!_&&(0,J.jsx)(`p`,{className:`mt-1 pl-6 text-[11px] text-destructive`,children:Lue[v]}),y===`ok`&&m&&!b&&(0,J.jsx)(`p`,{className:`mt-1 pl-6 text-[11px] text-muted-foreground`,children:`需先升级桌面端 EnsoCode 才能开启推送。`}),y===`needs-install`&&(0,J.jsx)(`p`,{className:`mt-1 pl-6 text-[11px] text-muted-foreground`,children:`iOS 需先用分享菜单「添加到主屏幕」,从主屏幕打开后才能开启。`}),y===`unsupported`&&(0,J.jsx)(`p`,{className:`mt-1 pl-6 text-[11px] text-muted-foreground`,children:`当前浏览器不支持推送。`})]}),(0,J.jsxs)(`div`,{className:`space-y-0.5`,children:[d.map(e=>{let t=e.pairId===f;return B===e.pairId?(0,J.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-dashed p-3`,children:[(0,J.jsxs)(`p`,{className:`text-xs`,children:[`解绑「`,e.label,`」后需重新扫码才能连接,确定吗?`]}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)(ji,{variant:`outline`,size:`sm`,onClick:()=>V(null),children:`取消`}),(0,J.jsx)(ji,{variant:`destructive`,size:`sm`,onClick:()=>{V(null),k(e.pairId)},children:`确定解绑`})]})]},e.pairId):(0,J.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>T(e.pairId),className:q(`flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-2 text-left text-sm transition-colors hover:bg-muted/60`,t?`text-foreground`:`text-muted-foreground`),children:[(0,J.jsx)(lt,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),t&&(0,J.jsx)(`span`,{className:q(`shrink-0 text-[10px]`,m?`text-muted-foreground`:`text-destructive`),children:h})]}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`重命名 ${e.label}`,onClick:()=>{let t=window.prompt(`给这台电脑起个名:`,e.label);t?.trim()&&O(e.pairId,t)},className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground`,children:(0,J.jsx)(kt,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`解绑 ${e.label}`,onClick:()=>V(e.pairId),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-destructive`,children:(0,J.jsx)(nn,{className:`h-3.5 w-3.5`})})]},e.pairId)}),(0,J.jsxs)(`button`,{type:`button`,onClick:E,className:`flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-muted-foreground text-sm transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,J.jsx)(Nt,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{children:`配对新电脑`})]})]}),(0,J.jsxs)(`p`,{className:`px-2 pt-0.5 text-center text-[10px] text-muted-foreground/60`,children:[`版本 `,`93adde0-dirty`]})]})]})]})}function G9({session:e,active:t,nowTick:n,subtitle:r,onSelect:i}){return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:q(`flex w-full items-center gap-2 rounded-lg py-2 pr-2 pl-4 text-left text-sm transition-colors`,t?`bg-brand/10 dark:bg-brand/15`:`hover:bg-muted/60`),children:[(0,J.jsx)(zue,{status:e.status,unread:e.unread}),e.pinned&&(0,J.jsx)(At,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.title||`新对话`,r&&(0,J.jsx)(`span`,{className:`ml-1.5 text-[10px] text-muted-foreground`,children:r})]}),e.updatedAt&&(0,J.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/80 tabular-nums`,children:X7(e.updatedAt,`zh`,n)})]})}function K9({name:e,badge:t,sessions:n,folded:r,revealedExtra:i,activeId:a,nowTick:o,canCreate:s,onToggleFold:c,onRevealMore:l,onSelect:u,onNew:d}){let{t:f}=Ro(),p=W9(n.length,i),m=n.slice(0,p),h=n.length-p;return(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex w-full items-center gap-1 rounded-lg px-2 py-2 transition-colors hover:bg-muted/60`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:c,className:`flex min-w-0 flex-1 items-center gap-1 text-left`,children:[(0,J.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,J.jsx)(ke,{className:q(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,!r&&`rotate-90`)})}),(0,J.jsx)(Qe,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-sm`,children:[e,t&&(0,J.jsx)(`span`,{className:`ml-1.5 rounded bg-muted px-1 py-0.5 text-[10px] font-normal text-muted-foreground`,children:t})]}),(0,J.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums`,children:n.length})]}),s&&d&&(0,J.jsx)(`button`,{type:`button`,onClick:d,className:`shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(_t,{className:`h-3.5 w-3.5`})})]}),!r&&(0,J.jsxs)(`div`,{className:`mt-0.5 flex flex-col gap-y-0.5`,children:[m.map(e=>(0,J.jsx)(G9,{session:e,active:a===e.id,nowTick:o,onSelect:u},e.id)),n.length>5&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[h>0&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>l(Pue(n.length,i)),className:`flex-1 rounded-lg py-1 text-center text-muted-foreground text-xs transition-colors hover:bg-muted/60 hover:text-foreground`,children:f(`Show {{n}} more`,{n:h})}),i>0&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>l(Fue(i)),className:`flex-1 rounded-lg py-1 text-center text-muted-foreground text-xs transition-colors hover:bg-muted/60 hover:text-foreground`,children:f(`Collapse`)})]})]})]})}function zue({status:e,unread:t}){let n=e===`running`,r=!n&&e===`failed`,i=!n&&!r&&t===!0;return(0,J.jsx)(`span`,{className:q(`h-1.5 w-1.5 shrink-0 rounded-full`,n&&`animate-pulse bg-brand`,r&&`bg-destructive`,i&&`bg-green-500`,!n&&!r&&!i&&`bg-muted-foreground/30`)})}function Bue(){window.electronAPI||Object.defineProperty(window,"electronAPI",{value:{git:{diffHead:async()=>({ok:!1,error:`unavailable`})},changes:{readSnapshots:async()=>({}),writeSnapshots:async()=>!1},workspaceFiles:{listDir:async()=>({ok:!1,error:`unavailable`}),read:async()=>({ok:!1,error:`unavailable`}),write:async()=>({ok:!1,error:`unavailable`}),watchStart:async()=>({ok:!1,error:`unavailable`}),watchStop:async()=>({ok:!1,error:`unavailable`}),onChange:()=>()=>void 0,search:async()=>({ok:!1,error:`unavailable`})},files:{read:async()=>null,search:async()=>[],pathForFile:()=>null},agentRegistry:{list:async()=>null},agent:{stopTask:async()=>({ok:!1,error:`not supported on phone`}),stopSubagent:async()=>({ok:!1,error:`not supported on phone`})},providers:{listOauth:async()=>[],getOauthUsage:async()=>null}},writable:!1})}function Vue(e){let t=window.electronAPI?.agent;t&&(t.stopTask=async(t,n)=>(e.stopTask(t,n),{ok:!0}),t.stopSubagent=async(t,n)=>(e.stopSubagent(t,n),{ok:!0}))}function Hue(e,t){return e?t.some(e=>e.status===`running`||typeof e.pendingAskCount==`number`&&e.pendingAskCount>0||typeof e.pendingApprovalCount==`number`&&e.pendingApprovalCount>0):!1}var q9=null;async function J9(e,t=typeof navigator>`u`?void 0:navigator.wakeLock){if(!e||!t){if(!q9)return;let e=q9;q9=null;try{await e.release()}catch{}return}if(!q9)try{let e=await t.request(`screen`);q9=e,e.addEventListener(`release`,()=>{q9===e&&(q9=null)})}catch{q9=null}}function Uue(){if(!window.location.hash.replace(/^#/,``).includes(`pk=`))return null;let e=window.location.href;return history.replaceState(null,``,window.location.pathname+window.location.search),e}var Wue={connecting:`连接中…`,online:`已连接`,"host-offline":`桌面端离线`,unauthorized:`配对已失效`,offline:`重连中…`},Y9=`enso-phone-push`,X9=`enso-phone-sidebar-pinned`,Gue=l();function Kue(){let e=j(window.location.search);if(!e)return null;let t=new URLSearchParams(window.location.search);t.delete(`session`);let n=t.toString();return history.replaceState(null,``,window.location.pathname+(n?`?${n}`:``)),e}function que(){return N9()?`ok`:/iphone|ipad|ipod/i.test(navigator.userAgent)&&!M9()?`needs-install`:`unsupported`}function Jue(){let[e,t]=(0,G.useState)(N),[n,r]=(0,G.useState)(k),i=C(e,n),[a]=(0,G.useState)(Uue),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(`connecting`),[u,f]=(0,G.useState)(`relay`),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)([]),[x,S]=(0,G.useState)([]),[E,D]=(0,G.useState)([]),[j,I]=(0,G.useState)([]),[R,z]=(0,G.useState)([]),[V]=(0,G.useState)(Kue),[ee]=(0,G.useState)(()=>T(i?.pairId??null,V)),[H,U]=(0,G.useState)(ee.activeId),[W,te]=(0,G.useState)(null),[ne,re]=(0,G.useState)(!1),[ie,ae]=(0,G.useState)(new Set),[oe,ce]=(0,G.useState)([]),[le,ue]=(0,G.useState)(!1),de=Ble(Vle),[fe,pe]=(0,G.useState)(()=>localStorage.getItem(X9)!==`off`),me=de&&fe,he=()=>{pe(e=>(localStorage.setItem(X9,e?`off`:`on`),!e))},[ge,K]=(0,G.useState)(!1),[_e,ve]=(0,G.useState)(null),[ye,be]=(0,G.useState)(!1),[xe,Se]=(0,G.useState)(()=>localStorage.getItem(Y9)===`on`),[Ce,we]=(0,G.useState)(!1),[Te,Ee]=(0,G.useState)(!1),[De,Oe]=(0,G.useState)(!1),[ke,Ae]=(0,G.useState)(!1),[je,Me]=(0,G.useState)(!1),[Ne,Pe]=(0,G.useState)(!1),[Fe,Ie]=(0,G.useState)(null),[Le,Re]=(0,G.useState)(!1),[ze,Be]=(0,G.useState)(!1),[Ve,He]=(0,G.useState)(!1),Ue=(0,G.useRef)(!1),[We,Ge]=(0,G.useState)(!1),[Ke,qe]=(0,G.useState)(!1),Je=(0,G.useRef)(!1),[Ye,Xe]=(0,G.useState)([]),[Ze,Qe]=(0,G.useState)([]),[$e,et]=(0,G.useState)([]),[tt,nt]=(0,G.useState)(!1),[rt,it]=(0,G.useState)([]),[at,ot]=(0,G.useState)({items:[],offset:0}),[st,ct]=(0,G.useState)(()=>U7(!0,ee.botChatId)),[lt,ut]=(0,G.useState)(ee.botChatId),[dt,ft]=(0,G.useState)(null),[pt,mt]=(0,G.useState)({}),[ht,gt]=(0,G.useState)({}),[_t,vt]=(0,G.useState)({}),[yt,bt]=(0,G.useState)(null),xt=(0,G.useRef)(null),St=(0,G.useMemo)(()=>new qi(e=>Ot.current?.send(e)),[]),Ct=(0,G.useMemo)(()=>new Do(e=>Ot.current?.send(e)),[]),wt=(0,G.useMemo)(()=>new ko(e=>Ot.current?.send(e)),[]),[Tt,Et]=(0,G.useState)([]),Ot=(0,G.useRef)(null),kt=(0,G.useRef)(H),At=(0,G.useRef)(g),jt=(0,G.useRef)(W);At.current=g,jt.current=W,kt.current=H;let Mt=lt?$e.find(e=>e.id===lt):void 0,Nt=Mt?.kind===`group`?ao(Mt,Ye):void 0,Pt=Nt?.current??Mt,Ft=Mt?.kind===`direct`?Mt.sessions[Mt.members[0]]?.conversationId??null:null,It=lt?Ft??dt:H,Lt=(0,G.useRef)(It);Lt.current=It;let Rt=(0,G.useRef)($e);Rt.current=$e;let zt=(0,G.useRef)(lt);zt.current=lt;let Bt=(0,G.useRef)(null);Bt.current=Nt?.current.id??null;let Vt=(0,G.useRef)(new Set);Vt.current=new Set(Nt?Object.values(Nt.current.sessions).map(e=>e.conversationId):[]);let Ht=(0,G.useRef)(null),Ut=(0,G.useRef)(new Map),Wt=(0,G.useRef)(null),[Kt,qt]=(0,G.useState)(!1),Jt=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(Cue(),!(`serviceWorker`in navigator))return;let e=e=>{let t=e.data;if(t?.type!==`open-session`)return;let n=O(t.sessionId);if(!n)return;let r=Rt.current.find(e=>Object.values(e.sessions).some(e=>e.conversationId===n));r?(ut(r.id),ft(null)):(ut(null),U(n)),fn()};return navigator.serviceWorker.addEventListener(`message`,e),()=>navigator.serviceWorker.removeEventListener(`message`,e)},[]),(0,G.useEffect)(()=>{Pi(Mi(g))},[g]),(0,G.useEffect)(()=>{let e=()=>{J9(Hue(document.visibilityState===`visible`&&c===`online`,g))};return e(),document.addEventListener(`visibilitychange`,e),document.addEventListener(`pointerdown`,e,{passive:!0}),()=>{document.removeEventListener(`visibilitychange`,e),document.removeEventListener(`pointerdown`,e),J9(!1)}},[g,c]),(0,G.useEffect)(()=>{if(V){w();return}w().then(e=>{e&&(ut(null),ft(null),U(e),fn())})},[V]),(0,G.useEffect)(()=>{a&&e.length>0&&s(!0)},[]),(0,G.useEffect)(()=>{if(!i)return;Jt.current=null,we(!1),ae(new Set),f(`relay`),Ee(!1),Oe(!1),Ae(!1),Me(!1),Be(!1),He(!1),Ue.current=!1,Ge(!1),qe(!1),Je.current=!1;let e=()=>{Oe(!0),Me(!0)},t=new b(i,{onState:e=>{e!==`online`&&(xt.current?.interrupted(),St.reset(),Ct.reset(),wt.reset(),Be(!1),Ge(!1)),l(e)},onBotArtifacts:e=>St.receive(e),onBotArtifactImage:e=>St.receiveImage(e),onBotNewSessionResult:t=>{Ct.receive(t),t.error===`read-only`&&e()},onBotThreadResult:t=>{wt.receive(t),t.error===`read-only`&&e()},onTransport:e=>{f(e),h(null)},onRtt:h,onVoiceInput:Ee,onRemoteDesktop:Ae,onReadOnly:e=>{Oe(e),e||Me(!1)},onCommandRejected:(t,n)=>{n===`read-only`&&e()},onCatalog:(e,t)=>{_(e),S(t??[])},onProjects:(e,t)=>{D(e),I(t??[])},onProviders:z,onSession:(e,t)=>{te(n=>e===Lt.current?t:n),Vt.current.has(e)&&vt(n=>({...n,[e]:t}))},onBotCatalog:(e,t,n,r)=>{Re(e),Be(e&&n),Ge(e&&r),Qe(t),!e&&(et([]),Xe([]),it([]),ot({items:[],offset:0}),ut(null),ft(null),ct(!1))},onBotChats:(e,t)=>{et(e),Xe(t),nt(!0)},onBotInbox:it,onBotActivity:(e,t)=>{for(let t of e)Ut.current.set(t.conversationId,t.botId);ot({items:e,offset:t})},onGroupTimeline:e=>{e.beforeSeq!==void 0&&Wt.current===`${e.chatId}:${e.beforeSeq}`&&(Wt.current=null,qt(!1)),mt(t=>({...t,[e.chatId]:lo(t[e.chatId],e)}))},onBotChatState:({type:e,chatId:t,...n})=>gt(e=>({...e,[t]:n})),onBotEvent:e=>{if(e.kind===`model-notice`){e.text&&(e.chatId===zt.current||e.chatId===Bt.current)&&bt(e.text);return}!e.chatId||e.chatId!==Bt.current||Ht.current||(Ht.current=setTimeout(()=>{Ht.current=null;let e=Bt.current;e&&t.send({type:`bot-chat-open`,chatId:e})},200))},onBotSendResult:t=>{xt.current?.settle(t.deliveryId,t.ok,t.error),t.error===`read-only`&&e()},onBotRetryResult:e=>{e.chatId===Bt.current&&bt(e.ok?`已开始重试`:`重试失败:${e.error===`session-busy`?`请等当前回复结束`:`该回复已过期或无法恢复,请重新发送需求`}`)},onSync:e=>re(e===`syncing`),onGhostSession:e=>{e===kt.current&&U(null)},onHistoryPending:(e,t)=>{ae(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},onPushConfig:e=>{Jt.current=e,we(!0),localStorage.getItem(Y9)===`on`&&P9(e).then(e=>{e.ok&&t.send({type:`push-subscribe`,subscription:e.subscription})})}});Ot.current=t,t.connect();let n=()=>{document.visibilityState===`visible`?(t.nudge(`visibility`),t.send({type:`presence`,visible:!0})):(t.conceal(),t.send({type:`presence`,visible:!1}),t.flushCache())},r=()=>{document.visibilityState===`visible`&&(t.nudge(`online`),t.send({type:`presence`,visible:!0}))},a=e=>{document.visibilityState===`visible`&&(t.nudge(e.persisted?`online`:`visibility`),t.send({type:`presence`,visible:!0}))},o=()=>{document.visibilityState===`visible`&&t.nudge(`visibility`)},s=()=>{t.conceal(),t.flushCache()};return document.addEventListener(`visibilitychange`,n),window.addEventListener(`online`,r),window.addEventListener(`pageshow`,a),window.addEventListener(`focus`,o),window.addEventListener(`pagehide`,s),()=>{document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`online`,r),window.removeEventListener(`pageshow`,a),window.removeEventListener(`focus`,o),window.removeEventListener(`pagehide`,s),Ht.current&&clearTimeout(Ht.current),Ht.current=null,t.close(),Ot.current=null,Ct.reset(),wt.reset()}},[i?.pairId,i?.token,i?.relayUrl,i?.contentKey]);let Yt=(0,G.useRef)(new Set);(0,G.useEffect)(()=>{let e=It!==null&&Yt.current.has(It);Ot.current?.subscribe(It,{fresh:e});for(let e of Yt.current)e!==It&&Yt.current.delete(e);te(It?Ot.current?.getSession(It)??null:null)},[It,i?.pairId]);let Xt=i?.pairId;(0,G.useEffect)(()=>{Xt&&P(Xt,{activeId:H,botChatId:lt})},[H,lt,Xt]),(0,G.useEffect)(()=>{if(!Xt)return;let e=new d(p,Xt);xt.current=e,Et([]);let t=e.subscribe(e=>Et([...e]));return e.restore().catch(()=>bt(`离线消息读取失败,请勿清除浏览器数据;恢复存储后可重试。`)),()=>{t(),xt.current===e&&(xt.current=null)}},[Xt]),(0,G.useEffect)(()=>{if(c===`online`)for(let e of xt.current?.drain()??[])Ot.current?.send({type:`bot-send`,chatId:e.chatId,text:e.text,...e.images?.length?{images:e.images}:{},deliveryId:e.deliveryId})},[c,Tt]),(0,G.useEffect)(()=>{let e=setInterval(()=>xt.current?.expire(),1e3);return()=>clearInterval(e)},[]);let Zt=Nt?.current.id??null;(0,G.useEffect)(()=>{!Zt||c!==`online`||(Wt.current=null,qt(!1),Ot.current?.send({type:`bot-chat-open`,chatId:Zt}))},[Zt,c]),(0,G.useEffect)(()=>{if(!Kt)return;let e=setTimeout(()=>{Wt.current=null,qt(!1),bt(`历史加载未完成,请点击加载重试。`)},1e4);return()=>clearTimeout(e)},[Kt]),(0,G.useEffect)(()=>{let e={};for(let t of Vt.current){let n=Ot.current?.getSession(t);n&&(e[t]=n)}vt(e)},[Zt,Nt?.current.sessions]),(0,G.useEffect)(()=>{if(!H||lt)return;let e=$e.find(e=>Object.values(e.sessions).some(e=>e.conversationId===H));e&&(ut(e.id),U(null))},[H,lt,$e]),(0,G.useEffect)(()=>{let e=(e,t)=>{let n=At.current.find(t=>t.id===e)?.queued,r=ale(n,e,t,R7(e===kt.current&&jt.current?[...jt.current.messages.values()]:[]));r&&ce(e=>[...e,r])};xne({removeQueuedMessage:(e,t)=>Ot.current?.send({type:`queue-remove`,sessionId:e,messageId:t}),updateQueuedMessage:(e,t,n)=>Ot.current?.send({type:`queue-update`,sessionId:e,messageId:t,text:n}),sendQueuedNow:(t,n)=>{e(t,n),Ot.current?.send({type:`queue-send-now`,sessionId:t,messageId:n})},interruptAndSendQueued:async(t,n)=>{e(t,n),Ot.current?.send({type:`queue-interrupt-send`,sessionId:t,messageId:n})},pauseGoal:e=>Ot.current?.send({type:`goal-pause`,sessionId:e}),resumeGoal:e=>Ot.current?.send({type:`goal-resume`,sessionId:e}),clearGoal:e=>Ot.current?.send({type:`goal-clear`,sessionId:e}),rewind:(e,t,n)=>Ot.current?.send({type:`rewind`,sessionId:e,userIndexFromEnd:t,...n?{restoreFiles:n}:{}}),retry:e=>Ot.current?.send({type:`retry`,sessionId:e})}),Vue({stopTask:(e,t)=>Ot.current?.send({type:`task-stop`,sessionId:e,taskId:t}),stopSubagent:(e,t)=>Ot.current?.send({type:`subagent-stop`,sessionId:e,agentId:t})})},[]);let Qt=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!H)return;let e=R7(W?[...W.messages.values()]:[]),t=W?.status===`running`,n=Qt.current,r=n?.id===H&&n.running&&!t;Qt.current={id:H,running:t},ce(t=>{let n=cle(t,H,e,{turnSettled:r});return n.length===t.length&&n.every((e,n)=>e===t[n])?t:n})},[W,H]);let $t=g.find(e=>!e.parentId)?.id;(0,G.useEffect)(()=>{!lt&&!H&&$t&&U($t)},[H,lt,$t]);let en=(0,G.useMemo)(()=>g.find(e=>e.id===H),[g,H]),tn=(0,G.useMemo)(()=>{if(!en)return;let e=en.parentId?g.find(e=>e.id===en.parentId):en;if(!e)return;let t=g.filter(t=>t.parentId===e.id);return t.length>0?{parent:e,children:t}:void 0},[g,en]),nn=en&&!en.parentId,rn=nn?R.find(e=>e.id===en.providerId)?.models.find(e=>e.id===en.modelId)?.label??en.modelId??`选择模型`:void 0,an=c===`online`?ble(u,m):Wue[c],on=e=>{_([]),S([]),D([]),I([]),z([]),te(null),re(!1),ce([]),h(null),Re(!1),Qe([]),et([]),Xe([]),nt(!1),ut(e.botChatId),ct(e.botChatId!==null),ft(null),mt({}),gt({}),ot({items:[],offset:0}),vt({}),bt(null),U(e.activeId)},sn=e=>{e!==i?.pairId&&(y(e),r(e),l(`connecting`),on(T(e)),fn())},cn=n=>{let i=B(e,n);t(i),A(i),y(n.pairId),r(n.pairId),on(T(n.pairId)),s(!1)},ln=n=>{let a=e.find(e=>e.pairId===n);a&&M(a.relayUrl,a.pairId,a.token).catch(()=>{}),n===i?.pairId&&Ot.current?.close(),F(n);let o=v(e,n);if(t(o),A(o),n===(i?.pairId??null)){let e=C(o,null);y(e?.pairId??null),r(e?.pairId??null),e&&l(`connecting`),on(T(e?.pairId??null)),e||fn()}},un=(n,r)=>{let i=L(e,n,r);t(i),A(i)};if(!i||o)return(0,J.jsx)(Sue,{autoInvite:a,onPaired:cn,onCancel:i?()=>s(!1):void 0});if(c===`unauthorized`){let t=e.length>1;return(0,J.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,J.jsx)(Gt,{className:`h-8 w-8 text-muted-foreground`}),(0,J.jsx)(`h1`,{className:`font-medium text-lg`,children:`配对已失效`}),(0,J.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[`「`,i.label,`」已解绑此设备,`,t?`可移除它并切到其他电脑。`:`请重新扫码配对。`]}),(0,J.jsx)(ji,{onClick:()=>ln(i.pairId),children:t?`移除此配对`:`重新配对`})]})}let dn=e=>Ot.current?.send(e),fn=()=>{(localStorage.getItem(X9)===`off`||!window.matchMedia(`(min-width: 900px)`).matches)&&ue(!1)},pn=()=>{ct(U7(Le,lt)),ue(!0),Le&&dn({type:`bot-catalog-request`})},mn=(e,t,n=[])=>{bt(null),xt.current?.enqueue({chatId:e,text:t,images:n})},hn=e=>(0,J.jsx)(_ue,{items:Tt.filter(t=>t.chatId===e),readOnly:De,onRetry:e=>xt.current?.retry(e),onDiscard:e=>xt.current?.discard(e)}),gn=new Map(Ze.map(e=>[e.id,e])),_n=e=>De?`只读设备不能新建会话`:c===`online`?ze?Ve?`正在新建会话…`:Tt.some(t=>t.chatId===e)?`请先处理待发送消息`:void 0:`请升级桌面端以支持新建会话`:`请先连接桌面端`,vn=async e=>{if(_n(e)||Ue.current)return;let t=Ot.current;Ue.current=!0,He(!0),bt(null);try{let n=await Ct.start(e,()=>t===Ot.current&&zt.current===e&&window.confirm(`群聊中仍有回复、排队或委派任务。新建会话将停止成员回复,并取消未标记保留的委派。旧消息会保留。继续吗?`));if(t!==Ot.current||zt.current!==e)return;bt(!n||n.ok?null:n.error===`read-only`?`只读设备不能新建会话`:n.error===`timeout`||n.error===`offline`?`未收到新会话确认,请连接后核对聊天状态,勿重复操作`:`新建会话失败:${n.error??`请稍后重试`}`),n?.ok&&(t?.send({type:`bot-catalog-request`}),t?.send({type:`bot-chat-open`,chatId:e}))}finally{t===Ot.current&&(Ue.current=!1,He(!1))}},yn=De?`只读设备不能切换或新建话题`:c===`online`?Ke?`正在处理话题…`:void 0:`请先连接桌面端`,bn=async e=>{if(yn||Je.current)return;let t=Ot.current;Je.current=!0,qe(!0),bt(null);try{let n=await wt.request(e);if(t!==Ot.current||zt.current!==e.chatId)return;n.ok?ft(null):bt(n.error===`read-only`?`只读设备不能切换或新建话题`:n.error===`timeout`||n.error===`offline`?`未收到桌面确认,请连接后核对当前话题`:n.error===`invalid`?`该话题已不存在或群已归档`:`话题操作失败:${n.error??`请稍后重试`}`)}finally{t===Ot.current&&(Je.current=!1,qe(!1))}},xn=e=>{if(e.kind===`group`&&!dt){let t=Object.entries(e.sessions).flatMap(([e,{conversationId:t}])=>{let n=_t[t];return n?[{sessionId:t,botId:e,view:n}]:[]});return(0,J.jsx)(zle,{chat:e,bots:gn,timeline:pt[e.id],state:ht[e.id],pending:t,activities:So(at.items,e.id),clockOffset:at.offset,connState:c,stateLabel:an,notice:yt,outbox:hn(e.id),deviceReadOnly:De,readOnlyRejected:je,onOpenDrawer:pn,drawerDocked:me,onNewSession:()=>void vn(e.id),canCreate:!_n(e.id),newSessionHint:_n(e.id),newSessionBusy:Ve,threads:We&&Nt&&Mt?{entries:Nt.entries,currentId:e.id,rootId:Mt.id,disabledHint:yn,onSelect:e=>void bn({type:`bot-thread-select`,chatId:Mt.id,threadId:e}),onCreate:()=>void bn({type:`bot-thread-create`,chatId:Mt.id})}:void 0,voice:Sn,onLoadOlder:()=>{let t=pt[e.id]?.entries[0]?.seq,n=`${e.id}:${t}`;c!==`online`||t===void 0||Wt.current||(Wt.current=n,qt(!0),dn({type:`bot-timeline`,chatId:e.id,beforeSeq:t}))},historyLoading:Kt,onJumpLatest:()=>{Wt.current=null,qt(!1),mt(t=>{let n={...t};return delete n[e.id],n}),dn({type:`bot-chat-open`,chatId:e.id})},onSend:(t,n)=>mn(e.id,t,n),onStop:()=>dn({type:`bot-stop`,chatId:e.id}),onRetry:t=>{bt(`正在请求重试…`),dn({type:`bot-retry`,chatId:e.id,entryId:t})},onOpenProcess:ft,onApproval:(e,t,n)=>dn({type:`approval-respond`,sessionId:e,requestId:t,decision:n}),onAsk:(e,t,n)=>dn({type:`ask-respond`,sessionId:e,requestId:t,answer:n})})}let t=e.kind===`group`,n=pt[e.id]?.entries.find(e=>e.kind===`bot`&&e.conversationId===dt),r=dt?Ut.current.get(dt):void 0,i=gn.get(t?n?.kind===`bot`?n.botId:r??``:e.members[0]);return(0,J.jsx)(B7,{sessionId:It??`bot-chat:${e.id}`,clockOffset:at.offset,title:t?`${i?.name??`成员`} · 过程`:i?.name??e.title,projectName:t?e.title:i?.title??``,view:It?W:Gue,connState:c,stateLabel:an,syncing:ne&&!!It,onOpenDrawer:pn,drawerDocked:me,onNewSession:()=>!t&&void vn(e.id),canCreate:!t&&!_n(e.id),newSessionHint:_n(e.id),newSessionBusy:Ve,hasOlder:!!(It&&W&&W.messages.size>0&&Math.min(...W.messages.keys())>0),historyLoading:!!(It&&ie.has(It)),onLoadOlder:()=>It&&Ot.current?.requestHistory(It),voice:Sn,bot:t?{readOnly:!0,onBack:()=>ft(null)}:{chatId:e.id,notice:yt,outbox:hn(e.id)},artifacts:!t&&It?{chatId:e.id,conversationId:It}:void 0,deviceReadOnly:De,readOnlyRejected:je,onSend:(t,n)=>mn(e.id,t,n),onAbort:()=>It&&dn({type:`abort`,sessionId:It}),onApproval:(e,t)=>It&&dn({type:`approval-respond`,sessionId:It,requestId:e,decision:t}),onAsk:(e,t)=>It&&dn({type:`ask-respond`,sessionId:It,requestId:e,answer:t})})},Sn=Te?e=>Ot.current?.startVoice(e)??{push:()=>{},finish:()=>Promise.resolve({ok:!1,error:`failed`}),cancel:()=>{}}:void 0,Cn=async e=>{if(Ie(null),!e){localStorage.setItem(Y9,`off`),Se(!1),dn({type:`push-unsubscribe`}),Eue();return}let t=Jt.current;if(!t)return;Se(!0),Pe(!0);let n=await P9(t);if(Pe(!1),!n.ok){Se(!1),Ie(n.reason);return}dn({type:`push-subscribe`,subscription:n.subscription}),localStorage.setItem(Y9,`on`)};return(0,J.jsxs)(`div`,{className:`phone-app-root flex h-full min-h-0`,children:[(0,J.jsx)(Rue,{open:me||le,docked:me,pinnable:de,onTogglePinned:he,projects:E,groups:j,catalog:g,pinnedOrder:x,activeId:lt?null:H,canCreate:c===`online`&&!De,devices:e,activeDevicePairId:i.pairId,remoteDesktop:ke,connected:c===`online`,connectionLabel:an,onClose:()=>fn(),onSelect:e=>{ut(null),ft(null),U(e),fn()},onNewConversation:e=>{fn(),ve(e),K(!0)},pushEnabled:xe,pushBusy:Ne,pushError:Fe,pushAvailability:que(),pushConfigReady:Ce,onTogglePush:e=>void Cn(e),onSwitchDevice:sn,onAddDevice:()=>{fn(),s(!0)},onRenameDevice:un,onUnpairDevice:ln,botSegment:Le?{active:st,onChange:e=>{ct(e),Sle(e?`bot`:`code`),e&&dn({type:`bot-catalog-request`})},panel:(0,J.jsx)(Eo,{bots:Ze,chats:$e,activeChatId:lt,inbox:rt,activities:at.items,onDismiss:De?void 0:e=>dn({type:`bot-inbox-dismiss`,key:e}),onSelect:e=>{ut(e),ft(null),bt(null),fn()}})}:void 0}),(0,J.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[de&&!me&&!le&&(0,J.jsx)(`button`,{type:`button`,onClick:pn,"aria-label":`打开会话列表`,className:`fixed top-1/2 left-0 z-40 flex h-16 w-6 -translate-y-1/2 items-center justify-center rounded-r-lg border border-l-0 bg-background/90 text-muted-foreground shadow-sm backdrop-blur transition-colors hover:bg-accent hover:text-foreground`,children:(0,J.jsx)(Dt,{className:`h-4.5 w-4.5`})}),Mt?(0,J.jsx)(Yi.Provider,{value:{port:St,online:c===`online`},children:xn(Pt??Mt)}):lt?(0,J.jsxs)(`div`,{className:`relative flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[!me&&(0,J.jsx)(`button`,{type:`button`,onClick:pn,"aria-label":`打开会话列表`,className:`absolute top-2 left-2 flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,J.jsx)(Dt,{className:`h-4.5 w-4.5`})}),(0,J.jsx)(`p`,{children:tt?`该 Bot 聊天已不存在或不可用`:`正在恢复 Bot 聊天…`}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:an}),(0,J.jsx)(ji,{onClick:pn,children:`选择聊天`})]}):(0,J.jsx)(B7,{sessionId:H,title:en?.title||(H?`会话`:`EnsoCode`),projectName:en?.projectName??``,cwd:en?.cwd,view:W,connState:c,stateLabel:an,syncing:ne&&!!H,onOpenDrawer:pn,drawerDocked:me,onNewSession:()=>{ve(null),K(!0)},canCreate:c===`online`&&E.length>0&&!De,modelLabel:c===`online`?rn:void 0,onOpenConfig:()=>be(!0),tabGroup:tn,onSelectTab:U,hasOlder:!!(H&&W&&W.messages.size>0&&Math.min(...W.messages.keys())>0),historyLoading:!!(H&&ie.has(H)),onLoadOlder:()=>H&&Ot.current?.requestHistory(H),voice:Sn,queued:ole(en?.queued,oe,H??``),echoes:oe,goal:en?.goal,context:en?.context,usageTotals:en?.usageTotals,slashCommands:en?.slashCommands,deviceReadOnly:De,readOnlyRejected:je,onSend:(e,t)=>{if(!H)return;let n=se(e);if(n){dn({type:`compact`,sessionId:H,...n.instructions?{instructions:n.instructions}:{}});return}let r=/^\/goal(?:\s+([\s\S]+))?$/.exec(e.trim());if(r){let e=r[1]?.trim();if(!e)return;dn(e===`clear`?{type:`goal-clear`,sessionId:H}:e===`pause`?{type:`goal-pause`,sessionId:H}:e===`resume`?{type:`goal-resume`,sessionId:H}:{type:`goal-set`,sessionId:H,text:e});return}dn({type:W?.status===`running`?`enqueue`:`prompt`,sessionId:H,text:e,...t.length?{images:t}:{}})},onAbort:()=>H&&dn({type:`abort`,sessionId:H}),onApproval:(e,t)=>H&&dn({type:`approval-respond`,sessionId:H,requestId:e,decision:t}),onAsk:(e,t)=>H&&dn({type:`ask-respond`,sessionId:H,requestId:e,answer:t})}),(0,J.jsx)(hue,{open:ge&&!De,projects:E,providers:R,preferredProjectId:_e,onClose:()=>{K(!1),ve(null)},onCreate:e=>{let t=crypto.randomUUID();dn({type:`spawn`,sessionId:t,...e}),Yt.current.add(t),K(!1),ve(null),ut(null),ft(null),U(t)}}),nn&&H&&!De&&(0,J.jsx)(Due,{open:ye,providers:R,config:{providerId:en.providerId,modelId:en.modelId,reasoningEnabled:en.reasoningEnabled,thinkingLevel:en.thinkingLevel},onClose:()=>be(!1),onSetModel:(e,t)=>dn({type:`set-model`,sessionId:H,providerId:e,modelId:t}),onSetReasoning:e=>dn({type:`set-reasoning`,sessionId:H,enabled:e}),onSetThinking:e=>dn({type:`set-thinking`,sessionId:H,level:e})})]})]})}function Yue(e){return!e.appleMobile||!e.standalone||e.safeTop<=0||e.innerHeight<=e.innerWidth?!1:e.innerHeight>=Math.max(e.screenWidth,e.screenHeight)-1}function Xue(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e&&!/^viewport-fit\s*=/i.test(e)).join(`, `)}function Zue(){return/iphone|ipad|ipod/i.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1}function Que(){let e=document.querySelector(`meta[name="viewport"]`);if(!e||!Zue())return;let t=document.createElement(`div`);t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:fixed;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom)`,document.body.appendChild(t);let n=()=>{let r=getComputedStyle(t);if(!Yue({appleMobile:!0,standalone:M9(),safeTop:Number.parseFloat(r.paddingTop)||0,innerWidth:window.innerWidth,innerHeight:window.innerHeight,screenWidth:window.screen.width,screenHeight:window.screen.height}))return;let i=Number.parseFloat(r.paddingBottom)||0;document.documentElement.style.setProperty(`--phone-safe-bottom`,`${i}px`),e.content=Xue(e.content),window.removeEventListener(`resize`,n),document.removeEventListener(`visibilitychange`,n),t.remove()};window.addEventListener(`resize`,n),document.addEventListener(`visibilitychange`,n),n()}var Z9=new URLSearchParams(location.search);if(Z9.get(`mode`)===`phone`){S(`phone`),Z9.delete(`mode`);let e=Z9.toString();history.replaceState(null,``,`${location.pathname}${e?`?${e}`:``}${location.hash}`)}var Q9=I(location.search,x(),N(),k());Q9&&location.replace(Q9),Bue(),h(),Que();var $9=document.getElementById(`root`);$9&&!Q9&&(0,ae.createRoot)($9).render((0,J.jsx)(G.StrictMode,{children:(0,J.jsx)(Jue,{})}));export{Y as t};
|
|
1626
|
+
`).trim()}var dle=e=>e===`outbox-discarding`?`正在移除…`:e===`outbox-discard`?`移除未保存,请勿关闭页面;请再次移除,重启后可能重新入队`:e===`outbox-storage`?`无法保存离线消息,请勿关闭页面;可重试或复制消息`:e===`delivery-unconfirmed`?`未收到回执,发送结果未确认;可重试确认`:e===`read-only`?`此设备为只读`:e&&Po(`zh`,Fi(e)??e),z7=(e=!1)=>e?`此设备为只读,刚才的操作未执行;可在桌面「设置 → 设备」切换为可操作`:`此设备为只读,只能查看;可在桌面「设置 → 设备」切换为可操作`,fle=70;function ple({percent:e,critical:t}){return(0,J.jsx)(`span`,{"aria-hidden":!0,className:`h-1 w-7 shrink-0 overflow-hidden rounded-full bg-muted-foreground/20`,children:(0,J.jsx)(`span`,{className:q(`block h-full rounded-full`,t?`bg-destructive`:e>=fle?`bg-warning`:`bg-muted-foreground/70`),style:{width:`${e}%`}})})}function mle(e,t){let n={inputTokens:0,outputTokens:0,...e};return t&&(n.contextUsed=t.used,t.window!==void 0&&(n.contextWindow=t.window)),n.inputTokens===0&&n.outputTokens===0&&n.cacheHitPercent===void 0&&n.ttftAvgMs===void 0&&n.tokensPerSecond===void 0&&n.contextUsed===void 0?void 0:n}function hle(e,t){let n={tokens:void 0,cache:void 0,context:void 0,speed:void 0};if(!t)return n;if(t.contextUsed!==void 0){let e=t.contextUsed,r=t.contextWindow??0;if(r>0){let t=Math.min(100,Math.round(e/r*100));n.context={compact:`${t}%`,full:`${_A(r)} · ${t}%`,percent:t,critical:t>=90}}else n.context={compact:`${_A(e)}·?`,full:`${_A(e)} · ?`}}let r=[],i=[];return t.ttftAvgMs!==void 0&&(r.push(vA(t.ttftAvgMs)),i.push(e(`First token avg {{duration}}`,{duration:vA(t.ttftAvgMs)}))),t.tokensPerSecond!==void 0&&(r.push(`${t.tokensPerSecond} tok/s`),i.push(e(`{{speed}} tok/s`,{speed:t.tokensPerSecond}))),r.length>0&&(n.speed={compact:r.join(` · `),full:i.join(` · `)}),(t.inputTokens>0||t.outputTokens>0)&&(n.tokens={compact:`↑${_A(t.inputTokens)} ↓${_A(t.outputTokens)}`,full:e(`Input {{input}} tok · Output {{output}} tok`,{input:_A(t.inputTokens),output:_A(t.outputTokens)})}),t.cacheHitPercent!==void 0&&(n.cache={compact:`${t.cacheHitPercent}%`,full:e(`Cache hit {{percent}}%`,{percent:t.cacheHitPercent})}),n}var gle=[[`tokens`,He],[`cache`,Ke],[`context`,tt],[`speed`,cn]];function _le({usageTotals:e,context:t}){let{t:n}=Ro(),r=hle(n,mle(e,t));return(0,J.jsx)(`div`,{"data-slot":`stats-line`,className:`flex min-h-6 flex-wrap items-center justify-center gap-x-3 px-1`,children:gle.map(([e,t])=>{let n=r[e];return n?(0,J.jsxs)(`span`,{className:q(`flex items-center gap-1 text-[11px] tabular-nums`,n.critical?`text-destructive`:`text-muted-foreground/80`),children:[n.percent===void 0?(0,J.jsx)(t,{className:`h-3 w-3 shrink-0 opacity-75`}):(0,J.jsx)(ple,{percent:n.percent,critical:!!n.critical}),n.compact]},e):null})})}function B7(e){let{view:t,sessionId:n}=e,r=(0,G.useRef)(null),[i,a]=(0,G.useState)(!1),o=(0,G.useRef)(null),s=(0,G.useRef)(null),c=(0,G.useRef)(!1);(0,G.useLayoutEffect)(()=>{let e=o.current,t=s.current,n=e?.querySelector(`[aria-selected="true"]`);!e||!t||!n||(c.current||(t.style.transition=`none`),t.style.transform=`translate(${n.offsetLeft}px, ${n.offsetTop}px)`,t.style.width=`${n.offsetWidth}px`,t.style.height=`${n.offsetHeight}px`,c.current||=(t.offsetWidth,t.style.transition=``,!0))},[n,e.tabGroup]);let l=t?.status===`running`,u=e.bot,d=!!(u?.readOnly||e.deviceReadOnly),f=e.artifacts?.chatId,p=e.artifacts?.conversationId,h=(0,G.useMemo)(()=>({...nle({sessionId:n,bot:u,deviceReadOnly:e.deviceReadOnly}),...f&&p?{turnFooter:e=>(0,J.jsx)(Qi,{target:{chatId:f,conversationId:p,messageIndex:e}})}:{}}),[n,u,e.deviceReadOnly,f,p]),g=(0,G.useMemo)(()=>{if(u)return[];let t=[{name:`/goal`,description:`Set a session goal (/goal <objective> · pause · resume · clear)`},{name:`/compact`,description:`Compact the context now (/compact [summary focus])`}],n=(e.slashCommands??[]).filter(e=>e.name!==`/goal`&&e.name!==`/compact`);return[...t,...n]},[e.slashCommands,u]),_=(0,G.useMemo)(()=>t?[...t.messages.entries()].sort((e,t)=>e[0]-t[0]):[],[t]),v=(0,G.useMemo)(()=>sle(_.map(([,e])=>e),e.echoes??[],n??``),[_,e.echoes,n]),y=v.length>0||t?.status===`running`||t?.status===`failed`;Sne(n?{id:n,projectId:``,status:t?.status??`idle`,started:y,spawning:!1,messages:v,queuedMessages:e.queued?.map(e=>({id:e.id,text:e.text}))}:null);let b=(0,G.useMemo)(()=>gI(v,l,[],e.cwd,{pendingApprovals:t?.approvals,compaction:t?.compaction,compactionNoticeAt:m(_.map(([e])=>e),t?.compactionNoticeAt)}),[v,_,l,e.cwd,t?.approvals,t?.compaction,t?.compactionNoticeAt]),x=t?.messages.size?Math.min(...t.messages.keys()):null,S=(0,G.useRef)(null),C=(0,G.useCallback)(()=>{if(!e.hasOlder||!e.onLoadOlder)return;let t=r.current?.getScroller();S.current=t?{height:t.scrollHeight,top:t.scrollTop}:null,e.onLoadOlder()},[e.hasOlder,e.onLoadOlder]);(0,G.useLayoutEffect)(()=>{let e=r.current?.getScroller(),t=S.current;!e||!t||(S.current=null,e.scrollTop=t.top+(e.scrollHeight-t.height))},[x]),(0,G.useEffect)(()=>{r.current?.isAtBottom()&&r.current.pinToBottom()},[b]);let w=async(t,n)=>{a(!0);try{let i=F7(n.length),a=[];for(let e of n)a.push(await vle(e,i));e.onSend(t,a),r.current?.scrollToBottom()}finally{a(!1)}};return(0,J.jsx)(wA.Provider,{value:h,children:(0,J.jsxs)(`div`,{className:`phone-chat-root flex h-full min-h-0 flex-col`,children:[(0,J.jsxs)(`header`,{className:`flex shrink-0 items-center gap-1 border-b bg-background px-2 py-2 pt-safe`,children:[u?.onBack||!e.drawerDocked?(0,J.jsx)(`button`,{type:`button`,onClick:u?.onBack??e.onOpenDrawer,"aria-label":u?.onBack?`返回群聊`:`打开会话列表`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:u?.onBack?(0,J.jsx)(Ae,{className:`h-4.5 w-4.5`}):(0,J.jsx)(Dt,{className:`h-4.5 w-4.5`})}):(0,J.jsx)(`span`,{className:`h-9 w-9 shrink-0`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 text-center`,children:[(0,J.jsxs)(`p`,{className:`flex min-w-0 items-center justify-center gap-1.5`,children:[e.connState!==`host-offline`&&e.connState!==`unauthorized`&&(0,J.jsx)(`span`,{className:q(`h-1.5 w-1.5 shrink-0 rounded-full`,e.connState===`online`&&!e.syncing?`bg-emerald-500`:`animate-pulse bg-amber-500`),title:e.connState===`online`&&e.syncing?`同步中…`:e.stateLabel}),(0,J.jsx)(`span`,{className:`truncate font-medium text-sm`,children:e.title})]}),(0,J.jsx)(`p`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:e.projectName||e.stateLabel})]}),u?.readOnly?(0,J.jsx)(`span`,{className:`h-9 w-9 shrink-0`}):(0,J.jsx)(`button`,{type:`button`,onClick:e.onNewSession,disabled:!e.canCreate||d||!!u&&i||e.connState!==`online`,"aria-label":`新建会话`,title:e.newSessionHint??`新建会话`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,children:(0,J.jsx)(Jt,{className:`h-4.5 w-4.5`})})]}),e.connState===`host-offline`&&(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-center gap-1.5 bg-amber-500/10 py-1 text-amber-700 text-xs dark:text-amber-400`,children:[(0,J.jsx)(pt,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:e.stateLabel})]}),e.tabGroup&&e.tabGroup.children.length>0&&(0,J.jsxs)(`div`,{ref:o,role:`tablist`,className:`t-tabs relative flex shrink-0 items-center justify-start gap-1 overflow-x-auto border-b px-2 py-1`,children:[(0,J.jsx)(`span`,{ref:s,"aria-hidden":`true`,className:`t-tabs-pill pointer-events-none absolute top-0 left-0 z-0 rounded-md bg-muted`}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===e.tabGroup.parent.id,className:V7(n===e.tabGroup.parent.id),onClick:()=>e.onSelectTab?.(e.tabGroup?.parent.id??``),children:[(0,J.jsx)(gt,{className:`h-3 w-3 shrink-0`}),(0,J.jsx)(`span`,{className:`max-w-40 truncate`,children:e.tabGroup.parent.title||`新对话`})]}),e.tabGroup.children.map(t=>(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===t.id,className:V7(n===t.id),onClick:()=>e.onSelectTab?.(t.id),children:[(0,J.jsx)(Ce,{className:`h-3 w-3 shrink-0`}),(0,J.jsx)(`span`,{className:`max-w-28 truncate`,children:t.title||`coworker`}),(0,J.jsx)(`span`,{className:q(`h-1.5 w-1.5 shrink-0 rounded-full`,t.status===`running`?`animate-pulse bg-brand`:t.status===`failed`?`bg-destructive`:`bg-muted-foreground/30`)})]},t.id))]}),n===null?(0,J.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,J.jsx)(`span`,{className:`mb-3 flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14`,children:(0,J.jsx)(EA,{className:`size-6`})}),(0,J.jsx)(`p`,{className:`font-semibold text-[22px] tracking-tight`,children:`EnsoCode`}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e.connState===`online`?`从左上角选择会话,或新建一个`:e.stateLabel})]}):(0,J.jsx)(Ace,{ref:r,items:b,busy:t===null?!!e.syncing:l,loading:t===null,running:l,error:void 0,emptyTitle:e.projectName||`EnsoCode`,virtualize:!1,historyLoading:e.historyLoading,hasOlder:e.hasOlder,firstItemIndex:x??0,onStartReached:e.hasOlder?C:void 0},n),n!==null&&(0,J.jsx)(`div`,{className:`phone-dock @container shrink-0 pt-1 pb-safe`,children:(0,J.jsxs)(`div`,{className:`enso-chat-col mx-auto w-full max-w-2xl px-4 @min-[56rem]:max-w-3xl @min-[72rem]:max-w-4xl @min-[84rem]:max-w-5xl @min-[96rem]:max-w-6xl @min-[112rem]:max-w-7xl`,children:[t?.retry&&(0,J.jsx)(Ice,{retry:t.retry}),!d&&(0,J.jsx)(Ene,{conversationId:n,queued:(e.queued??[]).map(e=>({id:e.id,text:e.text}))}),e.goal&&!d&&(0,J.jsx)(wne,{conversationId:n,goal:{...e.goal,noProgressRuns:0}}),(0,J.jsx)(Ose,{conversationId:n},n),(0,J.jsx)(qce,{sessionId:n,tasks:t?.tasks??[],subagents:t?.subagents??[],readOnly:e.deviceReadOnly}),u?.outbox,u?.notice&&(0,J.jsx)(`p`,{className:`mb-1 rounded-md bg-destructive/10 px-2 py-1 text-destructive text-xs`,children:u.notice}),e.deviceReadOnly?(0,J.jsx)(`p`,{className:`mb-1 rounded-md bg-muted px-2 py-1 text-center text-muted-foreground text-xs`,children:z7(e.readOnlyRejected)}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Eg,{approvals:t?.approvals??[],onRespond:e.onApproval,clockOffset:e.clockOffset}),(0,J.jsx)(Dg,{asks:t?.asks??[],onAnswer:e.onAsk,clockOffset:e.clockOffset,autoFocus:!1})]}),!d&&(0,J.jsx)(CA,{commands:g,running:l,busy:l,locked:e.newSessionBusy||!!u&&i||(t?.approvals??[]).length>0,focusKey:u?.chatId?`bot-chat:${u.chatId}`:n,autoFocus:!1,enterToSend:!1,toolbar:e.modelLabel&&e.onOpenConfig?(0,J.jsxs)(`button`,{type:`button`,onClick:e.onOpenConfig,className:`flex min-w-0 items-center gap-0.5 rounded-md px-1.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[(0,J.jsx)(`span`,{className:`truncate`,children:e.modelLabel}),(0,J.jsx)(Oe,{className:`h-3 w-3 shrink-0`})]}):void 0,onSend:e=>{w(e.text,e.images)},onAbort:e.onAbort,voice:e.voice,voiceMode:`hold`}),!d&&(0,J.jsx)(_le,{usageTotals:e.usageTotals,context:e.context})]})})]})})}function V7(e){return q(`t-tab flex min-w-0 shrink-0 items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors`,e?`font-medium`:`text-muted-foreground`)}async function vle(e,t){if(e.data.length*.75<=t)return e;let n=await(await fetch(`data:${e.mimeType};base64,${e.data}`)).blob();return I7(new File([n],`image`,{type:e.mimeType}),t)}function yle(e){if(e==null||!Number.isFinite(e)||e<0)return null;let t=Math.round(e);return t<1?`<1ms`:`${t}ms`}function ble(e,t){let n=e===`direct`?`直连`:`中继`,r=yle(t);return r?`已连接 · ${n} · ${r}`:`已连接 · ${n}`}var H7=`enso-phone-drawer-segment`;function xle(){let e=localStorage.getItem(H7);return e===`bot`||e===`code`?e:null}function Sle(e){localStorage.setItem(H7,e)}function U7(e,t){if(!e)return!1;let n=xle();return n?n===`bot`:t!==null}function Cle(e,t=0){let n=new Map;for(let r of e)if(!(r.seq<=t)&&((r.kind===`human`||r.newConversation)&&n.clear(),r.kind===`bot`&&r.botId&&n.delete(r.botId),r.failure&&n.set(r.failure.botId,r.id),r.retryOf))for(let[e,t]of n)t===r.retryOf&&n.delete(e);return new Set(n.values())}function wle(e,t){let n=RegExp(`#${t}(?!\\d)`).exec(e);if(!n)return;let r=n.index+n[0].length;return[e.slice(0,n.index),n[0],e.slice(r)]}function Tle({status:e}){return e===`running`?(0,J.jsx)(pt,{className:`h-3 w-3 shrink-0 animate-spin text-brand`}):e===`done`?(0,J.jsx)(De,{className:`h-3 w-3 shrink-0 text-muted-foreground`}):e===`denied`?(0,J.jsx)(Wt,{className:`h-3 w-3 shrink-0 text-muted-foreground`}):e===`timeout`?(0,J.jsx)(Ve,{className:`h-3 w-3 shrink-0 text-warning`}):(0,J.jsx)(sn,{className:`h-3 w-3 shrink-0 text-destructive`})}function Ele({item:e,bots:t,clockOffset:n,onOpen:r}){let i=t.get(e.botId),a=e.ownerBotId?t.get(e.ownerBotId):void 0,o=e.state!==`queued`,[s,c]=(0,G.useState)(()=>Date.now());(0,G.useEffect)(()=>{if(!o)return;let e=window.setInterval(()=>c(Date.now()),1e3);return()=>window.clearInterval(e)},[o]);let l=s-n,u=o&&r?()=>r(e.conversationId):void 0;return(0,J.jsxs)(`button`,{type:`button`,disabled:!u,onClick:u,className:`flex w-full gap-2 rounded-lg border bg-muted/30 px-2.5 py-2 text-left disabled:cursor-default`,children:[(0,J.jsx)(La,{bot:i,size:`sm`,busy:o}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,J.jsxs)(`span`,{className:`truncate font-medium`,children:[i?.name??`成员`,a?(0,J.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` 替 `,a.name]}):null]}),(0,J.jsx)(`span`,{className:q(`shrink-0`,o?`text-brand`:`text-muted-foreground`),children:bo(e)}),o&&e.startedAt!==void 0&&(0,J.jsx)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:Co(l-e.startedAt)}),u&&(0,J.jsx)(ke,{className:`ml-auto h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),e.more>0&&(0,J.jsxs)(`span`,{className:`mt-1 block text-[11px] text-muted-foreground`,children:[`+`,e.more,` 个更早的步骤`]}),e.steps.map((e,t)=>(0,J.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-[11px]`,children:[(0,J.jsx)(Tle,{status:e.status}),(0,J.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.name}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-muted-foreground`,children:e.detail}),e.status===`timeout`&&(0,J.jsx)(`span`,{className:`shrink-0 text-warning`,children:e.name===`ask_user`?`已超时未回答`:`已超时拒绝`}),(0,J.jsx)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:e.durationMs===void 0?e.startedAt===void 0?``:Co(l-e.startedAt):Co(e.durationMs)})]},t))]})]})}var W7=e=>[...e].sort((e,t)=>t.activityAt-e.activityAt);function Dle(e,t,n=10){let r=W7(e),i=e=>e.id===t.currentId||e.id===t.rootId?0:e.unread||e.running?1:2,a=new Set([...r].sort((e,t)=>i(e)-i(t)).slice(0,n).map(e=>e.id));return r.filter(e=>a.has(e.id)).sort((e,n)=>Number(n.id===t.rootId)-Number(e.id===t.rootId))}function Ole(e,t,n){let r=t.trim().toLowerCase();return W7(e).filter(e=>(n===`all`||(n===`unread`?e.unread:e.running))&&(!r||`${e.title}\n${e.preview??``}`.toLowerCase().includes(r)))}var kle=G.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=Jk(),{clearErrors:C}=Zk(),w=h||s,T=m??a,E={...p,disabled:w},{labelId:D}=$k(),O=tA({id:i});Z(()=>{let e=o!=null;S.inputRef.current?.value||e&&o!==``?b(!0):e&&o===``&&b(!1)},[S.inputRef,b,o]);let k=G.useRef(null);Z(()=>{u&&k.current===Ay(Dv(k.current))&&y(!0)},[u,y]);let[A]=xO({controlled:o,default:l,name:`FieldControl`,state:`value`}),j=o!==void 0,M=j?A:void 0,N=xv(()=>S.inputRef.current?.value);return Yk(S.inputRef,O,M,N,!w,a),Wn(`input`,e,{ref:[t,k],state:E,props:[{id:O,disabled:w,name:T,ref:S.inputRef,"aria-labelledby":D,autoFocus:u,...j?{value:M}:{defaultValue:l},onChange(e){let t=e.currentTarget.value;c?.(t,Kv(Mv,e.nativeEvent)),_(t!==(v.initialValue??``)),b(t!==``),e.nativeEvent.defaultPrevented||(C(T),S.change(t))},onFocus(){y(!0)},onBlur(e){g(!0),y(!1),x===`onBlur`&&S.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(g(!0),S.commit(e.currentTarget.value))}},f,e=>S.getValidationProps(w,e)],stateAttributesMapping:Gk})}),Ale=G.forwardRef(function(e,t){return(0,J.jsx)(kle,{ref:t,...e})});function G7({className:e,size:t=`default`,unstyled:n=!1,...r}){return(0,J.jsx)(`span`,{className:q(!n&&`relative inline-flex w-full rounded-lg border border-input bg-background bg-clip-padding text-base shadow-xs ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none has-focus-visible:ring-[3px] sm:text-sm dark:bg-input/32 dark:not-in-data-[slot=group]:bg-clip-border dark:has-aria-invalid:ring-destructive/24 dark:not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/8%)]`,e)||void 0,"data-size":t,"data-slot":`input-control`,children:(0,J.jsx)(Ale,{className:q(`h-8.5 w-full min-w-0 rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-8.5 outline-none placeholder:text-muted-foreground/72 sm:h-7.5 sm:leading-7.5`,t===`sm`&&`h-7.5 px-[calc(--spacing(2.5)-1px)] leading-7.5 sm:h-6.5 sm:leading-6.5`,t===`lg`&&`h-9.5 leading-9.5 sm:h-8.5 sm:leading-8.5`,r.type===`search`&&`[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none`,r.type===`file`&&`text-muted-foreground file:me-3 file:bg-transparent file:font-medium file:text-foreground file:text-sm`),"data-slot":`input`,size:typeof t==`number`?t:void 0,...r})})}var K7=nT,jle=Rw;function Mle({className:e,...t}){return(0,J.jsx)(X_,{className:q(`fixed inset-0 z-50 bg-black/32 backdrop-blur-sm transition-opacity duration-150 ease-out data-ending-style:opacity-0 data-starting-style:opacity-0`,e),"data-slot":`sheet-backdrop`,...t})}function Nle({className:e,side:t,inset:n=!1,...r}){return(0,J.jsx)(rT,{className:q(`fixed inset-0 z-50 grid`,t===`bottom`&&`grid grid-rows-[1fr_auto] pt-12`,t===`top`&&`grid grid-rows-[auto_1fr] pb-12`,t===`left`&&`flex justify-start`,t===`right`&&`flex justify-end`,n&&`sm:p-4`),"data-slot":`sheet-viewport`,...r})}function q7({className:e,children:t,showCloseButton:n=!0,side:r=`right`,inset:i=!1,...a}){return(0,J.jsxs)(jle,{children:[(0,J.jsx)($T,{}),(0,J.jsx)(Mle,{}),(0,J.jsx)(Nle,{inset:i,side:r,children:(0,J.jsxs)(Fw,{className:q(`relative flex max-h-full min-h-0 w-full min-w-0 flex-col bg-popover bg-clip-padding text-popover-foreground shadow-lg transition-[opacity,translate] duration-150 [transition-timing-function:cubic-bezier(0.34,1.56,0.64,1)] will-change-transform before:pointer-events-none before:absolute before:inset-0 before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:opacity-0 data-starting-style:opacity-0 max-sm:before:hidden dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,r===`bottom`&&`row-start-2 border-t data-ending-style:translate-y-8 data-starting-style:translate-y-8`,r===`top`&&`data-ending-style:-translate-y-8 data-starting-style:-translate-y-8 border-b`,r===`left`&&`data-ending-style:-translate-x-8 data-starting-style:-translate-x-8 w-[calc(100%-(--spacing(12)))] max-w-md border-e`,r===`right`&&`col-start-2 w-[calc(100%-(--spacing(12)))] max-w-md border-s data-ending-style:translate-x-8 data-starting-style:translate-x-8`,i&&`before:hidden sm:rounded-2xl sm:border sm:before:rounded-[calc(var(--radius-2xl)-1px)] sm:**:data-[slot=sheet-footer]:rounded-b-[calc(var(--radius-2xl)-1px)]`,e),"data-slot":`sheet-popup`,...a,children:[t,n&&(0,J.jsx)(qv,{"aria-label":`Close`,className:`absolute end-2 top-2`,render:(0,J.jsx)(ji,{size:`icon`,variant:`ghost`}),children:(0,J.jsx)(sn,{})})]})})]})}function J7({className:e,...t}){return(0,J.jsx)(`div`,{className:q(`flex flex-col gap-2 p-6 in-[[data-slot=sheet-popup]:has([data-slot=sheet-panel])]:pb-3 max-sm:pb-4`,e),"data-slot":`sheet-header`,...t})}function Y7({className:e,...t}){return(0,J.jsx)(iT,{className:q(`font-heading text-xl leading-none`,e),"data-slot":`sheet-title`,...t})}function X7(e,t,n=Date.now()){let r=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),i=e-n,a=Math.abs(i);return a<6e4?r.format(0,`second`):a<36e5?r.format(Math.trunc(i/6e4),`minute`):a<864e5?r.format(Math.trunc(i/36e5),`hour`):a<2592e6?r.format(Math.trunc(i/864e5),`day`):a<31536e6?r.format(Math.trunc(i/2592e6),`month`):r.format(Math.trunc(i/31536e6),`year`)}function Z7({entry:e}){return(0,J.jsxs)(J.Fragment,{children:[e.running&&(0,J.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-warning`}),(0,J.jsx)(`span`,{className:`shrink-0 text-muted-foreground text-xs`,children:X7(e.activityAt,`zh`)})]})}function Ple({threads:e,status:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(``),{entries:o,currentId:s,rootId:c,disabledHint:l}=e,u=o.find(e=>e.id===s),d=Dle(o,{currentId:s,rootId:c}),f=o.length-d.length,p=Ole(o,i,`all`),m=t=>{!l&&t!==s&&e.onSelect(t)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Nk,{children:[(0,J.jsxs)(Fk,{"aria-label":`切换话题`,className:`mx-auto flex max-w-full items-center justify-center gap-0.5 text-[11px] text-muted-foreground`,children:[(0,J.jsxs)(`span`,{className:`truncate`,children:[u?.title??`主话题`,t&&` · ${t}`]}),(0,J.jsx)(Oe,{className:`h-3 w-3 shrink-0`})]}),(0,J.jsxs)(Ik,{className:`w-72 max-w-[calc(100vw-1rem)]`,children:[(0,J.jsxs)(Rk,{children:[(0,J.jsx)(Bk,{children:`话题`}),d.map(e=>(0,J.jsxs)(zk,{disabled:!!l&&e.id!==s,onClick:()=>m(e.id),children:[(0,J.jsx)(De,{className:q(e.id!==s&&`invisible`)}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,J.jsx)(Z7,{entry:e})]},e.id))]}),(0,J.jsx)(Vk,{}),f>0&&(0,J.jsxs)(zk,{onClick:()=>{a(``),r(!0)},children:[(0,J.jsx)(ft,{}),`全部话题(`,o.length,`)`]}),(0,J.jsxs)(zk,{disabled:!!l,onClick:e.onCreate,children:[(0,J.jsx)(_t,{}),`新话题`]}),l&&(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-muted-foreground text-xs`,children:l})]})]}),(0,J.jsx)(K7,{open:n,onOpenChange:r,children:(0,J.jsxs)(q7,{side:`bottom`,className:`max-h-[80vh] pb-safe`,children:[(0,J.jsx)(J7,{children:(0,J.jsxs)(Y7,{children:[`全部话题(`,o.length,`)`]})}),(0,J.jsx)(`div`,{className:`px-4 pb-2`,children:(0,J.jsx)(G7,{value:i,placeholder:`搜索话题…`,onChange:e=>a(e.target.value)})}),l&&(0,J.jsx)(`p`,{className:`px-4 pb-2 text-muted-foreground text-xs`,children:l}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-3`,children:[p.map(e=>(0,J.jsxs)(`button`,{type:`button`,disabled:!!l&&e.id!==s,onClick:()=>{m(e.id),r(!1)},className:`flex w-full items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-accent disabled:opacity-60`,children:[(0,J.jsx)(De,{className:q(`h-4 w-4 shrink-0`,e.id!==s&&`invisible`)}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`block truncate text-sm`,children:e.title}),e.preview&&(0,J.jsx)(`span`,{className:`block truncate text-muted-foreground text-xs`,children:e.preview})]}),(0,J.jsx)(Z7,{entry:e})]},e.id)),p.length===0&&(0,J.jsx)(`p`,{className:`py-8 text-center text-muted-foreground text-sm`,children:`没有匹配的话题`})]})]})})]})}var Fle={queued:`排队中`,running:`进行中`,completed:`已完成`,failed:`失败`,canceled:`已取消`,blocked:`卡住了`},Q7=4,Ile=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),Lle={started:{icon:Ie,className:`border-brand/50 text-brand`},blocked:{icon:Ne,className:`border-warning/60 text-warning`},delivered:{icon:Pe,className:`border-success/60 text-success`}};function Rle({entry:e,bots:t}){let n=!!e.taskId,[r,i]=(0,G.useState)(!n),a=(0,J.jsxs)(J.Fragment,{children:[n&&(0,J.jsx)(ke,{"aria-hidden":!0,className:q(`h-3 w-3 shrink-0 transition-transform`,r&&`rotate-90`)}),(0,J.jsxs)(`span`,{className:`font-medium`,children:[t.get(e.from)?.name??`成员`,` → `,t.get(e.to)?.name??`成员`]}),(0,J.jsx)(`span`,{className:q(`rounded px-1.5 py-0.5`,e.state===`running`||e.state===`queued`?`bg-brand/10 text-brand`:e.state===`failed`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`),children:Fle[e.state]})]});return(0,J.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2 text-xs`,children:[n?(0,J.jsx)(`button`,{type:`button`,"aria-expanded":r,"aria-label":r?`收起委派结果`:`展开委派结果`,className:`flex w-full items-center gap-1.5 text-left`,onClick:()=>i(e=>!e),children:a}):(0,J.jsx)(`p`,{className:`flex items-center gap-1.5`,children:a}),r&&e.summary&&(0,J.jsx)(`p`,{className:`mt-1 line-clamp-3 text-muted-foreground`,children:e.summary})]})}function $7(e,t){let n=[...t].sort((e,t)=>t.length-e.length),r=[],i=e,a=0;for(;i;){let e=i.indexOf(`@`),t=e<0?void 0:n.find(t=>i.startsWith(t,e+1));if(e<0||!t){r.push(i);break}e>0&&r.push(i.slice(0,e)),r.push((0,J.jsxs)(`span`,{className:`font-medium text-brand`,children:[`@`,t]},a++)),i=i.slice(e+1+t.length)}return r}function zle(e){let{chat:t,bots:n,timeline:r,state:i}=e,a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useRef)(null),c=(0,G.useRef)(!0),l=(0,G.useRef)(null),u=(0,G.useRef)(null),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(0),[h,g]=(0,G.useState)([]),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(null),x=r?.entries??[],S=t.epochSeq??x.findLast(e=>e.kind===`system`&&e.newConversation)?.seq??0,[C,w]=(0,G.useState)(!1);(0,G.useEffect)(()=>w(!1),[t.id,S]);let T=S>0&&!C,E=co(x,S,C),D=Cle(x,S),O=t.members.map(e=>n.get(e)).filter(e=>!!(e&&!e.archived)),k=O.map(e=>e.name),A=!!i?.current||t.status!==`idle`,j=fo(d,p),M=j?mo(j.query,O):[],N=E[0]?.seq,P=E.at(-1)?.seq;(0,G.useLayoutEffect)(()=>{let e=a.current;if(!e)return;let t=s.current;t?(s.current=null,e.scrollTop=t.top+(e.scrollHeight-t.height)):c.current&&(e.scrollTop=e.scrollHeight)},[N,P,i?.current,e.activities.length]);let F=()=>{let t=a.current;!r?.hasOlder||!t||e.historyLoading||e.connState!==`online`||T&&(x[0]?.seq??S)<=S||(s.current={height:t.scrollHeight,top:t.scrollTop},e.onLoadOlder())},I=e=>{if(!j)return;let t=ho(d,j,p,e.name);f(t.text),m(t.caret),requestAnimationFrame(()=>{o.current?.focus(),o.current?.setSelectionRange(t.caret,t.caret)})},L=(0,G.useRef)(h);L.current=h,(0,G.useEffect)(()=>()=>{for(let e of L.current)URL.revokeObjectURL(e.url)},[]);let R=e=>{let t=[...e??[]].filter(e=>e.type.startsWith(`image/`)).slice(0,Q7-h.length).map(e=>({file:e,url:URL.createObjectURL(e)}));g(e=>[...e,...t]),b(null)},z=e=>{URL.revokeObjectURL(e),g(t=>t.filter(t=>t.url!==e))},B=async()=>{if(!d.trim()&&h.length===0||_||e.newSessionBusy)return;let t=[];if(h.length){v(!0);try{t=await ile(h.map(e=>e.file))}catch(e){b(e instanceof Error?e.message:`图片处理失败`);return}finally{v(!1)}}e.onSend(d,t);for(let e of h)URL.revokeObjectURL(e.url);g([]),b(null),f(``),m(0),c.current=!0},V=e=>{let t=o.current,n=t?.selectionStart??d.length,r=t?.selectionEnd??d.length,i=d.slice(0,n)+e+d.slice(r);f(i),m(n+e.length),requestAnimationFrame(()=>{t?.focus(),t?.setSelectionRange(n+e.length,n+e.length)})},ee=t=>{switch(t.kind){case`human`:return(0,J.jsxs)(`div`,{className:`flex flex-col items-end`,children:[t.text&&(0,J.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-brand/10 px-3 py-2 text-sm`,children:[$7(t.text,k),t.truncated&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`消息过长,仅显示部分内容`})]}),t.images?.length?(0,J.jsx)(Qi,{target:{chatId:e.chat.id,entryId:t.id}}):null]},t.seq);case`bot`:{let r=n.get(t.botId);return(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(La,{bot:r,size:`sm`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`p`,{className:`flex items-baseline gap-1.5 text-xs`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:r?.name??`成员`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:Ile(t.at)})]}),(0,J.jsxs)(`div`,{className:`mt-0.5 min-w-0 text-sm`,children:[(0,J.jsx)(I5,{text:t.text}),t.truncated&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`消息过长,仅显示部分内容`})]}),(0,J.jsx)(Qi,{target:{chatId:e.chat.id,entryId:t.id}}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>e.onOpenProcess(t.conversationId),className:`mt-0.5 flex items-center gap-0.5 text-muted-foreground text-xs hover:text-foreground`,children:[(0,J.jsx)(ke,{className:`h-3 w-3`}),`查看过程`]})]})]},t.seq)}case`delegation`:return(0,J.jsx)(Rle,{entry:t,bots:n},t.seq);case`progress`:{let e=n.get(t.botId),r=Lle[t.phase],i=r.icon,a=wle(t.text,t.taskSeq);return(0,J.jsxs)(`div`,{"data-phase":t.phase,className:`flex gap-2 text-xs`,children:[(0,J.jsx)(La,{bot:e,size:`sm`}),(0,J.jsxs)(`div`,{className:q(`flex min-w-0 items-start gap-1.5 rounded-md border-l-2 bg-muted/50 px-2 py-1`,r.className),children:[(0,J.jsx)(i,{"aria-hidden":!0,className:`mt-px h-3.5 w-3.5 shrink-0`}),(0,J.jsxs)(`p`,{className:`line-clamp-2 min-w-0 break-words text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.name??`成员`}),` `,a?(0,J.jsxs)(J.Fragment,{children:[$7(a[0],k),(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:a[1]}),$7(a[2],k)]}):$7(t.text,k)]})]})]},t.seq)}case`system`:return(0,J.jsxs)(`p`,{className:`text-center text-muted-foreground text-xs`,children:[t.text,D.has(t.id)&&e.onRetry&&!e.deviceReadOnly&&(0,J.jsx)(`button`,{type:`button`,className:`ml-2 underline disabled:opacity-50`,disabled:A||e.connState!==`online`,onClick:()=>e.onRetry?.(t.id),children:`重试`})]},t.seq)}},H=i?.current?n.get(i.current):void 0;return(0,J.jsxs)(`div`,{className:`phone-chat-root flex h-full min-h-0 flex-col`,children:[(0,J.jsxs)(`header`,{className:`flex shrink-0 items-center gap-1 border-b bg-background px-2 py-2 pt-safe`,children:[e.drawerDocked?(0,J.jsx)(`span`,{className:`h-9 w-9 shrink-0`}):(0,J.jsx)(`button`,{type:`button`,onClick:e.onOpenDrawer,"aria-label":`打开会话列表`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,J.jsx)(Dt,{className:`h-4.5 w-4.5`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 text-center`,children:[(0,J.jsx)(`p`,{className:`truncate font-medium text-sm`,children:t.title||`群聊`}),e.threads?(0,J.jsx)(Ple,{threads:e.threads,status:e.connState===`online`?void 0:e.stateLabel}):(0,J.jsx)(`p`,{className:`truncate text-[11px] text-muted-foreground`,children:e.connState===`online`?`${t.members.length} 位成员`:e.stateLabel})]}),e.threads?(0,J.jsx)(`button`,{type:`button`,onClick:e.threads.onCreate,disabled:!!e.threads.disabledHint,"aria-label":`新话题`,title:e.threads.disabledHint??`新话题`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,children:(0,J.jsx)(Jt,{className:`h-4.5 w-4.5`})}):(0,J.jsx)(`button`,{type:`button`,onClick:e.onNewSession,disabled:!e.canCreate||e.deviceReadOnly||_||e.connState!==`online`,"aria-label":`新建会话`,title:e.newSessionHint??`新建会话`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,children:(0,J.jsx)(Jt,{className:`h-4.5 w-4.5`})})]}),(0,J.jsxs)(`div`,{ref:a,onScroll:e=>{let t=e.currentTarget;c.current=t.scrollHeight-t.scrollTop-t.clientHeight<40,t.scrollTop<60&&F()},className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-3 py-3`,children:[r===void 0?(0,J.jsxs)(`p`,{className:`flex items-center justify-center gap-1.5 py-8 text-muted-foreground text-sm`,children:[(0,J.jsx)(pt,{className:`h-4 w-4 animate-spin`}),`读取中…`]}):r.hasOlder&&(!T||(x[0]?.seq??S)>S)?(0,J.jsx)(`button`,{type:`button`,onClick:F,disabled:e.historyLoading||e.connState!==`online`,className:`w-full py-1 text-center text-muted-foreground text-xs`,children:e.historyLoading?`加载中…`:`加载更早的消息`}):E.length===0?(0,J.jsx)(`p`,{className:`py-8 text-center text-muted-foreground text-sm`,children:`@ 成员开始对话,未 @ 时由群主回复`}):null,S>0&&(0,J.jsx)(`button`,{type:`button`,className:`w-full py-1 text-center text-muted-foreground text-xs`,onClick:()=>{w(!C),C&&r?.history?e.onJumpLatest?.():!C&&r?.hasOlder&&!x.some(e=>e.seq<S)&&e.onLoadOlder()},children:T?`更早的对话 · ${S-1} 条`:`收起更早的对话`}),r?.history&&(0,J.jsx)(`button`,{type:`button`,className:`w-full py-1 text-center text-brand text-xs`,onClick:()=>{c.current=!0,e.onJumpLatest?.()},children:`回到最新消息`}),E.map(ee),e.activities.map(t=>(0,J.jsx)(Ele,{item:t,bots:n,clockOffset:e.clockOffset,onOpen:e.onOpenProcess},t.conversationId)),H&&e.activities.length===0&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(La,{bot:H,size:`sm`,busy:!0}),(0,J.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[H.name,` 正在回复…`]})]})]}),(0,J.jsxs)(`div`,{className:`phone-dock shrink-0 space-y-2 px-3 pt-1 pb-safe`,children:[e.outbox,e.notice&&(0,J.jsx)(`p`,{className:`rounded-md bg-destructive/10 px-2 py-1 text-destructive text-xs`,children:e.notice}),e.deviceReadOnly&&(0,J.jsx)(`p`,{className:`rounded-md bg-muted px-2 py-1 text-center text-muted-foreground text-xs`,children:z7(e.readOnlyRejected)}),!e.deviceReadOnly&&e.pending.map(({sessionId:t,botId:r,view:i})=>i.approvals.length>0||i.asks.length>0?(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n.get(r)?.name??`成员`}),(0,J.jsx)(Eg,{approvals:i.approvals,clockOffset:e.clockOffset,onRespond:(n,r)=>e.onApproval(t,n,r)}),(0,J.jsx)(Dg,{asks:i.asks,clockOffset:e.clockOffset,onAnswer:(n,r)=>e.onAsk(t,n,r),autoFocus:!1})]},t):null),(0,J.jsxs)(`div`,{className:q(`relative`,e.deviceReadOnly&&`hidden`),children:[M.length>0&&(0,J.jsx)(`div`,{className:`absolute right-0 bottom-full left-0 mb-1 max-h-48 overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`,children:M.map(e=>{let t=n.get(e.id);return(0,J.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>I(e),className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-accent`,children:[t?(0,J.jsx)(La,{bot:t,size:`sm`}):(0,J.jsx)(`span`,{className:`flex h-7 w-7 items-center justify-center rounded-full bg-muted text-xs`,children:`@`}),(0,J.jsx)(`span`,{className:`font-medium`,children:e.name}),t?.title&&(0,J.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:t.title})]},e.id)})}),y&&(0,J.jsx)(`p`,{className:`mb-1 text-destructive text-xs`,children:y}),h.length>0&&(0,J.jsx)(`div`,{className:`mb-1.5 flex gap-1.5`,children:h.map(e=>(0,J.jsxs)(`div`,{className:`relative h-14 w-14 overflow-hidden rounded-lg border`,children:[(0,J.jsx)(`img`,{src:e.url,alt:``,className:`h-full w-full object-cover`}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`移除图片`,onClick:()=>z(e.url),className:`absolute top-0.5 right-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-black/60 text-white`,children:(0,J.jsx)(sn,{className:`h-3 w-3`})})]},e.url))}),(0,J.jsxs)(`div`,{ref:u,className:`flex items-end gap-2 rounded-2xl border bg-background px-3 py-2`,children:[(0,J.jsx)(`input`,{ref:l,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,onChange:e=>{R(e.target.files),e.target.value=``}}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`添加图片`,disabled:h.length>=Q7,onClick:()=>l.current?.click(),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-muted-foreground disabled:opacity-40`,children:(0,J.jsx)(ot,{className:`h-4.5 w-4.5`})}),e.voice&&(0,J.jsx)(`span`,{className:`flex h-8 shrink-0 items-center justify-center [&>div>button]:h-8 [&>div>button]:min-w-8 [&>div>button]:rounded-full`,children:(0,J.jsx)(lD,{startSession:e.voice,disabled:_,holdScope:u,onText:V})}),(0,J.jsx)(`textarea`,{ref:o,rows:1,value:d,placeholder:`@ 成员,或直接说…`,onChange:e=>{f(e.target.value),m(e.target.selectionStart??e.target.value.length)},onSelect:e=>m(e.currentTarget.selectionStart??0),className:`max-h-32 min-h-6 flex-1 resize-none bg-transparent text-sm outline-none field-sizing-content`}),A&&(0,J.jsx)(`button`,{type:`button`,"aria-label":`停止`,onClick:e.onStop,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-foreground`,children:(0,J.jsx)(Qt,{className:`h-3.5 w-3.5 fill-current`})}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`发送`,disabled:!d.trim()&&h.length===0||_||e.newSessionBusy||!e.outbox&&e.connState!==`online`,onClick:()=>void B(),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-brand text-brand-foreground disabled:opacity-40`,children:(0,J.jsx)(be,{className:`h-4 w-4`})})]})]})]})]})}var e9=e=>typeof window.matchMedia==`function`&&window.matchMedia(e).matches;function Ble(e){return(0,G.useSyncExternalStore)(t=>{if(typeof window.matchMedia!=`function`)return()=>{};let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},()=>e9(e),()=>e9(e))}var Vle=`(min-width: 900px)`;function Hle(e){let t=G.useRef(!0);t.current&&(t.current=!1,e())}var t9=G.createContext(null);function n9(){let e=G.useContext(t9);if(e===null)throw Error(En(60));return e}var Ule=(e,t)=>Object.is(e,t);function r9(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function i9(e,t,n){return!e||e.length===0?-1:e.findIndex(e=>e!==void 0&&r9(e,t,n))}function Wle(e,t,n){return e.filter(e=>!r9(t,e,n))}function a9(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function o9(e){return e!=null&&e.length>0&&typeof e[0]==`object`&&e[0]!=null&&`items`in e[0]}function Gle(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(o9(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function s9(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return a9(e)}function c9(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?a9(e.value):a9(e)}function l9(e,t,n){function r(){return s9(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){let n=t,i=o9(n)?n.flatMap(e=>e.items):n;if(typeof e!=`object`||!e){let t=i.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=i.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function Kle(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,J.jsx)(G.Fragment,{children:l9(r,t,n)},i)),e),[])}var u9={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:c9(t,r)!==``},hasNullItemLabel:(e,t)=>t?Gle(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>r9(t,e,n)):r9(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function qle(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:y=!1,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S=Ule,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=Zk(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=Jk(),F=tA({id:t}),I=M||d,L=j??c,[R,z]=xO({controlled:n,default:y?r??zn:r,name:`Select`,state:`value`}),[B,V]=xO({controlled:a,default:o,name:`Select`,state:`open`}),ee=G.useRef([]),H=G.useRef([]),U=G.useRef(null),W=G.useRef(null),te=G.useRef(0),ne=G.useRef(null),re=G.useRef([]),ie=G.useRef(!1),ae=G.useRef(null),oe=G.useRef(null),se=G.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ce=G.useRef(!1),{mounted:le,setMounted:ue,transitionStatus:de}=OC(B),{openMethod:fe,triggerProps:pe}=cT(B),me=On(()=>new wC({id:F,labelId:void 0,modal:m,multiple:y,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,value:R,open:B,mounted:le,transitionStatus:de,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,he=yC(me,u9.activeIndex),ge=yC(me,u9.selectedIndex),K=yC(me,u9.triggerElement),_e=yC(me,u9.positionerElement),ve=gk(fe),ye=fe??ve,be=G.useMemo(()=>y?``:c9(R,x),[y,R,x]),xe=G.useMemo(()=>y&&Array.isArray(R)?R.map(e=>c9(e,x)):c9(R,x),[y,R,x]);Yk(Jy(K),F,R,xv(()=>xe),!I,c);let Se=G.useRef(R),Ce=y?Array.isArray(R)&&R.length>0:R!=null&&be!==``;Z(()=>{A(Ce)},[Ce,A]),Z(function(){let e=R,t=!1;if(y){let n=Array.isArray(R)?R:[];t=n.length===0,e=n[n.length-1]}let n=t?-1:i9(re.current,e,S),r=n===-1?null:n;r===null&&(oe.current=null),!B&&me.set(`selectedIndex`,r)},[y,B,R,S,me]);function we(e){let t=k.initialValue;return Array.isArray(e)&&Array.isArray(t)?!Hk(e,t,(e,t)=>r9(e,t,S)):e!==t}oT(R,()=>{T(L),E(we(R)),N.change(R)});let Te=xv((e,t)=>{s?.(e,t),!t.isCanceled&&(V(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(D(!0),O(!1),P===`onBlur`&&N.commit(R)))}),Ee=xv(()=>{ue(!1),me.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)});AC({enabled:!h,open:B,ref:U,onComplete(){B||Ee()}}),G.useImperativeHandle(h,()=>({unmount:Ee}),[Ee]);let De=xv((e,t)=>{i?.(e,t),!t.isCanceled&&z(e)}),Oe=xv(e=>{let t=AT(e.scrollHeight,e.clientHeight),n=jT(e.scrollTop,t),r=n>0,i=n<t;me.set(`scrollUpArrowVisible`,r),me.set(`scrollDownArrowVisible`,i)}),ke=tw({open:B,onOpenChange:Te,elements:{reference:K,floating:_e}}),Ae=Vx(ke,{enabled:!f&&!I,event:`mousedown`}),je=Wx(ke),Me=xw(ke,{enabled:!f&&!I,listRef:ee,activeIndex:he,selectedIndex:ge,disabledIndices:zn,onNavigate(e){e===null&&!B||me.set(`activeIndex`,e)},focusItemOnHover:C}),Ne=Sw(ke,{enabled:!f&&!I&&(B||!y),listRef:H,activeIndex:he,selectedIndex:ge,disabledIndices:e=>Mk(ee.current[e]),onMatch(e){B?me.set(`activeIndex`,e):De(re.current[e],Kv(Mv))},onTyping(e){ie.current=e}}),Pe=G.useMemo(()=>dn(Ne.reference,Me.reference,je.reference,Ae.reference,pe),[Ae.reference,Ne.reference,Me.reference,je.reference,pe]),Fe=G.useMemo(()=>dn(jC,Ne.floating,Me.floating,je.floating),[Ne.floating,Me.floating,je.floating]),Ie=Me.item??Bn;Hle(()=>{me.update({popupProps:Fe,triggerProps:Pe})}),me.useSyncedValues({id:F,modal:m,multiple:y,value:R,open:B,mounted:le,transitionStatus:de,popupProps:Fe,triggerProps:Pe,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:ye});let Le=G.useMemo(()=>({store:me,floatingContext:ke,required:p,disabled:I,readOnly:f,multiple:y,highlightItemOnHover:C,setValue:De,setOpen:Te,listRef:ee,popupRef:U,scrollHandlerRef:W,handleScrollArrowVisibility:Oe,scrollArrowsMountedCountRef:te,itemProps:Ie,valueRef:ne,valuesRef:re,labelsRef:H,typingRef:ie,selectionRef:se,firstItemTextRef:ae,selectedItemTextRef:oe,validation:N,onOpenChangeComplete:_,alignItemWithTriggerActiveRef:ce,initialValueRef:Se}),[me,ke,p,I,f,y,C,De,Te,Ie,N,_,Oe]),Re=kn(g,N.inputRef),ze=y?void 0:L,Be=G.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=c9(e,x);return(0,J.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,J.jsxs)(t9.Provider,{value:Le,children:[w,(0,J.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){me.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=Kv(Mv,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=re.current.findIndex(t=>c9(t,x).toLowerCase()===e||s9(t,b).toLowerCase()===e);r===-1&&(r=re.current.findIndex((t,n)=>{let r=H.current[n];return r!=null&&r.toLowerCase()===e}));let i=re.current[r];i!=null&&De(i,n)}me.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&ze==null?`${F}-hidden-input`:void 0,form:l,name:ze,autoComplete:u,value:be,disabled:I,required:p&&!(y&&Ce),readOnly:f,ref:Re,style:L?nb:tb,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Be]})}var Jle=400,Yle={...q_,...Gk,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},Xle=G.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,setFocused:u,validationMode:d,state:f,disabled:p}=Jk(),{labelId:m}=$k(),{store:h,setOpen:g,selectionRef:_,validation:v,readOnly:y,required:b,alignItemWithTriggerActiveRef:x,disabled:S}=n9(),C=p||S||a,w=yC(h,u9.open),T=yC(h,u9.mounted),E=yC(h,u9.value),D=yC(h,u9.triggerProps),O=yC(h,u9.positionerElement),k=yC(h,u9.listElement),A=yC(h,u9.popupSide),j=yC(h,u9.id),M=yC(h,u9.labelId),N=yC(h,u9.hasSelectedValue),P=T&&O?A:null,F=i??j,I=eA(m,M);tA({id:F});let L=Jy(O),R=G.useRef(null),{getButtonProps:z,buttonRef:B}=kv({disabled:C,native:o}),V=h.useStateSetter(`triggerElement`),ee=ry(),H=ry(),U=ry();G.useEffect(()=>{if(w)return U.start(Jle,()=>{_.current.allowUnselectedMouseUp=!0,_.current.allowSelectedMouseUp=!0}),()=>{U.clear()};_.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},H.clear()},[w,_,H,U]);let W=dn(D,{id:F,role:`combobox`,"aria-expanded":w,"aria-haspopup":`listbox`,"aria-controls":w?k?.id??By(O)?.id:void 0,"aria-labelledby":I,"aria-readonly":y||void 0,"aria-required":b||void 0,tabIndex:C?-1:0,onFocus(e){u(!0),w&&x.current&&g(!1,Kv(Mv,e.nativeEvent)),ee.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){jy(O,e.relatedTarget)||(l(!0),u(!1),d===`onBlur`&&v.commit(E))},onMouseDown(e){if(w)return;let t=Dv(e.currentTarget);function n(e){if(!R.current)return;let t=e.target;jy(R.current,t)||jy(L.current,t)||ok(e,R.current)||g(!1,Kv(Hv,e))}H.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,z),te=v.getValidationProps(C,W);te.role=`combobox`;let ne={...f,open:w,disabled:C,value:E,readOnly:y,popupSide:P,placeholder:!N};return Wn(`button`,e,{ref:[t,R,B,V],state:ne,stateAttributesMapping:Yle,props:te})}),Zle={value:()=>null},Qle=G.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,{store:c,valueRef:l}=n9(),u=yC(c,u9.value),d=yC(c,u9.items),f=yC(c,u9.itemToStringLabel),p=yC(c,u9.hasSelectedValue),m=!p&&a!=null&&i==null,h=yC(c,u9.hasNullItemLabel,m),g={value:u,placeholder:!p},_=null;return _=typeof i==`function`?i(u):i??(m&&!h?a:Array.isArray(u)?Kle(u,d,f):l9(u,d,f)),Wn(`span`,e,{state:g,ref:[t,l],props:[{children:_},s],stateAttributesMapping:Zle})}),$le=G.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{store:o}=n9();return Wn(`span`,e,{state:{open:yC(o,u9.open)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:K_})}),eue=G.forwardRef(function(e,t){let{store:n}=n9(),r=yC(n,u9.mounted),i=yC(n,u9.forceMount);return r||i?(0,J.jsx)(xx,{ref:t,...e}):null}),d9=G.createContext(void 0);function f9(){let e=G.useContext(d9);if(!e)throw Error(En(59));return e}function p9(e,t){e&&Object.assign(e.style,t)}var m9={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},tue={position:`fixed`},nue=G.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=mx,style:_,...v}=e,{store:y,listRef:b,labelsRef:x,alignItemWithTriggerActiveRef:S,selectedItemTextRef:C,valuesRef:w,initialValueRef:T,popupRef:E,setValue:D,floatingContext:O}=n9(),k=yC(y,u9.open),A=yC(y,u9.mounted),j=yC(y,u9.modal),M=yC(y,u9.value),N=yC(y,u9.openMethod),P=yC(y,u9.positionerElement),F=yC(y,u9.triggerElement),I=yC(y,u9.isItemEqualToValue),L=yC(y,u9.transitionStatus),R=G.useRef(null),z=G.useRef(null),[B,V]=G.useState(h),ee=A&&B&&N!==`touch`;!A&&B!==h&&V(h),G.useImperativeHandle(S,()=>ee),qO((ee||j)&&k,N===`touch`,P,F);let H=TE({anchor:n,floatingRootContext:O,positionMethod:a,mounted:A,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??ee,collisionAvoidance:g,keepMounted:!0}),U=ee?`none`:H.side,W=ee?tue:H.positionerStyles,te={open:k,side:U,align:H.align,anchorHidden:H.anchorHidden};Z(()=>{y.set(`popupSide`,H.side)},[y,H.side]);let ne=OE(e,te,{styles:W,transitionStatus:L,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!A,inert:!k}),re=G.useRef(0),ie=xv(e=>{if(w.current.length===0)return;let t=re.current;if(re.current=e.size,e.size===t)return;let n=Kv(Mv);if(t!==0&&!y.state.multiple&&M!==null&&i9(w.current,M,I)===-1){let e=T.current,t=e!=null&&i9(w.current,e,I)!==-1?e:null;D(t,n),t===null&&(y.set(`selectedIndex`,null),C.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(M)){let e=M.filter(e=>i9(w.current,e,I)!==-1);e.length!==M.length&&(D(e,n),e.length===0&&(y.set(`selectedIndex`,null),C.current=null))}if(k&&ee){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};p9(P,e),p9(E.current,e)}}),ae=G.useMemo(()=>({...H,side:U,alignItemWithTriggerActive:ee,setControlledAlignItemWithTrigger:V,scrollUpArrowRef:R,scrollDownArrowRef:z}),[H,U,ee,V]);return(0,J.jsx)(zO,{elementsRef:b,labelsRef:x,onMapChange:ie,children:(0,J.jsxs)(d9.Provider,{value:ae,children:[A&&j&&(0,J.jsx)(Lw,{inert:Iw(!k),cutout:F}),ne]})})}),rue={...J_,...G_},iue=G.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s,popupRef:c,onOpenChangeComplete:l,setOpen:u,valueRef:d,firstItemTextRef:f,selectedItemTextRef:p,multiple:m,handleScrollArrowVisibility:h,scrollHandlerRef:g,listRef:_,highlightItemOnHover:v,floatingContext:y}=n9(),{side:b,align:x,alignItemWithTriggerActive:S,isPositioned:C,setControlledAlignItemWithTrigger:w}=f9(),T=PO(!0)!=null,E=OT(),{nonce:D,disableStyleElements:O}=yT(),k=yC(s,u9.id),A=yC(s,u9.open),j=yC(s,u9.openMethod),M=yC(s,u9.mounted),N=yC(s,u9.popupProps),P=yC(s,u9.transitionStatus),F=yC(s,u9.triggerElement),I=yC(s,u9.positionerElement),L=yC(s,u9.listElement),R=G.useRef(!1),z=G.useRef(!1),B=G.useRef({}),V=$y(),ee=xv(e=>{if(!I||!c.current||!z.current)return;let t=I.style.top===`0px`,n=I.style.bottom===`0px`;if(R.current||!S||!t&&!n){h(e);return}let r=_9(I),i=v9(I.getBoundingClientRect().height,`y`,r),a=Dv(I),o=$_(I),s=o.getComputedStyle(I),l=parseFloat(s.marginTop),u=parseFloat(s.marginBottom),d=h9(o.getComputedStyle(c.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,m=g9(e),g=null,_=e=>{I.style.height=`${e}px`},v=t?m-p:p,y=Math.min(i+v,f);if(v<=1){let n=kT(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?m:0,f-(i+n)<=1&&(R.current=!0),h(e);return}f-y>1?g=t?1/0:0:n&&p<m&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=kT(g,0,g9(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(R.current=!0),h(e)});G.useImperativeHandle(g,()=>ee,[ee]),AC({open:A,ref:c,onComplete(){A&&l?.(!0)}});let H={open:A,transitionStatus:P,side:b,align:x};Z(()=>{!I||!c.current||Object.keys(B.current).length||(B.current={top:I.style.top||`0`,left:I.style.left||`0`,right:I.style.right,height:I.style.height,bottom:I.style.bottom,minHeight:I.style.minHeight,maxHeight:I.style.maxHeight,marginTop:I.style.marginTop,marginBottom:I.style.marginBottom})},[c,I]),Z(()=>{A||S||(z.current=!1,R.current=!1,p9(I,B.current))},[A,S,I,c]),Z(()=>{let e=c.current;if(!A||!F||!I||!e||S&&!C||s.state.transitionStatus===`ending`)return;if(z.current=!0,e.style.removeProperty(`--transform-origin`),!S){V.request(()=>h(L||e));return}let t=aue(e);try{let t=p.current;t?.isConnected||(t=!u9.hasSelectedValue(s.state)&&f.current?.isConnected?f.current:null);let n=d.current,r=$_(I),i=r.getComputedStyle(I),a=r.getComputedStyle(e),o=Dv(F),c=_9(F),l=y9(F.getBoundingClientRect(),c),u=y9(I.getBoundingClientRect(),c),m=l.height,g=L||e,y=g.scrollHeight,b=parseFloat(a.borderBottomWidth),x=parseFloat(i.marginTop)||10,S=parseFloat(i.marginBottom)||10,C=parseFloat(i.minHeight)||100,T=h9(a),D=o.documentElement.clientHeight-x-S,O=o.documentElement.clientWidth,k=D-l.bottom+m,A,j=E===`rtl`?l.right-u.width:l.left,M=0;if(t&&n){let e=y9(n.getBoundingClientRect(),c);A=y9(t.getBoundingClientRect(),c),j=u.left+(E===`rtl`?e.right-A.right:e.left-A.left);let r=e.top-l.top+e.height/2;M=A.top-u.top+A.height/2-r}let N=k+M+S+b,P=Math.min(D,N),z=D-x-S,V=N-P,ee=O-5;I.style.left=`${kT(j,5,ee-u.width)}px`,I.style.height=`${P}px`,I.style.maxHeight=`none`,I.style.marginTop=`${x}px`,I.style.marginBottom=`${S}px`,e.style.height=`100%`;let H=g9(g),U=V>=H-1;U&&(P=Math.min(D,u.height)-(V-H));let W=l.top<20||l.bottom>D-20||Math.ceil(P)+1<Math.min(y,C),te=(r.visualViewport?.scale??1)!==1&&hy;if(W||te){p9(I,B.current),w(!1);return}let ne=Math.max(C,P);if(U){let e=Math.max(0,D-N);I.style.top=u.height>=z?`0`:`${e}px`,I.style.height=`${P}px`,g.scrollTop=g9(g)}else I.style.bottom=`0`,g.scrollTop=V;if(A){let t=u.top,n=u.height,r=A.top+A.height/2,i=kT(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(`--transform-origin`,`50% ${i}%`)}(ne===D||P>=T)&&(R.current=!0),h(g),v&&s.state.selectedIndex===null&&s.state.activeIndex===null&&_.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,A,I,F,d,f,p,c,h,S,w,V,L,_,v,E,C]),G.useEffect(()=>{if(!S||!I||!A)return;let e=$_(I);function t(e){u(!1,Kv(Gv,e))}return Ky(e,`resize`,t)},[u,S,I,A]);let U={...L?{role:`presentation`,"aria-orientation":void 0}:{role:`listbox`,"aria-multiselectable":m||void 0,id:`${k}-list`},onKeyDown(e){T&&Nw.has(e.key)&&e.stopPropagation()},onScroll(e){L||ee(e.currentTarget)},...S&&{style:L?{height:`100%`}:m9},className:!L&&S?mT.className:void 0},W=Wn(`div`,e,{ref:[t,c],state:H,stateAttributesMapping:rue,props:[N,U,DE(P),o]});return(0,J.jsxs)(G.Fragment,{children:[!O&&mT.getElement(D),(0,J.jsx)(Bx,{context:y,modal:!1,disabled:!M,openInteractionType:j,returnFocus:a,restoreFocus:!0,children:W})]})});function h9(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function g9(e){return AT(e.scrollHeight,e.clientHeight)}function _9(e){return DS.getScale(e)}function v9(e,t,n){return e/n[t]}function y9(e,t){return Sb({x:v9(e.x,`x`,t),y:v9(e.y,`y`,t),width:v9(e.width,`x`,t),height:v9(e.height,`y`,t)})}var b9=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function aue(e){let{style:t}=e,n={};for(let[e,r]of b9)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of b9){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var oue=G.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{store:o,scrollHandlerRef:s,multiple:c}=n9(),{alignItemWithTriggerActive:l}=f9(),u=yC(o,u9.hasScrollArrows),d=yC(o,u9.openMethod),f={id:`${yC(o,u9.id)}-list`,role:`listbox`,"aria-multiselectable":c||void 0,onScroll(e){s.current?.(e.currentTarget)},...l&&{style:m9},className:u&&d!==`touch`?mT.className:void 0};return Wn(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),x9=G.createContext(void 0);function S9(){let e=G.useContext(x9);if(!e)throw Error(En(57));return e}var sue=G.memo(G.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=G.useRef(null),d=DO({guess:!0,label:o,textRef:u}),{store:f,itemProps:p,setOpen:m,setValue:h,selectionRef:g,typingRef:_,valuesRef:v,multiple:y,selectedItemTextRef:b,disabled:x,readOnly:S}=n9(),C=x||s,w=yC(f,u9.isActive,d.index),T=yC(f,u9.open),E=yC(f,u9.isSelected,a),D=yC(f,u9.isSelectedByFocus,d.index),O=yC(f,u9.isItemEqualToValue),k=d.index,A=G.useRef(null);Z(()=>{let e=v.current;return e[k]=a,()=>{delete e[k]}},[k,a,v]),Z(()=>{let e=f.state.value,t=e;y&&Array.isArray(e)&&(t=e.length>0?e[e.length-1]:void 0),t!==void 0&&r9(a,t,O)&&(f.set(`selectedIndex`,k),u.current&&(b.current=u.current))},[k,y,O,f,a,b]);let j=G.useRef(`mouse`),M=G.useRef(!1),{getButtonProps:N,buttonRef:P}=kv({disabled:C,focusableWhenDisabled:!0,native:c,composite:!0}),F={disabled:C,selected:E,highlighted:w};function I(e){if(x||S)return;let t=f.state.value;if(y){let n=Array.isArray(t)?t:[],r=E?Wle(n,a,O):[...n,a];h(r,Kv(Lv,e))}else h(a,Kv(Lv,e)),m(!1,Kv(Lv,e))}function L(){g.current.dragY=0}let R={role:`option`,"aria-selected":E,tabIndex:T&&w?0:-1,onKeyDown(e){f.set(`activeIndex`,k),e.key===` `&&_.current&&e.preventDefault()},onClick(e){let t=j.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&by(e.nativeEvent)&&(n!==void 0||w),i=t&&!r&&!M.current;M.current=!1,!(C||i)&&I(e.nativeEvent)},onPointerEnter(e){j.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=g.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){j.current=e.pointerType,M.current=!0,L()},onMouseUp(){if(L(),C||j.current===`touch`||M.current)return;let e=!g.current.allowSelectedMouseUp&&E,t=!g.current.allowUnselectedMouseUp&&!E;e||t||(M.current=!0,A.current?.click(),M.current=!1)}},z=Wn(`div`,e,{ref:[P,t,d.ref,A],state:F,props:[p,R,l,N]}),B=G.useMemo(()=>({selected:E,index:k,textRef:u,selectedByFocus:D}),[E,k,u,D]);return(0,J.jsx)(x9.Provider,{value:B,children:z})})),cue=G.forwardRef(function(e,t){let{selected:n}=S9();return e.keepMounted||n?(0,J.jsx)(lue,{...e,ref:t}):null}),lue=G.memo(G.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=S9(),c=G.useRef(null),{transitionStatus:l,setMounted:u}=OC(s),d=Wn(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:G_});return AC({open:s,ref:c,onComplete(){s||u(!1)}}),d})),uue=G.memo(G.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=S9(),{firstItemTextRef:a,selectedItemTextRef:o}=n9(),{render:s,className:c,style:l,...u}=e;return Wn(`div`,e,{ref:[G.useCallback(e=>{e&&(n===0&&(a.current=e),i&&(o.current=e))},[a,o,n,i]),t,r],props:u})})),C9=G.forwardRef(function(e,t){let{render:n,className:r,style:i,direction:a,keepMounted:o,...s}=e,c=a===`up`,{store:l,popupRef:u,listRef:d,handleScrollArrowVisibility:f,scrollArrowsMountedCountRef:p}=n9(),{side:m,scrollDownArrowRef:h,scrollUpArrowRef:g}=f9(),_=yC(l,c?u9.scrollUpArrowVisible:u9.scrollDownArrowVisible),v=yC(l,u9.openMethod),y=_&&v!==`touch`,b=ry(),x=c?g:h,{mounted:S,transitionStatus:C,setMounted:w}=OC(y);Z(()=>(p.current+=1,l.set(`hasScrollArrows`,!0),()=>{p.current=Math.max(0,p.current-1),p.current===0&&l.set(`hasScrollArrows`,!1)}),[l,p]),AC({open:y,ref:x,onComplete(){y||w(!1)}});let T=Wn(`div`,e,{ref:[t,x],state:{direction:a,visible:y,side:m,transitionStatus:C},props:[{"aria-hidden":!0,children:c?`▲`:`▼`,style:{position:`absolute`},onMouseMove(e){if(e.movementX===0&&e.movementY===0||b.isStarted())return;l.set(`activeIndex`,null);function t(){let e=l.state.listElement??u.current;if(!e)return;l.set(`activeIndex`,null),f(e);let n=AT(e.scrollHeight,e.clientHeight),r=jT(e.scrollTop,n),i=r===(c?0:n),a=d.current;if(r!==e.scrollTop&&(e.scrollTop=r),i){b.clear();return}if(a.length>0){let t=x.current?.offsetHeight||0;e.scrollTop=due(a,c,r,e.clientHeight,t,n)}b.start(40,t)}b.start(40,t)},onMouseLeave(){b.clear()}},s],stateAttributesMapping:G_});return S||o?T:null});function due(e,t,n,r,i,a){if(t){let t=0,r=n+i-1;for(let n=0;n<e.length;n+=1){let i=e[n];if(i&&i.offsetTop>=r){t=n;break}}let o=Math.max(0,t-1),s=e[o];return o<t&&s?jT(s.offsetTop-i,a):0}let o=e.length-1,s=n+r-i+1;for(let t=0;t<e.length;t+=1){let n=e[t];if(n&&n.offsetTop+n.offsetHeight>s){o=Math.max(0,t-1);break}}let c=Math.min(e.length-1,o+1),l=e[c];return c>o&&l?jT(l.offsetTop+l.offsetHeight-r+i,a):a}var fue=G.forwardRef(function(e,t){return(0,J.jsx)(C9,{...e,ref:t,direction:`down`})}),pue=G.forwardRef(function(e,t){return(0,J.jsx)(C9,{...e,ref:t,direction:`up`})}),w9=qle;function T9({className:e,size:t=`default`,children:n,...r}){return(0,J.jsxs)(Xle,{className:q(`relative inline-flex min-h-9 w-full min-w-36 select-none items-center justify-between gap-2 rounded-lg border border-input bg-background bg-clip-padding px-[calc(--spacing(3)-1px)] text-left text-base shadow-xs outline-none ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-data-disabled:not-focus-visible:not-aria-invalid:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 focus-visible:border-ring focus-visible:ring-[3px] aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/16 data-disabled:pointer-events-none data-disabled:opacity-64 sm:min-h-8 sm:text-sm dark:bg-input/32 dark:not-in-data-[slot=group]:bg-clip-border dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-focus-visible:not-aria-invalid:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/8%)] [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0 [[data-disabled],:focus-visible,[aria-invalid],[data-pressed]]:shadow-none`,t===`sm`&&`min-h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] sm:min-h-7`,t===`lg`&&`min-h-10 sm:min-h-9`,e),"data-slot":`select-trigger`,...r,children:[n,(0,J.jsx)($le,{"data-slot":`select-icon`,children:(0,J.jsx)(Me,{className:`-me-1 size-4.5 opacity-80 sm:size-4`})})]})}function E9({className:e,...t}){return(0,J.jsx)(Qle,{className:q(`flex-1 truncate data-placeholder:text-muted-foreground`,e),"data-slot":`select-value`,...t})}function D9({className:e,children:t,sideOffset:n=4,alignItemWithTrigger:r=!0,zIndex:i,...a}){return(0,J.jsx)(eue,{children:(0,J.jsx)(nue,{alignItemWithTrigger:r,className:`select-none`,style:{zIndex:i??lE.DROPDOWN},"data-slot":`select-positioner`,sideOffset:n,children:(0,J.jsxs)(iue,{className:`origin-(--transform-origin) transition-[scale,opacity] has-data-[side=none]:scale-100 has-data-starting-style:scale-98 has-data-starting-style:opacity-0 has-data-[side=none]:transition-none`,"data-slot":`select-popup`,...a,children:[(0,J.jsx)(pue,{className:`top-0 z-50 flex h-6 w-full cursor-default items-center justify-center before:pointer-events-none before:absolute before:inset-x-px before:top-px before:h-[200%] before:rounded-t-[calc(var(--radius-lg)-1px)] before:bg-linear-to-b before:from-50% before:from-popover`,"data-slot":`select-scroll-up-arrow`,children:(0,J.jsx)(je,{className:`relative size-4.5 sm:size-4`})}),(0,J.jsx)(`span`,{className:`relative block h-full rounded-lg border bg-popover bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-lg dark:not-in-data-[slot=group]:bg-clip-border`,children:(0,J.jsx)(oue,{className:q(`max-h-(--available-height) min-w-(--anchor-width) overflow-y-auto p-1`,e),"data-slot":`select-list`,children:t})}),(0,J.jsx)(fue,{className:`bottom-0 z-50 flex h-6 w-full cursor-default items-center justify-center before:pointer-events-none before:absolute before:inset-x-px before:bottom-px before:h-[200%] before:rounded-b-[calc(var(--radius-lg)-1px)] before:bg-linear-to-t before:from-50% before:from-popover`,"data-slot":`select-scroll-down-arrow`,children:(0,J.jsx)(Oe,{className:`relative size-4.5 sm:size-4`})})]})})})}function O9({className:e,children:t,...n}){return(0,J.jsxs)(sue,{className:q(`grid min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default grid-cols-[1rem_1fr] items-center gap-2 rounded-sm py-1 ps-2 pe-4 text-base outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),"data-slot":`select-item`,...n,children:[(0,J.jsx)(cue,{className:`col-start-1`,children:(0,J.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,height:`24`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:`24`,xmlns:`http://www.w3.org/1500/svg`,children:(0,J.jsx)(`path`,{d:`M5.252 12.7 10.2 18.63 18.748 5.37`})})}),(0,J.jsx)(uue,{className:`col-start-2 min-w-0`,children:t})]})}function mue(e,t,n){return e.find(e=>e.id===t)?.id??e.find(e=>e.id===n)?.id??e[0]?.id??``}var k9={supervised:`受监督(每步确认)`,"auto-edits":`自动接受编辑`,full:`完全放行`,assistant:`助手代审`},A9={minimal:`极低`,low:`低`,medium:`中`,high:`高`,xhigh:`极高`,max:`最高`};function hue({projects:e,providers:t,open:n,preferredProjectId:r,onClose:i,onCreate:a}){let[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(`full`),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(`medium`),[v,y]=(0,G.useState)(n);n!==v&&(y(n),n&&s(null));let b=mue(e,o,r),x=t.find(e=>e.id===c)??t[0]??{id:``,models:[]},S=x.id,C=x.models.find(e=>e.id===u)?.id??x.models[0]?.id??``,w=!!(b&&S&&C);return(0,J.jsx)(K7,{open:n,onOpenChange:e=>!e&&i(),children:(0,J.jsxs)(q7,{side:`bottom`,className:`pb-safe`,children:[(0,J.jsx)(J7,{children:(0,J.jsx)(Y7,{children:`新建会话`})}),(0,J.jsxs)(`div`,{className:`space-y-4 p-4 pt-0`,children:[(0,J.jsx)(j9,{label:`项目`,children:(0,J.jsxs)(w9,{items:e.map(e=>({value:e.id,label:ie(e)})),value:b,onValueChange:e=>s(e),children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:e.map(e=>(0,J.jsx)(O9,{value:e.id,children:ie(e)},e.id))})]})}),(0,J.jsx)(j9,{label:`模型服务`,children:(0,J.jsxs)(w9,{items:t.map(e=>({value:e.id,label:e.name})),value:S,onValueChange:e=>{l(e),d(null)},children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:t.map(e=>(0,J.jsx)(O9,{value:e.id,children:e.name},e.id))})]})}),(0,J.jsx)(j9,{label:`模型`,children:(0,J.jsxs)(w9,{items:x.models.map(e=>({value:e.id,label:e.label??e.id})),value:C,onValueChange:e=>d(e),children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:x.models.map(e=>(0,J.jsx)(O9,{value:e.id,children:e.label??e.id},e.id))})]})}),(0,J.jsx)(j9,{label:`审批模式`,children:(0,J.jsxs)(w9,{items:Object.keys(k9).map(e=>({value:e,label:k9[e]})),value:f,onValueChange:e=>p(e),children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:Object.keys(k9).map(e=>(0,J.jsx)(O9,{value:e,children:k9[e]},e))})]})}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`推理`}),(0,J.jsx)(uA,{checked:m,onCheckedChange:h})]}),m&&(0,J.jsx)(j9,{label:`推理档位`,children:(0,J.jsxs)(w9,{items:Object.keys(A9).map(e=>({value:e,label:A9[e]})),value:g,onValueChange:e=>_(e),children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:Object.keys(A9).map(e=>(0,J.jsx)(O9,{value:e,children:A9[e]},e))})]})}),e.length===0&&(0,J.jsx)(`p`,{className:`text-destructive text-xs`,children:`桌面端还没有项目,请先在桌面添加。`}),e.length>0&&t.length===0&&(0,J.jsx)(`p`,{className:`text-destructive text-xs`,children:`桌面端没有可用的模型服务。`}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,J.jsx)(ji,{variant:`outline`,onClick:i,children:`取消`}),(0,J.jsx)(ji,{disabled:!w,onClick:()=>a({projectId:b,providerId:S,modelId:C,approvalMode:f,...m?{reasoningEnabled:m,thinkingLevel:g}:{}}),children:`创建`})]})]})]})})}function j9({label:e,children:t}){return(0,J.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e}),t]})}var gue={pending:`待发送`,sending:`发送中…`,failed:`发送失败`};function _ue({items:e,readOnly:t,onRetry:n,onDiscard:r}){return e.length===0?null:(0,J.jsx)(`div`,{className:`mb-1 space-y-1`,children:e.map(e=>(0,J.jsxs)(`div`,{className:q(`flex flex-wrap items-center gap-2 rounded-xl border px-2.5 py-1.5 text-xs`,e.status===`failed`?`border-destructive/40 bg-destructive/5`:`bg-muted/40`),children:[(0,J.jsx)(`span`,{className:q(`min-w-0 flex-1`,e.status===`failed`?`whitespace-pre-wrap break-words select-text`:`truncate`),children:e.text||(e.images?.length?`[${e.images.length} 张图片]`:``)}),(0,J.jsxs)(`span`,{className:q(`min-w-0 break-words`,e.status===`failed`?`text-destructive`:`text-muted-foreground`),children:[e.error?.startsWith(`outbox-discard`)?`移除消息`:e.error===`delivery-unconfirmed`?`结果未确认`:gue[e.status],e.status===`failed`&&e.error?`:${dle(e.error)}`:``]}),e.status===`failed`&&!e.error?.startsWith(`outbox-discard`)&&!t&&(0,J.jsx)(`button`,{type:`button`,"aria-label":`重试`,onClick:()=>n(e.deliveryId),className:`shrink-0 rounded p-0.5 text-foreground hover:bg-accent`,children:(0,J.jsx)(Lt,{className:`h-3.5 w-3.5`})}),e.status!==`sending`&&(0,J.jsx)(`button`,{type:`button`,"aria-label":`删除`,disabled:e.error===`outbox-discarding`,onClick:()=>r(e.deliveryId),className:`shrink-0 rounded p-0.5 text-muted-foreground hover:bg-accent`,children:(0,J.jsx)(sn,{className:`h-3.5 w-3.5`})})]},e.deliveryId))})}function vue(){let e=globalThis.BarcodeDetector;if(!e)return null;let t=new e({formats:[`qr_code`]});return{async scan(e){return(await t.detect(e))[0]?.rawValue??null}}}async function yue(){let{default:t}=await Y(async()=>{let{default:t}=await import(`./jsQR-B1eQcpQl.js`).then(t=>e(t.default,1));return{default:t}},__vite__mapDeps([144,1])),n=document.createElement(`canvas`),r=n.getContext(`2d`,{willReadFrequently:!0});return{async scan(e){if(!r||!e.videoWidth)return null;let i=Math.min(1,640/Math.max(e.videoWidth,e.videoHeight));n.width=Math.round(e.videoWidth*i),n.height=Math.round(e.videoHeight*i),r.drawImage(e,0,0,n.width,n.height);let{data:a,width:o,height:s}=r.getImageData(0,0,n.width,n.height);return t(a,o,s,{inversionAttempts:`dontInvert`})?.data??null}}}async function bue(){return vue()??await yue()}function xue(e){try{return _(e),!0}catch{return!1}}function Sue({onPaired:e,autoInvite:t,onCancel:n}){let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(!1),[s,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(!1),f=(0,G.useRef)(null),p=(0,G.useRef)(null),m=()=>{for(let e of p.current?.getTracks()??[])e.stop();p.current=null,d(!1)},h=async t=>{o(!0),l(null);try{let n=_(t),r=/iPhone|iPad|Android/i.exec(navigator.userAgent)?.[0]??`Phone`,i=await c(n.relay,n.publicKey,r);e({pairId:i.pairId,token:i.deviceToken,contentKey:btoa(String.fromCharCode(...i.contentKey)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``),deviceName:r,relayUrl:n.relay,pairedAt:Date.now()})}catch(e){l(e instanceof Error?e.message:String(e))}finally{o(!1)}},g=(0,G.useRef)(!1);(0,G.useEffect)(()=>{!t||g.current||(g.current=!0,h(t))},[t]);let v=(0,G.useRef)(()=>{});v.current=e=>{m(),h(e)};let y=async()=>{l(null);try{p.current=await navigator.mediaDevices.getUserMedia({video:{facingMode:`environment`}}),d(!0)}catch(e){l(window.isSecureContext?e instanceof DOMException&&e.name===`NotAllowedError`?`摄像头权限被拒绝,请在浏览器设置中允许后重试`:`无法访问摄像头,请粘贴配对码`:`扫码需要 HTTPS 环境,请改用粘贴配对码`),d(!1)}};return(0,G.useEffect)(()=>{if(!u)return;let e=f.current,t=p.current;if(!e||!t)return;let n=!1,r=0;return e.srcObject=t,e.muted=!0,(async()=>{try{await e.play();let t=await bue(),i=async()=>{if(!(n||!p.current)){try{let n=await t.scan(e);if(n&&xue(n)){v.current(n);return}}catch{}r=requestAnimationFrame(()=>void i())}};await i()}catch{n||l(`无法开始预览,请粘贴配对码`)}})(),()=>{n=!0,cancelAnimationFrame(r)}},[u]),(0,J.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-5 px-6 pt-safe pb-safe`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 text-center`,children:[(0,J.jsx)(`span`,{className:`mb-2 flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14`,children:(0,J.jsx)(EA,{className:`size-6`})}),(0,J.jsx)(`h1`,{className:`font-medium text-lg`,children:`连接到 EnsoCode`}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`在桌面端「设置 → 手机」生成配对码,扫码或粘贴。`})]}),u?(0,J.jsxs)(`div`,{className:`w-full max-w-sm space-y-2`,children:[(0,J.jsx)(`video`,{ref:f,playsInline:!0,muted:!0,className:`aspect-square w-full rounded-lg bg-black object-cover`}),(0,J.jsx)(ji,{variant:`outline`,className:`w-full`,onClick:m,children:`取消扫码`})]}):(0,J.jsxs)(ji,{className:`w-full max-w-sm`,onClick:()=>void y(),children:[(0,J.jsx)(Ee,{className:`mr-1.5 h-4 w-4`}),`扫描二维码`]}),(0,J.jsxs)(`div`,{className:`flex w-full max-w-sm items-center gap-2`,children:[(0,J.jsx)(G7,{value:r,onChange:e=>i(e.target.value),placeholder:`enso://pair?relay=…`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,className:`font-mono text-xs`}),(0,J.jsx)(ji,{variant:`outline`,className:`shrink-0`,disabled:a||!r.trim(),onClick:()=>void h(r.trim()),children:a?(0,J.jsx)(pt,{className:`h-4 w-4 animate-spin`}):`配对`})]}),s&&(0,J.jsx)(`p`,{className:`max-w-sm text-center text-destructive text-xs`,children:s}),n&&(0,J.jsx)(ji,{variant:`ghost`,className:`w-full max-w-sm`,onClick:n,children:`返回`})]})}function M9(){return window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0}function N9(){return`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window}async function Cue(){if(!(`serviceWorker`in navigator))return null;try{return await navigator.serviceWorker.register(`/sw.js`)}catch{return null}}function wue(e){let t=e+`=`.repeat((4-e.length%4)%4),n=atob(t.replace(/-/g,`+`).replace(/_/g,`/`));return Uint8Array.from(n,e=>e.charCodeAt(0))}function Tue(e){return e===`AbortError`?`service-unreachable`:e===`NotAllowedError`?`permission-denied`:`subscribe-failed`}async function P9(e){if(!N9())return{ok:!1,reason:`unsupported`};if(await Notification.requestPermission()!==`granted`)return{ok:!1,reason:`permission-denied`};let t=await navigator.serviceWorker.ready;try{let n=(await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:wue(e)})).toJSON();return!n.endpoint||!n.keys?.p256dh||!n.keys?.auth?{ok:!1,reason:`subscribe-failed`}:{ok:!0,subscription:{endpoint:n.endpoint,keys:{p256dh:n.keys.p256dh,auth:n.keys.auth}}}}catch(e){return{ok:!1,reason:Tue(e instanceof Error?e.name:``)}}}async function Eue(){if(`serviceWorker`in navigator)try{await(await(await navigator.serviceWorker.ready).pushManager.getSubscription())?.unsubscribe()}catch{}}var F9={minimal:`极低`,low:`低`,medium:`中`,high:`高`,xhigh:`极高`,max:`最高`};function Due({providers:e,config:t,open:n,onClose:r,onSetModel:i,onSetReasoning:a,onSetThinking:o}){let s=e.find(e=>e.id===t.providerId),c=t.reasoningEnabled??!1,l=t.thinkingLevel??`medium`;return(0,J.jsx)(K7,{open:n,onOpenChange:e=>!e&&r(),children:(0,J.jsxs)(q7,{side:`bottom`,className:`pb-safe`,children:[(0,J.jsx)(J7,{children:(0,J.jsx)(Y7,{children:`会话设置`})}),(0,J.jsxs)(`div`,{className:`space-y-4 p-4 pt-0`,children:[(0,J.jsx)(I9,{label:`模型服务`,children:(0,J.jsxs)(w9,{items:e.map(e=>({value:e.id,label:e.name})),value:t.providerId??``,onValueChange:t=>{let n=e.find(e=>e.id===t),r=n?.models[0]?.id;n&&r&&i(n.id,r)},children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:e.map(e=>(0,J.jsx)(O9,{value:e.id,children:e.name},e.id))})]})}),(0,J.jsx)(I9,{label:`模型`,children:(0,J.jsxs)(w9,{items:(s?.models??[]).map(e=>({value:e.id,label:e.label??e.id})),value:t.modelId??``,onValueChange:e=>{t.providerId&&i(t.providerId,e)},children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:(s?.models??[]).map(e=>(0,J.jsx)(O9,{value:e.id,children:e.label??e.id},e.id))})]})}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`推理`}),(0,J.jsx)(uA,{checked:c,onCheckedChange:a})]}),c&&(0,J.jsx)(I9,{label:`推理档位`,children:(0,J.jsxs)(w9,{items:Object.keys(F9).map(e=>({value:e,label:F9[e]})),value:l,onValueChange:e=>o(e),children:[(0,J.jsx)(T9,{className:`w-full`,children:(0,J.jsx)(E9,{})}),(0,J.jsx)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:Object.keys(F9).map(e=>(0,J.jsx)(O9,{value:e,children:F9[e]},e))})]})}),(0,J.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`模型切换对运行中的会话在下次启动时生效;推理档位即时生效。`})]})]})})}function I9({label:e,children:t}){return(0,J.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e}),t]})}function Oue(e){return e.status===`failed`&&!e.spawning?`failed`:(e.pendingAskCount??0)>0?`waiting`:e.status===`running`||e.spawning||e.hasRunningChild?`running`:e.unread?`unread`:`idle`}function L9(e){return[...e].sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0))}function R9(e){let t=e=>(e.pendingAskCount??0)>0||(e.pendingApprovalCount??0)>0;return[...e.filter(t),...e.filter(e=>!t(e))]}function kue(e,t){let n=L9(e),r=new Map(n.map(e=>[e.id,e])),i=[];for(let e of t){let t=r.get(e);t&&(i.push(t),r.delete(e))}return[...i,...R9([...r.values()])]}function z9(e){return R9([...L9(e.filter(e=>e.pinned)),...L9(e.filter(e=>!e.pinned))])}function Aue(e,t){return Oue({status:e.status,unread:e.unread,pendingAskCount:e.pendingAskCount,hasRunningChild:t})!==`idle`}var B9=`__all__`,V9=`__ungrouped__`;function H9(e){return new Set(e.map(e=>e.id))}function U9(e,t){return t.includes(e)}function jue(e,t){let n=e.groupId;return!n||!H9(t).has(n)}function Mue(e,t,n,r){let i=e.filter(e=>!U9(e.id,n));return r===`__all__`||r===`__recent__`?i:r===`__ungrouped__`?i.filter(e=>jue(e,t)):i.filter(e=>e.groupId===r)}function Nue(e,t,n){let r=e.filter(e=>!U9(e.id,n)),i=[...t].sort((e,t)=>e.order-t.order),a=H9(t),o=i.map(e=>({groupId:e.id,group:e,projects:r.filter(t=>t.groupId===e.id)})),s=r.filter(e=>!e.groupId||!a.has(e.groupId));return s.length>0&&o.push({groupId:V9,projects:s}),o}function W9(e,t){return e<=0?0:Math.min(e,5+Math.max(0,t))}function Pue(e,t){return W9(e,t)>=e?0:Math.min(Math.max(0,e-5),t+15)}function Fue(e){return Math.max(0,e-15)}var Iue=[{value:`auto`,label:`跟随桌面`},{value:`light`,label:`浅`},{value:`dark`,label:`深`}],Lue={unsupported:`当前浏览器不支持推送。`,"permission-denied":`通知权限被拒绝,请在浏览器站点设置中允许后重试。`,"service-unreachable":`无法连接 Google 推送服务(FCM),请检查网络或代理后重试。`,"subscribe-failed":`订阅失败,请稍后重试。`};function Rue({open:e,docked:t=!1,pinnable:n=!1,onTogglePinned:r,projects:a,groups:o=[],catalog:s,pinnedOrder:c=[],activeId:l,canCreate:u,devices:d,activeDevicePairId:f,remoteDesktop:p,connected:m,connectionLabel:h,pushEnabled:g,pushBusy:_,pushError:v,pushAvailability:y,pushConfigReady:b,onTogglePush:x,onClose:S,onSelect:C,onNewConversation:w,onSwitchDevice:T,onAddDevice:E,onRenameDevice:O,onUnpairDevice:k,botSegment:A}){let j=A?.active===!0,[M,N]=(0,G.useState)({}),[P,F]=(0,G.useState)({}),[I,L]=(0,G.useState)(!1),[B,V]=(0,G.useState)(null),ee=p?d.find(e=>e.pairId===f&&e.scope!==`read`):void 0,[H,U]=(0,G.useState)(z),[W,te]=(0,G.useState)(()=>{try{return localStorage.getItem(`enso-phone-selected-project-group`)??`__all__`}catch{return B9}}),[ie,ae]=(0,G.useState)({}),oe=W===`__all__`||W===`__ungrouped__`||o.some(e=>e.id===W)?W:B9;(0,G.useEffect)(()=>R(()=>U(z())),[]),(0,G.useEffect)(()=>{e||V(null)},[e]);let[se,ce]=(0,G.useState)(()=>Date.now());(0,G.useEffect)(()=>{if(!e)return;ce(Date.now());let t=setInterval(()=>ce(Date.now()),6e4);return()=>clearInterval(t)},[e]);let le=new Set(a.filter(e=>e.archived).map(e=>e.id)),ue=[...le],de=e=>e.archived||le.has(e.projectId),fe=Mue(a,o,ue,oe),pe=Nue(a,o,ue),me=new Set(fe.map(e=>e.id)),he=s.filter(e=>!e.parentId),ge=e=>!e.projectId||me.has(e.projectId),K=e=>s.some(t=>t.parentId===e&&t.status===`running`),ve=L9(he.filter(e=>!de(e)&&ge(e)&&Aue(e,K(e.id)))),ye=kue(he.filter(e=>e.pinned&&!de(e)&&ge(e)),c),be=L9(he.filter(e=>{if(!de(e))return!1;if(oe===`__all__`)return!0;let t=a.find(t=>t.id===e.projectId);return t?oe===`__ungrouped__`?!t.groupId||!o.some(e=>e.id===t.groupId):t.groupId===oe:oe===V9})),xe=he.filter(e=>!de(e)),Ce=new Set(a.map(e=>e.id)),we=z9(xe.filter(e=>!Ce.has(e.projectId)));return(0,J.jsxs)(J.Fragment,{children:[!t&&(0,J.jsx)(`button`,{type:`button`,"aria-label":`关闭侧栏`,onClick:S,className:q(`fixed inset-0 z-40 bg-black/40 transition-[opacity,visibility] duration-200`,e?`visible opacity-100`:`invisible pointer-events-none opacity-0`)}),(0,J.jsxs)(`aside`,{className:q(`flex shrink-0 flex-col border-r bg-background`,t?`relative h-full w-72`:q(`fixed inset-y-0 left-0 z-50 w-[82vw] max-w-xs transition-transform duration-200`,e?`translate-x-0`:`-translate-x-full`)),children:[(0,J.jsxs)(`div`,{className:q(`flex h-12 shrink-0 items-center justify-between px-3 pt-safe`,o.length===0&&`border-b`),children:[A?(0,J.jsx)(`span`,{className:`flex rounded-lg bg-muted p-0.5 text-sm`,children:[`项目`,`Bot`].map(e=>{let t=e===`Bot`===A.active;return(0,J.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>A.onChange(e===`Bot`),className:q(`rounded-md px-3 py-0.5 transition-colors`,t?`bg-background font-medium shadow-xs`:`text-muted-foreground`),children:e},e)})}):(0,J.jsx)(`span`,{className:`font-medium text-sm`,children:`项目`}),t?n&&r?(0,J.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`收起侧栏`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(Tt,{className:`h-4 w-4`})}):null:(0,J.jsxs)(`span`,{className:`flex items-center`,children:[n&&r&&(0,J.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`固定侧栏`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(Et,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{type:`button`,onClick:S,"aria-label":`关闭侧栏`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(sn,{className:`h-4 w-4`})})]})]}),!j&&o.length>0&&(0,J.jsx)(`div`,{className:`shrink-0 border-b px-3 pb-2`,children:(0,J.jsxs)(w9,{items:[{value:`__all__`,label:`全部`},...o.slice().sort((e,t)=>e.order-t.order).map(e=>({value:e.id,label:`${e.emoji?`${e.emoji} `:``}${e.name}`})),{value:`__ungrouped__`,label:`未分组`}],value:oe,onValueChange:e=>{if(e){te(e);try{localStorage.setItem(`enso-phone-selected-project-group`,e)}catch{}}},children:[(0,J.jsx)(T9,{className:`w-full`,size:`sm`,children:(0,J.jsx)(E9,{})}),(0,J.jsxs)(D9,{zIndex:lE.DROPDOWN_IN_MODAL,children:[(0,J.jsx)(O9,{value:`__all__`,children:`全部`}),o.slice().sort((e,t)=>e.order-t.order).map(e=>(0,J.jsxs)(O9,{value:e.id,children:[e.emoji?`${e.emoji} `:``,e.name]},e.id)),(0,J.jsx)(O9,{value:`__ungrouped__`,children:`未分组`})]})]})}),j?A?.panel:(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2`,children:[a.length===0&&(0,J.jsx)(`p`,{className:`rounded-lg border border-dashed px-3 py-6 text-center text-muted-foreground text-sm`,children:`桌面端还没有项目`}),ve.length>0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`flex items-center gap-1.5 px-2 py-2`,children:(0,J.jsx)(`span`,{className:`font-medium text-sm`,children:`活跃中`})}),(0,J.jsx)(`div`,{className:`flex flex-col gap-y-0.5`,children:ve.map(e=>(0,J.jsx)(G9,{session:e,active:l===e.id,nowTick:se,onSelect:C},e.id))})]}),ye.length>0&&(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-2`,children:[(0,J.jsx)(At,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`font-medium text-sm`,children:`置顶`})]}),(0,J.jsx)(`div`,{className:`flex flex-col gap-y-0.5`,children:ye.map(e=>(0,J.jsx)(G9,{session:e,active:l===e.id,nowTick:se,onSelect:C},e.id))})]}),(oe===`__all__`&&o.length>0?pe.flatMap(e=>{let t=ie[e.groupId]===!0;return[{kind:`header`,section:e,folded:t},...t?[]:e.projects.map(e=>({kind:`project`,project:e}))]}):fe.map(e=>({kind:`project`,project:e}))).map(e=>e.kind===`header`?(0,J.jsxs)(`button`,{type:`button`,onClick:()=>ae(t=>({...t,[e.section.groupId]:!t[e.section.groupId]})),className:`flex h-7 w-full items-center gap-1 rounded-md px-2 text-left text-xs font-medium text-muted-foreground`,children:[(0,J.jsx)(ke,{className:q(`h-3.5 w-3.5 shrink-0 transition-transform duration-150`,!e.folded&&`rotate-90`)}),e.section.group?.emoji&&(0,J.jsx)(`span`,{className:`shrink-0 text-sm`,children:e.section.group.emoji}),e.section.group?.color&&(0,J.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.section.group.color}}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.section.group?.name??`未分组`}),(0,J.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/70`,children:e.section.projects.length})]},`hdr-${e.section.groupId}`):(0,J.jsx)(K9,{name:re(e.project),badge:ne(e.project),sessions:z9(xe.filter(t=>t.projectId===e.project.id)),folded:M[e.project.id]===!0,revealedExtra:P[e.project.id]??0,activeId:l,nowTick:se,canCreate:u,onToggleFold:()=>N(t=>({...t,[e.project.id]:!t[e.project.id]})),onRevealMore:t=>F(n=>({...n,[e.project.id]:t})),onSelect:C,onNew:()=>w(e.project.id)},e.project.id)),we.length>0&&(0,J.jsx)(K9,{name:`其他`,sessions:we,folded:M.__orphan===!0,revealedExtra:P.__orphan??0,activeId:l,nowTick:se,canCreate:!1,onToggleFold:()=>N(e=>({...e,__orphan:!e.__orphan})),onRevealMore:e=>F(t=>({...t,__orphan:e})),onSelect:C})]}),!j&&be.length>0&&(0,J.jsxs)(`div`,{className:`shrink-0 border-t p-2`,children:[I&&(0,J.jsx)(`div`,{className:`mb-0.5 flex max-h-64 flex-col gap-y-0.5 overflow-y-auto`,children:be.map(e=>(0,J.jsx)(G9,{session:e,active:l===e.id,nowTick:se,subtitle:(()=>{let t=a.find(t=>t.id===e.projectId);return t?re(t):void 0})(),onSelect:C},e.id))}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>L(e=>!e),className:`flex w-full items-center gap-1 rounded-lg px-2 py-2 text-left transition-colors hover:bg-muted/60`,children:[(0,J.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,J.jsx)(ke,{className:q(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,I?`-rotate-90`:`rotate-0`)})}),(0,J.jsx)(_e,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground text-sm`,children:`已归档`}),(0,J.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums`,children:be.length})]})]}),(0,J.jsxs)(`div`,{className:`shrink-0 space-y-1 border-t p-2 pb-safe`,children:[!B&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,J.jsx)(wt,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground text-sm`,children:`主题`}),(0,J.jsx)(`div`,{className:`flex shrink-0 gap-0.5 rounded-md border p-0.5`,children:Iue.map(e=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>i(e.value),className:q(`rounded px-2 py-1 text-[11px] transition-colors`,H===e.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-accent`),children:e.label},e.value))})]}),!B&&ee&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,J.jsx)(St,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground text-sm`,children:`界面`}),(0,J.jsxs)(`div`,{className:`flex shrink-0 gap-0.5 rounded-md border p-0.5`,children:[(0,J.jsx)(`span`,{className:`rounded bg-primary px-2 py-1 text-[11px] text-primary-foreground`,children:`精简`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{window.location.href=D(ee.pairId)},className:`rounded px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-accent`,children:`完整`})]})]}),!B&&(0,J.jsxs)(`div`,{className:`px-2 py-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Se,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground text-sm`,children:`推送通知`}),(0,J.jsx)(uA,{checked:g,disabled:_||y!==`ok`||!m||!b,onCheckedChange:x})]}),_&&(0,J.jsx)(`p`,{className:`mt-1 pl-6 text-[11px] text-muted-foreground`,children:`正在开启…`}),v&&!_&&(0,J.jsx)(`p`,{className:`mt-1 pl-6 text-[11px] text-destructive`,children:Lue[v]}),y===`ok`&&m&&!b&&(0,J.jsx)(`p`,{className:`mt-1 pl-6 text-[11px] text-muted-foreground`,children:`需先升级桌面端 EnsoCode 才能开启推送。`}),y===`needs-install`&&(0,J.jsx)(`p`,{className:`mt-1 pl-6 text-[11px] text-muted-foreground`,children:`iOS 需先用分享菜单「添加到主屏幕」,从主屏幕打开后才能开启。`}),y===`unsupported`&&(0,J.jsx)(`p`,{className:`mt-1 pl-6 text-[11px] text-muted-foreground`,children:`当前浏览器不支持推送。`})]}),(0,J.jsxs)(`div`,{className:`space-y-0.5`,children:[d.map(e=>{let t=e.pairId===f;return B===e.pairId?(0,J.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-dashed p-3`,children:[(0,J.jsxs)(`p`,{className:`text-xs`,children:[`解绑「`,e.label,`」后需重新扫码才能连接,确定吗?`]}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)(ji,{variant:`outline`,size:`sm`,onClick:()=>V(null),children:`取消`}),(0,J.jsx)(ji,{variant:`destructive`,size:`sm`,onClick:()=>{V(null),k(e.pairId)},children:`确定解绑`})]})]},e.pairId):(0,J.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>T(e.pairId),className:q(`flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-2 text-left text-sm transition-colors hover:bg-muted/60`,t?`text-foreground`:`text-muted-foreground`),children:[(0,J.jsx)(lt,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),t&&(0,J.jsx)(`span`,{className:q(`shrink-0 text-[10px]`,m?`text-muted-foreground`:`text-destructive`),children:h})]}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`重命名 ${e.label}`,onClick:()=>{let t=window.prompt(`给这台电脑起个名:`,e.label);t?.trim()&&O(e.pairId,t)},className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground`,children:(0,J.jsx)(kt,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`解绑 ${e.label}`,onClick:()=>V(e.pairId),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-destructive`,children:(0,J.jsx)(nn,{className:`h-3.5 w-3.5`})})]},e.pairId)}),(0,J.jsxs)(`button`,{type:`button`,onClick:E,className:`flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-muted-foreground text-sm transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,J.jsx)(Nt,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{children:`配对新电脑`})]})]}),(0,J.jsxs)(`p`,{className:`px-2 pt-0.5 text-center text-[10px] text-muted-foreground/60`,children:[`版本 `,`8207b4c-dirty`]})]})]})]})}function G9({session:e,active:t,nowTick:n,subtitle:r,onSelect:i}){return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:q(`flex w-full items-center gap-2 rounded-lg py-2 pr-2 pl-4 text-left text-sm transition-colors`,t?`bg-brand/10 dark:bg-brand/15`:`hover:bg-muted/60`),children:[(0,J.jsx)(zue,{status:e.status,unread:e.unread}),e.pinned&&(0,J.jsx)(At,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.title||`新对话`,r&&(0,J.jsx)(`span`,{className:`ml-1.5 text-[10px] text-muted-foreground`,children:r})]}),e.updatedAt&&(0,J.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/80 tabular-nums`,children:X7(e.updatedAt,`zh`,n)})]})}function K9({name:e,badge:t,sessions:n,folded:r,revealedExtra:i,activeId:a,nowTick:o,canCreate:s,onToggleFold:c,onRevealMore:l,onSelect:u,onNew:d}){let{t:f}=Ro(),p=W9(n.length,i),m=n.slice(0,p),h=n.length-p;return(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex w-full items-center gap-1 rounded-lg px-2 py-2 transition-colors hover:bg-muted/60`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:c,className:`flex min-w-0 flex-1 items-center gap-1 text-left`,children:[(0,J.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,J.jsx)(ke,{className:q(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,!r&&`rotate-90`)})}),(0,J.jsx)(Qe,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-sm`,children:[e,t&&(0,J.jsx)(`span`,{className:`ml-1.5 rounded bg-muted px-1 py-0.5 text-[10px] font-normal text-muted-foreground`,children:t})]}),(0,J.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums`,children:n.length})]}),s&&d&&(0,J.jsx)(`button`,{type:`button`,onClick:d,className:`shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(_t,{className:`h-3.5 w-3.5`})})]}),!r&&(0,J.jsxs)(`div`,{className:`mt-0.5 flex flex-col gap-y-0.5`,children:[m.map(e=>(0,J.jsx)(G9,{session:e,active:a===e.id,nowTick:o,onSelect:u},e.id)),n.length>5&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[h>0&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>l(Pue(n.length,i)),className:`flex-1 rounded-lg py-1 text-center text-muted-foreground text-xs transition-colors hover:bg-muted/60 hover:text-foreground`,children:f(`Show {{n}} more`,{n:h})}),i>0&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>l(Fue(i)),className:`flex-1 rounded-lg py-1 text-center text-muted-foreground text-xs transition-colors hover:bg-muted/60 hover:text-foreground`,children:f(`Collapse`)})]})]})]})}function zue({status:e,unread:t}){let n=e===`running`,r=!n&&e===`failed`,i=!n&&!r&&t===!0;return(0,J.jsx)(`span`,{className:q(`h-1.5 w-1.5 shrink-0 rounded-full`,n&&`animate-pulse bg-brand`,r&&`bg-destructive`,i&&`bg-green-500`,!n&&!r&&!i&&`bg-muted-foreground/30`)})}function Bue(){window.electronAPI||Object.defineProperty(window,"electronAPI",{value:{git:{diffHead:async()=>({ok:!1,error:`unavailable`})},changes:{readSnapshots:async()=>({}),writeSnapshots:async()=>!1},workspaceFiles:{listDir:async()=>({ok:!1,error:`unavailable`}),read:async()=>({ok:!1,error:`unavailable`}),write:async()=>({ok:!1,error:`unavailable`}),watchStart:async()=>({ok:!1,error:`unavailable`}),watchStop:async()=>({ok:!1,error:`unavailable`}),onChange:()=>()=>void 0,search:async()=>({ok:!1,error:`unavailable`})},files:{read:async()=>null,search:async()=>[],pathForFile:()=>null},agentRegistry:{list:async()=>null},agent:{stopTask:async()=>({ok:!1,error:`not supported on phone`}),stopSubagent:async()=>({ok:!1,error:`not supported on phone`})},providers:{listOauth:async()=>[],getOauthUsage:async()=>null}},writable:!1})}function Vue(e){let t=window.electronAPI?.agent;t&&(t.stopTask=async(t,n)=>(e.stopTask(t,n),{ok:!0}),t.stopSubagent=async(t,n)=>(e.stopSubagent(t,n),{ok:!0}))}function Hue(e,t){return e?t.some(e=>e.status===`running`||typeof e.pendingAskCount==`number`&&e.pendingAskCount>0||typeof e.pendingApprovalCount==`number`&&e.pendingApprovalCount>0):!1}var q9=null;async function J9(e,t=typeof navigator>`u`?void 0:navigator.wakeLock){if(!e||!t){if(!q9)return;let e=q9;q9=null;try{await e.release()}catch{}return}if(!q9)try{let e=await t.request(`screen`);q9=e,e.addEventListener(`release`,()=>{q9===e&&(q9=null)})}catch{q9=null}}function Uue(){if(!window.location.hash.replace(/^#/,``).includes(`pk=`))return null;let e=window.location.href;return history.replaceState(null,``,window.location.pathname+window.location.search),e}var Wue={connecting:`连接中…`,online:`已连接`,"host-offline":`桌面端离线`,unauthorized:`配对已失效`,offline:`重连中…`},Y9=`enso-phone-push`,X9=`enso-phone-sidebar-pinned`,Gue=l();function Kue(){let e=j(window.location.search);if(!e)return null;let t=new URLSearchParams(window.location.search);t.delete(`session`);let n=t.toString();return history.replaceState(null,``,window.location.pathname+(n?`?${n}`:``)),e}function que(){return N9()?`ok`:/iphone|ipad|ipod/i.test(navigator.userAgent)&&!M9()?`needs-install`:`unsupported`}function Jue(){let[e,t]=(0,G.useState)(N),[n,r]=(0,G.useState)(k),i=C(e,n),[a]=(0,G.useState)(Uue),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(`connecting`),[u,f]=(0,G.useState)(`relay`),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)([]),[x,S]=(0,G.useState)([]),[E,D]=(0,G.useState)([]),[j,I]=(0,G.useState)([]),[R,z]=(0,G.useState)([]),[V]=(0,G.useState)(Kue),[ee]=(0,G.useState)(()=>T(i?.pairId??null,V)),[H,U]=(0,G.useState)(ee.activeId),[W,te]=(0,G.useState)(null),[ne,re]=(0,G.useState)(!1),[ie,ae]=(0,G.useState)(new Set),[oe,ce]=(0,G.useState)([]),[le,ue]=(0,G.useState)(!1),de=Ble(Vle),[fe,pe]=(0,G.useState)(()=>localStorage.getItem(X9)!==`off`),me=de&&fe,he=()=>{pe(e=>(localStorage.setItem(X9,e?`off`:`on`),!e))},[ge,K]=(0,G.useState)(!1),[_e,ve]=(0,G.useState)(null),[ye,be]=(0,G.useState)(!1),[xe,Se]=(0,G.useState)(()=>localStorage.getItem(Y9)===`on`),[Ce,we]=(0,G.useState)(!1),[Te,Ee]=(0,G.useState)(!1),[De,Oe]=(0,G.useState)(!1),[ke,Ae]=(0,G.useState)(!1),[je,Me]=(0,G.useState)(!1),[Ne,Pe]=(0,G.useState)(!1),[Fe,Ie]=(0,G.useState)(null),[Le,Re]=(0,G.useState)(!1),[ze,Be]=(0,G.useState)(!1),[Ve,He]=(0,G.useState)(!1),Ue=(0,G.useRef)(!1),[We,Ge]=(0,G.useState)(!1),[Ke,qe]=(0,G.useState)(!1),Je=(0,G.useRef)(!1),[Ye,Xe]=(0,G.useState)([]),[Ze,Qe]=(0,G.useState)([]),[$e,et]=(0,G.useState)([]),[tt,nt]=(0,G.useState)(!1),[rt,it]=(0,G.useState)([]),[at,ot]=(0,G.useState)({items:[],offset:0}),[st,ct]=(0,G.useState)(()=>U7(!0,ee.botChatId)),[lt,ut]=(0,G.useState)(ee.botChatId),[dt,ft]=(0,G.useState)(null),[pt,mt]=(0,G.useState)({}),[ht,gt]=(0,G.useState)({}),[_t,vt]=(0,G.useState)({}),[yt,bt]=(0,G.useState)(null),xt=(0,G.useRef)(null),St=(0,G.useMemo)(()=>new qi(e=>Ot.current?.send(e)),[]),Ct=(0,G.useMemo)(()=>new Do(e=>Ot.current?.send(e)),[]),wt=(0,G.useMemo)(()=>new ko(e=>Ot.current?.send(e)),[]),[Tt,Et]=(0,G.useState)([]),Ot=(0,G.useRef)(null),kt=(0,G.useRef)(H),At=(0,G.useRef)(g),jt=(0,G.useRef)(W);At.current=g,jt.current=W,kt.current=H;let Mt=lt?$e.find(e=>e.id===lt):void 0,Nt=Mt?.kind===`group`?ao(Mt,Ye):void 0,Pt=Nt?.current??Mt,Ft=Mt?.kind===`direct`?Mt.sessions[Mt.members[0]]?.conversationId??null:null,It=lt?Ft??dt:H,Lt=(0,G.useRef)(It);Lt.current=It;let Rt=(0,G.useRef)($e);Rt.current=$e;let zt=(0,G.useRef)(lt);zt.current=lt;let Bt=(0,G.useRef)(null);Bt.current=Nt?.current.id??null;let Vt=(0,G.useRef)(new Set);Vt.current=new Set(Nt?Object.values(Nt.current.sessions).map(e=>e.conversationId):[]);let Ht=(0,G.useRef)(null),Ut=(0,G.useRef)(new Map),Wt=(0,G.useRef)(null),[Kt,qt]=(0,G.useState)(!1),Jt=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(Cue(),!(`serviceWorker`in navigator))return;let e=e=>{let t=e.data;if(t?.type!==`open-session`)return;let n=O(t.sessionId);if(!n)return;let r=Rt.current.find(e=>Object.values(e.sessions).some(e=>e.conversationId===n));r?(ut(r.id),ft(null)):(ut(null),U(n)),fn()};return navigator.serviceWorker.addEventListener(`message`,e),()=>navigator.serviceWorker.removeEventListener(`message`,e)},[]),(0,G.useEffect)(()=>{Pi(Mi(g))},[g]),(0,G.useEffect)(()=>{let e=()=>{J9(Hue(document.visibilityState===`visible`&&c===`online`,g))};return e(),document.addEventListener(`visibilitychange`,e),document.addEventListener(`pointerdown`,e,{passive:!0}),()=>{document.removeEventListener(`visibilitychange`,e),document.removeEventListener(`pointerdown`,e),J9(!1)}},[g,c]),(0,G.useEffect)(()=>{if(V){w();return}w().then(e=>{e&&(ut(null),ft(null),U(e),fn())})},[V]),(0,G.useEffect)(()=>{a&&e.length>0&&s(!0)},[]),(0,G.useEffect)(()=>{if(!i)return;Jt.current=null,we(!1),ae(new Set),f(`relay`),Ee(!1),Oe(!1),Ae(!1),Me(!1),Be(!1),He(!1),Ue.current=!1,Ge(!1),qe(!1),Je.current=!1;let e=()=>{Oe(!0),Me(!0)},t=new b(i,{onState:e=>{e!==`online`&&(xt.current?.interrupted(),St.reset(),Ct.reset(),wt.reset(),Be(!1),Ge(!1)),l(e)},onBotArtifacts:e=>St.receive(e),onBotArtifactImage:e=>St.receiveImage(e),onBotNewSessionResult:t=>{Ct.receive(t),t.error===`read-only`&&e()},onBotThreadResult:t=>{wt.receive(t),t.error===`read-only`&&e()},onTransport:e=>{f(e),h(null)},onRtt:h,onVoiceInput:Ee,onRemoteDesktop:Ae,onReadOnly:e=>{Oe(e),e||Me(!1)},onCommandRejected:(t,n)=>{n===`read-only`&&e()},onCatalog:(e,t)=>{_(e),S(t??[])},onProjects:(e,t)=>{D(e),I(t??[])},onProviders:z,onSession:(e,t)=>{te(n=>e===Lt.current?t:n),Vt.current.has(e)&&vt(n=>({...n,[e]:t}))},onBotCatalog:(e,t,n,r)=>{Re(e),Be(e&&n),Ge(e&&r),Qe(t),!e&&(et([]),Xe([]),it([]),ot({items:[],offset:0}),ut(null),ft(null),ct(!1))},onBotChats:(e,t)=>{et(e),Xe(t),nt(!0)},onBotInbox:it,onBotActivity:(e,t)=>{for(let t of e)Ut.current.set(t.conversationId,t.botId);ot({items:e,offset:t})},onGroupTimeline:e=>{e.beforeSeq!==void 0&&Wt.current===`${e.chatId}:${e.beforeSeq}`&&(Wt.current=null,qt(!1)),mt(t=>({...t,[e.chatId]:lo(t[e.chatId],e)}))},onBotChatState:({type:e,chatId:t,...n})=>gt(e=>({...e,[t]:n})),onBotEvent:e=>{if(e.kind===`model-notice`){e.text&&(e.chatId===zt.current||e.chatId===Bt.current)&&bt(e.text);return}!e.chatId||e.chatId!==Bt.current||Ht.current||(Ht.current=setTimeout(()=>{Ht.current=null;let e=Bt.current;e&&t.send({type:`bot-chat-open`,chatId:e})},200))},onBotSendResult:t=>{xt.current?.settle(t.deliveryId,t.ok,t.error),t.error===`read-only`&&e()},onBotRetryResult:e=>{e.chatId===Bt.current&&bt(e.ok?`已开始重试`:`重试失败:${e.error===`session-busy`?`请等当前回复结束`:`该回复已过期或无法恢复,请重新发送需求`}`)},onSync:e=>re(e===`syncing`),onGhostSession:e=>{e===kt.current&&U(null)},onHistoryPending:(e,t)=>{ae(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},onPushConfig:e=>{Jt.current=e,we(!0),localStorage.getItem(Y9)===`on`&&P9(e).then(e=>{e.ok&&t.send({type:`push-subscribe`,subscription:e.subscription})})}});Ot.current=t,t.connect();let n=()=>{document.visibilityState===`visible`?(t.nudge(`visibility`),t.send({type:`presence`,visible:!0})):(t.conceal(),t.send({type:`presence`,visible:!1}),t.flushCache())},r=()=>{document.visibilityState===`visible`&&(t.nudge(`online`),t.send({type:`presence`,visible:!0}))},a=e=>{document.visibilityState===`visible`&&(t.nudge(e.persisted?`online`:`visibility`),t.send({type:`presence`,visible:!0}))},o=()=>{document.visibilityState===`visible`&&t.nudge(`visibility`)},s=()=>{t.conceal(),t.flushCache()};return document.addEventListener(`visibilitychange`,n),window.addEventListener(`online`,r),window.addEventListener(`pageshow`,a),window.addEventListener(`focus`,o),window.addEventListener(`pagehide`,s),()=>{document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`online`,r),window.removeEventListener(`pageshow`,a),window.removeEventListener(`focus`,o),window.removeEventListener(`pagehide`,s),Ht.current&&clearTimeout(Ht.current),Ht.current=null,t.close(),Ot.current=null,Ct.reset(),wt.reset()}},[i?.pairId,i?.token,i?.relayUrl,i?.contentKey]);let Yt=(0,G.useRef)(new Set);(0,G.useEffect)(()=>{let e=It!==null&&Yt.current.has(It);Ot.current?.subscribe(It,{fresh:e});for(let e of Yt.current)e!==It&&Yt.current.delete(e);te(It?Ot.current?.getSession(It)??null:null)},[It,i?.pairId]);let Xt=i?.pairId;(0,G.useEffect)(()=>{Xt&&P(Xt,{activeId:H,botChatId:lt})},[H,lt,Xt]),(0,G.useEffect)(()=>{if(!Xt)return;let e=new d(p,Xt);xt.current=e,Et([]);let t=e.subscribe(e=>Et([...e]));return e.restore().catch(()=>bt(`离线消息读取失败,请勿清除浏览器数据;恢复存储后可重试。`)),()=>{t(),xt.current===e&&(xt.current=null)}},[Xt]),(0,G.useEffect)(()=>{if(c===`online`)for(let e of xt.current?.drain()??[])Ot.current?.send({type:`bot-send`,chatId:e.chatId,text:e.text,...e.images?.length?{images:e.images}:{},deliveryId:e.deliveryId})},[c,Tt]),(0,G.useEffect)(()=>{let e=setInterval(()=>xt.current?.expire(),1e3);return()=>clearInterval(e)},[]);let Zt=Nt?.current.id??null;(0,G.useEffect)(()=>{!Zt||c!==`online`||(Wt.current=null,qt(!1),Ot.current?.send({type:`bot-chat-open`,chatId:Zt}))},[Zt,c]),(0,G.useEffect)(()=>{if(!Kt)return;let e=setTimeout(()=>{Wt.current=null,qt(!1),bt(`历史加载未完成,请点击加载重试。`)},1e4);return()=>clearTimeout(e)},[Kt]),(0,G.useEffect)(()=>{let e={};for(let t of Vt.current){let n=Ot.current?.getSession(t);n&&(e[t]=n)}vt(e)},[Zt,Nt?.current.sessions]),(0,G.useEffect)(()=>{if(!H||lt)return;let e=$e.find(e=>Object.values(e.sessions).some(e=>e.conversationId===H));e&&(ut(e.id),U(null))},[H,lt,$e]),(0,G.useEffect)(()=>{let e=(e,t)=>{let n=At.current.find(t=>t.id===e)?.queued,r=ale(n,e,t,R7(e===kt.current&&jt.current?[...jt.current.messages.values()]:[]));r&&ce(e=>[...e,r])};xne({removeQueuedMessage:(e,t)=>Ot.current?.send({type:`queue-remove`,sessionId:e,messageId:t}),updateQueuedMessage:(e,t,n)=>Ot.current?.send({type:`queue-update`,sessionId:e,messageId:t,text:n}),sendQueuedNow:(t,n)=>{e(t,n),Ot.current?.send({type:`queue-send-now`,sessionId:t,messageId:n})},interruptAndSendQueued:async(t,n)=>{e(t,n),Ot.current?.send({type:`queue-interrupt-send`,sessionId:t,messageId:n})},pauseGoal:e=>Ot.current?.send({type:`goal-pause`,sessionId:e}),resumeGoal:e=>Ot.current?.send({type:`goal-resume`,sessionId:e}),clearGoal:e=>Ot.current?.send({type:`goal-clear`,sessionId:e}),rewind:(e,t,n)=>Ot.current?.send({type:`rewind`,sessionId:e,userIndexFromEnd:t,...n?{restoreFiles:n}:{}}),retry:e=>Ot.current?.send({type:`retry`,sessionId:e})}),Vue({stopTask:(e,t)=>Ot.current?.send({type:`task-stop`,sessionId:e,taskId:t}),stopSubagent:(e,t)=>Ot.current?.send({type:`subagent-stop`,sessionId:e,agentId:t})})},[]);let Qt=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!H)return;let e=R7(W?[...W.messages.values()]:[]),t=W?.status===`running`,n=Qt.current,r=n?.id===H&&n.running&&!t;Qt.current={id:H,running:t},ce(t=>{let n=cle(t,H,e,{turnSettled:r});return n.length===t.length&&n.every((e,n)=>e===t[n])?t:n})},[W,H]);let $t=g.find(e=>!e.parentId)?.id;(0,G.useEffect)(()=>{!lt&&!H&&$t&&U($t)},[H,lt,$t]);let en=(0,G.useMemo)(()=>g.find(e=>e.id===H),[g,H]),tn=(0,G.useMemo)(()=>{if(!en)return;let e=en.parentId?g.find(e=>e.id===en.parentId):en;if(!e)return;let t=g.filter(t=>t.parentId===e.id);return t.length>0?{parent:e,children:t}:void 0},[g,en]),nn=en&&!en.parentId,rn=nn?R.find(e=>e.id===en.providerId)?.models.find(e=>e.id===en.modelId)?.label??en.modelId??`选择模型`:void 0,an=c===`online`?ble(u,m):Wue[c],on=e=>{_([]),S([]),D([]),I([]),z([]),te(null),re(!1),ce([]),h(null),Re(!1),Qe([]),et([]),Xe([]),nt(!1),ut(e.botChatId),ct(e.botChatId!==null),ft(null),mt({}),gt({}),ot({items:[],offset:0}),vt({}),bt(null),U(e.activeId)},sn=e=>{e!==i?.pairId&&(y(e),r(e),l(`connecting`),on(T(e)),fn())},cn=n=>{let i=B(e,n);t(i),A(i),y(n.pairId),r(n.pairId),on(T(n.pairId)),s(!1)},ln=n=>{let a=e.find(e=>e.pairId===n);a&&M(a.relayUrl,a.pairId,a.token).catch(()=>{}),n===i?.pairId&&Ot.current?.close(),F(n);let o=v(e,n);if(t(o),A(o),n===(i?.pairId??null)){let e=C(o,null);y(e?.pairId??null),r(e?.pairId??null),e&&l(`connecting`),on(T(e?.pairId??null)),e||fn()}},un=(n,r)=>{let i=L(e,n,r);t(i),A(i)};if(!i||o)return(0,J.jsx)(Sue,{autoInvite:a,onPaired:cn,onCancel:i?()=>s(!1):void 0});if(c===`unauthorized`){let t=e.length>1;return(0,J.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,J.jsx)(Gt,{className:`h-8 w-8 text-muted-foreground`}),(0,J.jsx)(`h1`,{className:`font-medium text-lg`,children:`配对已失效`}),(0,J.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[`「`,i.label,`」已解绑此设备,`,t?`可移除它并切到其他电脑。`:`请重新扫码配对。`]}),(0,J.jsx)(ji,{onClick:()=>ln(i.pairId),children:t?`移除此配对`:`重新配对`})]})}let dn=e=>Ot.current?.send(e),fn=()=>{(localStorage.getItem(X9)===`off`||!window.matchMedia(`(min-width: 900px)`).matches)&&ue(!1)},pn=()=>{ct(U7(Le,lt)),ue(!0),Le&&dn({type:`bot-catalog-request`})},mn=(e,t,n=[])=>{bt(null),xt.current?.enqueue({chatId:e,text:t,images:n})},hn=e=>(0,J.jsx)(_ue,{items:Tt.filter(t=>t.chatId===e),readOnly:De,onRetry:e=>xt.current?.retry(e),onDiscard:e=>xt.current?.discard(e)}),gn=new Map(Ze.map(e=>[e.id,e])),_n=e=>De?`只读设备不能新建会话`:c===`online`?ze?Ve?`正在新建会话…`:Tt.some(t=>t.chatId===e)?`请先处理待发送消息`:void 0:`请升级桌面端以支持新建会话`:`请先连接桌面端`,vn=async e=>{if(_n(e)||Ue.current)return;let t=Ot.current;Ue.current=!0,He(!0),bt(null);try{let n=await Ct.start(e,()=>t===Ot.current&&zt.current===e&&window.confirm(`群聊中仍有回复、排队或委派任务。新建会话将停止成员回复,并取消未标记保留的委派。旧消息会保留。继续吗?`));if(t!==Ot.current||zt.current!==e)return;bt(!n||n.ok?null:n.error===`read-only`?`只读设备不能新建会话`:n.error===`timeout`||n.error===`offline`?`未收到新会话确认,请连接后核对聊天状态,勿重复操作`:`新建会话失败:${n.error??`请稍后重试`}`),n?.ok&&(t?.send({type:`bot-catalog-request`}),t?.send({type:`bot-chat-open`,chatId:e}))}finally{t===Ot.current&&(Ue.current=!1,He(!1))}},yn=De?`只读设备不能切换或新建话题`:c===`online`?Ke?`正在处理话题…`:void 0:`请先连接桌面端`,bn=async e=>{if(yn||Je.current)return;let t=Ot.current;Je.current=!0,qe(!0),bt(null);try{let n=await wt.request(e);if(t!==Ot.current||zt.current!==e.chatId)return;n.ok?ft(null):bt(n.error===`read-only`?`只读设备不能切换或新建话题`:n.error===`timeout`||n.error===`offline`?`未收到桌面确认,请连接后核对当前话题`:n.error===`invalid`?`该话题已不存在或群已归档`:`话题操作失败:${n.error??`请稍后重试`}`)}finally{t===Ot.current&&(Je.current=!1,qe(!1))}},xn=e=>{if(e.kind===`group`&&!dt){let t=Object.entries(e.sessions).flatMap(([e,{conversationId:t}])=>{let n=_t[t];return n?[{sessionId:t,botId:e,view:n}]:[]});return(0,J.jsx)(zle,{chat:e,bots:gn,timeline:pt[e.id],state:ht[e.id],pending:t,activities:So(at.items,e.id),clockOffset:at.offset,connState:c,stateLabel:an,notice:yt,outbox:hn(e.id),deviceReadOnly:De,readOnlyRejected:je,onOpenDrawer:pn,drawerDocked:me,onNewSession:()=>void vn(e.id),canCreate:!_n(e.id),newSessionHint:_n(e.id),newSessionBusy:Ve,threads:We&&Nt&&Mt?{entries:Nt.entries,currentId:e.id,rootId:Mt.id,disabledHint:yn,onSelect:e=>void bn({type:`bot-thread-select`,chatId:Mt.id,threadId:e}),onCreate:()=>void bn({type:`bot-thread-create`,chatId:Mt.id})}:void 0,voice:Sn,onLoadOlder:()=>{let t=pt[e.id]?.entries[0]?.seq,n=`${e.id}:${t}`;c!==`online`||t===void 0||Wt.current||(Wt.current=n,qt(!0),dn({type:`bot-timeline`,chatId:e.id,beforeSeq:t}))},historyLoading:Kt,onJumpLatest:()=>{Wt.current=null,qt(!1),mt(t=>{let n={...t};return delete n[e.id],n}),dn({type:`bot-chat-open`,chatId:e.id})},onSend:(t,n)=>mn(e.id,t,n),onStop:()=>dn({type:`bot-stop`,chatId:e.id}),onRetry:t=>{bt(`正在请求重试…`),dn({type:`bot-retry`,chatId:e.id,entryId:t})},onOpenProcess:ft,onApproval:(e,t,n)=>dn({type:`approval-respond`,sessionId:e,requestId:t,decision:n}),onAsk:(e,t,n)=>dn({type:`ask-respond`,sessionId:e,requestId:t,answer:n})})}let t=e.kind===`group`,n=pt[e.id]?.entries.find(e=>e.kind===`bot`&&e.conversationId===dt),r=dt?Ut.current.get(dt):void 0,i=gn.get(t?n?.kind===`bot`?n.botId:r??``:e.members[0]);return(0,J.jsx)(B7,{sessionId:It??`bot-chat:${e.id}`,clockOffset:at.offset,title:t?`${i?.name??`成员`} · 过程`:i?.name??e.title,projectName:t?e.title:i?.title??``,view:It?W:Gue,connState:c,stateLabel:an,syncing:ne&&!!It,onOpenDrawer:pn,drawerDocked:me,onNewSession:()=>!t&&void vn(e.id),canCreate:!t&&!_n(e.id),newSessionHint:_n(e.id),newSessionBusy:Ve,hasOlder:!!(It&&W&&W.messages.size>0&&Math.min(...W.messages.keys())>0),historyLoading:!!(It&&ie.has(It)),onLoadOlder:()=>It&&Ot.current?.requestHistory(It),voice:Sn,bot:t?{readOnly:!0,onBack:()=>ft(null)}:{chatId:e.id,notice:yt,outbox:hn(e.id)},artifacts:!t&&It?{chatId:e.id,conversationId:It}:void 0,deviceReadOnly:De,readOnlyRejected:je,onSend:(t,n)=>mn(e.id,t,n),onAbort:()=>It&&dn({type:`abort`,sessionId:It}),onApproval:(e,t)=>It&&dn({type:`approval-respond`,sessionId:It,requestId:e,decision:t}),onAsk:(e,t)=>It&&dn({type:`ask-respond`,sessionId:It,requestId:e,answer:t})})},Sn=Te?e=>Ot.current?.startVoice(e)??{push:()=>{},finish:()=>Promise.resolve({ok:!1,error:`failed`}),cancel:()=>{}}:void 0,Cn=async e=>{if(Ie(null),!e){localStorage.setItem(Y9,`off`),Se(!1),dn({type:`push-unsubscribe`}),Eue();return}let t=Jt.current;if(!t)return;Se(!0),Pe(!0);let n=await P9(t);if(Pe(!1),!n.ok){Se(!1),Ie(n.reason);return}dn({type:`push-subscribe`,subscription:n.subscription}),localStorage.setItem(Y9,`on`)};return(0,J.jsxs)(`div`,{className:`phone-app-root flex h-full min-h-0`,children:[(0,J.jsx)(Rue,{open:me||le,docked:me,pinnable:de,onTogglePinned:he,projects:E,groups:j,catalog:g,pinnedOrder:x,activeId:lt?null:H,canCreate:c===`online`&&!De,devices:e,activeDevicePairId:i.pairId,remoteDesktop:ke,connected:c===`online`,connectionLabel:an,onClose:()=>fn(),onSelect:e=>{ut(null),ft(null),U(e),fn()},onNewConversation:e=>{fn(),ve(e),K(!0)},pushEnabled:xe,pushBusy:Ne,pushError:Fe,pushAvailability:que(),pushConfigReady:Ce,onTogglePush:e=>void Cn(e),onSwitchDevice:sn,onAddDevice:()=>{fn(),s(!0)},onRenameDevice:un,onUnpairDevice:ln,botSegment:Le?{active:st,onChange:e=>{ct(e),Sle(e?`bot`:`code`),e&&dn({type:`bot-catalog-request`})},panel:(0,J.jsx)(Eo,{bots:Ze,chats:$e,activeChatId:lt,inbox:rt,activities:at.items,onDismiss:De?void 0:e=>dn({type:`bot-inbox-dismiss`,key:e}),onSelect:e=>{ut(e),ft(null),bt(null),fn()}})}:void 0}),(0,J.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[de&&!me&&!le&&(0,J.jsx)(`button`,{type:`button`,onClick:pn,"aria-label":`打开会话列表`,className:`fixed top-1/2 left-0 z-40 flex h-16 w-6 -translate-y-1/2 items-center justify-center rounded-r-lg border border-l-0 bg-background/90 text-muted-foreground shadow-sm backdrop-blur transition-colors hover:bg-accent hover:text-foreground`,children:(0,J.jsx)(Dt,{className:`h-4.5 w-4.5`})}),Mt?(0,J.jsx)(Yi.Provider,{value:{port:St,online:c===`online`},children:xn(Pt??Mt)}):lt?(0,J.jsxs)(`div`,{className:`relative flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[!me&&(0,J.jsx)(`button`,{type:`button`,onClick:pn,"aria-label":`打开会话列表`,className:`absolute top-2 left-2 flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,J.jsx)(Dt,{className:`h-4.5 w-4.5`})}),(0,J.jsx)(`p`,{children:tt?`该 Bot 聊天已不存在或不可用`:`正在恢复 Bot 聊天…`}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:an}),(0,J.jsx)(ji,{onClick:pn,children:`选择聊天`})]}):(0,J.jsx)(B7,{sessionId:H,title:en?.title||(H?`会话`:`EnsoCode`),projectName:en?.projectName??``,cwd:en?.cwd,view:W,connState:c,stateLabel:an,syncing:ne&&!!H,onOpenDrawer:pn,drawerDocked:me,onNewSession:()=>{ve(null),K(!0)},canCreate:c===`online`&&E.length>0&&!De,modelLabel:c===`online`?rn:void 0,onOpenConfig:()=>be(!0),tabGroup:tn,onSelectTab:U,hasOlder:!!(H&&W&&W.messages.size>0&&Math.min(...W.messages.keys())>0),historyLoading:!!(H&&ie.has(H)),onLoadOlder:()=>H&&Ot.current?.requestHistory(H),voice:Sn,queued:ole(en?.queued,oe,H??``),echoes:oe,goal:en?.goal,context:en?.context,usageTotals:en?.usageTotals,slashCommands:en?.slashCommands,deviceReadOnly:De,readOnlyRejected:je,onSend:(e,t)=>{if(!H)return;let n=se(e);if(n){dn({type:`compact`,sessionId:H,...n.instructions?{instructions:n.instructions}:{}});return}let r=/^\/goal(?:\s+([\s\S]+))?$/.exec(e.trim());if(r){let e=r[1]?.trim();if(!e)return;dn(e===`clear`?{type:`goal-clear`,sessionId:H}:e===`pause`?{type:`goal-pause`,sessionId:H}:e===`resume`?{type:`goal-resume`,sessionId:H}:{type:`goal-set`,sessionId:H,text:e});return}dn({type:W?.status===`running`?`enqueue`:`prompt`,sessionId:H,text:e,...t.length?{images:t}:{}})},onAbort:()=>H&&dn({type:`abort`,sessionId:H}),onApproval:(e,t)=>H&&dn({type:`approval-respond`,sessionId:H,requestId:e,decision:t}),onAsk:(e,t)=>H&&dn({type:`ask-respond`,sessionId:H,requestId:e,answer:t})}),(0,J.jsx)(hue,{open:ge&&!De,projects:E,providers:R,preferredProjectId:_e,onClose:()=>{K(!1),ve(null)},onCreate:e=>{let t=crypto.randomUUID();dn({type:`spawn`,sessionId:t,...e}),Yt.current.add(t),K(!1),ve(null),ut(null),ft(null),U(t)}}),nn&&H&&!De&&(0,J.jsx)(Due,{open:ye,providers:R,config:{providerId:en.providerId,modelId:en.modelId,reasoningEnabled:en.reasoningEnabled,thinkingLevel:en.thinkingLevel},onClose:()=>be(!1),onSetModel:(e,t)=>dn({type:`set-model`,sessionId:H,providerId:e,modelId:t}),onSetReasoning:e=>dn({type:`set-reasoning`,sessionId:H,enabled:e}),onSetThinking:e=>dn({type:`set-thinking`,sessionId:H,level:e})})]})]})}function Yue(e){return!e.appleMobile||!e.standalone||e.safeTop<=0||e.innerHeight<=e.innerWidth?!1:e.innerHeight>=Math.max(e.screenWidth,e.screenHeight)-1}function Xue(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e&&!/^viewport-fit\s*=/i.test(e)).join(`, `)}function Zue(){return/iphone|ipad|ipod/i.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1}function Que(){let e=document.querySelector(`meta[name="viewport"]`);if(!e||!Zue())return;let t=document.createElement(`div`);t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:fixed;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom)`,document.body.appendChild(t);let n=()=>{let r=getComputedStyle(t);if(!Yue({appleMobile:!0,standalone:M9(),safeTop:Number.parseFloat(r.paddingTop)||0,innerWidth:window.innerWidth,innerHeight:window.innerHeight,screenWidth:window.screen.width,screenHeight:window.screen.height}))return;let i=Number.parseFloat(r.paddingBottom)||0;document.documentElement.style.setProperty(`--phone-safe-bottom`,`${i}px`),e.content=Xue(e.content),window.removeEventListener(`resize`,n),document.removeEventListener(`visibilitychange`,n),t.remove()};window.addEventListener(`resize`,n),document.addEventListener(`visibilitychange`,n),n()}var Z9=new URLSearchParams(location.search);if(Z9.get(`mode`)===`phone`){S(`phone`),Z9.delete(`mode`);let e=Z9.toString();history.replaceState(null,``,`${location.pathname}${e?`?${e}`:``}${location.hash}`)}var Q9=I(location.search,x(),N(),k());Q9&&location.replace(Q9),Bue(),h(),Que();var $9=document.getElementById(`root`);$9&&!Q9&&(0,ae.createRoot)($9).render((0,J.jsx)(G.StrictMode,{children:(0,J.jsx)(Jue,{})}));export{Y as t};
|