@kingsoftcloud/ksadk-web 0.3.7 → 0.3.8
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/CHANGELOG.md +6 -0
- package/RELEASE_PROVENANCE.json +2 -2
- package/dist-ksadk/assets/{ArtifactsPanel-CGbWlMNh.js → ArtifactsPanel-CbUDzOQO.js} +1 -1
- package/dist-ksadk/assets/{CodeBlock-b4C7upmO.js → CodeBlock-BwoN4XSB.js} +1 -1
- package/dist-ksadk/assets/{MathMessageMarkdown-DbdW5A4_.js → MathMessageMarkdown-CE8kmnzT.js} +1 -1
- package/dist-ksadk/assets/{MermaidBlock-BEBN4Ksz.js → MermaidBlock-E2c6OIM3.js} +6 -6
- package/dist-ksadk/assets/{NativeTerminalPanel-zvL-WpAn.js → NativeTerminalPanel-DPLNV-9q.js} +1 -1
- package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-BYafW7Za.js → abnfDiagram-VCTEODGH-BOEVF10j.js} +1 -1
- package/dist-ksadk/assets/{arc-bTohInsS.js → arc-D8m73GUU.js} +1 -1
- package/dist-ksadk/assets/architecture-7GRP2DOG-rCXFSJus.js +1 -0
- package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-Ch5Lbzsi.js → architectureDiagram-5GKGNRK7-CZB47JMF.js} +1 -1
- package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-kqF4MDOG.js → blockDiagram-NRAW4CY4-Cv2NU94T.js} +1 -1
- package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-8uSRIODv.js → c4Diagram-UCG6FXSJ-opDgjD87.js} +1 -1
- package/dist-ksadk/assets/channel-hnxAcHmY.js +1 -0
- package/dist-ksadk/assets/chunk-2Q5K7J3B-CULEGhLm.js +1 -0
- package/dist-ksadk/assets/{chunk-5VM5RSS4-DkhehZDr.js → chunk-5VM5RSS4-Ck1iwW_G.js} +1 -1
- package/dist-ksadk/assets/{chunk-F27PBJKO-BdXhtPe9.js → chunk-F27PBJKO-B8zFIVuU.js} +1 -1
- package/dist-ksadk/assets/{chunk-G27WJ6UU-DPTpvpwi.js → chunk-G27WJ6UU-CjEsmMNX.js} +1 -1
- package/dist-ksadk/assets/{chunk-JWPE2WC7-Pqoh38el.js → chunk-JWPE2WC7-CUCDIyfQ.js} +1 -1
- package/dist-ksadk/assets/{chunk-LCL6LL3I-DeU00qC-.js → chunk-LCL6LL3I-DnfLBbwZ.js} +1 -1
- package/dist-ksadk/assets/{chunk-POPQ4Y6H-CzxScFkr.js → chunk-POPQ4Y6H-1y0OEgko.js} +1 -1
- package/dist-ksadk/assets/{chunk-RHFEMEQ7-DpqMx-ux.js → chunk-RHFEMEQ7-BXaPo939.js} +1 -1
- package/dist-ksadk/assets/{chunk-SVP7TREG-C6t0SypQ.js → chunk-SVP7TREG-3RCiOG-8.js} +1 -1
- package/dist-ksadk/assets/{chunk-XXDRQBXY-DVaeafZk.js → chunk-XXDRQBXY-Bpt5C4kv.js} +1 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-ChOM9CGx.js +1 -0
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-ChOM9CGx.js +1 -0
- package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-Bf9D3tzJ.js → cose-bilkent-JH36ORCC-CltU2Iio.js} +1 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-s8NJ5Tm_.js +1 -0
- package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-B9cY3iTz.js → cynefinDiagram-5FMLGOSQ-Bnah0vhH.js} +1 -1
- package/dist-ksadk/assets/{dagre-3AP2YEHR-CSwlx3CB.js → dagre-3AP2YEHR-BQng1ROC.js} +1 -1
- package/dist-ksadk/assets/{dagre-UBpgon5q.js → dagre-CoKqxJD2.js} +1 -1
- package/dist-ksadk/assets/{diagram-S7CK7UJ4-C9akhN9a.js → diagram-S7CK7UJ4-BXDuD2zO.js} +1 -1
- package/dist-ksadk/assets/{diagram-UQ7AKVKN-CgedhTPI.js → diagram-UQ7AKVKN-DIfNFAeg.js} +1 -1
- package/dist-ksadk/assets/{diagram-VSXAHHWV-Cjucz5BY.js → diagram-VSXAHHWV-DKAwDqkb.js} +1 -1
- package/dist-ksadk/assets/{diagram-VX7I27RA-Dd4Vleyn.js → diagram-VX7I27RA-qFFDltev.js} +1 -1
- package/dist-ksadk/assets/{diagram-Z3DM3KII-CZ2jGtYW.js → diagram-Z3DM3KII-zMIfhqzQ.js} +1 -1
- package/dist-ksadk/assets/{dist-fBO2v5Kt.js → dist-1s_bzCxO.js} +1 -1
- package/dist-ksadk/assets/{dist-B3FR1SKK.js → dist-2cBTzdEm.js} +1 -1
- package/dist-ksadk/assets/{dist-DiixqL0J.js → dist-4ml45Gmg.js} +1 -1
- package/dist-ksadk/assets/{dist-D_ctSS2i.js → dist-ASt3FSxr.js} +1 -1
- package/dist-ksadk/assets/{dist-DFD6Qa6T.js → dist-B29N3_Ie.js} +1 -1
- package/dist-ksadk/assets/{dist-C1NMAY5a.js → dist-BEABF8oE.js} +1 -1
- package/dist-ksadk/assets/{dist-ClYUxfeK.js → dist-BGIxM2Vg.js} +1 -1
- package/dist-ksadk/assets/{dist-BgV_owcB.js → dist-BH4O3hsm.js} +1 -1
- package/dist-ksadk/assets/{dist-ufY3F5p6.js → dist-Blo8ntwU.js} +1 -1
- package/dist-ksadk/assets/{dist-B2_CVgKv.js → dist-Bzxnd_qQ.js} +1 -1
- package/dist-ksadk/assets/{dist-BIr4DSRq.js → dist-C60M2KmF.js} +1 -1
- package/dist-ksadk/assets/{dist-Cf125P_m.js → dist-C965y3AU.js} +1 -1
- package/dist-ksadk/assets/{dist-C5_ZAZsG.js → dist-CPy8MMAV.js} +1 -1
- package/dist-ksadk/assets/{dist-CFzsn6BG.js → dist-CU5pKkyk.js} +1 -1
- package/dist-ksadk/assets/{dist-CB9iJrvg.js → dist-Coj7US2k.js} +1 -1
- package/dist-ksadk/assets/{dist-DvFK7p5S.js → dist-DCeG0nKY.js} +1 -1
- package/dist-ksadk/assets/{dist-DVCOWtha.js → dist-DI-Jbiqn.js} +1 -1
- package/dist-ksadk/assets/{dist-BnaTiyzN.js → dist-DzXJwPG5.js} +1 -1
- package/dist-ksadk/assets/{dist-Bj730Ib4.js → dist-GOJu-1O3.js} +1 -1
- package/dist-ksadk/assets/{dist-btbmmX5O.js → dist-Ha8Q7H83.js} +1 -1
- package/dist-ksadk/assets/{dist-DoVSwoDb.js → dist-RXjVy4Wc.js} +1 -1
- package/dist-ksadk/assets/{dist-QfkEHOlb.js → dist-YZwAStAT.js} +1 -1
- package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-Ci8NqqZu.js → ebnfDiagram-PWID7BFC-Y-b0ShII.js} +1 -1
- package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-CCIOhLZG.js → erDiagram-SSCWMZ5O-CGX9tK2T.js} +1 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-DSV5ve2-.js +1 -0
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-B3rM8szx.js +1 -0
- package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-Cp_r9Hb6.js → ganttDiagram-EL5Y4UJY-R7T0Mwkt.js} +1 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-B4xZV0AQ.js +1 -0
- package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-Dlhc8Wr8.js → gitGraphDiagram-WWUBYQGX-gzn4XbP8.js} +1 -1
- package/dist-ksadk/assets/index-CYNEAutW.css +2 -0
- package/dist-ksadk/assets/{index-Dh2XHqPK.js → index-obJvgClV.js} +6 -6
- package/dist-ksadk/assets/info-A6RAGUB7-iLxaj0HG.js +1 -0
- package/dist-ksadk/assets/{infoDiagram-RXCK75RN-CO0rRTRA.js → infoDiagram-RXCK75RN-DrE_0Ol8.js} +1 -1
- package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-CHiaedSS.js → ishikawaDiagram-5VMMS53U-CYEgalv4.js} +1 -1
- package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-CHcCIB09.js → journeyDiagram-EYS64GPL-Bu-fPVb1.js} +1 -1
- package/dist-ksadk/assets/{kanban-definition-3QL26DDD-CJ_ebBZf.js → kanban-definition-3QL26DDD-CUFLrae5.js} +1 -1
- package/dist-ksadk/assets/{katex-B4weu383.js → katex-CXN0YSjg.js} +1 -1
- package/dist-ksadk/assets/{linear-V-MgYHW1.js → linear-BSbK6DWk.js} +1 -1
- package/dist-ksadk/assets/{mermaid-parser.core-CBijEX_c.js → mermaid-parser.core-D7K14JJL.js} +2 -2
- package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-Bc-pQvpp.js → mindmap-definition-FBJOCRG2-VVy1xsSW.js} +1 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-Cn-vZ0Ty.js +1 -0
- package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-D7genGLl.js → pegDiagram-XKGWAZYB-BSK45EeA.js} +1 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-DFyCNLMM.js +1 -0
- package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-Bxj32zwD.js → pieDiagram-E7YTZNPT-D7CnjFEg.js} +1 -1
- package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-BURv2mGh.js → quadrantDiagram-AXDQQJYC-D2XhCNms.js} +1 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-DOHzZ4f2.js +1 -0
- package/dist-ksadk/assets/railroad-74A4TZTK-3tTa8qz5.js +1 -0
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-BCeMbyzT.js +1 -0
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-CBtr8GVh.js +1 -0
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-CL9v6-uA.js +1 -0
- package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-CCsh3avW.js → railroadDiagram-O6MQD6OU-CRzXwklx.js} +1 -1
- package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-_FRRBKEd.js → requirementDiagram-EFPCY7ZU-Cc9PcBiM.js} +1 -1
- package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-C-gr2o9M.js → sankeyDiagram-P5KCCOFB-C96FB-uX.js} +1 -1
- package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-D97NmfKg.js → sequenceDiagram-WJ2MYXX4-CKOJAXyc.js} +1 -1
- package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-DjrPC5FX.js → sizeCapture-X5ZJPWSS-D9YhRNJt.js} +1 -1
- package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-DzMNg1hh.js → stateDiagram-HBIQ2CUA-BS0ROr-u.js} +1 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-jtOYkJhr.js +1 -0
- package/dist-ksadk/assets/{swimlanes-XN3QIQJK-Cssf_CsU.js → swimlanes-XN3QIQJK-DShW7VAE.js} +1 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-fHwNs_3X.js +8 -0
- package/dist-ksadk/assets/{timeline-definition-24CTP7MA-BWTHzyS1.js → timeline-definition-24CTP7MA-DSeFMeHD.js} +1 -1
- package/dist-ksadk/assets/treeView-Q6P3EWNA-BkRpaj3X.js +1 -0
- package/dist-ksadk/assets/treemap-WGGIJYW6-BUpY1xKR.js +1 -0
- package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-BSKgJsmR.js → vennDiagram-4TSXK5OY-CZEKlEip.js} +1 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-CJDNWytu.js +1 -0
- package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-eflHNoaZ.js → wardleyDiagram-VM6X3IG4-DTOzWBuZ.js} +1 -1
- package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-eYqrQ-v4.js → xychartDiagram-S5SC5T6Z-RbQFiLqZ.js} +1 -1
- package/dist-ksadk/index.html +2 -2
- package/dist-lib/{ArtifactsPanel-rz8e8OIc.js → ArtifactsPanel-DByDntRi.js} +1 -1
- package/dist-lib/{AttachmentPreview-CBpwnWxP.js → AttachmentPreview-BKMo_SaP.js} +133 -292
- package/dist-lib/{CodeBlock-DCUUY0PL.js → CodeBlock-CgGEMQi-.js} +2 -2
- package/dist-lib/{ConnectedComposer-DQ-yODJ-.js → ConnectedComposer-B5icGTSY.js} +268 -274
- package/dist-lib/{ConnectedMessageList-DfSvxYLL.js → ConnectedMessageList-C01x96Jz.js} +442 -712
- package/dist-lib/ExecutionTree-v3HexvPo.js +277 -0
- package/dist-lib/InteractionSchemaForm-BNoW5wzt.js +157 -0
- package/dist-lib/{MathMessageMarkdown-CBcDrAw-.js → MathMessageMarkdown--DoGNUu-.js} +2 -2
- package/dist-lib/{MenuChip-So0XESNz.js → MenuChip-CT8v3QtQ.js} +1 -1
- package/dist-lib/MessageMarkdown-C0NKq4TZ.js +255 -0
- package/dist-lib/{NativeTerminalPanel-D2J75bIU.js → NativeTerminalPanel-beSt6mii.js} +1 -1
- package/dist-lib/{WorkspacePanelContainer-Q8Tt_oXe.js → WorkspacePanelContainer-BKdoP1vC.js} +16 -16
- package/dist-lib/{a2ui-BVAet3qy.js → a2ui-C7sqee_K.js} +47 -51
- package/dist-lib/chat-composer.js +4 -4
- package/dist-lib/chat-timeline.js +4 -3
- package/dist-lib/clipboard-MB6Ru6h6.js +20 -0
- package/dist-lib/components/chat/ConnectedComposer.d.ts.map +1 -1
- package/dist-lib/components/chat/ConnectedMessageList.d.ts.map +1 -1
- package/dist-lib/components/teams/CreateGroupDialog.d.ts +16 -0
- package/dist-lib/components/teams/CreateGroupDialog.d.ts.map +1 -0
- package/dist-lib/components/teams/ExecutionTree.d.ts +24 -0
- package/dist-lib/components/teams/ExecutionTree.d.ts.map +1 -0
- package/dist-lib/components/teams/InteractionMessage.d.ts +4 -0
- package/dist-lib/components/teams/InteractionMessage.d.ts.map +1 -0
- package/dist-lib/components/teams/TeamWorkspace.d.ts +100 -0
- package/dist-lib/components/teams/TeamWorkspace.d.ts.map +1 -0
- package/dist-lib/components.js +11 -10
- package/dist-lib/conversation.js +3 -2
- package/dist-lib/core/teams/client.d.ts +91 -0
- package/dist-lib/core/teams/client.d.ts.map +1 -0
- package/dist-lib/core/teams/contracts.d.ts +639 -0
- package/dist-lib/core/teams/contracts.d.ts.map +1 -0
- package/dist-lib/core/teams/observer.d.ts +52 -0
- package/dist-lib/core/teams/observer.d.ts.map +1 -0
- package/dist-lib/core/teams/presentation.d.ts +17 -0
- package/dist-lib/core/teams/presentation.d.ts.map +1 -0
- package/dist-lib/core/teams/reducer.d.ts +13 -0
- package/dist-lib/core/teams/reducer.d.ts.map +1 -0
- package/dist-lib/core/teams/types.d.ts +293 -0
- package/dist-lib/core/teams/types.d.ts.map +1 -0
- package/dist-lib/{feedback-D256P415.js → feedback-CuC5jRi_.js} +88 -84
- package/dist-lib/hooks/useTeamChat.d.ts +17 -0
- package/dist-lib/hooks/useTeamChat.d.ts.map +1 -0
- package/dist-lib/hooks.js +32 -31
- package/dist-lib/{permission--lxoX90f.js → permission-Cu2xehB-.js} +1 -1
- package/dist-lib/{persisted-session-history-Bb3ScKrL.js → persisted-session-history-CJAtRhxZ.js} +371 -636
- package/dist-lib/presentation-yYw7xK60.js +53 -0
- package/dist-lib/public/team-components.d.ts +4 -0
- package/dist-lib/public/team-components.d.ts.map +1 -0
- package/dist-lib/public/team-execution.d.ts +3 -0
- package/dist-lib/public/team-execution.d.ts.map +1 -0
- package/dist-lib/public/teams.d.ts +8 -0
- package/dist-lib/public/teams.d.ts.map +1 -0
- package/dist-lib/reducer-B-uAlhi2.js +372 -0
- package/dist-lib/reducer-BP8YVv-Q.js +270 -0
- package/dist-lib/runtime.js +35 -34
- package/dist-lib/styles.css +1 -1
- package/dist-lib/team-components.js +1366 -0
- package/dist-lib/team-execution.js +2 -0
- package/dist-lib/teams.css +316 -0
- package/dist-lib/teams.js +338 -0
- package/dist-lib/{useSessionLifecycle-DQCw8YmE.js → useSessionLifecycle-DN68JYHx.js} +386 -385
- package/dist-lib/utils-CX-Pz5p6.js +8 -0
- package/package.json +17 -3
- package/schemas/teams-v1-execution-snapshot.schema.json +197 -0
- package/schemas/teams-v1-group-event.schema.json +53 -0
- package/schemas/teams-v1-group-snapshot.schema.json +1016 -0
- package/schemas/teams-v1-interaction-ref.schema.json +64 -0
- package/dist-ksadk/assets/architecture-7GRP2DOG-BW5UtSnx.js +0 -1
- package/dist-ksadk/assets/channel-CF5Up3hQ.js +0 -1
- package/dist-ksadk/assets/chunk-2Q5K7J3B-KkXX47WI.js +0 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-Cz81acRQ.js +0 -1
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-Cz81acRQ.js +0 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-DVWs8a2t.js +0 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-CQqR2hg3.js +0 -1
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-DDRRbGPm.js +0 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-fgWEf7UD.js +0 -1
- package/dist-ksadk/assets/index-DcTML1Up.css +0 -2
- package/dist-ksadk/assets/info-A6RAGUB7-BUecLTdt.js +0 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-BeW-btFv.js +0 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-X0xh4SaT.js +0 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-DzRMSqjd.js +0 -1
- package/dist-ksadk/assets/railroad-74A4TZTK-Cc44icX-.js +0 -1
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-D6S4BdV-.js +0 -1
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-vD3aVE2o.js +0 -1
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-CYbW_b4T.js +0 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-BIcjKFhF.js +0 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-tq3K3Ybl.js +0 -8
- package/dist-ksadk/assets/treeView-Q6P3EWNA-DBXt3GdU.js +0 -1
- package/dist-ksadk/assets/treemap-WGGIJYW6-DrCy4E_l.js +0 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-CefhOliM.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MathMessageMarkdown-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MathMessageMarkdown-CE8kmnzT.js","./CodeBlock-BwoN4XSB.js","./MermaidBlock-E2c6OIM3.js","./katex-CXN0YSjg.js","./MathMessageMarkdown-BorAY7qD.css","./NativeTerminalPanel-DPLNV-9q.js","./NativeTerminalPanel-CHOd7Rch.css","./dist-BGIxM2Vg.js","./dist-BH4O3hsm.js","./dist-1s_bzCxO.js","./dist-Bzxnd_qQ.js","./dist-2cBTzdEm.js","./dist-RXjVy4Wc.js","./dist-Blo8ntwU.js","./dist-YZwAStAT.js","./dist-DI-Jbiqn.js","./dist-Coj7US2k.js","./dist-B29N3_Ie.js","./dist-C965y3AU.js","./dist-Ha8Q7H83.js","./dist-BEABF8oE.js","./dist-CPy8MMAV.js","./dist-C60M2KmF.js","./dist-ASt3FSxr.js","./dist-4ml45Gmg.js","./dist-CU5pKkyk.js","./dist-GOJu-1O3.js","./dockerfile-BLkNEvjs.js","./simple-mode-DRpGK0lJ.js","./factor-D7LVTn2l.js","./nsis-AQ_alPln.js","./pug-Bugr-47h.js","./javascript-9Tg8ixDm.js","./dist-DCeG0nKY.js","./dist-DzXJwPG5.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((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,T());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}var S=!1,ee=-1,C=5,w=-1;function te(){return g?!0:!(e.unstable_now()-w<C)}function ne(){if(g=!1,S){var t=e.unstable_now();w=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(ee),ee=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&te());){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&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?T():S=!1}}}var T;if(typeof y==`function`)T=function(){y(ne)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=ne,T=function(){ie.postMessage(null)}}else T=function(){_(ne,0)};function ae(t,n){ee=_(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`):C=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(ee),ee=-1):h=!0,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,T()))),r},e.unstable_shouldYield=te,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function ee(){}var C={H:null,A:null,T:null,S:null},w=Object.prototype.hasOwnProperty;function te(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function ne(e,t){return te(e.type,t,e.props)}function T(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function re(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ie=/\/+/g;function ae(e,t){return typeof e==`object`&&e&&e.key!=null?re(``+e.key):t.toString(36)}function oe(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(ee,ee):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function se(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,se(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ae(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ie,`$&/`)+`/`),se(o,r,i,``,function(e){return e})):o!=null&&(T(o)&&(o=ne(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ie,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ae(a,u),c+=se(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ae(a,u++),c+=se(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return se(oe(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ce(e,t,n){if(e==null)return e;var r=[],i=0;return se(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function le(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var E=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},D={map:ce,forEach:function(e,t,n){ce(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ce(e,function(){t++}),t},toArray:function(e){return ce(e,function(e){return e})||[]},only:function(e){if(!T(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=D,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return C.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!w.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return te(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)w.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return te(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=T,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:le}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=C.T,n={};C.T=n;try{var r=e(),i=C.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(ee,E)}catch(e){E(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),C.T=t}},e.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},e.use=function(e){return C.H.use(e)},e.useActionState=function(e,t,n){return C.H.useActionState(e,t,n)},e.useCallback=function(e,t){return C.H.useCallback(e,t)},e.useContext=function(e){return C.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return C.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return C.H.useEffect(e,t)},e.useEffectEvent=function(e){return C.H.useEffectEvent(e)},e.useId=function(){return C.H.useId()},e.useImperativeHandle=function(e,t,n){return C.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return C.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return C.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return C.H.useMemo(e,t)},e.useOptimistic=function(e,t){return C.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return C.H.useReducer(e,t,n)},e.useRef=function(e){return C.H.useRef(e)},e.useState=function(e){return C.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return C.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return C.H.useTransition()},e.version=`19.2.4`})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=p();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.4`})),h=o(((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=m()})),g=o((e=>{var t=d(),n=p(),r=h();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 f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),ee=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),te=Symbol.for(`react.suspense_list`),ne=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),re=Symbol.for(`react.activity`),ie=Symbol.for(`react.memo_cache_sentinel`),ae=Symbol.iterator;function oe(e){return typeof e!=`object`||!e?null:(e=ae&&e[ae]||e[`@@iterator`],typeof e==`function`?e:null)}var se=Symbol.for(`react.client.reference`);function ce(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===se?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case w:return`Suspense`;case te:return`SuspenseList`;case re:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case ee:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ne:return t=e.displayName||null,t===null?ce(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}var le=Array.isArray,E=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue={pending:!1,data:null,method:null,action:null},de=[],fe=-1;function pe(e){return{current:e}}function me(e){0>fe||(e.current=de[fe],de[fe]=null,fe--)}function O(e,t){fe++,de[fe]=e.current,e.current=t}var he=pe(null),ge=pe(null),_e=pe(null),ve=pe(null);function ye(e,t){switch(O(_e,t),O(ge,e),O(he,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?sf(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=sf(t),e=cf(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}me(he),O(he,e)}function be(){me(he),me(ge),me(_e)}function xe(e){e.memoizedState!==null&&O(ve,e);var t=he.current,n=cf(t,e.type);t!==n&&(O(ge,e),O(he,n))}function Se(e){ge.current===e&&(me(he),me(ge)),ve.current===e&&(me(ve),gp._currentValue=ue)}var Ce,we;function Te(e){if(Ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ce=t&&t[1]||``,we=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Ce+e+we}var Ee=!1;function De(e,t){if(!e||Ee)return``;Ee=!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(`
|
|
@@ -70,7 +70,7 @@ Error generating stack: `+e.message+`
|
|
|
70
70
|
|
|
71
71
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=yn,s=!rn.jitless,c=s&&bn.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Hi([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Gi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!In(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Bn(e,r,an())))}),t)}var Ki=A(`$ZodUnion`,(e,t)=>{ii.init(e,t),pn(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),pn(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),pn(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),pn(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>un(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Gi(t,r,e,i)):Gi(o,r,e,i)}}),qi=A(`$ZodIntersection`,(e,t)=>{ii.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Yi(e,t,n)):Yi(e,i,a)}});function Ji(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(xn(e)&&xn(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Ji(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ji(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Yi(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),In(e))return e;let o=Ji(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Xi=A(`$ZodRecord`,(e,t)=>{ii.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!xn(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Bn(e,r,an())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Rn(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Rn(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Fr.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Bn(e,r,an())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Rn(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Rn(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Zi=A(`$ZodEnum`,(e,t)=>{ii.init(e,t);let n=on(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Cn.has(typeof e)).map(e=>typeof e==`string`?wn(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Qi=A(`$ZodLiteral`,(e,t)=>{if(ii.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?wn(e):e?wn(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),$i=A(`$ZodTransform`,(e,t)=>{ii.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new nn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new tn;return n.value=i,n.fallback=!0,n}});function ea(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var ta=A(`$ZodOptional`,(e,t)=>{ii.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,pn(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),pn(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${un(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>ea(e,r)):ea(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),na=A(`$ZodExactOptional`,(e,t)=>{ta.init(e,t),pn(e._zod,`values`,()=>t.innerType._zod.values),pn(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ra=A(`$ZodNullable`,(e,t)=>{ii.init(e,t),pn(e._zod,`optin`,()=>t.innerType._zod.optin),pn(e._zod,`optout`,()=>t.innerType._zod.optout),pn(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${un(e.source)}|null)$`):void 0}),pn(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ia=A(`$ZodDefault`,(e,t)=>{ii.init(e,t),e._zod.optin=`optional`,pn(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>aa(e,t)):aa(r,t)}});function aa(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var oa=A(`$ZodPrefault`,(e,t)=>{ii.init(e,t),e._zod.optin=`optional`,pn(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),sa=A(`$ZodNonOptional`,(e,t)=>{ii.init(e,t),pn(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>ca(t,e)):ca(i,e)}});function ca(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var la=A(`$ZodCatch`,(e,t)=>{ii.init(e,t),e._zod.optin=`optional`,pn(e._zod,`optout`,()=>t.innerType._zod.optout),pn(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Bn(e,n,an()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Bn(e,n,an()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),ua=A(`$ZodPipe`,(e,t)=>{ii.init(e,t),pn(e._zod,`values`,()=>t.in._zod.values),pn(e._zod,`optin`,()=>t.in._zod.optin),pn(e._zod,`optout`,()=>t.out._zod.optout),pn(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>da(e,t.in,n)):da(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>da(e,t.out,n)):da(r,t.out,n)}});function da(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var fa=A(`$ZodReadonly`,(e,t)=>{ii.init(e,t),pn(e._zod,`propValues`,()=>t.innerType._zod.propValues),pn(e._zod,`values`,()=>t.innerType._zod.values),pn(e._zod,`optin`,()=>t.innerType?._zod?.optin),pn(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(pa):pa(r)}});function pa(e){return e.value=Object.freeze(e.value),e}var ma=A(`$ZodCustom`,(e,t)=>{zr.init(e,t),ii.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ha(t,n,r,e));ha(i,n,r,e)}});function ha(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Hn(e))}}var ga,_a=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function va(){return new _a}(ga=globalThis).__zod_globalRegistry??(ga.__zod_globalRegistry=va());var ya=globalThis.__zod_globalRegistry;function ba(e,t){return new e({type:`string`,...En(t)})}function xa(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...En(t)})}function Sa(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...En(t)})}function Ca(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...En(t)})}function wa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...En(t)})}function Ta(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...En(t)})}function Ea(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...En(t)})}function Da(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...En(t)})}function Oa(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...En(t)})}function ka(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...En(t)})}function Aa(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...En(t)})}function ja(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...En(t)})}function Ma(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...En(t)})}function Na(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...En(t)})}function Pa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...En(t)})}function Fa(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...En(t)})}function Ia(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...En(t)})}function La(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...En(t)})}function Ra(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...En(t)})}function za(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...En(t)})}function Ba(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...En(t)})}function Va(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...En(t)})}function Ha(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...En(t)})}function Ua(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...En(t)})}function Wa(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...En(t)})}function Ga(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...En(t)})}function Ka(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...En(t)})}function qa(e,t){return new e({type:`number`,checks:[],...En(t)})}function Ja(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...En(t)})}function Ya(e,t){return new e({type:`boolean`,...En(t)})}function Xa(e){return new e({type:`unknown`})}function Za(e,t){return new e({type:`never`,...En(t)})}function Qa(e,t){return new Vr({check:`less_than`,...En(t),value:e,inclusive:!1})}function $a(e,t){return new Vr({check:`less_than`,...En(t),value:e,inclusive:!0})}function eo(e,t){return new Hr({check:`greater_than`,...En(t),value:e,inclusive:!1})}function to(e,t){return new Hr({check:`greater_than`,...En(t),value:e,inclusive:!0})}function no(e,t){return new Ur({check:`multiple_of`,...En(t),value:e})}function ro(e,t){return new Gr({check:`max_length`,...En(t),maximum:e})}function io(e,t){return new Kr({check:`min_length`,...En(t),minimum:e})}function ao(e,t){return new qr({check:`length_equals`,...En(t),length:e})}function oo(e,t){return new Yr({check:`string_format`,format:`regex`,...En(t),pattern:e})}function so(e){return new Xr({check:`string_format`,format:`lowercase`,...En(e)})}function co(e){return new Zr({check:`string_format`,format:`uppercase`,...En(e)})}function lo(e,t){return new Qr({check:`string_format`,format:`includes`,...En(t),includes:e})}function uo(e,t){return new $r({check:`string_format`,format:`starts_with`,...En(t),prefix:e})}function fo(e,t){return new ei({check:`string_format`,format:`ends_with`,...En(t),suffix:e})}function po(e){return new ti({check:`overwrite`,tx:e})}function mo(e){return po(t=>t.normalize(e))}function ho(){return po(e=>e.trim())}function go(){return po(e=>e.toLowerCase())}function _o(){return po(e=>e.toUpperCase())}function vo(){return po(e=>_n(e))}function yo(e,t,n){return new e({type:`array`,element:t,...En(n)})}function bo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...En(n)})}function xo(e,t){let n=So(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Hn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Hn(r))}},e(t.value,t)),t);return n}function So(e,t){let n=new zr({check:`custom`,...En(t)});return n._zod.check=e,n}function Co(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??ya,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function wo(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,wo(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Do(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function To(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
72
72
|
|
|
73
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Eo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:ko(t,`input`,e.processors),output:ko(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Do(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Do(r.element,n);if(r.type===`set`)return Do(r.valueType,n);if(r.type===`lazy`)return Do(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Do(r.innerType,n);if(r.type===`intersection`)return Do(r.left,n)||Do(r.right,n);if(r.type===`record`||r.type===`map`)return Do(r.keyType,n)||Do(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Do(r.in,n)||Do(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Do(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Do(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Do(e,n))return!0;return!!(r.rest&&Do(r.rest,n))}return!1}var Oo=(e,t={})=>n=>{let r=Co({...n,processors:t});return wo(e,r),To(r,e),Eo(r,e)},ko=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Co({...i??{},target:a,io:t,processors:n});return wo(e,o),To(o,e),Eo(o,e)},Ao={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},jo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Ao[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Mo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},No=(e,t,n,r)=>{n.type=`boolean`},Po=(e,t,n,r)=>{n.not={}},Fo=(e,t,n,r)=>{let i=e._zod.def,a=on(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Io=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Lo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ro=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},zo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=wo(a.element,t,{...r,path:[...r.path,`items`]})},Bo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=wo(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=wo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Vo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>wo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ho=(e,t,n,r)=>{let i=e._zod.def,a=wo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=wo(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Uo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=wo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=wo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=wo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Wo=(e,t,n,r)=>{let i=e._zod.def,a=wo(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Go=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ko=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},qo=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Jo=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Yo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;wo(o,t,r);let s=t.seen.get(e);s.ref=o},Xo=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Zo=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Qo=A(`ZodISODateTime`,(e,t)=>{vi.init(e,t),Ts.init(e,t)});function $o(e){return Ua(Qo,e)}var es=A(`ZodISODate`,(e,t)=>{yi.init(e,t),Ts.init(e,t)});function ts(e){return Wa(es,e)}var ns=A(`ZodISOTime`,(e,t)=>{bi.init(e,t),Ts.init(e,t)});function rs(e){return Ga(ns,e)}var is=A(`ZodISODuration`,(e,t)=>{xi.init(e,t),Ts.init(e,t)});function as(e){return Ka(is,e)}var os=A(`ZodError`,(e,t)=>{Wn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>qn(e,t)},flatten:{value:t=>Kn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,sn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,sn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),ss=Jn(os),cs=Yn(os),ls=Xn(os),us=Qn(os),ds=er(os),fs=tr(os),ps=nr(os),ms=rr(os),hs=ir(os),gs=ar(os),_s=or(os),vs=sr(os),ys=new WeakMap;function bs(e,t,n){let r=Object.getPrototypeOf(e),i=ys.get(r);if(i||(i=new Set,ys.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var xs=A(`ZodType`,(e,t)=>(ii.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ko(e,`input`),output:ko(e,`output`)}}),e.toJSONSchema=Oo(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ss(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ls(e,t,n),e.parseAsync=async(t,n)=>cs(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>us(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ds(e,t,n),e.decode=(t,n)=>fs(e,t,n),e.encodeAsync=async(t,n)=>ps(e,t,n),e.decodeAsync=async(t,n)=>ms(e,t,n),e.safeEncode=(t,n)=>hs(e,t,n),e.safeDecode=(t,n)=>gs(e,t,n),e.safeEncodeAsync=async(t,n)=>_s(e,t,n),e.safeDecodeAsync=async(t,n)=>vs(e,t,n),bs(e,`ZodType`,{check(...e){let t=this.def;return this.clone(hn(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Tn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ic(e,t))},superRefine(e,t){return this.check(Lc(e,t))},overwrite(e){return this.check(po(e))},optional(){return vc(this)},exactOptional(){return bc(this)},nullable(){return Sc(this)},nullish(){return vc(Sc(this))},nonoptional(e){return Oc(this,e)},array(){return nc(this)},or(e){return oc([this,e])},and(e){return cc(this,e)},transform(e){return Mc(this,gc(e))},default(e){return wc(this,e)},prefault(e){return Ec(this,e)},catch(e){return Ac(this,e)},pipe(e){return Mc(this,e)},readonly(){return Pc(this)},describe(e){let t=this.clone();return ya.add(t,{description:e}),t},meta(...e){if(e.length===0)return ya.get(this);let t=this.clone();return ya.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return ya.get(e)?.description},configurable:!0}),e)),Ss=A(`_ZodString`,(e,t)=>{ai.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,bs(e,`_ZodString`,{regex(...e){return this.check(oo(...e))},includes(...e){return this.check(lo(...e))},startsWith(...e){return this.check(uo(...e))},endsWith(...e){return this.check(fo(...e))},min(...e){return this.check(io(...e))},max(...e){return this.check(ro(...e))},length(...e){return this.check(ao(...e))},nonempty(...e){return this.check(io(1,...e))},lowercase(e){return this.check(so(e))},uppercase(e){return this.check(co(e))},trim(){return this.check(ho())},normalize(...e){return this.check(mo(...e))},toLowerCase(){return this.check(go())},toUpperCase(){return this.check(_o())},slugify(){return this.check(vo())}})}),Cs=A(`ZodString`,(e,t)=>{ai.init(e,t),Ss.init(e,t),e.email=t=>e.check(xa(Es,t)),e.url=t=>e.check(Da(ks,t)),e.jwt=t=>e.check(Ha(Ws,t)),e.emoji=t=>e.check(Oa(As,t)),e.guid=t=>e.check(Sa(Ds,t)),e.uuid=t=>e.check(Ca(Os,t)),e.uuidv4=t=>e.check(wa(Os,t)),e.uuidv6=t=>e.check(Ta(Os,t)),e.uuidv7=t=>e.check(Ea(Os,t)),e.nanoid=t=>e.check(ka(js,t)),e.guid=t=>e.check(Sa(Ds,t)),e.cuid=t=>e.check(Aa(Ms,t)),e.cuid2=t=>e.check(ja(Ns,t)),e.ulid=t=>e.check(Ma(Ps,t)),e.base64=t=>e.check(za(Vs,t)),e.base64url=t=>e.check(Ba(Hs,t)),e.xid=t=>e.check(Na(Fs,t)),e.ksuid=t=>e.check(Pa(Is,t)),e.ipv4=t=>e.check(Fa(Ls,t)),e.ipv6=t=>e.check(Ia(Rs,t)),e.cidrv4=t=>e.check(La(zs,t)),e.cidrv6=t=>e.check(Ra(Bs,t)),e.e164=t=>e.check(Va(Us,t)),e.datetime=t=>e.check($o(t)),e.date=t=>e.check(ts(t)),e.time=t=>e.check(rs(t)),e.duration=t=>e.check(as(t))});function ws(e){return ba(Cs,e)}var Ts=A(`ZodStringFormat`,(e,t)=>{oi.init(e,t),Ss.init(e,t)}),Es=A(`ZodEmail`,(e,t)=>{li.init(e,t),Ts.init(e,t)}),Ds=A(`ZodGUID`,(e,t)=>{si.init(e,t),Ts.init(e,t)}),Os=A(`ZodUUID`,(e,t)=>{ci.init(e,t),Ts.init(e,t)}),ks=A(`ZodURL`,(e,t)=>{ui.init(e,t),Ts.init(e,t)}),As=A(`ZodEmoji`,(e,t)=>{di.init(e,t),Ts.init(e,t)}),js=A(`ZodNanoID`,(e,t)=>{fi.init(e,t),Ts.init(e,t)}),Ms=A(`ZodCUID`,(e,t)=>{pi.init(e,t),Ts.init(e,t)}),Ns=A(`ZodCUID2`,(e,t)=>{mi.init(e,t),Ts.init(e,t)}),Ps=A(`ZodULID`,(e,t)=>{hi.init(e,t),Ts.init(e,t)}),Fs=A(`ZodXID`,(e,t)=>{gi.init(e,t),Ts.init(e,t)}),Is=A(`ZodKSUID`,(e,t)=>{_i.init(e,t),Ts.init(e,t)}),Ls=A(`ZodIPv4`,(e,t)=>{Si.init(e,t),Ts.init(e,t)}),Rs=A(`ZodIPv6`,(e,t)=>{Ci.init(e,t),Ts.init(e,t)}),zs=A(`ZodCIDRv4`,(e,t)=>{wi.init(e,t),Ts.init(e,t)}),Bs=A(`ZodCIDRv6`,(e,t)=>{Ti.init(e,t),Ts.init(e,t)}),Vs=A(`ZodBase64`,(e,t)=>{Di.init(e,t),Ts.init(e,t)}),Hs=A(`ZodBase64URL`,(e,t)=>{ki.init(e,t),Ts.init(e,t)}),Us=A(`ZodE164`,(e,t)=>{Ai.init(e,t),Ts.init(e,t)}),Ws=A(`ZodJWT`,(e,t)=>{Mi.init(e,t),Ts.init(e,t)}),Gs=A(`ZodNumber`,(e,t)=>{Ni.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),bs(e,`ZodNumber`,{gt(e,t){return this.check(eo(e,t))},gte(e,t){return this.check(to(e,t))},min(e,t){return this.check(to(e,t))},lt(e,t){return this.check(Qa(e,t))},lte(e,t){return this.check($a(e,t))},max(e,t){return this.check($a(e,t))},int(e){return this.check(Js(e))},safe(e){return this.check(Js(e))},positive(e){return this.check(eo(0,e))},nonnegative(e){return this.check(to(0,e))},negative(e){return this.check(Qa(0,e))},nonpositive(e){return this.check($a(0,e))},multipleOf(e,t){return this.check(no(e,t))},step(e,t){return this.check(no(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Ks(e){return qa(Gs,e)}var qs=A(`ZodNumberFormat`,(e,t)=>{Pi.init(e,t),Gs.init(e,t)});function Js(e){return Ja(qs,e)}var Ys=A(`ZodBoolean`,(e,t)=>{Fi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r)});function Xs(e){return Ya(Ys,e)}var Zs=A(`ZodUnknown`,(e,t)=>{Ii.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Qs(){return Xa(Zs)}var $s=A(`ZodNever`,(e,t)=>{Li.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r)});function ec(e){return Za($s,e)}var tc=A(`ZodArray`,(e,t)=>{zi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zo(e,t,n,r),e.element=t.element,bs(e,`ZodArray`,{min(e,t){return this.check(io(e,t))},nonempty(e){return this.check(io(1,e))},max(e,t){return this.check(ro(e,t))},length(e,t){return this.check(ao(e,t))},unwrap(){return this.element}})});function nc(e,t){return yo(tc,e,t)}var rc=A(`ZodObject`,(e,t)=>{Wi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r),pn(e,`shape`,()=>t.shape),bs(e,`ZodObject`,{keyof(){return fc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Qs()})},loose(){return this.clone({...this._zod.def,catchall:Qs()})},strict(){return this.clone({...this._zod.def,catchall:ec()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return jn(this,e)},safeExtend(e){return Mn(this,e)},merge(e){return Nn(this,e)},pick(e){return kn(this,e)},omit(e){return An(this,e)},partial(...e){return Pn(_c,this,e[0])},required(...e){return Fn(Dc,this,e[0])}})});function ic(e,t){return new rc({type:`object`,shape:e??{},...En(t)})}var ac=A(`ZodUnion`,(e,t)=>{Ki.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vo(e,t,n,r),e.options=t.options});function oc(e,t){return new ac({type:`union`,options:e,...En(t)})}var sc=A(`ZodIntersection`,(e,t)=>{qi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r)});function cc(e,t){return new sc({type:`intersection`,left:e,right:t})}var lc=A(`ZodRecord`,(e,t)=>{Xi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function uc(e,t,n){return!t||!t._zod?new lc({type:`record`,keyType:ws(),valueType:e,...En(t)}):new lc({type:`record`,keyType:e,valueType:t,...En(n)})}var dc=A(`ZodEnum`,(e,t)=>{Zi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new dc({...t,checks:[],...En(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new dc({...t,checks:[],...En(r),entries:i})}});function fc(e,t){return new dc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...En(t)})}var pc=A(`ZodLiteral`,(e,t)=>{Qi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function mc(e,t){return new pc({type:`literal`,values:Array.isArray(e)?e:[e],...En(t)})}var hc=A(`ZodTransform`,(e,t)=>{$i.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new nn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Hn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Hn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function gc(e){return new hc({type:`transform`,transform:e})}var _c=A(`ZodOptional`,(e,t)=>{ta.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vc(e){return new _c({type:`optional`,innerType:e})}var yc=A(`ZodExactOptional`,(e,t)=>{na.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bc(e){return new yc({type:`optional`,innerType:e})}var xc=A(`ZodNullable`,(e,t)=>{ra.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Sc(e){return new xc({type:`nullable`,innerType:e})}var Cc=A(`ZodDefault`,(e,t)=>{ia.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function wc(e,t){return new Cc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Sn(t)}})}var Tc=A(`ZodPrefault`,(e,t)=>{oa.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ec(e,t){return new Tc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Sn(t)}})}var Dc=A(`ZodNonOptional`,(e,t)=>{sa.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Oc(e,t){return new Dc({type:`nonoptional`,innerType:e,...En(t)})}var kc=A(`ZodCatch`,(e,t)=>{la.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ac(e,t){return new kc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var jc=A(`ZodPipe`,(e,t)=>{ua.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),e.in=t.in,e.out=t.out});function Mc(e,t){return new jc({type:`pipe`,in:e,out:t})}var Nc=A(`ZodReadonly`,(e,t)=>{fa.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pc(e){return new Nc({type:`readonly`,innerType:e})}var Fc=A(`ZodCustom`,(e,t)=>{ma.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r)});function Ic(e,t={}){return bo(Fc,e,t)}function Lc(e,t){return xo(e,t)}var Rc=class extends Error{constructor(e){super(e),this.name=`ContractMismatchError`}},zc=new Set([`schema_version`,`command_id`,`status`,`message_id`,`run_id`,`accepted_seq`,`error`]),Bc=ic({code:ws().min(1),message:ws(),retryable:Xs(),details:uc(ws(),Qs()).optional()});function Vc(e){let t=ic({schema_version:mc(1),command_id:ws().min(1),status:fc([`accepted`,`duplicate`,`rejected`,`unsupported`,`queue_full`,`persistence_uncertain`]),message_id:ws().min(1).nullable().optional(),run_id:ws().min(1).nullable().optional(),accepted_seq:Ks().int().min(0).nullable().optional(),error:Bc.nullable().optional()}).passthrough().safeParse(e);if(!t.success)throw new Rc(`AgentControlReceipt/v1 mismatch: ${t.error.message}`);let n=t.data;if((n.status===`rejected`||n.status===`unsupported`||n.status===`queue_full`||n.status===`persistence_uncertain`)&&!n.error)throw new Rc(`AgentControlReceipt/v1 mismatch: status ${n.status} requires error`);let r={};for(let[e,t]of Object.entries(n))zc.has(e)||(r[e]=t);let i=n.error?{...n.error,extensions:{}}:null;return{schema_version:1,command_id:n.command_id,status:n.status,message_id:n.message_id??null,run_id:n.run_id??null,accepted_seq:n.accepted_seq??null,error:i,extensions:r}}var Hc=new Set([`schema_version`,`event_id`,`session_id`,`seq`,`timestamp`,`family`,`family_version`,`event_type`,`payload`,`run_id`,`causation_id`,`correlation_id`,`actor_ref`]),Uc=new Map([[`control`,1],[`runtime`,2]]),Wc=ic({schema_version:mc(1),event_id:ws().min(1),session_id:ws().min(1),seq:Ks().int().min(0),timestamp:ws().min(1),family:ws().min(1),family_version:Ks().int().min(1),event_type:ws().min(1),payload:uc(ws(),Qs()),run_id:ws().min(1).nullable().optional(),causation_id:ws().min(1).nullable().optional(),correlation_id:ws().min(1).nullable().optional(),actor_ref:ws().min(1).nullable().optional()}).passthrough();function Gc(e){let t=Wc.safeParse(e);if(!t.success)return{ok:!1,error:new Rc(`SessionEventEnvelope/v1 mismatch: ${t.error.message}`)};let n=t.data,r=Uc.get(n.family);if(r!==void 0&&n.family_version!==r)return{ok:!1,error:new Rc(`SessionEventEnvelope/v1 mismatch: family ${n.family} requires family_version ${r}`)};let i={};for(let[e,t]of Object.entries(n))Hc.has(e)||(i[e]=t);return{ok:!0,value:{schema_version:1,event_id:n.event_id,session_id:n.session_id,seq:n.seq,timestamp:n.timestamp,family:n.family,family_version:n.family_version,event_type:n.event_type,payload:n.payload,run_id:n.run_id??null,causation_id:n.causation_id??null,correlation_id:n.correlation_id??null,actor_ref:n.actor_ref??null,extensions:i}}}var Kc=class{client;constructor(e={}){this.client=new $t(e)}async compactSession(e,t){return this.client.postJsonAction(`CompactSession`,{AgentId:e,SessionId:t})}async listSessions(e,t){let n=await this.client.postJsonAction(`ListSessions`,{AgentId:e,Page:t?.page,PageSize:t?.pageSize},t),r=n.Sessions??[];return{Sessions:r,Total:Number.isFinite(Number(n.Total))?Number(n.Total):r.length,Page:Number.isFinite(Number(n.Page))?Number(n.Page):t?.page??1,PageSize:Number.isFinite(Number(n.PageSize))?Number(n.PageSize):t?.pageSize??r.length}}async createSession(e,t){let n=await this.client.postJsonAction(`CreateSession`,{AgentId:e},t);return{SessionId:String(n.Session?.SessionId||``)}}async deleteSession(e,t){return this.client.postJsonAction(`DeleteSession`,{SessionId:e},t)}async getSession(e,t){return(await this.client.postJsonAction(`GetSession`,{SessionId:e},t)).Session}async listSessionEvents(e,t){let n=await this.client.postJsonAction(`ListSessionEvents`,{SessionId:e,Offset:t?.offset,Limit:t?.limit},t),r=n.Events??[];return{Events:r,Total:Number.isFinite(Number(n.Total))?Number(n.Total):r.length,Offset:Number.isFinite(Number(n.Offset))?Number(n.Offset):t?.offset??0,Limit:Number.isFinite(Number(n.Limit))?Number(n.Limit):t?.limit??r.length}}async listSessionMessages(e,t){let n=await this.client.postJsonAction(`ListSessionMessages`,{AgentId:t?.agentId,SessionId:e,AfterSeqId:t?.afterSeqId,BeforeSeqId:t?.beforeSeqId,Limit:t?.limit,IncludeReasoning:t?.includeReasoning,IncludeToolEvents:t?.includeToolEvents,IncludeAttachments:t?.includeAttachments},t);return{Messages:n.Messages??[],LatestSeqId:Number.isFinite(Number(n.LatestSeqId))?Number(n.LatestSeqId):0,HasMore:!!n.HasMore,NextCursor:n.NextCursor===null||n.NextCursor===void 0?null:Number.isFinite(Number(n.NextCursor))?Number(n.NextCursor):null}}async listSessionCheckpoints(e,t){return this.client.postJsonAction(`ListSessionCheckpoints`,{AgentId:e.agentId,SessionId:e.sessionId,...e.runId?{RunId:e.runId}:{}},t)}async previewCheckpointResume(e,t){return this.client.postJsonAction(`GetCheckpointResumePreview`,{AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId},t)}async listToolReceipts(e,t){return this.client.postJsonAction(`ListToolReceipts`,{AgentId:e.agentId,SessionId:e.sessionId,...e.runId?{RunId:e.runId}:{},...e.checkpointId?{CheckpointId:e.checkpointId}:{}},t)}async runAgent(e,t){return this.client.streamAction(`RunAgent`,e,t)}async resumeRun(e,t){return this.client.streamAction(`ResumeRun`,{AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId,Stream:!0,...e.resumeAttemptId?{ResumeAttemptId:e.resumeAttemptId}:{},...e.invocationId?{InvocationId:e.invocationId}:{}},t)}async subscribeRunEvents(e,t){return this.client.streamGetAction(`SubscribeRunEvents`,{SessionId:e.sessionId,InvocationId:e.invocationId,AfterSeqId:String(e.afterSeqId)},t)}async submitControl(e,t){return Vc(await this.client.postJsonAction(`SubmitAgentControl`,{CommandType:e.command_type,IdempotencyKey:e.idempotency_key,Payload:e.payload},t))}async submitInteraction(e,t){return Vc(await this.client.postJsonAction(`SubmitInteraction`,{...e},t))}async getAgentStatus(e){return this.client.postJsonAction(`GetAgentStatus`,{},e)}async subscribeSessionEvents(e,t,n){return this.client.streamGetAction(`SubscribeSessionEvents`,{SessionId:e,after_seq:String(t)},n)}async cancelRun(e,t,n,r){return this.client.postJsonAction(`CancelRun`,{AgentId:e,SessionId:t,InvocationId:n},r)}async getResponseFeedback(e,t){return this.client.postJsonAction(`GetResponseFeedback`,e,t)}async upsertResponseFeedback(e,t){return this.client.postJsonAction(`UpsertResponseFeedback`,e,t)}async deleteResponseFeedback(e,t){await this.client.postJsonAction(`DeleteResponseFeedback`,e,t)}async listWorkspaceFiles(e,t,n,r){return this.client.postJsonAction(`ListWorkspaceFiles`,{AgentId:e,Path:t,Recursive:n},r)}async addWorkspaceFile(e,t){return this.client.postFormAction(`AddWorkspaceFile`,e,t)}async deleteWorkspaceFile(e,t,n){await this.client.postJsonAction(`DeleteWorkspaceFile`,{AgentId:e,Path:t},n)}async getWorkspaceFileContent(e,t,n){return this.client.getResource(`GetWorkspaceFileContent`,{AgentId:e,Path:t},n)}async listAgentModels(e,t){return this.client.postJsonAction(`ListAgentModels`,{AgentId:e},t)}async getAgentUiBootstrap(e,t){return this.client.postJsonAction(`GetAgentUiBootstrap`,e?{AgentId:e}:{},t)}async uploadFile(e,t){return this.client.postFormAction(`UploadFile`,e,t)}};function qc(e){return e instanceof Jt&&(e.code===401||e.code===403)?`auth-required`:`error`}function Jc(e){if(!Array.isArray(e))return[`responses`,`chat_completions`];let t=e.filter(e=>e===`responses`||e===`chat_completions`);return t.length>0?t:[`responses`,`chat_completions`]}var Yc=new Kc;async function Xc(e,t=Yc){try{let n=await t.listAgentModels(e),r=n?.Models;Array.isArray(r)&&We.getState().upsertModels(r);let i=n;i?.Current&&!We.getState().selectedModel&&We.getState().setSelectedModel(String(i.Current)),i?.Source&&We.getState().setModelSource(String(i.Source))}catch(e){console.error(`Failed to fetch models:`,e)}finally{We.getState().setModelCatalogLoaded(!0)}}function Zc(e,t,n=Yc,r){(0,v.useEffect)(()=>{let i=new AbortController;return(async()=>{He.getState().setStatus(`loading`);try{let a=r??await n.getAgentUiBootstrap(t,{signal:i.signal});if(i.signal.aborted)return;let o=a,s=o?.Agent,c=String(s?.AgentId||`default-agent`);if(He.getState().setAgentId(c),s?.Name){let e=String(s.Name);He.getState().setAgentName(e),document.title=e}let l=String(s?.Framework||``).trim().toLowerCase();He.getState().setAgentFramework(l);let u=ze(a);He.getState().setCapabilities(u),He.getState().setApiFormats(Jc(u.HostedChat.ApiFormats)),He.getState().setAccessMode(String(o?.AccessMode||`Owner`));let d=u.WorkspaceFiles&&o?.WorkspaceFiles?o.WorkspaceFiles:null;He.getState().setWorkspaceFiles(d),d||ve.getState().setWorkspacePanelOpen(!1),Be(u)&&e.fetchSessions(c,Nt(c));let f=o?.Model;f?.id&&(We.getState().setSelectedModel(f.id),We.getState().upsertModels([f]),We.getState().setModelSource(f.source||``)),Xc(c,n),He.getState().setStatus(`ready`)}catch(e){if(i.signal.aborted)return;console.error(`Failed to fetch bootstrap:`,e);let t=qc(e);He.getState().setStatus(t,t===`auth-required`?`当前访问链接未授权或已过期。`:`无法加载 Agent 配置,请稍后重试。`)}})(),()=>i.abort()},[n,t,r])}var Qc=te()(e=>({messages:[],setMessages:t=>e({messages:t}),patchMessages:t=>e(e=>({messages:t(e.messages)}))}));function $c(){return{toolNames:new Map,toolArguments:new Map,callIds:new Map,currentResponseId:``,sawTextDelta:!1,sawReasoningDelta:!1}}function el(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&typeof e.text==`string`?e.text:``).join(``):e&&typeof e==`object`&&typeof e.text==`string`?e.text:``}function tl(e){return e==null?``:typeof e==`string`?e:typeof e==`object`?JSON.stringify(e,null,2):String(e)}function nl(...e){for(let t of e){let e=el(t);if(e)return e}return``}function rl(e,t){return String(e?.id||e?.item_id||e?.call_id||t?.item_id||t?.call_id||t?.output_index||``)}function il(e,t,n,r,i){t&&(e.toolNames.set(t,r),e.toolArguments.set(t,i));let a=String(n?.call_id||``);a&&(e.callIds.set(a,t||r),e.toolNames.set(a,r),e.toolArguments.set(a,i))}function al(e,t,n,r=`tool`){let i=String(n?.call_id||``);return String(n?.name||n?.tool_name||(t?e.toolNames.get(t):``)||(i?e.toolNames.get(i):``)||r)}function ol(e){if(!e||typeof e!=`object`)return``;let t=el(e.content);return nl(e.output_text,e.text,e.summary_text,e.summary,e.delta,t)}function sl(e){let t=e?.response&&typeof e.response==`object`?e.response:e,n=nl(t?.output_text,t?.text);if(n)return n;let r=Array.isArray(t?.output)?t.output:[];for(let e of r){let t=ol(e);if(t)return t}return``}function cl(e){let t=e?.response&&typeof e.response==`object`?e.response:e;return Array.isArray(t?.output)?t.output:[]}function ll(e){let t=e;if(typeof t==`string`)try{t=JSON.parse(t)}catch{return{}}return Array.isArray(t)&&(t=t[0]||{}),!t||typeof t!=`object`?{}:t.value&&typeof t.value==`object`&&!Array.isArray(t.value)?{...t.value,approval_request_id:t.value.approval_request_id||t.value.id||t.id}:t}function ul({data:e,state:t,status:n}){let r=e?.item||e?.output_item||e||{},i=String(r.type||``).trim(),a=rl(r,e);if(i===`function_call`){let e=al(t,a,r),i=tl(r.arguments??r.args??r.input);return il(t,a,r,e,i),[{type:`tool_upsert`,name:e,args:i,status:n}]}if(i===`function_call_output`)return[{type:`tool_result`,name:al(t,a,r),output:tl(r.output??r.result??r.content)}];if(i===`mcp_approval_request`){let n=String(r.name||`approval`),i=tl(r.arguments??r.args),a=String(r.id||r.approval_request_id||``),o=String(r.run_id||r.runId||e?.run_id||e?.runId||``);return[{type:`tool_upsert`,name:n,args:i,status:`paused`,approvalRequestId:a,previousResponseId:String(e?.response_id||t.currentResponseId||``),serverLabel:String(r.server_label||``)},{type:`approval_request`,approvalRequestId:a,previousResponseId:String(e?.response_id||t.currentResponseId||``),...o?{runId:o}:{},name:n,args:i}]}if(i===`reasoning`||i===`reasoning_summary`||i===`reasoning_summary_text`){let e=ol(r);return e?[{type:`reasoning_delta`,text:e}]:[]}if(i===`message`){let e=ol(r);return e?[{type:n===`completed`?`text_final`:`text_delta`,text:e}]:[]}return[]}function dl({eventName:e,data:t,state:n}){let r=String(t?.type||e||``).trim(),i=String(t?.id||t?.response?.id||t?.response_id||``);if(i.startsWith(`resp_`)&&(n.currentResponseId=i),r===`response.tool_call`)return[{type:`tool_upsert`,name:String(t?.name||t?.tool_name||`tool`),args:tl(t?.args??t?.arguments),status:`running`}];if(r===`response.tool_result`||r===`response.ksadk.tool_result`)return[{type:`tool_result`,name:String(t?.name||t?.tool_name||`tool`),output:tl(t?.output??t?.result)}];if(r===`response.output_item.added`)return ul({data:t,state:n,status:`running`});if(r===`response.output_item.done`)return ul({data:t,state:n,status:`completed`});if(r===`response.function_call_arguments.delta`){let e=String(t?.item_id||t?.call_id||``),r=al(n,e,t),i=`${n.toolArguments.get(e)||``}${String(t?.delta||``)}`;return n.toolArguments.set(e,i),[{type:`tool_upsert`,name:r,args:i,status:`running`}]}if(r===`response.function_call_arguments.done`){let e=String(t?.item_id||t?.call_id||``),r=al(n,e,t),i=tl(t?.arguments??n.toolArguments.get(e));return n.toolArguments.set(e,i),[{type:`tool_upsert`,name:r,args:i,status:`running`}]}if(r===`response.reasoning.delta`||r===`response.reasoning_text.delta`||r===`response.reasoning_summary.delta`||r===`response.reasoning_summary_text.delta`){let e=nl(t?.delta,t?.text);return e&&(n.sawReasoningDelta=!0),e?[{type:`reasoning_delta`,text:e}]:[]}if(r===`response.output_text.delta`){let e=nl(t?.delta,t?.text);return e&&(n.sawTextDelta=!0),e?[{type:`text_delta`,text:e}]:[]}if(r===`response.output_text.done`){let e=nl(t?.text,t?.delta);return e?[{type:`text_final`,text:e}]:[]}if(r===`response.content_part.delta`){let e=String(t?.part?.type||t?.delta?.type||t?.content_type||``),r=nl(t?.delta?.text,t?.delta,t?.text);return r?e.includes(`reasoning`)?(n.sawReasoningDelta=!0,[{type:`reasoning_delta`,text:r}]):(n.sawTextDelta=!0,[{type:`text_delta`,text:r}]):[]}if(r===`response.completed`){let e=sl(t),r=cl(t).flatMap(e=>ul({data:{...t,item:e},state:n,status:`completed`})).filter(e=>!(n.sawTextDelta&&e.type===`text_final`)&&!(n.sawReasoningDelta&&e.type===`reasoning_delta`)),i=r.some(e=>e.type===`text_final`);return[...r,...e&&!n.sawTextDelta&&!i?[{type:`text_final`,text:e}]:[],{type:`terminal`,status:`completed`}]}if(r===`response.failed`)return[{type:`failed`,message:t?.error?.message||`Agent 运行失败`},{type:`terminal`,status:`failed`}];if(r===`response.incomplete`)return[{type:`incomplete`},{type:`terminal`,status:`incomplete`}];if(r===`response.cancelled`)return[{type:`terminal`,status:`cancelled`}];if(r===`response.approval_request`||r===`response.ksadk.approval_request`){let e=ll(t?.interrupt_info),r=String(e.approval_request_id||e.id||``),i=String(t?.response_id||n.currentResponseId||``),a=String(t?.run_id||t?.runId||``),o=e.approval_requests&&typeof e.approval_requests==`object`?e.approval_requests:e,s=Array.isArray(o.action_requests)?o.action_requests:[];if(s.length>0){let e=s.map(e=>({type:`tool_upsert`,name:String(e?.name||`tool`),args:JSON.stringify(e?.args??{}),status:`paused`,approvalRequestId:r,previousResponseId:i})),t=s[0]||{};return[...e,{type:`approval_request`,approvalRequestId:r,previousResponseId:i,...a?{runId:a}:{},name:String(t?.name||`人工确认`),args:JSON.stringify(t?.args??{})}]}return[{type:`approval_request`,approvalRequestId:r,previousResponseId:i,...a?{runId:a}:{}}]}if(r===`response.approval_resolved`||r===`response.ksadk.approval_resolved`){let e=String(t?.decision||t?.outcome||``).toLowerCase(),n=e===`reject`||e===`rejected`||e===`denied`?`rejected`:e===`cancel`||e===`cancelled`||e===`canceled`?`cancelled`:`approved`;return[{type:`approval_resolved`,approvalRequestId:String(t?.approval_request_id||t?.approvalRequestId||t?.approval_id||t?.approvalId||``),decision:n,revision:Number(t?.revision||2)}]}if(new Set([`response.ksadk.a2ui_surface_begin`,`a2ui.surface.begin`,`response.a2ui.createSurface`,`a2ui.createSurface`,`createSurface`]).has(r)){let e=t?.surface&&typeof t.surface==`object`?t.surface:{};return[{type:`a2ui_surface_begin`,surfaceId:String(t?.surface_id||t?.surfaceId||e.surface_id||e.surfaceId||``),surface:e}]}if(new Set([`response.ksadk.a2ui_surface_update`,`a2ui.surface.update`,`response.a2ui.updateComponents`,`a2ui.updateComponents`,`updateComponents`]).has(r)){let e=t?.surface&&typeof t.surface==`object`?t.surface:{};return[{type:`a2ui_surface_update`,surfaceId:String(t?.surface_id||t?.surfaceId||e.surface_id||e.surfaceId||``),surface:e}]}if(new Set([`response.ksadk.a2ui_surface_end`,`a2ui.surface.end`,`response.a2ui.deleteSurface`,`a2ui.deleteSurface`,`deleteSurface`]).has(r))return[{type:`a2ui_surface_end`,surfaceId:String(t?.surface_id||t?.surfaceId||``)}];if(new Set([`response.ksadk.a2ui_interaction`,`a2ui.interaction`]).has(r))return[{type:`a2ui_interaction`,surfaceId:String(t?.surface_id||t?.surfaceId||``),interactionId:String(t?.interaction_id||t?.interactionId||``),kind:String(t?.kind||`input`),inputSchema:t?.input_schema&&typeof t.input_schema==`object`?t.input_schema:{}}];let a=t?.content?.parts?.[0]?.text;return a&&!t?.actions?.finishReason?[{type:`text_delta`,text:String(a)}]:[]}var fl=class{id=`responses`;createState(){return $c()}parseItemOperations(e,t,n){return Qe(e.eventName,e.data,t,n)}parse(e,t){return dl({eventName:e.eventName,data:e.data,state:t}).map(e=>{if(e.type===`tool_upsert`){let{approvalRequestId:t,previousResponseId:n,serverLabel:r,...i}=e;return{...i,extra:{...t?{approvalRequestId:t}:{},...n?{previousResponseId:n}:{},...r?{serverLabel:r}:{},...t?{approvalProtocol:`responses`}:{}}}}return e})}};function pl(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`?e.text:``).join(``):``}function ml(e){return e&&typeof e==`object`?e:{}}function hl(e){let t=ml(e).choices,n=ml(Array.isArray(t)?t[0]:null),r=ml(n.delta),i=ml(n.message);return{content:pl(r.content),reasoning:pl(r.reasoning_content),finalText:pl(i.content)}}var gl=class{id=`chat_completions`;createState(){return{}}parse(e){let t=e.data;if(typeof t!=`object`||!t)return[];let n=hl(t),r=[];return n.reasoning&&r.push({type:`reasoning_delta`,text:n.reasoning}),n.content&&r.push({type:`text_delta`,text:n.content}),n.finalText&&r.push({type:`text_final`,text:n.finalText}),r}},_l=new Map;_l.set(`responses`,new fl),_l.set(`chat_completions`,new gl);function vl(e){return _l.get(e)||_l.get(`responses`)}function yl(e=[]){return e.some(e=>{if(e?.type!==`terminal`)return!1;let t=String(e.status||``).toLowerCase();return t===`failed`||t===`incomplete`||t===`cancelled`})}function bl(e){let t=[],n=e.trim();if(!n)return t;let r=n.split(`
|
|
73
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Eo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:ko(t,`input`,e.processors),output:ko(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Do(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Do(r.element,n);if(r.type===`set`)return Do(r.valueType,n);if(r.type===`lazy`)return Do(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Do(r.innerType,n);if(r.type===`intersection`)return Do(r.left,n)||Do(r.right,n);if(r.type===`record`||r.type===`map`)return Do(r.keyType,n)||Do(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Do(r.in,n)||Do(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Do(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Do(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Do(e,n))return!0;return!!(r.rest&&Do(r.rest,n))}return!1}var Oo=(e,t={})=>n=>{let r=Co({...n,processors:t});return wo(e,r),To(r,e),Eo(r,e)},ko=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Co({...i??{},target:a,io:t,processors:n});return wo(e,o),To(o,e),Eo(o,e)},Ao={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},jo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Ao[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Mo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},No=(e,t,n,r)=>{n.type=`boolean`},Po=(e,t,n,r)=>{n.not={}},Fo=(e,t,n,r)=>{let i=e._zod.def,a=on(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Io=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Lo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ro=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},zo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=wo(a.element,t,{...r,path:[...r.path,`items`]})},Bo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=wo(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=wo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Vo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>wo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ho=(e,t,n,r)=>{let i=e._zod.def,a=wo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=wo(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Uo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=wo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=wo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=wo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Wo=(e,t,n,r)=>{let i=e._zod.def,a=wo(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Go=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ko=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},qo=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Jo=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Yo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;wo(o,t,r);let s=t.seen.get(e);s.ref=o},Xo=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Zo=(e,t,n,r)=>{let i=e._zod.def;wo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Qo=A(`ZodISODateTime`,(e,t)=>{vi.init(e,t),Ts.init(e,t)});function $o(e){return Ua(Qo,e)}var es=A(`ZodISODate`,(e,t)=>{yi.init(e,t),Ts.init(e,t)});function ts(e){return Wa(es,e)}var ns=A(`ZodISOTime`,(e,t)=>{bi.init(e,t),Ts.init(e,t)});function rs(e){return Ga(ns,e)}var is=A(`ZodISODuration`,(e,t)=>{xi.init(e,t),Ts.init(e,t)});function as(e){return Ka(is,e)}var os=A(`ZodError`,(e,t)=>{Wn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>qn(e,t)},flatten:{value:t=>Kn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,sn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,sn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),ss=Jn(os),cs=Yn(os),ls=Xn(os),us=Qn(os),ds=er(os),fs=tr(os),ps=nr(os),ms=rr(os),hs=ir(os),gs=ar(os),_s=or(os),vs=sr(os),ys=new WeakMap;function bs(e,t,n){let r=Object.getPrototypeOf(e),i=ys.get(r);if(i||(i=new Set,ys.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var xs=A(`ZodType`,(e,t)=>(ii.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ko(e,`input`),output:ko(e,`output`)}}),e.toJSONSchema=Oo(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ss(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ls(e,t,n),e.parseAsync=async(t,n)=>cs(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>us(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ds(e,t,n),e.decode=(t,n)=>fs(e,t,n),e.encodeAsync=async(t,n)=>ps(e,t,n),e.decodeAsync=async(t,n)=>ms(e,t,n),e.safeEncode=(t,n)=>hs(e,t,n),e.safeDecode=(t,n)=>gs(e,t,n),e.safeEncodeAsync=async(t,n)=>_s(e,t,n),e.safeDecodeAsync=async(t,n)=>vs(e,t,n),bs(e,`ZodType`,{check(...e){let t=this.def;return this.clone(hn(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Tn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ic(e,t))},superRefine(e,t){return this.check(Lc(e,t))},overwrite(e){return this.check(po(e))},optional(){return vc(this)},exactOptional(){return bc(this)},nullable(){return Sc(this)},nullish(){return vc(Sc(this))},nonoptional(e){return Oc(this,e)},array(){return nc(this)},or(e){return oc([this,e])},and(e){return cc(this,e)},transform(e){return Mc(this,gc(e))},default(e){return wc(this,e)},prefault(e){return Ec(this,e)},catch(e){return Ac(this,e)},pipe(e){return Mc(this,e)},readonly(){return Pc(this)},describe(e){let t=this.clone();return ya.add(t,{description:e}),t},meta(...e){if(e.length===0)return ya.get(this);let t=this.clone();return ya.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return ya.get(e)?.description},configurable:!0}),e)),Ss=A(`_ZodString`,(e,t)=>{ai.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,bs(e,`_ZodString`,{regex(...e){return this.check(oo(...e))},includes(...e){return this.check(lo(...e))},startsWith(...e){return this.check(uo(...e))},endsWith(...e){return this.check(fo(...e))},min(...e){return this.check(io(...e))},max(...e){return this.check(ro(...e))},length(...e){return this.check(ao(...e))},nonempty(...e){return this.check(io(1,...e))},lowercase(e){return this.check(so(e))},uppercase(e){return this.check(co(e))},trim(){return this.check(ho())},normalize(...e){return this.check(mo(...e))},toLowerCase(){return this.check(go())},toUpperCase(){return this.check(_o())},slugify(){return this.check(vo())}})}),Cs=A(`ZodString`,(e,t)=>{ai.init(e,t),Ss.init(e,t),e.email=t=>e.check(xa(Es,t)),e.url=t=>e.check(Da(ks,t)),e.jwt=t=>e.check(Ha(Ws,t)),e.emoji=t=>e.check(Oa(As,t)),e.guid=t=>e.check(Sa(Ds,t)),e.uuid=t=>e.check(Ca(Os,t)),e.uuidv4=t=>e.check(wa(Os,t)),e.uuidv6=t=>e.check(Ta(Os,t)),e.uuidv7=t=>e.check(Ea(Os,t)),e.nanoid=t=>e.check(ka(js,t)),e.guid=t=>e.check(Sa(Ds,t)),e.cuid=t=>e.check(Aa(Ms,t)),e.cuid2=t=>e.check(ja(Ns,t)),e.ulid=t=>e.check(Ma(Ps,t)),e.base64=t=>e.check(za(Vs,t)),e.base64url=t=>e.check(Ba(Hs,t)),e.xid=t=>e.check(Na(Fs,t)),e.ksuid=t=>e.check(Pa(Is,t)),e.ipv4=t=>e.check(Fa(Ls,t)),e.ipv6=t=>e.check(Ia(Rs,t)),e.cidrv4=t=>e.check(La(zs,t)),e.cidrv6=t=>e.check(Ra(Bs,t)),e.e164=t=>e.check(Va(Us,t)),e.datetime=t=>e.check($o(t)),e.date=t=>e.check(ts(t)),e.time=t=>e.check(rs(t)),e.duration=t=>e.check(as(t))});function ws(e){return ba(Cs,e)}var Ts=A(`ZodStringFormat`,(e,t)=>{oi.init(e,t),Ss.init(e,t)}),Es=A(`ZodEmail`,(e,t)=>{li.init(e,t),Ts.init(e,t)}),Ds=A(`ZodGUID`,(e,t)=>{si.init(e,t),Ts.init(e,t)}),Os=A(`ZodUUID`,(e,t)=>{ci.init(e,t),Ts.init(e,t)}),ks=A(`ZodURL`,(e,t)=>{ui.init(e,t),Ts.init(e,t)}),As=A(`ZodEmoji`,(e,t)=>{di.init(e,t),Ts.init(e,t)}),js=A(`ZodNanoID`,(e,t)=>{fi.init(e,t),Ts.init(e,t)}),Ms=A(`ZodCUID`,(e,t)=>{pi.init(e,t),Ts.init(e,t)}),Ns=A(`ZodCUID2`,(e,t)=>{mi.init(e,t),Ts.init(e,t)}),Ps=A(`ZodULID`,(e,t)=>{hi.init(e,t),Ts.init(e,t)}),Fs=A(`ZodXID`,(e,t)=>{gi.init(e,t),Ts.init(e,t)}),Is=A(`ZodKSUID`,(e,t)=>{_i.init(e,t),Ts.init(e,t)}),Ls=A(`ZodIPv4`,(e,t)=>{Si.init(e,t),Ts.init(e,t)}),Rs=A(`ZodIPv6`,(e,t)=>{Ci.init(e,t),Ts.init(e,t)}),zs=A(`ZodCIDRv4`,(e,t)=>{wi.init(e,t),Ts.init(e,t)}),Bs=A(`ZodCIDRv6`,(e,t)=>{Ti.init(e,t),Ts.init(e,t)}),Vs=A(`ZodBase64`,(e,t)=>{Di.init(e,t),Ts.init(e,t)}),Hs=A(`ZodBase64URL`,(e,t)=>{ki.init(e,t),Ts.init(e,t)}),Us=A(`ZodE164`,(e,t)=>{Ai.init(e,t),Ts.init(e,t)}),Ws=A(`ZodJWT`,(e,t)=>{Mi.init(e,t),Ts.init(e,t)}),Gs=A(`ZodNumber`,(e,t)=>{Ni.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),bs(e,`ZodNumber`,{gt(e,t){return this.check(eo(e,t))},gte(e,t){return this.check(to(e,t))},min(e,t){return this.check(to(e,t))},lt(e,t){return this.check(Qa(e,t))},lte(e,t){return this.check($a(e,t))},max(e,t){return this.check($a(e,t))},int(e){return this.check(Js(e))},safe(e){return this.check(Js(e))},positive(e){return this.check(eo(0,e))},nonnegative(e){return this.check(to(0,e))},negative(e){return this.check(Qa(0,e))},nonpositive(e){return this.check($a(0,e))},multipleOf(e,t){return this.check(no(e,t))},step(e,t){return this.check(no(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Ks(e){return qa(Gs,e)}var qs=A(`ZodNumberFormat`,(e,t)=>{Pi.init(e,t),Gs.init(e,t)});function Js(e){return Ja(qs,e)}var Ys=A(`ZodBoolean`,(e,t)=>{Fi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r)});function Xs(e){return Ya(Ys,e)}var Zs=A(`ZodUnknown`,(e,t)=>{Ii.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Qs(){return Xa(Zs)}var $s=A(`ZodNever`,(e,t)=>{Li.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r)});function ec(e){return Za($s,e)}var tc=A(`ZodArray`,(e,t)=>{zi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zo(e,t,n,r),e.element=t.element,bs(e,`ZodArray`,{min(e,t){return this.check(io(e,t))},nonempty(e){return this.check(io(1,e))},max(e,t){return this.check(ro(e,t))},length(e,t){return this.check(ao(e,t))},unwrap(){return this.element}})});function nc(e,t){return yo(tc,e,t)}var rc=A(`ZodObject`,(e,t)=>{Wi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r),pn(e,`shape`,()=>t.shape),bs(e,`ZodObject`,{keyof(){return fc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Qs()})},loose(){return this.clone({...this._zod.def,catchall:Qs()})},strict(){return this.clone({...this._zod.def,catchall:ec()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return jn(this,e)},safeExtend(e){return Mn(this,e)},merge(e){return Nn(this,e)},pick(e){return kn(this,e)},omit(e){return An(this,e)},partial(...e){return Pn(_c,this,e[0])},required(...e){return Fn(Dc,this,e[0])}})});function ic(e,t){return new rc({type:`object`,shape:e??{},...En(t)})}var ac=A(`ZodUnion`,(e,t)=>{Ki.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vo(e,t,n,r),e.options=t.options});function oc(e,t){return new ac({type:`union`,options:e,...En(t)})}var sc=A(`ZodIntersection`,(e,t)=>{qi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r)});function cc(e,t){return new sc({type:`intersection`,left:e,right:t})}var lc=A(`ZodRecord`,(e,t)=>{Xi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function uc(e,t,n){return!t||!t._zod?new lc({type:`record`,keyType:ws(),valueType:e,...En(t)}):new lc({type:`record`,keyType:e,valueType:t,...En(n)})}var dc=A(`ZodEnum`,(e,t)=>{Zi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new dc({...t,checks:[],...En(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new dc({...t,checks:[],...En(r),entries:i})}});function fc(e,t){return new dc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...En(t)})}var pc=A(`ZodLiteral`,(e,t)=>{Qi.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function mc(e,t){return new pc({type:`literal`,values:Array.isArray(e)?e:[e],...En(t)})}var hc=A(`ZodTransform`,(e,t)=>{$i.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new nn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Hn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Hn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function gc(e){return new hc({type:`transform`,transform:e})}var _c=A(`ZodOptional`,(e,t)=>{ta.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vc(e){return new _c({type:`optional`,innerType:e})}var yc=A(`ZodExactOptional`,(e,t)=>{na.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bc(e){return new yc({type:`optional`,innerType:e})}var xc=A(`ZodNullable`,(e,t)=>{ra.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Sc(e){return new xc({type:`nullable`,innerType:e})}var Cc=A(`ZodDefault`,(e,t)=>{ia.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function wc(e,t){return new Cc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Sn(t)}})}var Tc=A(`ZodPrefault`,(e,t)=>{oa.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ec(e,t){return new Tc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Sn(t)}})}var Dc=A(`ZodNonOptional`,(e,t)=>{sa.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Oc(e,t){return new Dc({type:`nonoptional`,innerType:e,...En(t)})}var kc=A(`ZodCatch`,(e,t)=>{la.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ac(e,t){return new kc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var jc=A(`ZodPipe`,(e,t)=>{ua.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),e.in=t.in,e.out=t.out});function Mc(e,t){return new jc({type:`pipe`,in:e,out:t})}var Nc=A(`ZodReadonly`,(e,t)=>{fa.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pc(e){return new Nc({type:`readonly`,innerType:e})}var Fc=A(`ZodCustom`,(e,t)=>{ma.init(e,t),xs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r)});function Ic(e,t={}){return bo(Fc,e,t)}function Lc(e,t){return xo(e,t)}var Rc=class extends Error{constructor(e){super(e),this.name=`ContractMismatchError`}},zc=new Set([`schema_version`,`command_id`,`status`,`message_id`,`run_id`,`accepted_seq`,`error`]),Bc=ic({code:ws().min(1),message:ws(),retryable:Xs(),details:uc(ws(),Qs()).optional()});function Vc(e){let t=ic({schema_version:mc(1),command_id:ws().min(1),status:fc([`accepted`,`duplicate`,`rejected`,`unsupported`,`queue_full`,`persistence_uncertain`]),message_id:ws().min(1).nullable().optional(),run_id:ws().min(1).nullable().optional(),accepted_seq:Ks().int().min(0).nullable().optional(),error:Bc.nullable().optional()}).passthrough().safeParse(e);if(!t.success)throw new Rc(`AgentControlReceipt/v1 mismatch: ${t.error.message}`);let n=t.data;if((n.status===`rejected`||n.status===`unsupported`||n.status===`queue_full`||n.status===`persistence_uncertain`)&&!n.error)throw new Rc(`AgentControlReceipt/v1 mismatch: status ${n.status} requires error`);let r={};for(let[e,t]of Object.entries(n))zc.has(e)||(r[e]=t);let i=n.error?{...n.error,extensions:{}}:null;return{schema_version:1,command_id:n.command_id,status:n.status,message_id:n.message_id??null,run_id:n.run_id??null,accepted_seq:n.accepted_seq??null,error:i,extensions:r}}var Hc=new Set([`schema_version`,`event_id`,`session_id`,`seq`,`timestamp`,`family`,`family_version`,`event_type`,`payload`,`run_id`,`causation_id`,`correlation_id`,`actor_ref`]),Uc=new Map([[`control`,1],[`runtime`,2]]),Wc=ic({schema_version:mc(1),event_id:ws().min(1),session_id:ws().min(1),seq:Ks().int().min(0),timestamp:ws().min(1),family:ws().min(1),family_version:Ks().int().min(1),event_type:ws().min(1),payload:uc(ws(),Qs()),run_id:ws().min(1).nullable().optional(),causation_id:ws().min(1).nullable().optional(),correlation_id:ws().min(1).nullable().optional(),actor_ref:ws().min(1).nullable().optional()}).passthrough();function Gc(e){let t=Wc.safeParse(e);if(!t.success)return{ok:!1,error:new Rc(`SessionEventEnvelope/v1 mismatch: ${t.error.message}`)};let n=t.data,r=Uc.get(n.family);if(r!==void 0&&n.family_version!==r)return{ok:!1,error:new Rc(`SessionEventEnvelope/v1 mismatch: family ${n.family} requires family_version ${r}`)};let i={};for(let[e,t]of Object.entries(n))Hc.has(e)||(i[e]=t);return{ok:!0,value:{schema_version:1,event_id:n.event_id,session_id:n.session_id,seq:n.seq,timestamp:n.timestamp,family:n.family,family_version:n.family_version,event_type:n.event_type,payload:n.payload,run_id:n.run_id??null,causation_id:n.causation_id??null,correlation_id:n.correlation_id??null,actor_ref:n.actor_ref??null,extensions:i}}}var Kc=class{client;constructor(e={}){this.client=new $t(e)}async compactSession(e,t){return this.client.postJsonAction(`CompactSession`,{AgentId:e,SessionId:t})}async listSessions(e,t){let n=await this.client.postJsonAction(`ListSessions`,{AgentId:e,Page:t?.page,PageSize:t?.pageSize},t),r=n.Sessions??[];return{Sessions:r,Total:Number.isFinite(Number(n.Total))?Number(n.Total):r.length,Page:Number.isFinite(Number(n.Page))?Number(n.Page):t?.page??1,PageSize:Number.isFinite(Number(n.PageSize))?Number(n.PageSize):t?.pageSize??r.length}}async createSession(e,t){let n=await this.client.postJsonAction(`CreateSession`,{AgentId:e},t);return{SessionId:String(n.Session?.SessionId||``)}}async deleteSession(e,t){return this.client.postJsonAction(`DeleteSession`,{SessionId:e},t)}async getSession(e,t){return(await this.client.postJsonAction(`GetSession`,{SessionId:e},t)).Session}async listSessionEvents(e,t){let n=await this.client.postJsonAction(`ListSessionEvents`,{SessionId:e,Offset:t?.offset,Limit:t?.limit},t),r=n.Events??[];return{Events:r,Total:Number.isFinite(Number(n.Total))?Number(n.Total):r.length,Offset:Number.isFinite(Number(n.Offset))?Number(n.Offset):t?.offset??0,Limit:Number.isFinite(Number(n.Limit))?Number(n.Limit):t?.limit??r.length}}async listSessionMessages(e,t){let n=await this.client.postJsonAction(`ListSessionMessages`,{AgentId:t?.agentId,SessionId:e,AfterSeqId:t?.afterSeqId,BeforeSeqId:t?.beforeSeqId,Limit:t?.limit,IncludeReasoning:t?.includeReasoning,IncludeToolEvents:t?.includeToolEvents,IncludeAttachments:t?.includeAttachments},t);return{Messages:n.Messages??[],LatestSeqId:Number.isFinite(Number(n.LatestSeqId))?Number(n.LatestSeqId):0,HasMore:!!n.HasMore,NextCursor:n.NextCursor===null||n.NextCursor===void 0?null:Number.isFinite(Number(n.NextCursor))?Number(n.NextCursor):null}}async listSessionCheckpoints(e,t){return this.client.postJsonAction(`ListSessionCheckpoints`,{AgentId:e.agentId,SessionId:e.sessionId,...e.runId?{RunId:e.runId}:{}},t)}async previewCheckpointResume(e,t){return this.client.postJsonAction(`GetCheckpointResumePreview`,{AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId},t)}async listToolReceipts(e,t){return this.client.postJsonAction(`ListToolReceipts`,{AgentId:e.agentId,SessionId:e.sessionId,...e.runId?{RunId:e.runId}:{},...e.checkpointId?{CheckpointId:e.checkpointId}:{}},t)}async runAgent(e,t){return this.client.streamAction(`RunAgent`,e,t)}async resumeRun(e,t){return this.client.streamAction(`ResumeRun`,{AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId,Stream:!0,...e.resumeAttemptId?{ResumeAttemptId:e.resumeAttemptId}:{},...e.invocationId?{InvocationId:e.invocationId}:{}},t)}async subscribeRunEvents(e,t){return this.client.streamGetAction(`SubscribeRunEvents`,{SessionId:e.sessionId,InvocationId:e.invocationId,AfterSeqId:String(e.afterSeqId)},t)}async submitControl(e,t){return Vc(await this.client.postJsonAction(`SubmitAgentControl`,{CommandType:e.command_type,IdempotencyKey:e.idempotency_key,Payload:e.payload},t))}async submitInteraction(e,t){return Vc(await this.client.postJsonAction(`SubmitInteraction`,{...e},t))}async getAgentStatus(e){return this.client.postJsonAction(`GetAgentStatus`,{},e)}async subscribeSessionEvents(e,t,n){return this.client.streamGetAction(`SubscribeSessionEvents`,{SessionId:e,after_seq:String(t)},n)}async cancelRun(e,t,n,r){return this.client.postJsonAction(`CancelRun`,{AgentId:e,SessionId:t,InvocationId:n},r)}async getResponseFeedback(e,t){return this.client.postJsonAction(`GetResponseFeedback`,e,t)}async upsertResponseFeedback(e,t){return this.client.postJsonAction(`UpsertResponseFeedback`,e,t)}async deleteResponseFeedback(e,t){await this.client.postJsonAction(`DeleteResponseFeedback`,e,t)}async listWorkspaceFiles(e,t,n,r){return this.client.postJsonAction(`ListWorkspaceFiles`,{AgentId:e,Path:t,Recursive:n},r)}async addWorkspaceFile(e,t){return this.client.postFormAction(`AddWorkspaceFile`,e,t)}async deleteWorkspaceFile(e,t,n){await this.client.postJsonAction(`DeleteWorkspaceFile`,{AgentId:e,Path:t},n)}async getWorkspaceFileContent(e,t,n){return this.client.getResource(`GetWorkspaceFileContent`,{AgentId:e,FilePath:t},n)}async listAgentModels(e,t){return this.client.postJsonAction(`ListAgentModels`,{AgentId:e},t)}async getAgentUiBootstrap(e,t){return this.client.postJsonAction(`GetAgentUiBootstrap`,e?{AgentId:e}:{},t)}async uploadFile(e,t){return this.client.postFormAction(`UploadFile`,e,t)}};function qc(e){return e instanceof Jt&&(e.code===401||e.code===403)?`auth-required`:`error`}function Jc(e){if(!Array.isArray(e))return[`responses`,`chat_completions`];let t=e.filter(e=>e===`responses`||e===`chat_completions`);return t.length>0?t:[`responses`,`chat_completions`]}var Yc=new Kc;async function Xc(e,t=Yc){try{let n=await t.listAgentModels(e),r=n?.Models;Array.isArray(r)&&We.getState().upsertModels(r);let i=n;i?.Current&&!We.getState().selectedModel&&We.getState().setSelectedModel(String(i.Current)),i?.Source&&We.getState().setModelSource(String(i.Source))}catch(e){console.error(`Failed to fetch models:`,e)}finally{We.getState().setModelCatalogLoaded(!0)}}function Zc(e,t,n=Yc,r){(0,v.useEffect)(()=>{let i=new AbortController;return(async()=>{He.getState().setStatus(`loading`);try{let a=r??await n.getAgentUiBootstrap(t,{signal:i.signal});if(i.signal.aborted)return;let o=a,s=o?.Agent,c=String(s?.AgentId||`default-agent`);if(He.getState().setAgentId(c),s?.Name){let e=String(s.Name);He.getState().setAgentName(e),document.title=e}let l=String(s?.Framework||``).trim().toLowerCase();He.getState().setAgentFramework(l);let u=ze(a);He.getState().setCapabilities(u),He.getState().setApiFormats(Jc(u.HostedChat.ApiFormats)),He.getState().setAccessMode(String(o?.AccessMode||`Owner`));let d=u.WorkspaceFiles&&o?.WorkspaceFiles?o.WorkspaceFiles:null;He.getState().setWorkspaceFiles(d),d||ve.getState().setWorkspacePanelOpen(!1),Be(u)&&e.fetchSessions(c,Nt(c));let f=o?.Model;f?.id&&(We.getState().setSelectedModel(f.id),We.getState().upsertModels([f]),We.getState().setModelSource(f.source||``)),Xc(c,n),He.getState().setStatus(`ready`)}catch(e){if(i.signal.aborted)return;console.error(`Failed to fetch bootstrap:`,e);let t=qc(e);He.getState().setStatus(t,t===`auth-required`?`当前访问链接未授权或已过期。`:`无法加载 Agent 配置,请稍后重试。`)}})(),()=>i.abort()},[n,t,r])}var Qc=te()(e=>({messages:[],setMessages:t=>e({messages:t}),patchMessages:t=>e(e=>({messages:t(e.messages)}))}));function $c(){return{toolNames:new Map,toolArguments:new Map,callIds:new Map,currentResponseId:``,sawTextDelta:!1,sawReasoningDelta:!1}}function el(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&typeof e.text==`string`?e.text:``).join(``):e&&typeof e==`object`&&typeof e.text==`string`?e.text:``}function tl(e){return e==null?``:typeof e==`string`?e:typeof e==`object`?JSON.stringify(e,null,2):String(e)}function nl(...e){for(let t of e){let e=el(t);if(e)return e}return``}function rl(e,t){return String(e?.id||e?.item_id||e?.call_id||t?.item_id||t?.call_id||t?.output_index||``)}function il(e,t,n,r,i){t&&(e.toolNames.set(t,r),e.toolArguments.set(t,i));let a=String(n?.call_id||``);a&&(e.callIds.set(a,t||r),e.toolNames.set(a,r),e.toolArguments.set(a,i))}function al(e,t,n,r=`tool`){let i=String(n?.call_id||``);return String(n?.name||n?.tool_name||(t?e.toolNames.get(t):``)||(i?e.toolNames.get(i):``)||r)}function ol(e){if(!e||typeof e!=`object`)return``;let t=el(e.content);return nl(e.output_text,e.text,e.summary_text,e.summary,e.delta,t)}function sl(e){let t=e?.response&&typeof e.response==`object`?e.response:e,n=nl(t?.output_text,t?.text);if(n)return n;let r=Array.isArray(t?.output)?t.output:[];for(let e of r){let t=ol(e);if(t)return t}return``}function cl(e){let t=e?.response&&typeof e.response==`object`?e.response:e;return Array.isArray(t?.output)?t.output:[]}function ll(e){let t=e;if(typeof t==`string`)try{t=JSON.parse(t)}catch{return{}}return Array.isArray(t)&&(t=t[0]||{}),!t||typeof t!=`object`?{}:t.value&&typeof t.value==`object`&&!Array.isArray(t.value)?{...t.value,approval_request_id:t.value.approval_request_id||t.value.id||t.id}:t}function ul({data:e,state:t,status:n}){let r=e?.item||e?.output_item||e||{},i=String(r.type||``).trim(),a=rl(r,e);if(i===`function_call`){let e=al(t,a,r),i=tl(r.arguments??r.args??r.input);return il(t,a,r,e,i),[{type:`tool_upsert`,name:e,args:i,status:n}]}if(i===`function_call_output`)return[{type:`tool_result`,name:al(t,a,r),output:tl(r.output??r.result??r.content)}];if(i===`mcp_approval_request`){let n=String(r.name||`approval`),i=tl(r.arguments??r.args),a=String(r.id||r.approval_request_id||``),o=String(r.run_id||r.runId||e?.run_id||e?.runId||``);return[{type:`tool_upsert`,name:n,args:i,status:`paused`,approvalRequestId:a,previousResponseId:String(e?.response_id||t.currentResponseId||``),serverLabel:String(r.server_label||``)},{type:`approval_request`,approvalRequestId:a,previousResponseId:String(e?.response_id||t.currentResponseId||``),...o?{runId:o}:{},name:n,args:i}]}if(i===`reasoning`||i===`reasoning_summary`||i===`reasoning_summary_text`){let e=ol(r);return e?[{type:`reasoning_delta`,text:e}]:[]}if(i===`message`){let e=ol(r);return e?[{type:n===`completed`?`text_final`:`text_delta`,text:e}]:[]}return[]}function dl({eventName:e,data:t,state:n}){let r=String(t?.type||e||``).trim(),i=String(t?.id||t?.response?.id||t?.response_id||``);if(i.startsWith(`resp_`)&&(n.currentResponseId=i),r===`response.tool_call`)return[{type:`tool_upsert`,name:String(t?.name||t?.tool_name||`tool`),args:tl(t?.args??t?.arguments),status:`running`}];if(r===`response.tool_result`||r===`response.ksadk.tool_result`)return[{type:`tool_result`,name:String(t?.name||t?.tool_name||`tool`),output:tl(t?.output??t?.result)}];if(r===`response.output_item.added`)return ul({data:t,state:n,status:`running`});if(r===`response.output_item.done`)return ul({data:t,state:n,status:`completed`});if(r===`response.function_call_arguments.delta`){let e=String(t?.item_id||t?.call_id||``),r=al(n,e,t),i=`${n.toolArguments.get(e)||``}${String(t?.delta||``)}`;return n.toolArguments.set(e,i),[{type:`tool_upsert`,name:r,args:i,status:`running`}]}if(r===`response.function_call_arguments.done`){let e=String(t?.item_id||t?.call_id||``),r=al(n,e,t),i=tl(t?.arguments??n.toolArguments.get(e));return n.toolArguments.set(e,i),[{type:`tool_upsert`,name:r,args:i,status:`running`}]}if(r===`response.reasoning.delta`||r===`response.reasoning_text.delta`||r===`response.reasoning_summary.delta`||r===`response.reasoning_summary_text.delta`){let e=nl(t?.delta,t?.text);return e&&(n.sawReasoningDelta=!0),e?[{type:`reasoning_delta`,text:e}]:[]}if(r===`response.output_text.delta`){let e=nl(t?.delta,t?.text);return e&&(n.sawTextDelta=!0),e?[{type:`text_delta`,text:e}]:[]}if(r===`response.output_text.done`){let e=nl(t?.text,t?.delta);return e?[{type:`text_final`,text:e}]:[]}if(r===`response.content_part.delta`){let e=String(t?.part?.type||t?.delta?.type||t?.content_type||``),r=nl(t?.delta?.text,t?.delta,t?.text);return r?e.includes(`reasoning`)?(n.sawReasoningDelta=!0,[{type:`reasoning_delta`,text:r}]):(n.sawTextDelta=!0,[{type:`text_delta`,text:r}]):[]}if(r===`response.completed`){let e=sl(t),r=cl(t).flatMap(e=>ul({data:{...t,item:e},state:n,status:`completed`})).filter(e=>!(n.sawTextDelta&&e.type===`text_final`)&&!(n.sawReasoningDelta&&e.type===`reasoning_delta`)),i=r.some(e=>e.type===`text_final`);return[...r,...e&&!n.sawTextDelta&&!i?[{type:`text_final`,text:e}]:[],{type:`terminal`,status:`completed`}]}if(r===`response.failed`)return[{type:`failed`,message:t?.error?.message||`Agent 运行失败`},{type:`terminal`,status:`failed`}];if(r===`response.incomplete`)return[{type:`incomplete`},{type:`terminal`,status:`incomplete`}];if(r===`response.cancelled`)return[{type:`terminal`,status:`cancelled`}];if(r===`response.approval_request`||r===`response.ksadk.approval_request`){let e=ll(t?.interrupt_info),r=String(e.approval_request_id||e.id||``),i=String(t?.response_id||n.currentResponseId||``),a=String(t?.run_id||t?.runId||``),o=e.approval_requests&&typeof e.approval_requests==`object`?e.approval_requests:e,s=Array.isArray(o.action_requests)?o.action_requests:[];if(s.length>0){let e=s.map(e=>({type:`tool_upsert`,name:String(e?.name||`tool`),args:JSON.stringify(e?.args??{}),status:`paused`,approvalRequestId:r,previousResponseId:i})),t=s[0]||{};return[...e,{type:`approval_request`,approvalRequestId:r,previousResponseId:i,...a?{runId:a}:{},name:String(t?.name||`人工确认`),args:JSON.stringify(t?.args??{})}]}return[{type:`approval_request`,approvalRequestId:r,previousResponseId:i,...a?{runId:a}:{}}]}if(r===`response.approval_resolved`||r===`response.ksadk.approval_resolved`){let e=String(t?.decision||t?.outcome||``).toLowerCase(),n=e===`reject`||e===`rejected`||e===`denied`?`rejected`:e===`cancel`||e===`cancelled`||e===`canceled`?`cancelled`:`approved`;return[{type:`approval_resolved`,approvalRequestId:String(t?.approval_request_id||t?.approvalRequestId||t?.approval_id||t?.approvalId||``),decision:n,revision:Number(t?.revision||2)}]}if(new Set([`response.ksadk.a2ui_surface_begin`,`a2ui.surface.begin`,`response.a2ui.createSurface`,`a2ui.createSurface`,`createSurface`]).has(r)){let e=t?.surface&&typeof t.surface==`object`?t.surface:{};return[{type:`a2ui_surface_begin`,surfaceId:String(t?.surface_id||t?.surfaceId||e.surface_id||e.surfaceId||``),surface:e}]}if(new Set([`response.ksadk.a2ui_surface_update`,`a2ui.surface.update`,`response.a2ui.updateComponents`,`a2ui.updateComponents`,`updateComponents`]).has(r)){let e=t?.surface&&typeof t.surface==`object`?t.surface:{};return[{type:`a2ui_surface_update`,surfaceId:String(t?.surface_id||t?.surfaceId||e.surface_id||e.surfaceId||``),surface:e}]}if(new Set([`response.ksadk.a2ui_surface_end`,`a2ui.surface.end`,`response.a2ui.deleteSurface`,`a2ui.deleteSurface`,`deleteSurface`]).has(r))return[{type:`a2ui_surface_end`,surfaceId:String(t?.surface_id||t?.surfaceId||``)}];if(new Set([`response.ksadk.a2ui_interaction`,`a2ui.interaction`]).has(r))return[{type:`a2ui_interaction`,surfaceId:String(t?.surface_id||t?.surfaceId||``),interactionId:String(t?.interaction_id||t?.interactionId||``),kind:String(t?.kind||`input`),inputSchema:t?.input_schema&&typeof t.input_schema==`object`?t.input_schema:{}}];let a=t?.content?.parts?.[0]?.text;return a&&!t?.actions?.finishReason?[{type:`text_delta`,text:String(a)}]:[]}var fl=class{id=`responses`;createState(){return $c()}parseItemOperations(e,t,n){return Qe(e.eventName,e.data,t,n)}parse(e,t){return dl({eventName:e.eventName,data:e.data,state:t}).map(e=>{if(e.type===`tool_upsert`){let{approvalRequestId:t,previousResponseId:n,serverLabel:r,...i}=e;return{...i,extra:{...t?{approvalRequestId:t}:{},...n?{previousResponseId:n}:{},...r?{serverLabel:r}:{},...t?{approvalProtocol:`responses`}:{}}}}return e})}};function pl(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`?e.text:``).join(``):``}function ml(e){return e&&typeof e==`object`?e:{}}function hl(e){let t=ml(e).choices,n=ml(Array.isArray(t)?t[0]:null),r=ml(n.delta),i=ml(n.message);return{content:pl(r.content),reasoning:pl(r.reasoning_content),finalText:pl(i.content)}}var gl=class{id=`chat_completions`;createState(){return{}}parse(e){let t=e.data;if(typeof t!=`object`||!t)return[];let n=hl(t),r=[];return n.reasoning&&r.push({type:`reasoning_delta`,text:n.reasoning}),n.content&&r.push({type:`text_delta`,text:n.content}),n.finalText&&r.push({type:`text_final`,text:n.finalText}),r}},_l=new Map;_l.set(`responses`,new fl),_l.set(`chat_completions`,new gl);function vl(e){return _l.get(e)||_l.get(`responses`)}function yl(e=[]){return e.some(e=>{if(e?.type!==`terminal`)return!1;let t=String(e.status||``).toLowerCase();return t===`failed`||t===`incomplete`||t===`cancelled`})}function bl(e){let t=[],n=e.trim();if(!n)return t;let r=n.split(`
|
|
74
74
|
`);if(r.every(e=>e.startsWith(`:`)))return t.push({eventName:`__ping__`,data:null}),t;let i=`message`,a=[];for(let e of r)e.startsWith(`:`)||(e.startsWith(`event:`)?i=e.substring(6).trim()||`message`:e.startsWith(`data:`)&&a.push(e.substring(5).trim()));let o=a.join(`
|
|
75
75
|
`).trim();if(o===`[DONE]`)return t.push({eventName:`__done__`,data:null}),t;if(!o)return t;try{let e=JSON.parse(o);t.push({eventName:i,data:e})}catch{t.push({eventName:i,data:o})}return t}function xl(e){let t=e.split(`
|
|
76
76
|
|
|
@@ -193,11 +193,11 @@ $2`),t=t.replace(/([。;;::\.])\s*-(?!-)\s*/g,`$1
|
|
|
193
193
|
`:i||a?`
|
|
194
194
|
`:r})}function mq(e){if(!e)return e;let t=String(e).replace(/\r\n/g,`
|
|
195
195
|
`).replace(/\r/g,`
|
|
196
|
-
`).trim();return t=$K(t),t=iq(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),pq(t.split("```")).join("```").trim()}var hq=`modulepreload`,gq=function(e,t){return new URL(e,t).href},_q={},J=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=gq(t,n),t in _q)return;_q[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:hq,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},vq=v.lazy(()=>J(()=>import(`./CodeBlock-
|
|
196
|
+
`).trim();return t=$K(t),t=iq(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),pq(t.split("```")).join("```").trim()}var hq=`modulepreload`,gq=function(e,t){return new URL(e,t).href},_q={},J=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=gq(t,n),t in _q)return;_q[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:hq,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},vq=v.lazy(()=>J(()=>import(`./CodeBlock-BwoN4XSB.js`).then(e=>({default:e.CodeBlock})),[],import.meta.url)),yq=v.lazy(()=>J(()=>import(`./MermaidBlock-E2c6OIM3.js`).then(e=>({default:e.MermaidBlock})),[],import.meta.url)),bq=v.lazy(()=>J(()=>import(`./MathMessageMarkdown-CE8kmnzT.js`).then(e=>({default:e.MathMessageMarkdown})),__vite__mapDeps([0,1,2,3,4]),import.meta.url));function xq(e){return/\$[^$]+\$|\$\$[^$]+\$\$/.test(e)}var Sq={h1({children:e}){return(0,O.jsx)(`h1`,{className:`mb-3.5 mt-5 text-[17px] font-semibold text-foreground`,children:e})},h2({children:e}){return(0,O.jsx)(`h2`,{className:`mb-2.5 mt-4.5 text-[15px] font-semibold text-foreground`,children:e})},h3({children:e}){return(0,O.jsx)(`h3`,{className:`mb-2 mt-3.5 text-[14px] font-semibold text-foreground`,children:e})},p({children:e}){return(0,O.jsx)(`p`,{className:`mb-2.5 min-w-0 break-words leading-[1.65] text-foreground`,children:e})},ul({children:e}){return(0,O.jsx)(`ul`,{className:`mb-3 list-disc space-y-1.5 pl-5 text-foreground`,children:e})},ol({children:e}){return(0,O.jsx)(`ol`,{className:`mb-3 list-decimal space-y-1.5 pl-8 text-foreground`,children:e})},li({children:e}){return(0,O.jsx)(`li`,{className:`min-w-0 break-words pl-1 leading-6 text-foreground`,children:e})},strong({children:e}){return(0,O.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e})},blockquote({children:e}){return(0,O.jsx)(`blockquote`,{className:`mb-3 border-l-2 border-border pl-4 text-text-secondary`,children:e})},code({className:e,children:t,...n}){let r=/language-(\w+)/.exec(e||``),i=String(t??``);if(!r&&!i.includes(`
|
|
197
197
|
`))return(0,O.jsx)(`code`,{className:`break-all font-mono text-[0.92em] text-text-primary before:content-none after:content-none`,...n,children:t});let a=r?r[1]:``;return a===`mermaid`?(0,O.jsx)(v.Suspense,{fallback:(0,O.jsx)(`div`,{className:`h-32 animate-pulse rounded bg-muted`}),children:(0,O.jsx)(yq,{chart:i})}):(0,O.jsx)(v.Suspense,{fallback:(0,O.jsx)(`pre`,{className:`p-4 text-sm`,children:i}),children:(0,O.jsx)(vq,{language:a,value:i})})},table({children:e,...t}){return(0,O.jsx)(`div`,{className:`mb-3 max-w-full overflow-x-auto rounded-lg border border-border`,children:(0,O.jsx)(`table`,{className:`w-full min-w-[36rem] table-auto border-collapse text-sm text-foreground`,...t,children:e})})},th({children:e,...t}){return(0,O.jsx)(`th`,{className:`break-words border-b border-border bg-muted/40 px-3 py-2 text-left align-top font-semibold text-foreground`,...t,children:e})},td({children:e,...t}){return(0,O.jsx)(`td`,{className:`break-words border-b border-border px-3 py-2 align-top text-text-secondary`,...t,children:e})},a({children:e,href:t,...n}){return(0,O.jsx)(`a`,{href:t,className:`text-primary hover:underline`,target:`_blank`,rel:`noopener noreferrer`,...n,children:e})}},Cq=v.memo(({content:e})=>{let t=mq(e);return(0,O.jsx)(`div`,{className:`max-w-none break-words text-[14px] leading-[1.65] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,O.jsx)(GU,{remarkPlugins:[YK,QK],components:Sq,children:t})})}),wq=v.memo(({content:e})=>xq(e)?(0,O.jsx)(v.Suspense,{fallback:(0,O.jsx)(Cq,{content:e}),children:(0,O.jsx)(bq,{content:e})}):(0,O.jsx)(Cq,{content:e})),Tq=/^diff --git "?a\/(.+?)"? "?b\/(.+?)"?$/;function Eq(e){let t=[],n=new Map,r=null;for(let i of e.split(`
|
|
198
198
|
`)){let e=i.match(Tq);if(e){let a=e[2],o=n.get(a);if(o){o.lines.push(i),r=o;continue}r={oldPath:e[1],path:a,lines:[i]},n.set(a,r),t.push(r);continue}r?.lines.push(i)}return t}function Dq(e){let t=0,n=0;for(let r of e.lines)r.startsWith(`+`)&&!r.startsWith(`+++`)?t+=1:r.startsWith(`-`)&&!r.startsWith(`---`)&&(n+=1);return{added:t,removed:n}}function Oq(e){return/^diff --git /m.test(e)}function kq(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Aq(e){let t=kq(e.properties)||{},n=Array.isArray(e.required)?new Set(e.required.map(String)):new Set,r=[];for(let[e,i]of Object.entries(t)){let t=kq(i),a=String(t?.type||``).toLowerCase(),o=a===`string`||a===`number`||a===`boolean`||a===`array`?a:`unknown`,s=kq(t?.items),c=Array.isArray(t?.[`x-codex-options`])?t[`x-codex-options`].map(kq).map(e=>e?.label).filter(e=>typeof e==`string`):[],l=c.length?c:void 0;r.push({name:e,title:typeof t?.title==`string`?t.title:void 0,description:typeof t?.description==`string`?t.description:void 0,allowOther:t?.[`x-codex-is-other`]===!0,secret:t?.[`x-codex-is-secret`]===!0,type:o,required:n.has(e),enumValues:Array.isArray(t?.enum)?t.enum:Array.isArray(s?.enum)?s.enum:l})}return r}function jq({schema:e,values:t,onChange:n,disabled:r,onSubmit:i,onCancel:a}){let o=Aq(e),[s,c]=(0,v.useState)(``);return(0,O.jsxs)(`form`,{className:`mt-3`,"data-testid":`interaction-schema-form`,onKeyDown:e=>{e.key===`Enter`&&e.nativeEvent.isComposing&&e.preventDefault()},onSubmit:e=>{if(e.preventDefault(),!r){if(!o.every(e=>{let n=t[e.name];return!e.required||(Array.isArray(n)?n.length>0:String(n??``).trim().length>0)})){c(`请回答必填问题后再提交。`);return}c(``),i()}},children:[o.map(e=>(0,O.jsxs)(`div`,{className:`mb-2 block text-xs text-[var(--ksadk-interaction-muted)]`,children:[(0,O.jsxs)(`span`,{className:`mb-1 block font-medium`,children:[e.description||e.title||e.name,e.required?(0,O.jsx)(`span`,{className:`ml-0.5 text-rose-500`,children:`*`}):null]}),e.enumValues&&e.enumValues.length>0?(0,O.jsxs)(`div`,{className:`space-y-1`,"data-testid":`interaction-field-${e.name}`,children:[e.enumValues.map((i,a)=>{let o=e.type===`array`?Array.isArray(t[e.name])&&t[e.name].includes(i):t[e.name]===i;return(0,O.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-2 rounded-xl px-2 text-sm text-[var(--ksadk-interaction-foreground)] hover:bg-[var(--ksadk-interaction-muted-background)]`,children:[(0,O.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-[var(--ksadk-interaction-muted-background)] text-xs text-[var(--ksadk-interaction-muted)]`,children:a+1}),(0,O.jsx)(`input`,{type:e.type===`array`?`checkbox`:`radio`,name:e.name,disabled:r,checked:!!o,onChange:r=>{let a=Array.isArray(t[e.name])?t[e.name]:[],o=e.type===`array`?r.target.checked?[...a,i]:a.filter(e=>e!==i):i;n({...t,[e.name]:o})},className:`h-4 w-4 accent-current`}),(0,O.jsx)(`span`,{children:String(i)})]},String(i))}),e.allowOther?(0,O.jsx)(`input`,{"aria-label":`${e.title||e.name}:自定义回答`,placeholder:`或填写自己的回答`,type:e.secret?`password`:`text`,disabled:r,value:e.type===`array`?(Array.isArray(t[e.name])?t[e.name]:[]).filter(t=>!e.enumValues.includes(t)).join(`
|
|
199
199
|
`):e.enumValues.includes(t[e.name])?``:String(t[e.name]??``),onChange:r=>{let i=r.target.value,a=(Array.isArray(t[e.name])?t[e.name]:[]).filter(t=>e.enumValues.includes(t));n({...t,[e.name]:e.type===`array`?[...a,...i.trim()?[i]:[]]:i})},className:`w-full rounded-lg border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] px-3 py-2 text-sm text-[var(--ksadk-interaction-foreground)]`}):null]}):e.type===`boolean`?(0,O.jsx)(`input`,{type:`checkbox`,"data-testid":`interaction-field-${e.name}`,disabled:r,checked:!!t[e.name],onChange:r=>n({...t,[e.name]:r.target.checked}),className:`h-4 w-4`}):e.type===`number`?(0,O.jsx)(`input`,{type:`number`,"data-testid":`interaction-field-${e.name}`,disabled:r,value:t[e.name]===void 0?``:String(t[e.name]),onChange:r=>n({...t,[e.name]:r.target.value===``?void 0:Number(r.target.value)}),className:`w-full rounded-md border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] px-2 py-1.5 text-sm text-foreground`}):(0,O.jsx)(`input`,{type:e.secret?`password`:`text`,"data-testid":`interaction-field-${e.name}`,disabled:r,value:String(t[e.name]??``),onChange:r=>n({...t,[e.name]:r.target.value}),className:`w-full rounded-md border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] px-2 py-1.5 text-sm text-foreground`})]},e.name)),s?(0,O.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-rose-600`,children:s}):null,(0,O.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,O.jsx)(`button`,{type:`submit`,"data-testid":`interaction-submit`,disabled:r,className:`inline-flex min-h-8 items-center rounded-md bg-[var(--ksadk-interaction-primary-background)] px-3 py-1.5 text-xs font-semibold text-[var(--ksadk-interaction-primary-foreground)] disabled:cursor-not-allowed disabled:opacity-55`,children:`提交`}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-form-cancel`,disabled:r,onClick:a,className:`inline-flex min-h-8 items-center rounded-md px-3 py-1.5 text-xs font-medium text-slate-500 underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:opacity-55 dark:text-slate-400`,children:`取消本次确认`})]})]})}function Mq({surfaceId:e,serializedMessages:t}){let{processMessages:n}=MO();return(0,v.useEffect)(()=>{n(JSON.parse(t))},[t,n]),(0,O.jsx)(Kte,{surfaceId:e,className:`w-full`,fallback:(0,O.jsx)(`div`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`界面内容暂不可用`}),loadingFallback:(0,O.jsx)(`div`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`正在加载界面`})})}function Nq({surfaceId:e,messages:t,onAction:n}){let r=e.startsWith(`input-`)?$te(t):null;if(r)return(0,O.jsxs)(`details`,{className:`mx-auto mb-3 w-full max-w-3xl px-6 text-sm text-muted-foreground`,"data-testid":`legacy-question-history`,children:[(0,O.jsxs)(`summary`,{className:`cursor-pointer`,children:[`历史提问 · `,r.length,` 个问题`]}),(0,O.jsx)(`ul`,{className:`mt-2 list-disc space-y-1 pl-5`,children:r.map((e,t)=>(0,O.jsx)(`li`,{children:e},t))})]});let i=JSON.stringify(t);return(0,O.jsx)(`div`,{className:`mb-3 w-full overflow-hidden rounded-lg border border-slate-200 bg-white p-3 shadow-sm dark:border-slate-700 dark:bg-slate-900`,children:(0,O.jsx)(Vte,{catalog:FO,onAction:n,children:(0,O.jsx)(Mq,{surfaceId:e,serializedMessages:i})},`${e}:${i}`)})}function Pq({a2ui:e,disabled:t,onSubmit:n,onCancel:r}){return(0,O.jsxs)(`div`,{className:`mt-3`,"data-testid":`interaction-a2ui-surface`,children:[(0,O.jsx)(Nq,{surfaceId:`interaction-${e.wireVersion}`,messages:e.messages,onAction:t?void 0:e=>{let t=e.userAction?.context||{};n(typeof t.payload==`object`&&t.payload!==null?t.payload:{...t})}}),t?null:(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-a2ui-cancel`,onClick:r,className:`mt-1 inline-flex min-h-8 items-center rounded-md px-3 py-1.5 text-xs font-medium text-slate-500 underline-offset-2 hover:underline dark:text-slate-400`,children:`取消本次确认`})]})}function Fq(e){for(let t of e?.messages||[]){let e=t.inputSchema??t.input_schema??t.schema;if(typeof e==`object`&&e)return e}return null}function Iq(e){if(!e.expiresAt)return!1;let t=Date.parse(e.expiresAt);return Number.isFinite(t)&&t<=Date.now()}function Lq(e){let t=e.extensions.submit_error;return typeof t==`object`&&t&&`code`in t&&`message`in t?{code:String(t.code),message:String(t.message),retryable:!!(`retryable`in t&&t.retryable)}:null}function Rq(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function zq(e){let t=Rq(e);if(t)return t;if(typeof e!=`string`)return null;try{return Rq(JSON.parse(e))}catch{return null}}function Bq(e){return Array.isArray(e)?e.map(String).join(` `):typeof e==`string`?e:``}function Vq(e){let t=zq(e.extensions.detail),n=zq(e.extensions.arguments),r=t||n||{},i=e.title.replace(/^审批[::]\s*/,``).trim();return{operation:{command_execution:`命令执行`,file_change:`文件修改`,mcp_tool_call:`MCP 工具调用`}[i]||i,command:Bq(r.command??r.cmd),reason:Bq(r.reason??r.justification),cwd:Bq(r.cwd??r.workdir)}}var Hq={approved:`已同意`,rejected:`已拒绝`,submitted:`已提交`,cancelled:`已取消`,expired:`已过期`};function Uq({interactions:e,activeIndex:t,onSelectIndex:n,onRespond:r,localCatalog:i,className:a}){let[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)({}),u=e[Math.min(t,Math.max(e.length-1,0))];if(!u)return null;let d=Iq(u),f=Lq(u),p=Vq(u),m=d||u.status===`resolving`,h=gA(u.presentation?.a2ui,i),g=u.requestSchema??Fq(u.presentation?.a2ui)??null,_=u.kind===`approval`?`basic-controls`:h===`a2ui`?`a2ui`:h===`json-schema-form`&&g||u.requestSchema&&!u.presentation?`json-schema-form`:`basic-controls`,y=_===`json-schema-form`&&g||u.requestSchema,b=(e,t)=>{m||Promise.resolve(r({interactionId:u.interactionId,expectedRevision:u.revision,action:e,response:t,idempotencyKey:Xk(u.interactionId,u.revision)})).catch(()=>{})};return(0,O.jsx)(`div`,{"data-testid":`interaction-tray`,"data-slot":`interaction-tray`,"data-ui":`interaction-tray`,"data-interaction-status":u.status,"data-interaction-count":e.length,className:K(`mx-auto mb-2 w-full max-w-[64rem] px-3 sm:px-4`,a),children:(0,O.jsxs)(`div`,{"data-slot":`interaction-card`,className:`rounded-2xl border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-background)] px-3 py-3 text-[var(--ksadk-interaction-foreground)] shadow-sm`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-[var(--ksadk-interaction-muted)]`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,O.jsx)(PN,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7,"aria-hidden":`true`}),(0,O.jsx)(`span`,{"data-testid":`interaction-tray-title`,children:u.title}),p.operation?(0,O.jsx)(`span`,{className:`truncate text-[11px] text-[var(--ksadk-interaction-muted)]`,children:p.operation}):null]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.length>1?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-tray-prev`,disabled:t<=0,onClick:()=>n(Math.max(t-1,0)),className:`rounded p-1 transition hover:bg-[var(--ksadk-interaction-muted-background)] disabled:opacity-30`,"aria-label":`上一条待确认`,children:(0,O.jsx)(mN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,O.jsxs)(`span`,{"data-testid":`interaction-tray-count`,className:`min-w-10 text-center`,children:[t+1,` of `,e.length]}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-tray-next`,disabled:t>=e.length-1,onClick:()=>n(Math.min(t+1,e.length-1)),className:`rounded p-1 transition hover:bg-[var(--ksadk-interaction-muted-background)] disabled:opacity-30`,"aria-label":`下一条待确认`,children:(0,O.jsx)(hN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]}):null,(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-cancel`,disabled:m,onClick:()=>b(`cancel`,{}),className:`rounded p-1 transition hover:bg-[var(--ksadk-interaction-muted-background)] hover:text-[var(--ksadk-interaction-foreground)] disabled:opacity-30`,"aria-label":`取消本次确认`,children:(0,O.jsx)(cP,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]})]}),u.message===p.command?null:(0,O.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm font-medium leading-5 text-[var(--ksadk-interaction-foreground)]`,"data-testid":`interaction-tray-message`,children:u.message}),p.command||p.reason||p.cwd?(0,O.jsxs)(`div`,{"data-slot":`interaction-summary`,className:`mt-1.5 space-y-1 rounded-xl bg-[var(--ksadk-interaction-muted-background)] px-2.5 py-2 text-xs leading-5`,children:[p.command?(0,O.jsx)(`code`,{className:`block max-h-12 overflow-auto whitespace-pre-wrap break-all font-mono text-[var(--ksadk-interaction-foreground)]`,children:p.command}):null,p.reason?(0,O.jsx)(`p`,{className:`text-[var(--ksadk-interaction-muted)]`,children:p.reason}):null,p.cwd?(0,O.jsx)(`p`,{className:`truncate font-mono text-[11px] text-[var(--ksadk-interaction-muted)]`,title:p.cwd,children:p.cwd}):null]}):null,d?(0,O.jsxs)(`p`,{className:`mt-2 text-xs font-medium text-rose-600 dark:text-rose-400`,"data-testid":`interaction-tray-expired`,children:[`该确认已过期(`,Hq.expired,`),等待运行时继续处理。`]}):null,f?(0,O.jsxs)(`p`,{className:`mt-2 text-xs font-medium text-rose-600 dark:text-rose-400`,"data-testid":`interaction-tray-error`,children:[`提交失败(`,f.code,`):`,f.message,f.retryable?`,可重试。`:``]}):null,_===`a2ui`&&u.presentation?.a2ui?(0,O.jsx)(Pq,{a2ui:u.presentation.a2ui,disabled:m,onSubmit:e=>b(`submit`,e),onCancel:()=>b(`cancel`,{})}):_===`json-schema-form`&&y?(0,O.jsx)(jq,{schema:y,values:c,onChange:l,disabled:m,onSubmit:()=>b(`submit`,c),onCancel:()=>b(`cancel`,{})}):u.kind===`approval`?(0,O.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,"data-testid":`interaction-tray-basic`,children:[(0,O.jsxs)(`button`,{type:`button`,"data-testid":`interaction-approve`,disabled:m,onClick:()=>b(`approve`,{decision:`approve`}),className:`group flex min-h-9 w-full items-center gap-2.5 rounded-xl px-2.5 py-1.5 text-left text-sm font-medium text-[var(--ksadk-interaction-foreground)] transition hover:bg-[var(--ksadk-interaction-muted-background)] disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,O.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-[var(--ksadk-interaction-muted-background)] text-xs text-[var(--ksadk-interaction-muted)]`,children:`1`}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1`,children:`批准并继续`}),(0,O.jsx)(lN,{className:`h-3.5 w-3.5 text-[var(--ksadk-interaction-muted)] opacity-0 transition group-hover:opacity-100`,"aria-hidden":`true`})]}),(0,O.jsxs)(`button`,{type:`button`,"data-testid":`interaction-reject`,disabled:m,onClick:()=>b(`reject`,{decision:`reject`}),className:`group flex min-h-9 w-full items-center gap-2.5 rounded-xl px-2.5 py-1.5 text-left text-sm font-medium text-[var(--ksadk-interaction-foreground)] transition hover:bg-[var(--ksadk-interaction-muted-background)] disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,O.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-[var(--ksadk-interaction-muted-background)] text-xs text-[var(--ksadk-interaction-muted)]`,children:`2`}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1`,children:`拒绝`}),(0,O.jsx)(lN,{className:`h-3.5 w-3.5 text-[var(--ksadk-interaction-muted)] opacity-0 transition group-hover:opacity-100`,"aria-hidden":`true`})]}),(0,O.jsxs)(`label`,{className:`mt-0.5 flex min-w-0 items-center gap-2.5 rounded-xl bg-[var(--ksadk-interaction-muted-background)]/60 px-2.5 py-1.5`,children:[(0,O.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] text-[var(--ksadk-interaction-muted)]`,children:(0,O.jsx)(HN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,O.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.nativeEvent.isComposing||!o.trim()||(e.preventDefault(),b(`cancel`,{feedback:o.trim()}))},placeholder:`告诉 Agent 要如何修改`,disabled:m,"data-testid":`interaction-tray-comment`,className:`h-8 min-w-0 flex-1 border-0 bg-transparent px-0 text-sm font-medium text-[var(--ksadk-interaction-foreground)] outline-none placeholder:text-[var(--ksadk-interaction-muted)] disabled:cursor-not-allowed disabled:opacity-55`}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-feedback-submit`,"aria-label":`提交修改意见`,disabled:m||!o.trim(),onClick:()=>b(`cancel`,{feedback:o.trim()}),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-[var(--ksadk-interaction-muted)] transition hover:bg-[var(--ksadk-interaction-control-background)] hover:text-[var(--ksadk-interaction-foreground)] disabled:opacity-30`,children:(0,O.jsx)(lN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]})]}):(0,O.jsxs)(`div`,{className:`mt-2.5`,"data-testid":`interaction-tray-basic`,children:[(0,O.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.nativeEvent.isComposing||!o.trim()||(e.preventDefault(),b(`submit`,{value:o.trim()}))},placeholder:`输入回复`,disabled:m,"data-testid":`interaction-tray-comment`,className:`mb-2 h-8 w-full rounded-lg border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] px-2.5 text-sm text-[var(--ksadk-interaction-foreground)] outline-none placeholder:text-[var(--ksadk-interaction-muted)] focus:ring-1 focus:ring-[var(--ksadk-interaction-focus-ring)]`}),(0,O.jsx)(`div`,{className:`flex justify-end gap-2`,children:(0,O.jsx)(`button`,{type:`button`,"data-testid":`interaction-submit`,disabled:m,onClick:()=>b(`submit`,{value:o}),className:`inline-flex h-8 items-center gap-1.5 rounded-lg bg-[var(--ksadk-interaction-primary-background)] px-3 text-xs font-medium text-[var(--ksadk-interaction-primary-foreground)] shadow-sm transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-55`,children:`提交`})})]}),u.status===`resolving`?(0,O.jsx)(`p`,{className:`mt-2 text-xs text-[var(--ksadk-interaction-muted)]`,children:`正在提交,请稍候…`}):null]})})}function Wq({outcome:e}){return(0,O.jsx)(`span`,{className:K(`rounded border px-1.5 py-0.5 text-xs font-medium`,e===`approved`?`border-emerald-300 text-emerald-700 dark:border-emerald-900 dark:text-emerald-300`:e===`rejected`?`border-rose-300 text-rose-700 dark:border-rose-900 dark:text-rose-300`:`border-slate-300 text-slate-600 dark:border-slate-700 dark:text-slate-300`),children:Hq[e]||e})}function Gq(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function Kq(e){let t=e?.properties;return typeof t!=`object`||!t?[]:Object.keys(t)}function qq({interaction:e}){if(e.outcome===`cancelled`||e.status===`cancelled`)return null;let t=e.status===`resolved`||e.status===`expired`,n=Kq(e.requestSchema);return(0,O.jsxs)(`div`,{"data-testid":`interaction-history-anchor`,"data-interaction-id":e.interactionId,"data-interaction-status":e.status,className:`mt-2 rounded-lg border border-border bg-muted/55 px-3 py-2 text-xs text-text-secondary`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.title}),(0,O.jsx)(Wq,{outcome:e.outcome||e.status})]}),t?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`mt-1 leading-relaxed`,children:[e.actor?(0,O.jsxs)(`span`,{children:[`操作人:`,e.actor,` · `]}):null,e.resolvedAt?(0,O.jsxs)(`span`,{children:[`决定时间:`,Gq(e.resolvedAt),` · `]}):null,(0,O.jsx)(`span`,{"data-testid":`interaction-history-response-summary`,children:e.responseSummary||`响应内容已脱敏`})]}),(0,O.jsxs)(`details`,{"data-testid":`interaction-history-detail`,className:`mt-1`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer select-none text-text-muted hover:text-text-primary`,children:`查看确认快照`}),(0,O.jsxs)(`div`,{"data-testid":`interaction-history-snapshot`,className:`mt-1 rounded border border-border bg-card px-2 py-1.5 leading-relaxed text-card-foreground`,children:[(0,O.jsxs)(`div`,{children:[`操作者:`,(0,O.jsx)(`span`,{"data-testid":`interaction-history-actor-ref`,children:e.actor||`—`})]}),(0,O.jsxs)(`div`,{children:[`决定时间:`,Gq(e.resolvedAt)||`—`]}),(0,O.jsxs)(`div`,{children:[`关键参数:`,n.length>0?(0,O.jsx)(`span`,{"data-testid":`interaction-history-schema-keys`,children:n.join(`、`)}):(0,O.jsx)(`span`,{children:`无结构化参数`})]})]})]})]}):(0,O.jsxs)(`div`,{className:`mt-1`,children:[`状态:`,e.status===`pending`?`待处理(见输入区确认面板)`:`处理中…`]})]})}function Jq({summary:e,children:t,defaultOpen:n=!1,streaming:r=!1}){let[i,a]=(0,v.useState)(n);return(0,O.jsxs)(`div`,{className:`mb-1.5`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-1.5 rounded px-1 py-1 text-left text-[13px] text-slate-500 transition-colors hover:bg-slate-100/70 dark:text-slate-400 dark:hover:bg-slate-800/40`,children:[r?(0,O.jsx)(MN,{className:`h-3.5 w-3.5 animate-spin text-slate-400`}):(0,O.jsx)(pN,{className:K(`h-3.5 w-3.5 text-slate-400 transition-transform`,i&&`rotate-90`)}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})]}),i&&(0,O.jsx)(`div`,{className:`mt-1.5 border-l border-slate-200 pl-3.5 dark:border-slate-700/60`,children:t})]})}function Yq({block:e}){let[t,n]=(0,v.useState)(!1),r=e.status===`streaming`,i=e.content.length,a=`${e.id}-thinking-detail`;return(0,O.jsxs)(`div`,{className:`mb-1.5 min-w-0`,children:[(0,O.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":a,onClick:()=>n(e=>!e),className:`inline-flex max-w-full items-center gap-1.5 rounded px-1 py-1 text-left text-[13px] leading-5 text-slate-400 transition-colors hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300`,children:[!r&&(0,O.jsx)(QN,{className:`h-3.5 w-3.5 shrink-0`}),(0,O.jsx)(`span`,{className:K(`min-w-0 truncate`,r&&`waiting-thinking-text`),"data-testid":r?`thinking-indicator`:void 0,role:r?`status`:void 0,children:r?`正在思考…`:`已思考`}),!r&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{className:`text-slate-300 dark:text-slate-600`,children:`·`}),(0,O.jsxs)(`span`,{className:`font-mono text-xs text-slate-400 dark:text-slate-500`,children:[i,` 字`]})]}),(0,O.jsx)(pN,{className:K(`h-3.5 w-3.5 shrink-0 transition-transform`,t&&`rotate-180`)})]}),t&&e.content&&(0,O.jsx)(`div`,{id:a,className:`custom-scrollbar mt-1.5 max-h-[min(46vh,28rem)] overflow-y-auto border-l border-slate-200/80 pl-3.5 text-[12px] leading-5 text-slate-500 dark:border-slate-700/60 dark:text-slate-400 [&_h1]:!mb-2 [&_h1]:!mt-3 [&_h1]:!text-[13px] [&_h2]:!mb-1.5 [&_h2]:!mt-3 [&_h2]:!text-[12px] [&_h3]:!mb-1 [&_h3]:!mt-2.5 [&_h3]:!text-[12px] [&_li]:!text-[12px] [&_li]:!leading-5 [&_p]:!my-1.5 [&_p]:!text-[12px] [&_p]:!leading-5 [&_p]:!text-slate-500 dark:[&_p]:!text-slate-400 [&_pre]:!my-1.5`,children:(0,O.jsx)(wq,{content:e.content})})]})}function Xq({block:e,tool:t,isStreaming:n,interactionRecord:r,onRespondToApproval:i,onRespondToAguiApproval:a}){let o=t?.status??e.status,s=t?.args??e.args,c=t?.output??e.output,l=e.extra||{},u=(r?.outcome===`cancelled`||r?.outcome===`expired`||r?.status===`cancelled`||r?.status===`expired`?`cancelled`:r?.outcome===`rejected`?`rejected`:r?.outcome===`approved`?`approved`:void 0)||l.approvalStatus||t?.approvalStatus,d=l.approvalRequestId||t?.approvalRequestId,f=l.approvalMessage||t?.approvalMessage,p=l.approvalProtocol||t?.approvalProtocol,m=l.previousResponseId||t?.previousResponseId,h=o===`running`,g=u===`cancelled`||u===`rejected`,_=o===`error`&&!g,v=o===`paused`,y=_?`执行失败`:u===`pending`?`等待确认`:u===`rejected`?`已拒绝`:u===`cancelled`?`已取消`:h?u===`approved`?`已授权 · 执行中`:`正在运行`:u===`approved`?`已授权`:v?`已暂停`:`已完成`,b=_?`text-rose-500 dark:text-rose-400`:v?`text-amber-500 dark:text-amber-400`:h?`text-slate-500 dark:text-slate-400`:`text-slate-400 dark:text-slate-500`;return(0,O.jsx)(Jq,{streaming:h&&!s,defaultOpen:u===`pending`||v,summary:(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(sP,{className:K(`h-3.5 w-3.5 shrink-0`,b)}),(0,O.jsx)(`span`,{className:b,children:y}),(0,O.jsx)(`span`,{className:`truncate font-medium text-slate-600 dark:text-slate-300`,children:e.toolName}),h&&s&&(0,O.jsx)(`span`,{className:`ml-0.5 animate-pulse text-slate-400`,children:`…`})]}),children:(0,O.jsxs)(`div`,{className:`flex flex-col gap-2.5 py-1 text-[13px]`,children:[d&&u===`pending`&&!r&&(0,O.jsxs)(`section`,{"data-slot":`tool-approval-card`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-[var(--ksadk-approval-border)] bg-[var(--ksadk-approval-background)] px-2.5 py-2 font-sans text-[12px] text-[var(--ksadk-approval-foreground)] shadow-[0_1px_2px_rgba(15,23,42,0.03)]`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--ksadk-approval-foreground)]`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`shrink-0 font-medium`,children:`需要确认`}),(0,O.jsx)(`span`,{className:`min-w-0 truncate opacity-75`,children:f||`允许后将执行此工具调用。`})]}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,O.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>p===`ag-ui`?a?.({interruptId:d||``,approve:!0}):i?.({approvalRequestId:d||``,approve:!0,previousResponseId:m}),className:`inline-flex h-7 items-center rounded-md bg-primary px-2.5 text-[12px] font-medium text-primary-foreground transition hover:bg-primary/90 disabled:opacity-55`,children:`允许执行`}),(0,O.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>p===`ag-ui`?a?.({interruptId:d||``,approve:!1}):i?.({approvalRequestId:d||``,approve:!1,previousResponseId:m}),className:`inline-flex h-7 items-center rounded-md px-2 text-[12px] font-medium text-slate-500 transition hover:bg-slate-100 hover:text-rose-600 disabled:opacity-55 dark:text-slate-400 dark:hover:bg-slate-800`,children:`拒绝`})]})]}),d&&u===`pending`&&r?(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 font-sans text-xs text-slate-500 dark:text-slate-400`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400`,"aria-hidden":`true`}),`请在输入区确认面板中操作。`]}):null,d&&u&&u!==`pending`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 font-sans text-xs text-slate-500 dark:text-slate-400`,children:[(0,O.jsx)(`span`,{children:u===`approved`?`已授权`:u===`cancelled`?`已取消`:`已拒绝`}),u===`approved`&&h?(0,O.jsx)(`span`,{children:`· 工具执行中`}):null,u===`approved`&&_?(0,O.jsx)(`span`,{children:`· 工具执行失败`}):null]}),s?(0,O.jsx)(tJ,{label:`入参`,value:s,tone:`input`}):null,c&&!g?Zq(e.toolName,c,_):null]})})}function Zq(e,t,n){if(Oq(t))return(0,O.jsx)(Qq,{output:t});let r=e.toLowerCase();if(r.includes(`web_search`)||r.includes(`search`)){let e=$q(t);if(e.length>0)return(0,O.jsx)(eJ,{sources:e})}return(0,O.jsx)(tJ,{label:`输出`,value:t,tone:n?`error`:`output`})}function Qq({output:e}){let t=Eq(e),[n,r]=(0,v.useState)(!1),i=n?t:t.slice(0,3);return(0,O.jsxs)(`div`,{className:`my-2 overflow-hidden rounded-xl border border-border bg-background`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs font-medium text-text-secondary`,children:[(0,O.jsx)(EN,{className:`h-3.5 w-3.5 text-primary`}),(0,O.jsxs)(`span`,{children:[`改动 `,t.length,` 个文件`]})]}),(0,O.jsx)(`div`,{className:`flex flex-col`,children:i.map(e=>{let{added:t,removed:n}=Dq(e);return(0,O.jsxs)(`div`,{className:`group/file-change-row flex min-w-0 items-center gap-2 px-3 py-2 text-sm transition-colors hover:bg-muted`,children:[(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[13px] text-text-primary`,children:e.path}),(0,O.jsxs)(`span`,{className:`flex-shrink-0 text-[11px] font-mono`,children:[(0,O.jsxs)(`span`,{className:`text-emerald-600`,children:[`+`,t]}),` `,(0,O.jsxs)(`span`,{className:`text-rose-500`,children:[`−`,n]})]})]},e.path)})}),t.length>3?(0,O.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-center justify-center gap-1 border-t border-border py-1.5 text-xs text-text-muted transition hover:bg-muted hover:text-text-primary`,children:n?`收起`:`展开剩余 ${t.length-3} 个文件`}):null]})}function $q(e){try{let t=JSON.parse(e),n=Array.isArray(t)?t:t?.results??t?.sources??[];return Array.isArray(n)?n.map(e=>{let t=e,n=String(t?.url??t?.link??t?.href??``),r=String(t?.title??t?.name??n);return n?{url:n,title:r}:null}).filter(e=>e!==null):[]}catch{return[]}}function eJ({sources:e}){return(0,O.jsx)(`div`,{className:`mt-2 flex min-w-0`,children:(0,O.jsxs)(`span`,{className:`group/web-search-sources relative inline-flex min-w-0`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md border border-border bg-surface px-2 text-xs text-text-secondary transition-colors hover:bg-muted hover:text-text-primary`,children:[(0,O.jsx)(xN,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7}),(0,O.jsxs)(`span`,{children:[`来源 · `,e.length]})]}),(0,O.jsx)(`span`,{className:`absolute bottom-full left-0 z-30 hidden max-w-[calc(100vw-3rem)] pb-1 group-hover/web-search-sources:block`,children:(0,O.jsx)(`span`,{className:`block w-[min(26rem,calc(100vw-3rem))] rounded-xl border border-border bg-popover p-2 text-left text-text-primary shadow-2xl`,children:(0,O.jsx)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:e.map((e,t)=>(0,O.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-sm leading-5 text-text-secondary transition-colors hover:bg-muted hover:text-text-primary`,children:[(0,O.jsx)(xN,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]},`${e.url}-${t}`))})})})]})})}function tJ({label:e,tone:t,value:n}){return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-slate-400`,children:e}),(0,O.jsx)(`pre`,{className:K(`custom-scrollbar max-h-60 overflow-auto rounded-lg px-3 py-2 text-[12.5px] leading-relaxed whitespace-pre-wrap break-all`,t===`error`?`bg-rose-50/60 text-rose-700 dark:bg-rose-950/20 dark:text-rose-200`:t===`output`?`bg-emerald-50/40 text-emerald-800 dark:bg-emerald-950/20 dark:text-emerald-200`:`bg-slate-50 text-slate-700 dark:bg-slate-900/40 dark:text-slate-200`),children:n})]})}function nJ({block:e}){return e.content?(0,O.jsx)(`div`,{className:`w-full break-words py-0.5 text-[14px] leading-[1.65]`,children:(0,O.jsx)(wq,{content:e.content})}):null}function rJ({message:e,isStreaming:t,onRespondToApproval:n,onRespondToAguiApproval:r,interactionRecords:i,className:a}){let o=e.blocks??[];return(0,O.jsx)(`div`,{className:K(`mb-3 min-w-0`,a),"data-slot":`processing-blocks`,children:o.map(a=>{if(a.type===`thinking`)return(0,O.jsx)(Yq,{block:a},a.id);if(a.type===`tool`){let o=a.extra||{},s=String(o.approvalRequestId||e.tools?.[a.toolName]?.approvalRequestId||``),c=String(o.callId||o.call_id||``),l=s?i?.find(e=>e.interactionId===s):c?i?.find(e=>String(e.extensions.call_id||``)===c):void 0;return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(Xq,{block:a,tool:e.tools?.[a.toolName],isStreaming:t,interactionRecord:l,onRespondToApproval:n,onRespondToAguiApproval:r}),l?(0,O.jsx)(qq,{interaction:l}):null]},a.id)}return(0,O.jsx)(nJ,{block:a},a.id)})})}function iJ({onRetry:e}){let t=k(e=>e.banner);if(!t)return null;let n=t.kind===`rate_limited`?(0,O.jsx)(aJ,{message:t.message,retryAfterSec:t.retryAfterSec},t.createdAt||`${t.sessionId||``}:${t.retryAfterSec||0}`):null,r={rate_limited:{icon:(0,O.jsx)(lP,{className:`h-4 w-4 text-neutral-500`}),bg:`border-neutral-200/70 bg-neutral-50/70 dark:border-neutral-900/40 dark:bg-neutral-950/20`,text:`text-neutral-700 dark:text-neutral-200`,label:n},network:{icon:(0,O.jsx)(MN,{className:`h-4 w-4 animate-spin text-text-secondary`}),bg:`border-border/70 bg-muted/60`,text:`text-text-secondary`,label:t.message||`网络异常,正在重连…`},error:{icon:(0,O.jsx)(oP,{className:`h-4 w-4 text-rose-500`}),bg:`border-rose-200/70 bg-rose-50/70 dark:border-rose-900/40 dark:bg-rose-950/20`,text:`text-rose-600 dark:text-rose-300`,label:t.message||`运行失败,请重试`}}[t.kind];return(0,O.jsxs)(`div`,{className:K(`mx-auto mb-3 flex w-full max-w-3xl items-center gap-2.5 rounded-xl border px-3.5 py-2.5 text-sm shadow-sm`,r.bg,r.text),role:`status`,children:[r.icon,(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.label}),t.kind===`error`&&e?(0,O.jsxs)(`button`,{type:`button`,onClick:e,className:`flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium text-rose-600 transition hover:bg-rose-100 dark:text-rose-300 dark:hover:bg-rose-950/40`,children:[(0,O.jsx)(qN,{className:`h-3 w-3`}),`重试`]}):null]})}function aJ({message:e,retryAfterSec:t}){let[n,r]=(0,v.useState)(t||0);return(0,v.useEffect)(()=>{if(!t)return;let e=setInterval(()=>{r(e=>e>0?e-1:0)},1e3);return()=>clearInterval(e)},[t]),n>0?`${e}(${n}s 后可重试)`:e}async function oJ(e,t=globalThis){let n=String(e??``),r=t?.navigator;if(r?.clipboard?.writeText)try{return await r.clipboard.writeText(n),!0}catch{}let i=t?.document,a=i?.body;if(!i?.createElement||!a?.appendChild||!a?.removeChild)return!1;let o=i.createElement(`textarea`);o.value=n,o.setAttribute?.(`readonly`,``),o.style&&(o.style.position=`fixed`,o.style.top=`0`,o.style.left=`-9999px`,o.style.opacity=`0`,o.style.pointerEvents=`none`);let s=i.activeElement;a.appendChild(o),o.focus?.(),o.select?.(),o.setSelectionRange?.(0,n.length);try{return typeof i.execCommand==`function`?!!i.execCommand(`copy`):!1}finally{a.removeChild(o),s?.focus?.()}}function sJ(e,t,n){return Math.max(t,Math.min(n,e))}function cJ({items:e=[],scrollTop:t=0,viewportHeight:n=0,overscan:r=4,defaultItemHeight:i=120,measuredHeights:a=new Map,getItemKey:o=(e,t)=>e?.id||String(t)}={}){let s=Math.max(0,Number(n)||0),c=Math.max(0,Number(t)||0),l=Math.max(0,Number(r)||0),u=Math.max(1,Number(i)||120);if(!e.length)return{startIndex:0,endIndex:0,offsetTop:0,totalHeight:0,visibleItems:[]};let d=e.map((e,t)=>{let n=o(e,t),r=Number(a.get(n));return Number.isFinite(r)&&r>0?r:u}),f=Array(e.length),p=0;for(let t=0;t<e.length;t+=1)f[t]=p,p+=d[t];let m=p,h=c+s,g=0;for(;g<e.length&&f[g]+d[g]<=c;)g+=1;let _=g;for(;_<e.length&&f[_]<h;)_+=1;return g=sJ(g-l,0,e.length),_=sJ(Math.max(g+1,_+l),0,e.length),{startIndex:g,endIndex:_,offsetTop:f[g]||0,totalHeight:m,visibleItems:e.slice(g,_).map((e,t)=>{let n=g+t;return{index:n,item:e,top:f[n]||0,height:d[n]||u}})}}function lJ({scrollHeight:e,scrollTop:t,clientHeight:n}){return Math.max(0,e-t-n)}function uJ(e){return e.scrollHeight>e.clientHeight+1&&lJ(e)>96}function dJ(e){return String(e?.runId||e?.invocationId||``).trim()}function fJ(e,t){if(e?.role!==`model`||t.role!==`model`)return!1;let n=dJ(e);return!!(n&&n===dJ(t))}var pJ=140,mJ=4;function hJ(e){let t=String(e||``).trim().toLowerCase();return t===`elevated`?`高风险`:t===`always`?`始终确认`:t===`confirm`?`需确认`:e||``}function gJ(e){return String(e||``).trim().toLowerCase()===`elevated`?`border-[var(--ksadk-approval-elevated-border)] bg-[var(--ksadk-approval-elevated-background)] text-[var(--ksadk-approval-elevated-foreground)]`:`border-[var(--ksadk-approval-border)] bg-[var(--ksadk-approval-background)] text-[var(--ksadk-approval-foreground)]`}function _J({messageId:e,top:t,onMeasure:n,children:r}){let i=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let r=i.current;if(!r)return;let a=()=>n(e,r.offsetHeight,t);if(a(),typeof ResizeObserver>`u`)return;let o=new ResizeObserver(a);return o.observe(r),()=>o.disconnect()},[e,n,t]),(0,O.jsx)(`div`,{ref:i,style:{position:`absolute`,top:t,left:0,right:0},children:r})}function vJ({agentName:e}){return(0,O.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[50vh] px-4`,children:[(0,O.jsx)(`div`,{className:`mb-6 h-16 w-16 rounded-2xl bg-gradient-to-br from-blue-500 to-indigo-600
|
|
200
|
-
flex items-center justify-center shadow-lg shadow-blue-500/20`,children:(0,O.jsx)(dN,{className:`h-8 w-8 text-white`})}),(0,O.jsx)(`h2`,{className:`text-xl font-semibold text-slate-900 dark:text-slate-50`,children:`有什么我可以帮您的吗?`}),(0,O.jsxs)(`p`,{className:`mt-2 text-sm text-slate-500`,children:[`我是 `,e,`,由 Ksyun AgentEngine 驱动`]})]})}function yJ(){return(0,O.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[44rem] flex-col gap-5 px-2 py-8`,"aria-label":`正在加载会话历史`,children:[(0,O.jsx)(`div`,{className:`h-4 w-28 animate-pulse rounded bg-slate-200/80 dark:bg-slate-800`}),(0,O.jsx)(`div`,{className:`h-20 w-4/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,O.jsx)(`div`,{className:`ml-auto h-12 w-3/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,O.jsx)(`div`,{className:`h-16 w-11/12 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`})]})}function bJ({attachments:e,isMobile:t,onOpenAttachmentPreview:n}){return(0,O.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-3`,children:e.map((e,r)=>e.type.startsWith(`image/`)?e.url?(0,O.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:K(`group relative overflow-hidden rounded-xl border border-slate-200 shadow-sm dark:border-slate-700`,t?`w-full max-w-full`:`max-w-[200px]`),children:(0,O.jsx)(`img`,{src:e.url,alt:e.name,className:K(`object-cover transition group-hover:scale-[1.02]`,t?`max-h-[16rem] w-full max-w-full`:`max-h-[200px] max-w-[200px]`)})},`${e.name}-${r}`):(0,O.jsx)(`div`,{className:K(`flex items-center justify-center rounded-xl border border-dashed border-slate-300 bg-slate-50 px-4 text-sm text-slate-500 dark:border-slate-700 dark:bg-slate-900/40 dark:text-slate-400`,t?`h-28 w-full`:`h-[120px] w-[200px]`),children:e.name},`${e.name}-${r}`):(0,O.jsxs)(`div`,{className:K(`flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-2 shadow-sm dark:border-slate-700 dark:bg-slate-800`,t?`w-full max-w-full`:`w-max max-w-full`),children:[(0,O.jsx)(VN,{className:`h-4 w-4 flex-shrink-0 text-blue-500`}),e.url?(0,O.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`truncate text-sm text-slate-700 hover:underline dark:text-slate-300`,title:e.name,children:e.name}):(0,O.jsx)(`span`,{className:`truncate text-sm text-slate-700 dark:text-slate-300`,title:e.name,children:e.name})]},`${e.name}-${r}`))})}function xJ({message:e}){return(0,O.jsx)(`div`,{className:`w-full px-0 py-2 sm:px-4`,children:(0,O.jsxs)(`div`,{className:`mx-auto max-w-3xl rounded-xl border border-neutral-200/70 bg-neutral-50/60 px-4 py-3 text-sm text-neutral-600 dark:border-neutral-800 dark:bg-neutral-900/40 dark:text-neutral-300`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`running`?(0,O.jsx)(KN,{className:`h-4 w-4 animate-spin text-neutral-600 dark:text-neutral-300`}):e.status===`failed`?(0,O.jsx)(gN,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,O.jsx)(fN,{className:`h-4 w-4 text-emerald-600 dark:text-emerald-400`}),(0,O.jsx)(`span`,{children:e.content})]}),e.compactedUntilSeqId?(0,O.jsxs)(`div`,{className:`mt-1 text-xs text-neutral-700/80 dark:text-neutral-200/80`,children:[`已折叠到会话事件 #`,e.compactedUntilSeqId]}):null,e.summary?(0,O.jsxs)(`details`,{className:`mt-3 rounded-xl border border-neutral-200/80 bg-white/70 px-3 py-2 dark:border-neutral-900/60 dark:bg-slate-950/40`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-neutral-800 dark:text-neutral-200`,children:`查看压缩摘要`}),(0,O.jsx)(`div`,{className:`mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200`,children:(0,O.jsx)(wq,{content:e.summary})})]}):null]})})}function SJ({label:e,tone:t,value:n}){let[r,i]=(0,v.useState)(`idle`),a=kA(n);(0,v.useEffect)(()=>{if(r===`idle`)return;let e=window.setTimeout(()=>i(`idle`),1600);return()=>window.clearTimeout(e)},[r]);let o=async()=>{i(await oJ(a)?`copied`:`failed`)};return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,O.jsx)(`div`,{className:K(`text-xs font-semibold uppercase`,t===`input`?`text-blue-500`:t===`error`?`text-rose-500`:`text-emerald-500`),children:e}),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{o()},className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[11px] font-medium text-slate-500 transition hover:bg-white hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,children:[r===`copied`?(0,O.jsx)(fN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,O.jsx)(yN,{className:`h-3.5 w-3.5`}),r===`copied`?`已复制`:r===`failed`?`复制失败`:`复制`]})]}),(0,O.jsx)(`div`,{className:`custom-scrollbar max-h-[220px] overflow-y-auto whitespace-pre-wrap break-words rounded-xl border border-slate-200/30 bg-white/70 p-3 text-slate-600 shadow-sm dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 sm:max-h-[300px]`,children:a})]})}function CJ({isLastMessage:e,isStreaming:t,message:n,onDeleteFeedback:r,onSubmitFeedback:i,alwaysVisible:a=!1}){let[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(n.feedback?.comment||``),u=sM(n,t,e),d=!!n.feedback?.pending,f=n.feedback?.rating,p=async()=>{let e=n.content||``;e&&oJ(e)};return u?(0,O.jsxs)(`div`,{className:K(`mt-2 flex flex-col gap-2 transition-opacity duration-150 focus-within:opacity-100`,a?`opacity-100`:`opacity-0 group-hover:opacity-100`),children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-text-muted`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>{p()},className:`inline-flex items-center gap-1 rounded-full px-2 py-1 font-medium text-text-secondary transition hover:bg-muted hover:text-text-primary`,title:`复制`,children:(0,O.jsx)(yN,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`span`,{className:`text-text-muted/60`,children:`·`}),(0,O.jsx)(`span`,{className:`font-medium`,children:`本次回复有帮助吗?`}),(0,O.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>i({message:n,rating:`up`,comment:``}),className:K(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,f===`up`?`border-primary/30 bg-primary/10 text-primary`:`border-border bg-background text-text-secondary hover:border-primary/30 hover:text-primary`),children:[(0,O.jsx)(rP,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,O.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>{l(n.feedback?.comment||``),s(e=>!e)},className:K(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,f===`down`?`border-rose-300 bg-rose-50 text-rose-600 dark:border-rose-900/70 dark:bg-rose-950/30 dark:text-rose-300`:`border-border bg-background text-text-secondary hover:border-rose-300 hover:text-rose-600`),children:[(0,O.jsx)(nP,{className:`h-3.5 w-3.5`}),`需改进`]}),n.feedback?(0,O.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>r(n),className:`inline-flex items-center gap-1 rounded-full border border-transparent px-2 py-1 font-medium text-slate-400 transition hover:border-slate-200 hover:text-slate-700 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:border-slate-800 dark:hover:text-slate-200`,children:[(0,O.jsx)(iP,{className:`h-3.5 w-3.5`}),`删除反馈`]}):null,d?(0,O.jsx)(`span`,{className:`text-slate-400`,children:`提交中…`}):null]}),o?(0,O.jsxs)(`div`,{className:`max-w-xl rounded-2xl border border-rose-100 bg-rose-50/60 p-3 shadow-sm dark:border-rose-900/60 dark:bg-rose-950/20`,children:[(0,O.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:`可以补充哪里不准确、缺失或不符合预期。`,className:`min-h-[84px] w-full resize-y rounded-xl border border-rose-100 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition placeholder:text-slate-400 focus:border-rose-300 focus:ring-2 focus:ring-rose-100 dark:border-rose-900/70 dark:bg-slate-950 dark:text-slate-100 dark:focus:border-rose-700 dark:focus:ring-rose-950`}),(0,O.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded-xl px-3 py-1.5 text-xs font-semibold text-slate-500 transition hover:bg-white hover:text-slate-800 dark:text-slate-400 dark:hover:bg-slate-950 dark:hover:text-slate-100`,children:`取消`}),(0,O.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>{i({message:n,rating:`down`,comment:c}),s(!1)},className:`rounded-xl bg-rose-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-rose-500 disabled:cursor-not-allowed disabled:opacity-60`,children:`提交点踩`})]})]}):f===`down`&&n.feedback?.comment?(0,O.jsxs)(`div`,{className:`max-w-xl rounded-xl border border-rose-100 bg-rose-50/50 px-3 py-2 text-xs text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-200`,children:[`反馈:`,n.feedback.comment]}):null,n.feedback?.error?(0,O.jsx)(`div`,{className:`text-xs text-rose-600 dark:text-rose-300`,children:n.feedback.error}):null]}):null}function wJ({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,showAgentHeader:i,message:a,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onRespondToAguiApproval:l,onSubmitFeedback:u,onSubmitAguiAction:d,interactionRecords:f}){if(a.role===`user`)return(0,O.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,O.jsxs)(`div`,{className:`max-w-[80%] rounded-2xl bg-muted px-3 py-2 text-[14px] leading-relaxed text-foreground`,children:[a.attachments?.length?(0,O.jsx)(bJ,{attachments:a.attachments,isMobile:t,onOpenAttachmentPreview:s}):null,a.content]})});if(a.role===`a2ui`&&a.aguiActivity)return(0,O.jsx)(Nq,{surfaceId:a.aguiActivity.surfaceId,messages:a.aguiActivity.messages,onAction:d});let p=n&&r&&!a.content;return(0,O.jsxs)(`div`,{className:`group mx-auto mb-3 w-full max-w-[60rem] px-2 sm:px-4`,children:[i?(0,O.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs text-text-muted`,children:[(0,O.jsx)(dN,{className:`w-3.5 h-3.5`}),(0,O.jsx)(`span`,{children:e})]}):null,a.attachments?.length?(0,O.jsx)(bJ,{attachments:a.attachments,isMobile:t,onOpenAttachmentPreview:s}):null,a.blocks?.length?(0,O.jsx)(rJ,{message:a,isStreaming:n,onRespondToApproval:c,interactionRecords:f,onRespondToAguiApproval:l}):(0,O.jsxs)(O.Fragment,{children:[a.reasoning?(0,O.jsxs)(`details`,{className:`group/details mb-3 overflow-hidden rounded-md border border-slate-200/80 bg-slate-50/60 text-sm text-slate-600 transition-colors open:bg-white dark:border-slate-700/80 dark:bg-slate-900/40 dark:text-slate-300 dark:open:bg-slate-950/30`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 font-medium outline-none marker:hidden`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[p?null:(0,O.jsx)(fN,{className:`h-4 w-4 text-slate-400`}),(0,O.jsx)(`span`,{className:K(`truncate`,p&&`waiting-thinking-text`),"data-testid":p?`legacy-thinking-indicator`:void 0,role:p?`status`:void 0,children:p?`正在思考…`:`思考过程`}),p?null:(0,O.jsx)(`span`,{className:`rounded-full bg-slate-200/70 px-2 py-0.5 text-[11px] font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300`,children:`已完成`})]}),(0,O.jsx)(pN,{className:`h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180`})]}),(0,O.jsx)(`div`,{className:`border-t border-slate-200/70 bg-white/70 dark:border-slate-800 dark:bg-slate-950/20`,children:(0,O.jsx)(`div`,{className:`custom-scrollbar max-h-[min(46vh,28rem)] overflow-y-auto px-4 py-3 text-[14px] leading-7 text-slate-600 dark:text-slate-300 [&_p]:my-2 [&_pre]:my-2`,children:(0,O.jsx)(wq,{content:a.reasoning})})})]}):null,a.tools?Object.values(a.tools).map((e,t)=>(0,O.jsxs)(`details`,{open:e.approvalStatus===`pending`||e.status===`paused`?!0:void 0,className:K(`group/details mb-2 overflow-hidden rounded-md border text-sm transition-colors`,e.status===`paused`?`border-neutral-200/80 bg-neutral-50/25 text-slate-700 dark:border-neutral-900/60 dark:bg-neutral-950/10 dark:text-slate-200`:e.status===`error`?`border-rose-200/80 bg-rose-50/25 text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/10 dark:text-rose-200`:`border-slate-200/80 bg-slate-50/40 text-slate-600 dark:border-slate-700/80 dark:bg-slate-900/30 dark:text-slate-300`),children:[(0,O.jsx)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-3 py-2 font-medium`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`running`?(0,O.jsx)(KN,{className:`h-4 w-4 animate-spin text-slate-500`}):e.status===`paused`?(0,O.jsx)(ZN,{className:`h-4 w-4 text-neutral-500`}):e.status===`error`?(0,O.jsx)(_N,{className:`h-4 w-4 text-rose-500`}):(0,O.jsx)(fN,{className:`h-4 w-4 text-slate-400`}),(0,O.jsxs)(`span`,{children:[e.approvalStatus===`pending`?`等待审批:`:e.approvalStatus===`approved`?`已批准:`:e.approvalStatus===`rejected`?`已拒绝:`:e.approvalStatus===`cancelled`?`已取消:`:e.status===`error`?`工具调用失败:`:`工具调用:`,e.name]})]})}),(0,O.jsxs)(`div`,{className:K(`flex flex-col gap-3 border-t px-3 py-3 font-mono text-[13px] leading-relaxed`,e.status===`paused`?`border-neutral-200/70 dark:border-neutral-900/60`:e.status===`error`?`border-rose-200/70 dark:border-rose-900/60`:`border-slate-200/70 dark:border-slate-800`),children:[e.approvalRequestId?(0,O.jsxs)(`div`,{className:`font-sans text-sm text-slate-700 dark:text-slate-200`,children:[(0,O.jsx)(`div`,{className:`font-medium`,children:e.approvalStatus===`approved`?`已批准该工具调用。`:e.approvalStatus===`rejected`?`已拒绝该工具调用。`:e.approvalStatus===`cancelled`?`已取消该工具调用。`:e.approvalMessage||`该工具调用需要人工确认后继续。`}),e.approvalLevel?(0,O.jsxs)(`div`,{className:K(`mt-2 inline-flex items-center rounded border px-1.5 py-0.5 text-xs font-medium`,gJ(e.approvalLevel)),children:[`审批级别:`,hJ(e.approvalLevel)]}):null,e.serverLabel?(0,O.jsxs)(`div`,{className:`mt-1 text-xs text-neutral-700/80 dark:text-neutral-200/80`,children:[`MCP Server: `,e.serverLabel]}):null,e.approvalStatus===`pending`?(0,O.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,O.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?l?.({interruptId:e.approvalRequestId||``,approve:!0}):c({approvalRequestId:e.approvalRequestId||``,approve:!0,previousResponseId:e.previousResponseId}),className:`inline-flex min-h-8 items-center gap-1.5 rounded-md bg-emerald-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,O.jsx)(fN,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,O.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?l?.({interruptId:e.approvalRequestId||``,approve:!1}):c({approvalRequestId:e.approvalRequestId||``,approve:!1,previousResponseId:e.previousResponseId}),className:`inline-flex min-h-8 items-center gap-1.5 rounded-md border border-slate-300 bg-white px-3 py-1.5 text-xs font-semibold text-slate-600 transition hover:border-rose-300 hover:bg-rose-50 hover:text-rose-600 disabled:cursor-not-allowed disabled:opacity-55 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-300 dark:hover:border-rose-800 dark:hover:bg-rose-950/30 dark:hover:text-rose-300`,children:[(0,O.jsx)(_N,{className:`h-3.5 w-3.5`}),`拒绝`]})]}):(0,O.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-slate-500 dark:text-slate-400`,children:[e.approvalStatus===`approved`?(0,O.jsx)(fN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,O.jsx)(_N,{className:`h-3.5 w-3.5 text-rose-500`}),e.approvalStatus===`approved`?`已批准`:e.approvalStatus===`cancelled`?`已取消`:`已拒绝`]})]}):null,e.args?(0,O.jsx)(SJ,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,O.jsx)(SJ,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,a.tools?Object.values(a.tools).filter(e=>f?.some(t=>t.interactionId===e.approvalRequestId)).map(e=>(0,O.jsx)(qq,{interaction:f.find(t=>t.interactionId===e.approvalRequestId)},`anchor-${e.approvalRequestId}`)):null,(0,O.jsx)(`div`,{className:`w-full break-words`,children:a.content?(0,O.jsx)(wq,{content:a.content}):n&&r&&!a.reasoning&&!a.tools||a.eventType===`optimistic_assistant_placeholder`?(0,O.jsx)(`span`,{className:`relative mt-1 inline-flex h-4 w-4 items-center justify-center`,role:`status`,"aria-label":`正在生成`,children:(0,O.jsx)(`span`,{className:`waiting-generation-breathe h-2.5 w-2.5 rounded-full`})}):null})]}),a.aguiActivities?.map(e=>(0,O.jsx)(Nq,{surfaceId:e.surfaceId,messages:e.messages,onAction:d},e.surfaceId)),(0,O.jsx)(CJ,{isLastMessage:r,isStreaming:n,message:a,onDeleteFeedback:o,onSubmitFeedback:u})]})}function TJ({agentName:e,emptyState:t,isMobile:n,isStreaming:r,activity:i,contextIndicator:a,messages:o,isLoadingInitialHistory:s=!1,onDeleteFeedback:c,onOpenAttachmentPreview:l,onRespondToApproval:u,onRespondToAguiApproval:d,onSubmitFeedback:f,onSubmitAguiAction:p,onStopGeneration:m,onCancelRemote:h,onScrollToBottom:g,checkpoints:_=[],onResumeCheckpoint:y,interactionRecords:b,scrollRef:x,className:S}){let[ee,C]=(0,v.useState)(0),[w,te]=(0,v.useState)(0),[ne,T]=(0,v.useState)(0),[re,ie]=(0,v.useState)(new Map),ae=(0,v.useRef)(re);(0,v.useLayoutEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{C(e.scrollTop),te(e.clientHeight),T(e.scrollHeight)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>t());return n.observe(e),e.firstElementChild instanceof HTMLElement&&n.observe(e.firstElementChild),()=>n.disconnect()},[x]);let oe=(0,v.useMemo)(()=>cJ({items:o,scrollTop:ee,viewportHeight:w,overscan:mJ,defaultItemHeight:pJ,measuredHeights:re,getItemKey:(e,t)=>e?.id||String(t)}),[re,o,ee,w]),se=oe.visibleItems,ce=(0,v.useCallback)((e,t,n)=>{if(!e||!Number.isFinite(t)||t<=0)return;let r=ae.current,i=r.get(e)??pJ;if(i===t)return;let a=new Map(r);a.set(e,t),ae.current=a,ie(a);let o=x.current;o&&n<o.scrollTop&&(o.scrollTop+=t-i,C(o.scrollTop),T(o.scrollHeight))},[x]),le=lJ({scrollHeight:ne,scrollTop:ee,clientHeight:w}),E=uJ({scrollHeight:ne,scrollTop:ee,clientHeight:w});return(0,O.jsxs)(`div`,{ref:x,onScroll:e=>{C(e.currentTarget.scrollTop),te(e.currentTarget.clientHeight),T(e.currentTarget.scrollHeight)},className:K(`custom-scrollbar relative min-h-0 flex-1 overflow-y-auto scroll-smooth`,n?`px-3 py-3`:`px-4 py-5`,S),"data-slot":`message-list`,children:[(0,O.jsx)(`div`,{className:`mx-auto flex w-full max-w-[64rem] flex-col pb-6 sm:pb-8`,children:o.length===0&&s?(0,O.jsx)(yJ,{}):o.length===0?t===void 0?(0,O.jsx)(vJ,{agentName:e}):t:(0,O.jsx)(`div`,{style:{height:oe.totalHeight},className:`relative`,children:se.map(t=>(0,O.jsx)(_J,{messageId:t.item.id||String(t.index),top:t.top,onMeasure:ce,children:t.item.role===`system`?(0,O.jsx)(xJ,{message:t.item}):(0,O.jsx)(wJ,{agentName:e,isMobile:n,isStreaming:r,isLastMessage:t.index===o.length-1,showAgentHeader:!fJ(o[t.index-1],t.item),message:t.item,onDeleteFeedback:c,onOpenAttachmentPreview:l,onRespondToApproval:u,interactionRecords:b,onRespondToAguiApproval:d,onSubmitFeedback:f,onSubmitAguiAction:p})},t.item.id||t.index))})}),(0,O.jsx)(iJ,{}),E?(0,O.jsx)(`button`,{type:`button`,"aria-label":`回到底部`,"data-distance-from-bottom":Math.round(le),onClick:()=>{if(g){g();return}let e=x.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`auto`})},className:`sticky bottom-4 left-1/2 z-20 mx-auto flex h-9 w-9 -translate-x-1/2 items-center justify-center rounded-full border border-border bg-surface text-text-secondary shadow-[0_8px_24px_rgba(15,23,42,0.12)] transition hover:text-text-primary`,title:`回到底部`,children:r?(0,O.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center gap-0.5`,"data-scroll-indicator":`streaming`,children:[0,1,2].map(e=>(0,O.jsx)(`span`,{className:`h-1 w-1 animate-bounce rounded-full bg-current motion-reduce:animate-none`,style:{animationDelay:`${e*120}ms`}},e))}):(0,O.jsx)(pN,{"aria-hidden":`true`,className:`h-5 w-5`,"data-scroll-indicator":`idle`})}):null]})}var EJ=RR,DJ=zR,OJ=v.forwardRef(({className:e,...t},n)=>(0,O.jsx)(BR,{ref:n,className:K(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));OJ.displayName=BR.displayName;var kJ=v.forwardRef(({className:e,children:t,...n},r)=>(0,O.jsxs)(DJ,{children:[(0,O.jsx)(OJ,{}),(0,O.jsxs)(VR,{ref:r,className:K(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...n,children:[t,(0,O.jsxs)(WR,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground`,children:[(0,O.jsx)(cP,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));kJ.displayName=VR.displayName;var AJ=({className:e,...t})=>(0,O.jsx)(`div`,{className:K(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});AJ.displayName=`DialogHeader`;var jJ=({className:e,...t})=>(0,O.jsx)(`div`,{className:K(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});jJ.displayName=`DialogFooter`;var MJ=v.forwardRef(({className:e,...t},n)=>(0,O.jsx)(HR,{ref:n,className:K(`text-lg font-semibold leading-none tracking-tight`,e),...t}));MJ.displayName=HR.displayName;var NJ=v.forwardRef(({className:e,...t},n)=>(0,O.jsx)(UR,{ref:n,className:K(`text-sm text-muted-foreground`,e),...t}));NJ.displayName=UR.displayName;function PJ(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function FJ(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function IJ({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,O.jsx)(EJ,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,O.jsxs)(kJ,{className:K(`gap-0 overflow-hidden border-slate-700 bg-slate-950 p-0 text-slate-100 shadow-2xl [&>button]:right-3 [&>button]:top-3 [&>button]:rounded-md [&>button]:border [&>button]:border-slate-700 [&>button]:bg-slate-900/70 [&>button]:p-1.5 [&>button]:text-slate-200 [&>button]:opacity-100`,t?`left-0 top-0 h-[var(--app-height)] max-h-[var(--app-height)] w-screen max-w-none translate-x-0 translate-y-0 rounded-none border-0`:`max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] rounded-2xl`),style:FJ(t,n),children:[(0,O.jsx)(`div`,{className:`flex items-center gap-3 border-b border-slate-800 px-4 py-3 pr-16`,children:(0,O.jsx)(MJ,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,O.jsx)(`div`,{className:K(`flex items-center justify-center overflow-auto bg-slate-950`,t?`h-full p-4 pb-[calc(var(--safe-area-bottom)+1rem)]`:`max-h-[calc(100vh-7rem)] p-4`),children:e?e.type.startsWith(`image/`)?(0,O.jsx)(`img`,{src:e.url,alt:e.name,className:K(`object-contain`,t?`h-auto max-h-full w-full max-w-full`:`h-auto w-auto max-h-[calc(100vh-9rem)] max-w-[calc(100vw-5rem)]`),style:PJ(t,n),onLoad:e=>{let t=e.currentTarget;i({width:t.naturalWidth,height:t.naturalHeight})}}):(0,O.jsx)(`iframe`,{src:e.url,title:e.name,className:`h-full min-h-[24rem] w-full rounded-xl border border-slate-800 bg-white`}):null})]})})}function LJ(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>0)return t}return null}function RJ(e){return e?LJ(e.context_window_tokens)??LJ(e?.limits?.context_window_tokens):null}function zJ(e){return e?LJ(e.auto_compact_threshold_percentage)??84:84}function BJ({selectedModel:e,contextUsage:t}){let n=t&&(!t.model||t.model===e?.id)?t:null,r=LJ(n?.used_tokens),i=LJ(n?.context_window_tokens),a=i??RJ(e),o={contextWindowTokens:a??void 0,contextWindowSource:a?i?`runtime`:`model`:void 0},s=n?.source===`last_request`?`上次请求输入`:`上下文占用`;if(!r)return{label:`上下文用量暂不可用`,phase:`default`,...o};let c=a?Math.round(r/a*100):void 0;return{label:s,phase:c!==void 0&&c>=zJ(e)?`warning`:`normal`,percent:c,usedTokens:r,...o}}function VJ(e){return e.requestedSessionId===e.activeSessionId&&e.requestToken===e.activeRequestToken}function HJ({agentName:e,emptyState:t,isMobile:n,onDeleteFeedback:r,onSubmitFeedback:i,onRespondToApproval:a,onRespondToAguiApproval:o,onSubmitAguiAction:s,onStopGeneration:c,onCancelRemote:l,checkpointResumeEnabled:u=!1,onResumeCheckpoint:d,onLoadOlderSessionMessages:f,interactionRecords:p,className:m}){let h=Qc(e=>e.messages),g=E(e=>e.currentSessionId),_=E(e=>e.isLoadingSessions),y=k(e=>!!(e.getSessionActivity(g)&&e.isSessionStreaming(g))),b=k(e=>e.getSessionActivity(g)),x=kj(e=>e.getSessionCheckpoints(g)),S=E(e=>g?e.messageHistory[g]:null),ee=_||!!S?.isLoadingInitial,C=ve(e=>e.input),w=We(e=>e.availableModels),te=We(e=>e.selectedModel),ne=ve(e=>e.previewAttachment),T=ve(e=>e.previewImageSize),re=(0,v.useRef)(null),ie=(0,v.useRef)(!0),ae=(0,v.useRef)(!1),oe=(0,v.useRef)(0),se=(0,v.useRef)(y),ce=(0,v.useRef)(!1),le=(0,v.useRef)(null),D=(0,v.useRef)(!0),ue=(0,v.useRef)(``),de=(0,v.useMemo)(()=>w.find(e=>e.id===te)||null,[w,te]),fe=(0,v.useMemo)(()=>BJ({messages:h,draftInput:C,selectedModel:de}),[C,h,de]),pe=(0,v.useCallback)(()=>{let e=re.current;if(!e)return;ie.current=!0,ae.current=!1;let t=e.style.scrollBehavior;e.style.scrollBehavior=`auto`;let n=0,r=0,i=-1,a=()=>{if(re.current===e){if(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)),r=e.scrollHeight===i?r+1:0,i=e.scrollHeight,n+=1,r>=3||n>=12){e.style.scrollBehavior=t;return}requestAnimationFrame(a)}};a()},[]);return(0,v.useEffect)(()=>{se.current=y},[y]),(0,v.useEffect)(()=>{D.current=!0,ie.current=!0,ae.current=!1,oe.current=0,ce.current=!1,le.current=null,ue.current=``},[g]),(0,v.useEffect)(()=>{let e=h.at(-1),t=ue.current;ue.current=String(e?.id||``),e?.role===`user`&&e.id!==t&&!D.current&&pe()},[h,pe]),(0,v.useEffect)(()=>{let e=re.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<oe.current-2;if(oe.current=e.scrollTop,!D.current&&n&&e.scrollTop<200&&g&&S?.hasMore&&!S.isLoadingOlder&&!ce.current&&f){let t=e.scrollHeight,n=g,r=Symbol(n);ce.current=!0,le.current=r,f(n).then(()=>{VJ({requestedSessionId:n,activeSessionId:E.getState().currentSessionId,requestToken:r,activeRequestToken:le.current})&&requestAnimationFrame(()=>{if(!VJ({requestedSessionId:n,activeSessionId:E.getState().currentSessionId,requestToken:r,activeRequestToken:le.current}))return;let e=re.current;if(!e)return;let i=e.scrollHeight-t;e.scrollTop+=i,oe.current=e.scrollTop})}).finally(()=>{le.current===r&&(le.current=null,ce.current=!1)})}if(se.current&&n){ae.current=!0,ie.current=!1;return}if(ae.current){let e=t<=12;ae.current=!e,ie.current=e;return}ie.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[S,g,f]),(0,v.useEffect)(()=>{let e=re.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{!D.current&&!ie.current||(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))});return t.observe(e),e.firstElementChild instanceof HTMLElement&&t.observe(e.firstElementChild),()=>t.disconnect()},[g]),(0,v.useEffect)(()=>{let e=re.current;if(e){if(h.length>0&&D.current){let e=E.getState().currentSessionId,t=re.current,n=t?t.style.scrollBehavior:``;t&&(t.style.scrollBehavior=`auto`,t.scrollTop=t.scrollHeight,oe.current=t.scrollTop);let r=0,i=t?.scrollHeight??-1,a=!1,o=0,s=()=>{let e=re.current;e&&(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))},c=()=>{a||(a=!0,s(),t&&(t.style.scrollBehavior=n),ie.current=!0,ae.current=!1,D.current=!1)},l=()=>{if(a)return;if(E.getState().currentSessionId!==e){a=!0;return}let t=re.current;if(t){if(t.scrollHeight!==i)i=t.scrollHeight,s(),r=0;else if(r+=1,r>=3){c();return}o=requestAnimationFrame(l)}},u=window.setTimeout(c,2e3);return o=requestAnimationFrame(l),()=>{if(cancelAnimationFrame(o),window.clearTimeout(u),E.getState().currentSessionId!==e){c();return}t&&(t.style.scrollBehavior=n)}}ie.current&&(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop)}},[h,y]),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(TJ,{emptyState:t,agentName:e,isMobile:n,isStreaming:y,activity:b,contextIndicator:fe,messages:h,isLoadingInitialHistory:ee,onDeleteFeedback:r,onOpenAttachmentPreview:e=>{ve.getState().setPreviewAttachment(e),ve.getState().setPreviewImageSize(null)},onRespondToApproval:a,onRespondToAguiApproval:o,interactionRecords:p,onScrollToBottom:pe,onSubmitFeedback:i,onSubmitAguiAction:s,onStopGeneration:c,onCancelRemote:l,checkpoints:u?x:[],onResumeCheckpoint:d,scrollRef:re,className:m}),(0,O.jsx)(IJ,{attachment:ne,isMobile:n,previewImageSize:T,onClose:()=>{ve.getState().setPreviewAttachment(null),ve.getState().setPreviewImageSize(null)},onImageLoad:e=>ve.getState().setPreviewImageSize(e)})]})}function UJ({indicator:e,onCompact:t,disabled:n}){let r=(0,v.useRef)(null),[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!i)return;let e=e=>{e.target instanceof Node&&!r.current?.contains(e.target)&&(o.current=!1,a(!1))},t=e=>{e.key===`Escape`&&(o.current=!1,a(!1),r.current?.querySelector(`button`)?.focus())};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,t)}},[i]);let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),d=typeof e.usedTokens==`number`&&Number.isFinite(e.usedTokens)&&e.usedTokens>=0,f=d&&typeof e.percent==`number`&&Number.isFinite(e.percent)?Math.max(0,Math.min(100,e.percent)):void 0,p=async()=>{if(!(!t||s||n)){c(!0),u(``);try{await t(),u(`上下文已压缩`)}catch(e){u(e instanceof Error?e.message:`压缩失败,请重试`)}finally{c(!1)}}};return(0,O.jsxs)(`div`,{ref:r,className:`relative flex h-8 w-8 items-center justify-center`,onPointerEnter:e=>{e.pointerType!==`touch`&&a(!0)},onPointerLeave:()=>{o.current||a(!1)},children:[(0,O.jsx)(`button`,{type:`button`,"aria-label":`上下文用量与压缩`,"aria-expanded":i,onClick:()=>{o.current=!o.current,a(o.current),u(``)},className:K(`flex h-8 w-8 items-center justify-center rounded-full`,e.phase===`warning`?`text-text-primary`:`text-text-muted`),children:(0,O.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,className:s?`animate-pulse`:void 0,style:{display:`block`,flexShrink:0},children:[(0,O.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`var(--ksadk-menu-border, #b8bcb5)`,strokeWidth:`2`}),f!==void 0&&(0,O.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,pathLength:`100`,strokeDasharray:`${f} 100`,transform:`rotate(-90 8 8)`})]})}),(0,O.jsxs)(`div`,{style:{background:`var(--ksadk-menu-background, hsl(var(--popover)))`,borderColor:`var(--ksadk-menu-border, hsl(var(--border)))`,boxShadow:`var(--ksadk-menu-shadow, 0 18px 44px rgba(15, 23, 42, 0.16))`},role:i?`dialog`:void 0,"aria-label":i?`上下文`:void 0,className:K(`absolute bottom-full right-0 z-30 w-60 rounded-xl border border-border bg-background p-4 text-sm text-foreground shadow-lg`,i?`block`:`hidden`),children:[(0,O.jsx)(`p`,{className:K(`font-medium`,s&&`waiting-thinking-text`),children:s?`正在压缩上下文…`:d?e.label:`上下文用量暂不可用`}),d&&(0,O.jsxs)(`p`,{className:`mt-1 text-text-secondary`,children:[`${WJ(e.usedTokens)} tokens`,e.contextWindowTokens?` / ${WJ(e.contextWindowTokens)}`:``]}),e.contextWindowTokens&&(0,O.jsxs)(`p`,{className:`mt-1 text-text-muted`,children:[`模型窗口:`,WJ(e.contextWindowTokens),` tokens`]}),d&&!e.contextWindowTokens&&(0,O.jsx)(`p`,{className:`mt-1 text-text-muted`,children:`模型窗口大小未报告`}),f!==void 0&&(0,O.jsxs)(`p`,{className:`text-text-muted`,children:[f,`% 已使用`]}),i&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>void p(),disabled:!t||s||n,className:`mt-3 w-full rounded-lg border border-border bg-muted px-3 py-2 disabled:opacity-50`,children:s?`正在压缩…`:`压缩上下文`}),(0,O.jsx)(`p`,{className:`mt-2 text-xs text-text-muted`,children:n?`请等待当前运行结束`:t?`压缩模型上下文,保留聊天记录`:`当前会话尚不支持手动压缩`}),l&&(0,O.jsx)(`p`,{role:`status`,className:`mt-2 text-xs`,children:l})]})]})]})}function WJ(e){return new Intl.NumberFormat(`zh-CN`).format(e)}var GJ=[{value:`plan`,label:`计划模式`,description:`先分析并形成可执行计划`,icon:jN},{value:`goal`,label:`设定目标`,description:`朝可验证的停止条件持续推进`,icon:tP}],KJ={plan:`计划模式`,goal:`目标`};function qJ({attachmentsEnabled:e,mode:t,support:n,onSelectMode:r,onUpload:i}){let[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(null),c=GJ.filter(e=>n[e.value]);return(0,v.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]),!e&&c.length===0?null:(0,O.jsxs)(`div`,{ref:s,className:`relative flex min-w-0 items-center gap-1`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-text-secondary transition hover:bg-muted hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,"aria-expanded":a,"aria-haspopup":`menu`,"aria-label":`添加附件或选择执行模式`,title:`添加附件或选择执行模式`,children:(0,O.jsx)(GN,{className:`h-[19px] w-[19px]`})}),t?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:K(`flex h-8 max-w-[8.5rem] items-center gap-1 rounded-xl px-2 text-[12px] transition`,t===`goal`?`bg-neutral-50 text-neutral-700 hover:bg-neutral-100 dark:bg-neutral-950/40 dark:text-neutral-300`:`text-text-secondary hover:bg-muted hover:text-text-primary`),"aria-label":`当前执行模式:${KJ[t]}`,children:[(0,O.jsx)(`span`,{className:`truncate`,children:KJ[t]}),(0,O.jsx)(pN,{className:`h-3.5 w-3.5 shrink-0`})]}):null,a?(0,O.jsxs)(`div`,{role:`menu`,"aria-label":`附件与执行模式`,className:`absolute bottom-[calc(100%+0.6rem)] left-0 z-40 w-[min(18rem,calc(100vw-2rem))] rounded-xl border border-border/80 bg-popover p-1 shadow-[0_10px_24px_rgba(15,23,42,0.12)]`,style:{backgroundColor:`var(--ksadk-popover, #fff)`,borderColor:`var(--ksadk-border, rgba(15, 23, 42, 0.12))`},children:[e?(0,O.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{i(),o(!1)},className:`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition hover:bg-muted/70`,children:[(0,O.jsx)(aP,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,O.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:`上传附件`}),(0,O.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:`添加文件或图片`})]}):null,c.map(e=>{let n=e.icon,i=t===e.value;return(0,O.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":i,onClick:()=>{r(e.value),o(!1)},className:K(`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition`,i?`bg-muted`:`hover:bg-muted/70`),children:[(0,O.jsx)(n,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,O.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:e.label}),(0,O.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),i?(0,O.jsx)(fN,{className:`h-4 w-4 shrink-0 text-text-primary`}):null]},e.value)})]}):null]})}var JJ=[{value:`auto`,label:`自动`},{value:`enabled`,label:`开启`},{value:`disabled`,label:`关闭`}],YJ={auto:`自动`,enabled:`开启`,disabled:`关闭`};function XJ({availableModels:e,selectedModel:t,thinkingEnabled:n,thinkingMode:r,onSelectModel:i,onSelectThinkingMode:a}){let[o,s]=(0,v.useState)(!1),c=(0,v.useRef)(null),l=e.find(e=>e.id===t)?.display_name||t||`选择模型`;return(0,v.useEffect)(()=>{if(!o)return;let e=e=>{c.current&&!c.current.contains(e.target)&&s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]),(0,O.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex h-8 max-w-[15rem] items-center gap-1.5 rounded-xl px-3 text-[13px] text-text-primary transition hover:brightness-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,style:{background:`var(--ksadk-menu-trigger-background, hsl(var(--muted)))`},"aria-expanded":o,"aria-haspopup":`menu`,"aria-label":n?`模型 ${l},推理 ${YJ[r]}`:`模型 ${l}`,title:n?`选择模型与推理设置`:`选择模型`,children:[(0,O.jsx)(`span`,{className:`min-w-0 truncate`,children:l}),n?(0,O.jsx)(`span`,{className:`shrink-0 text-text-muted`,children:YJ[r]}):null,(0,O.jsx)(pN,{className:K(`h-3.5 w-3.5 shrink-0 text-text-muted transition-transform`,o&&`rotate-180`)})]}),o?(0,O.jsxs)(`div`,{role:`menu`,"aria-label":`选择模型`,className:`absolute bottom-[calc(100%+0.65rem)] right-0 z-40 w-[min(17rem,calc(100vw-2rem))] overflow-hidden rounded-2xl border p-1.5`,style:{background:`var(--ksadk-menu-background, hsl(var(--popover)))`,borderColor:`var(--ksadk-menu-border, hsl(var(--border)))`,boxShadow:`var(--ksadk-menu-shadow, 0 18px 44px rgba(15, 23, 42, 0.16))`},children:[(0,O.jsx)(`div`,{className:`px-2.5 pb-1.5 pt-1 text-[11px] font-medium text-text-muted`,children:`模型`}),(0,O.jsx)(`div`,{className:`max-h-[min(45vh,18rem)] overflow-y-auto`,children:e.map(e=>{let n=e.id===t;return(0,O.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":n,onClick:()=>{i(e.id),s(!1)},className:K(`flex w-full items-center gap-2 rounded-xl px-2.5 py-2 text-left text-[13px] transition-colors`,n?`bg-muted text-text-primary`:`text-text-secondary hover:bg-muted hover:text-text-primary`),children:[(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.display_name||e.id}),n?(0,O.jsx)(fN,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}):null]},e.id)})}),n?(0,O.jsx)(`div`,{className:`mt-1 border-t border-border px-1 pt-1.5`,children:(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 pb-1`,children:[(0,O.jsx)(`span`,{className:`text-[11px] font-medium text-text-muted`,children:`推理`}),(0,O.jsx)(`div`,{className:`flex rounded-lg bg-muted p-0.5`,children:JJ.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(e.value),className:K(`rounded-md px-2 py-1 text-[11px] transition-colors`,e.value===r?`bg-card text-text-primary shadow-sm`:`text-text-muted hover:text-text-primary`),children:e.label},e.value))})]})}):null]}):null]})}var ZJ=[{value:`ask`,label:`请求批准`,description:`Agent 请求授权时确认`,icon:kN},{value:`risk`,label:`风险操作需确认`,description:`仅副作用操作`,icon:ZN},{value:`full`,label:`完全访问`,description:`不再确认`,icon:XN}],QJ={ask:`请求批准`,risk:`风险确认`,full:`完全访问`};function $J({approvalPolicy:e}){let[t,n]=(0,v.useState)(!1),r=(0,v.useRef)(null),i=fe(e=>e.permissionMode),a=fe(e=>e.setPermissionMode),o=i===`ask`?kN:i===`full`?XN:ZN,s=(0,v.useMemo)(()=>ZJ.filter(t=>!e||e.Modes.includes(t.value)),[e]);return(0,v.useEffect)(()=>{s.some(e=>e.value===i)||a(e?.DefaultMode||s[0]?.value||`risk`)},[e?.DefaultMode,i,a,s]),(0,v.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),(0,O.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:K(`flex h-8 items-center gap-1.5 rounded-xl px-2.5 text-[13px] transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,i===`full`?`text-amber-600 dark:text-amber-400`:`text-text-secondary hover:text-text-primary`),"aria-expanded":t,"aria-haspopup":`menu`,title:`设置本次会话的工具审批规则`,children:[(0,O.jsx)(o,{className:`h-3.5 w-3.5`}),(0,O.jsx)(`span`,{children:QJ[i]}),(0,O.jsx)(pN,{className:K(`h-3.5 w-3.5 transition-transform`,t&&`rotate-180`)})]}),t?(0,O.jsx)(`div`,{role:`menu`,"aria-label":`工具权限`,className:`absolute bottom-[calc(100%+0.6rem)] left-0 z-30 w-[18rem] rounded-xl border border-border/80 bg-popover p-1 shadow-[0_10px_24px_rgba(15,23,42,0.12)]`,style:{backgroundColor:`var(--ksadk-popover, #fff)`,borderColor:`var(--ksadk-border, rgba(15, 23, 42, 0.12))`},children:s.map(e=>{let t=e.icon,r=e.value===i;return(0,O.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,onClick:()=>{a(e.value),n(!1)},className:K(`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition-colors`,r?`bg-primary/[0.08]`:`hover:bg-muted/75`),children:[(0,O.jsx)(t,{className:K(`h-4 w-4 shrink-0`,r?`text-primary`:`text-text-muted`)}),(0,O.jsx)(`span`,{className:K(`shrink-0 text-[13px] font-medium`,r?`text-text-primary`:`text-text-secondary`),children:e.label}),(0,O.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),r?(0,O.jsx)(fN,{className:`h-4 w-4 shrink-0 text-primary`,"aria-hidden":`true`}):null]},e.value)})}):null]})}function eY({onCompactContext:e,attachments:t,composerContextIndicator:n,composerMaxHeight:r,fileInputRef:i,input:a,isMobile:o,isStreaming:s,attachmentsEnabled:c=!0,approvalEnabled:l=!1,approvalPolicy:u,thinkingEnabled:d=!1,executionMode:f,executionModeSupport:p,queuedDrafts:m,onAppendAttachments:h,onInputChange:g,onSelectExecutionMode:_,onPaste:y,onRemoveAttachment:b,onStopGeneration:x,onCancelRemote:S,onSubmit:ee,textareaRef:C,className:w}){let[te,ne]=(0,v.useState)(!1),T=e?async()=>{ne(!0);try{await e()}finally{ne(!1)}}:void 0,re=f===`goal`?`描述需要持续完成的目标…`:f===`plan`?`描述需要先规划的任务…`:o?`发送消息...`:`发送消息…`,ie=S?`保留恢复点并结束本次执行`:`停止生成`,ae=f===`goal`?!!a.trim():!!(a.trim()||t.length>0),oe=We(e=>e.availableModels),se=We(e=>e.selectedModel),ce=We(e=>e.thinkingMode),le=We(e=>e.setSelectedModel),E=We(e=>e.setThinkingMode),D=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`;return(0,O.jsx)(`div`,{className:K(`relative z-10 flex-shrink-0 bg-background/95 px-3 py-3 backdrop-blur sm:px-4 sm:py-3`,w),"data-slot":`composer`,children:(0,O.jsxs)(`div`,{className:`mx-auto w-full max-w-[64rem]`,children:[te&&(0,O.jsxs)(`div`,{role:`status`,className:`mb-3 flex items-center gap-2 px-2 text-sm text-text-muted`,children:[(0,O.jsx)(DN,{size:16,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`waiting-thinking-text`,children:`正在压缩上下文`})]}),m.length>0?(0,O.jsxs)(`div`,{className:`mb-2 rounded-2xl border border-neutral-200/80 bg-neutral-50/80 px-3 py-2 text-xs text-neutral-900 shadow-sm dark:border-neutral-900/60 dark:bg-neutral-950/30 dark:text-neutral-100`,children:[(0,O.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`span`,{className:`font-semibold`,children:[`发送队列 · `,m.length]}),(0,O.jsx)(`span`,{className:`text-neutral-700/75 dark:text-neutral-200/75`,children:`当前回复完成后依次发送`})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[m.slice(0,3).map((e,t)=>{let n=e.text.trim()||(e.attachments.length>0?`仅附件消息`:`空消息`);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-background/70 px-2 py-1.5`,children:[(0,O.jsx)(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-neutral-100 font-mono text-[10px] text-neutral-700 dark:bg-neutral-900/50 dark:text-neutral-100`,children:t+1}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:n}),e.attachments.length>0?(0,O.jsxs)(`span`,{className:`flex-shrink-0 rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] text-neutral-700 dark:bg-neutral-900/50 dark:text-neutral-100`,children:[e.attachments.length,` 附件`]}):null]},`${t}-${n}-${e.attachments.length}`)}),m.length>3?(0,O.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-neutral-700/80 dark:text-neutral-200/80`,children:[`还有 `,m.length-3,` 条等待发送`]}):null]})]}):null,(0,O.jsx)(`div`,{className:`relative rounded-[28px] bg-surface shadow-[0_0_0_0.5px_rgba(15,23,42,0.08),0_5px_18px_rgba(15,23,42,0.07)] dark:shadow-[0_0_0_0.5px_rgba(255,255,255,0.06),0_8px_24px_rgba(0,0,0,0.24)]`,children:(0,O.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,O.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),te)return;if(s){S?S():x();return}let n=a.trim();ae&&ee(n,t)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),c&&e.dataTransfer.files&&e.dataTransfer.files.length>0&&h(Array.from(e.dataTransfer.files))},className:`relative flex min-h-[116px] min-w-0 flex-1 flex-col rounded-[28px] border border-border/55 bg-background px-4 pb-3 pt-3 transition-all focus-within:border-primary/40 focus-within:ring-2 focus-within:ring-primary/15 sm:px-5`,children:[t.length>0?(0,O.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-2`,children:t.map((e,t)=>(0,O.jsxs)(`div`,{className:K(`group relative flex items-center gap-2 rounded-xl border border-border bg-background px-3 py-2 text-xs`,o?`max-w-full`:`max-w-[14rem]`),children:[(0,O.jsx)(`span`,{className:`flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-muted text-text-muted`,children:(0,O.jsx)(VN,{className:`h-3.5 w-3.5`})}),(0,O.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`span`,{className:`block truncate font-medium text-text-primary`,children:e.name}),(0,O.jsx)(`span`,{className:`block text-[10px] text-text-muted`,children:D(e.size)})]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>b(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full border border-border bg-background text-text-muted shadow-sm transition hover:text-rose-500`,"aria-label":`移除附件 ${e.name}`,children:(0,O.jsx)(`span`,{className:`text-[11px] leading-none`,children:`×`})})]},`${e.name}-${e.size}-${t}`))}):null,(0,O.jsx)(`textarea`,{ref:C,rows:1,value:a,onChange:g,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},onPaste:y,placeholder:re,className:K(`custom-scrollbar max-h-[176px] min-h-[62px] w-full resize-none overflow-y-auto border-0 bg-transparent px-0 pb-1 pt-1 text-[15px] leading-6 text-text-primary outline-none placeholder:text-text-muted/60`,o?`text-[16px]`:`text-[14px]`),style:{maxHeight:`${r}px`,overflowY:`auto`}}),(0,O.jsxs)(`div`,{className:`mt-auto flex min-h-8 items-center justify-between gap-2 pt-1.5`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,O.jsx)(`input`,{ref:i,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(h(Array.from(e.target.files)),e.target.value=``)}}),(0,O.jsx)(qJ,{attachmentsEnabled:c,mode:f,support:p,onSelectMode:_,onUpload:()=>i.current?.click()}),l?(0,O.jsx)($J,{approvalPolicy:u}):null]}),(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[n?(0,O.jsx)(UJ,{indicator:n,onCompact:T,disabled:s}):null,oe.length>0?(0,O.jsx)(XJ,{availableModels:oe,selectedModel:se,thinkingEnabled:d,thinkingMode:ce,onSelectModel:le,onSelectThinkingMode:E}):null,(0,O.jsx)(`button`,{type:`submit`,disabled:te||!s&&!ae,className:K(`flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,s||ae?`bg-[#1f1f1f] text-white hover:opacity-80`:`bg-muted text-text-muted/45`),title:s?ie:`发送消息`,children:s?(0,O.jsx)(eP,{className:`h-3.5 w-3.5 fill-current`}):(0,O.jsx)(uN,{className:`h-[18px] w-[18px]`})})]})]})]})})})]})})}function tY(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function nY(e,t){let n=new Map;for(let t of e)n.set(tY(t),t);for(let e of t)n.set(tY(e),e);return Array.from(n.values())}function rY(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function iY({onCompactContext:e,composerMaxHeight:t,submitDraft:n,stopGeneration:r,cancelRemote:i,isMobile:a,attachmentsEnabled:o=!0,approvalEnabled:s=!1,approvalPolicy:c,thinkingEnabled:l=!1,runtimeCapabilityMatrix:u,pendingInteractions:d,onRespondInteraction:f,localCatalog:p,className:m}){let[h,g]=(0,v.useState)(0),[_,y]=(0,v.useState)(),b=ve(e=>e.input),x=ve(e=>e.attachments),S=E(e=>e.currentSessionId),ee=k(e=>!!(e.getSessionActivity(S)&&e.isSessionStreaming(S))),C=ve(e=>e.queuedDrafts),w=Qc(e=>e.messages),te=E(e=>e.sessions.find(e=>e.SessionId===S)?.ContextUsage),ne=We(e=>e.availableModels),T=We(e=>e.selectedModel),re=We(e=>e.setThinkingMode),ie=(0,v.useRef)(null),ae=(0,v.useRef)(null),oe=(0,v.useMemo)(()=>ne.find(e=>e.id===T)||null,[ne,T]),se=(0,v.useMemo)(()=>BJ({messages:w,draftInput:b,selectedModel:oe,contextUsage:te}),[b,w,oe,te]),ce=(0,v.useMemo)(()=>({plan:!!u?.plan?.supported,goal:!!u?.goal?.supported}),[u]),le=_&&ce[_]?_:void 0,D=(0,v.useCallback)((e,t)=>{!e&&t.length===0||(ve.getState().setInput(``),ve.getState().setAttachments([]),n(e,t,void 0,void 0,le),le===`goal`&&y(void 0))},[le,n]);(0,v.useEffect)(()=>{ae.current&&(ae.current.style.height=`auto`,ae.current.style.height=`${Math.min(ae.current.scrollHeight,t)}px`)},[b,t]);let ue=e=>{ve.getState().setInput(e.target.value),e.target.style.height=`auto`,e.target.style.height=`${Math.min(e.target.scrollHeight,t)}px`},de=e=>{!o||!e.length||ve.getState().setAttachments(t=>nY(t,e))},fe=e=>{if(!o)return;let t=rY(e);t.length&&(e.preventDefault(),e.stopPropagation(),de(t))},pe=d||[],me=Math.min(h,Math.max(pe.length-1,0));return(0,v.useEffect)(()=>{l||re(`auto`)},[re,l]),(0,O.jsxs)(`div`,{className:`flex w-full flex-col justify-center`,children:[pe.length>0&&f?(0,O.jsx)(Uq,{interactions:pe,activeIndex:me,onSelectIndex:g,onRespond:f,localCatalog:p}):null,(0,O.jsx)(eY,{onCompactContext:S?e:void 0,attachments:x,composerContextIndicator:se,composerMaxHeight:t,fileInputRef:ie,input:b,isMobile:a,isStreaming:ee,attachmentsEnabled:o,approvalEnabled:s,approvalPolicy:c,thinkingEnabled:l,executionMode:le,executionModeSupport:ce,queuedDrafts:C,onAppendAttachments:de,onInputChange:ue,onSelectExecutionMode:y,onPaste:fe,onRemoveAttachment:e=>ve.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:r,onCancelRemote:i,onSubmit:D,textareaRef:ae,className:m},S||`new-session`)]})}var aY=(0,v.lazy)(()=>J(()=>import(`./NativeTerminalPanel-zvL-WpAn.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function oY({availableModels:e,selectedModel:t,onSelectModel:n,selectedModelLabel:r,modelCatalogLoaded:i,modelSource:a,thinkingEnabled:o,thinkingMode:s,onSelectThinkingMode:c,compact:l=!1}){let u=K(`rounded-full border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition-colors focus:ring-1 focus:ring-blue-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300`,l?`w-full`:`max-w-[13rem]`),d=e.length>1?(0,O.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:u,children:e.map(e=>(0,O.jsx)(`option`,{value:e.id,children:e.display_name||e.id},e.id))}):r?(0,O.jsx)(`span`,{className:K(u,`inline-flex max-w-full items-center`,l?`justify-start`:``),title:a||r,children:(0,O.jsx)(`span`,{className:`truncate`,children:r})}):(0,O.jsx)(`span`,{className:`text-sm text-slate-400`,children:i?`未配置模型`:`Loading models...`}),f=o?(0,O.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:K(u,l?``:`max-w-[9rem]`),title:`控制模型 thinking/reasoning 参数`,children:[(0,O.jsx)(`option`,{value:`auto`,children:`思考自动`}),(0,O.jsx)(`option`,{value:`enabled`,children:`开启思考`}),(0,O.jsx)(`option`,{value:`disabled`,children:`关闭思考`})]}):null;return(0,O.jsxs)(`div`,{className:K(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function sY({agentName:e,currentSessionId:t,isMobile:n,sidebarOpen:r,mobileSidebarOpen:i,onToggleSidebar:a,availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,mobileActionsOpen:h,onMobileActionsOpenChange:g,workspaceEnabled:_,onOpenWorkspace:y,nativeManagementLink:b,nativeTerminal:x,nativeLauncherMode:S=!1}){let[ee,C]=(0,v.useState)(!1),w=!!x?.Enabled,te=n?i?(0,O.jsx)(zN,{className:`h-5 w-5`}):(0,O.jsx)(BN,{className:`h-5 w-5`}):r?(0,O.jsx)(zN,{className:`h-5 w-5`}):(0,O.jsx)(BN,{className:`h-5 w-5`});return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`header`,{className:K(`flex flex-shrink-0 items-center justify-between border-b border-black/[0.06] bg-background/95 px-3 py-2 backdrop-blur dark:border-white/[0.08] dark:bg-background/95 sm:px-4`,n?`pt-[calc(var(--safe-area-top)+0.5rem)]`:`h-12`),children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[S?null:(0,O.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":n?`打开历史记录`:`切换侧边栏`,children:te}),(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base`,children:e}),(0,O.jsx)(`div`,{className:`text-[11px] text-slate-400 dark:text-slate-500`,children:S?`原生运行时入口`:`智能体`})]})]}),n?(0,O.jsx)(`button`,{type:`button`,onClick:()=>g(!0),className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":`打开会话操作`,children:(0,O.jsx)(SN,{className:`h-5 w-5`})}):(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b?(0,O.jsxs)(`a`,{href:b.href,target:`_blank`,rel:`noreferrer`,title:b.title,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(CN,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{children:b.label})]}):null,_?(0,O.jsxs)(`button`,{type:`button`,onClick:y,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(ON,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{children:`Workspace`})]}):null,w?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>C(!0),className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm font-medium leading-none text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,O.jsx)($N,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{children:`TUI`})]}):null,!S&&n?(0,O.jsx)(oY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0}):null,!S&&t?(0,O.jsxs)(`span`,{className:`rounded bg-slate-50 px-2 py-1 text-xs font-mono text-slate-400 dark:bg-slate-800`,children:[`ID: `,t.slice(0,8)]}):null]})]}),n?(0,O.jsx)(qR,{open:h,onOpenChange:g,children:(0,O.jsxs)(YR,{side:`bottom`,className:`rounded-t-[1.75rem] border-slate-200 bg-white px-4 pb-[calc(var(--safe-area-bottom)+1rem)] pt-6 dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsxs)(XR,{className:`text-left`,children:[(0,O.jsx)(ZR,{children:`会话设置`}),(0,O.jsx)(QR,{className:`sr-only`,children:`调整当前会话的模型和 Workspace 操作。`})]}),(0,O.jsxs)(`div`,{className:`mt-6 flex flex-col gap-4`,children:[_?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),y()},className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(ON,{className:`h-4 w-4`}),`工作区文件`]}):null,w?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),C(!0)},className:`inline-flex items-center gap-2 rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-3 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,O.jsx)($N,{className:`h-4 w-4`}),`原生 TUI`]}):null,b?(0,O.jsxs)(`a`,{href:b.href,target:`_blank`,rel:`noreferrer`,title:b.title,onClick:()=>g(!1),className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(CN,{className:`h-4 w-4`}),b.label]}):null,S?(0,O.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm leading-6 text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:`当前运行时对话在原生管理台中进行;这里保留管理入口和 Workspace 文件操作。`}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`模型`}),(0,O.jsx)(oY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`当前会话`}),(0,O.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:t?(0,O.jsx)(`span`,{className:`break-all font-mono`,children:t}):`新对话尚未创建会话 ID`})]})]})]})]})}):null,x&&ee?(0,O.jsx)(v.Suspense,{fallback:null,children:(0,O.jsx)(aY,{capability:x,open:ee,sessionId:t,onClose:()=>C(!1)})}):null]})}var cY=(0,v.lazy)(()=>J(()=>import(`./NativeTerminalPanel-zvL-WpAn.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function lY({productLabel:e=`原生运行时`,nativeManagementLink:t,nativeTerminal:n,workspaceEnabled:r,onOpenWorkspace:i}){let a=!!n?.Enabled,[o,s]=(0,v.useState)(!1);return(0,O.jsxs)(`section`,{className:`flex min-h-0 flex-1 overflow-y-auto bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.12),transparent_34%),linear-gradient(135deg,#f8fafc_0%,#ffffff_48%,#f1f5f9_100%)] px-4 py-8 dark:bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_34%),linear-gradient(135deg,#020617_0%,#0f172a_52%,#111827_100%)] sm:px-8`,children:[(0,O.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col justify-center`,children:(0,O.jsxs)(`div`,{className:`overflow-hidden rounded-[2rem] border border-slate-200/80 bg-white/90 shadow-xl shadow-slate-200/60 backdrop-blur dark:border-slate-800 dark:bg-slate-900/85 dark:shadow-black/30`,children:[(0,O.jsxs)(`div`,{className:`border-b border-slate-200/80 bg-slate-50/80 px-6 py-5 dark:border-slate-800 dark:bg-slate-950/40 sm:px-8`,children:[(0,O.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-sky-200 bg-sky-50 px-3 py-1 text-xs font-medium text-sky-700 dark:border-sky-900/60 dark:bg-sky-950/50 dark:text-sky-300`,children:[(0,O.jsx)(ZN,{className:`h-3.5 w-3.5`}),e,` native runtime`]}),(0,O.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl`,children:`对话请使用原生管理台`}),(0,O.jsx)(`p`,{className:`mt-3 max-w-2xl text-sm leading-6 text-slate-600 dark:text-slate-300 sm:text-base`,children:`当前运行时的对话状态由原生管理台承载。AgentEngine Hosted UI 在这里保留统一入口和 Workspace 文件管理,不重复实现运行时内部已有的复杂对话状态机。`})]}),(0,O.jsxs)(`div`,{className:`grid gap-4 p-6 md:grid-cols-3 sm:p-8`,children:[(0,O.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-slate-950 text-white dark:bg-slate-100 dark:text-slate-950`,children:(0,O.jsx)(IN,{className:`h-5 w-5`})}),(0,O.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生管理台`}),(0,O.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。`}),t?(0,O.jsxs)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer`,title:t.title,className:`mt-5 inline-flex items-center gap-2 rounded-2xl bg-slate-950 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-950 dark:hover:bg-white`,children:[(0,O.jsx)(CN,{className:`h-4 w-4`}),`打开`,t.label]}):(0,O.jsx)(`div`,{className:`mt-5 rounded-2xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm leading-6 text-neutral-800 dark:border-neutral-900/60 dark:bg-neutral-950/30 dark:text-neutral-200`,children:`当前访问模式不开放原生管理入口。需要完整对话体验时,请使用 owner/private 链接或 CLI。`})]}),(0,O.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-300`,children:(0,O.jsx)(ON,{className:`h-5 w-5`})}),(0,O.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`Workspace 文件管理`}),(0,O.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。`}),r?(0,O.jsxs)(`button`,{type:`button`,onClick:i,className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-medium text-slate-800 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:hover:bg-slate-700`,children:[(0,O.jsx)(ON,{className:`h-4 w-4`}),`打开 Workspace`]}):(0,O.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前链接未开放 Workspace 文件管理。Owner 或 private 链接可使用该能力。`})]}),(0,O.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300`,children:(0,O.jsx)($N,{className:`h-5 w-5`})}),(0,O.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生 TUI`}),(0,O.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。`}),a?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-2.5 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,O.jsx)($N,{className:`h-4 w-4`}),`打开 TUI`]}):(0,O.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前运行时未声明可用的浏览器 TUI 能力。`})]})]})]})}),n&&o?(0,O.jsx)(v.Suspense,{fallback:null,children:(0,O.jsx)(cY,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var uY=[],dY=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?dY:uY).push(n+=e[t])})();function fY(e){if(e<768)return!1;for(let t=0,n=uY.length;;){let r=t+n>>1;if(e<uY[r])n=r;else if(e>=dY[r])t=r+1;else return!0;if(t==n)return!1}}function pY(e){return e>=127462&&e<=127487}var mY=8205;function hY(e,t,n=!0,r=!0){return(n?gY:_Y)(e,t,r)}function gY(e,t,n){if(t==e.length)return t;t&&yY(e.charCodeAt(t))&&bY(e.charCodeAt(t-1))&&t--;let r=vY(e,t);for(t+=xY(r);t<e.length;){let i=vY(e,t);if(r==mY||i==mY||n&&fY(i))t+=xY(i),r=i;else if(pY(i)){let n=0,r=t-2;for(;r>=0&&pY(vY(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function _Y(e,t,n){for(;t>0;){let r=gY(e,t-2,n);if(r<t)return r;t--}return 0}function vY(e,t){let n=e.charCodeAt(t);if(!bY(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return yY(r)?(n-55296<<10)+(r-56320)+65536:n}function yY(e){return e>=56320&&e<57344}function bY(e){return e>=55296&&e<56320}function xY(e){return e<65536?1:2}var SY=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=MY(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),wY.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=MY(this,e,t);let n=[];return this.decompose(e,t,n,0),wY.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new OY(this),i=new OY(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new OY(this,e)}iterRange(e,t=this.length){return new kY(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new AY(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new CY(t):wY.from(CY.split(t,[]))}},CY=class e extends SY{constructor(e,t=TY(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new jY(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(DY(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=EY(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=MY(this,t,n);let i=EY(this.text,EY(r.text,DY(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):wY.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
200
|
+
flex items-center justify-center shadow-lg shadow-blue-500/20`,children:(0,O.jsx)(dN,{className:`h-8 w-8 text-white`})}),(0,O.jsx)(`h2`,{className:`text-xl font-semibold text-slate-900 dark:text-slate-50`,children:`有什么我可以帮您的吗?`}),(0,O.jsxs)(`p`,{className:`mt-2 text-sm text-slate-500`,children:[`我是 `,e,`,由 Ksyun AgentEngine 驱动`]})]})}function yJ(){return(0,O.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[44rem] flex-col gap-5 px-2 py-8`,"aria-label":`正在加载会话历史`,children:[(0,O.jsx)(`div`,{className:`h-4 w-28 animate-pulse rounded bg-slate-200/80 dark:bg-slate-800`}),(0,O.jsx)(`div`,{className:`h-20 w-4/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,O.jsx)(`div`,{className:`ml-auto h-12 w-3/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,O.jsx)(`div`,{className:`h-16 w-11/12 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`})]})}function bJ({attachments:e,isMobile:t,onOpenAttachmentPreview:n}){return(0,O.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-3`,children:e.map((e,r)=>e.type.startsWith(`image/`)?e.url?(0,O.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:K(`group relative overflow-hidden rounded-xl border border-slate-200 shadow-sm dark:border-slate-700`,t?`w-full max-w-full`:`max-w-[200px]`),children:(0,O.jsx)(`img`,{src:e.url,alt:e.name,className:K(`object-cover transition group-hover:scale-[1.02]`,t?`max-h-[16rem] w-full max-w-full`:`max-h-[200px] max-w-[200px]`)})},`${e.name}-${r}`):(0,O.jsx)(`div`,{className:K(`flex items-center justify-center rounded-xl border border-dashed border-slate-300 bg-slate-50 px-4 text-sm text-slate-500 dark:border-slate-700 dark:bg-slate-900/40 dark:text-slate-400`,t?`h-28 w-full`:`h-[120px] w-[200px]`),children:e.name},`${e.name}-${r}`):(0,O.jsxs)(`div`,{className:K(`flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-2 shadow-sm dark:border-slate-700 dark:bg-slate-800`,t?`w-full max-w-full`:`w-max max-w-full`),children:[(0,O.jsx)(VN,{className:`h-4 w-4 flex-shrink-0 text-blue-500`}),e.url?(0,O.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`truncate text-sm text-slate-700 hover:underline dark:text-slate-300`,title:e.name,children:e.name}):(0,O.jsx)(`span`,{className:`truncate text-sm text-slate-700 dark:text-slate-300`,title:e.name,children:e.name})]},`${e.name}-${r}`))})}function xJ({message:e}){return(0,O.jsx)(`div`,{className:`w-full px-0 py-2 sm:px-4`,children:(0,O.jsxs)(`div`,{className:`mx-auto max-w-3xl rounded-xl border border-neutral-200/70 bg-neutral-50/60 px-4 py-3 text-sm text-neutral-600 dark:border-neutral-800 dark:bg-neutral-900/40 dark:text-neutral-300`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`running`?(0,O.jsx)(KN,{className:`h-4 w-4 animate-spin text-neutral-600 dark:text-neutral-300`}):e.status===`failed`?(0,O.jsx)(gN,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,O.jsx)(fN,{className:`h-4 w-4 text-emerald-600 dark:text-emerald-400`}),(0,O.jsx)(`span`,{children:e.content})]}),e.compactedUntilSeqId?(0,O.jsxs)(`div`,{className:`mt-1 text-xs text-neutral-700/80 dark:text-neutral-200/80`,children:[`已折叠到会话事件 #`,e.compactedUntilSeqId]}):null,e.summary?(0,O.jsxs)(`details`,{className:`mt-3 rounded-xl border border-neutral-200/80 bg-white/70 px-3 py-2 dark:border-neutral-900/60 dark:bg-slate-950/40`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-neutral-800 dark:text-neutral-200`,children:`查看压缩摘要`}),(0,O.jsx)(`div`,{className:`mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200`,children:(0,O.jsx)(wq,{content:e.summary})})]}):null]})})}function SJ({label:e,tone:t,value:n}){let[r,i]=(0,v.useState)(`idle`),a=kA(n);(0,v.useEffect)(()=>{if(r===`idle`)return;let e=window.setTimeout(()=>i(`idle`),1600);return()=>window.clearTimeout(e)},[r]);let o=async()=>{i(await oJ(a)?`copied`:`failed`)};return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,O.jsx)(`div`,{className:K(`text-xs font-semibold uppercase`,t===`input`?`text-blue-500`:t===`error`?`text-rose-500`:`text-emerald-500`),children:e}),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{o()},className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[11px] font-medium text-slate-500 transition hover:bg-white hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,children:[r===`copied`?(0,O.jsx)(fN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,O.jsx)(yN,{className:`h-3.5 w-3.5`}),r===`copied`?`已复制`:r===`failed`?`复制失败`:`复制`]})]}),(0,O.jsx)(`div`,{className:`custom-scrollbar max-h-[220px] overflow-y-auto whitespace-pre-wrap break-words rounded-xl border border-slate-200/30 bg-white/70 p-3 text-slate-600 shadow-sm dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 sm:max-h-[300px]`,children:a})]})}function CJ({isLastMessage:e,isStreaming:t,message:n,onDeleteFeedback:r,onSubmitFeedback:i,alwaysVisible:a=!1}){let[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(n.feedback?.comment||``),u=sM(n,t,e),d=!!n.feedback?.pending,f=n.feedback?.rating,p=async()=>{let e=n.content||``;e&&oJ(e)};return u?(0,O.jsxs)(`div`,{className:K(`mt-2 flex flex-col gap-2 transition-opacity duration-150 focus-within:opacity-100`,a?`opacity-100`:`opacity-0 group-hover:opacity-100`),children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-text-muted`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>{p()},className:`inline-flex items-center gap-1 rounded-full px-2 py-1 font-medium text-text-secondary transition hover:bg-muted hover:text-text-primary`,title:`复制`,children:(0,O.jsx)(yN,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`span`,{className:`text-text-muted/60`,children:`·`}),(0,O.jsx)(`span`,{className:`font-medium`,children:`本次回复有帮助吗?`}),(0,O.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>i({message:n,rating:`up`,comment:``}),className:K(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,f===`up`?`border-primary/30 bg-primary/10 text-primary`:`border-border bg-background text-text-secondary hover:border-primary/30 hover:text-primary`),children:[(0,O.jsx)(rP,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,O.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>{l(n.feedback?.comment||``),s(e=>!e)},className:K(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,f===`down`?`border-rose-300 bg-rose-50 text-rose-600 dark:border-rose-900/70 dark:bg-rose-950/30 dark:text-rose-300`:`border-border bg-background text-text-secondary hover:border-rose-300 hover:text-rose-600`),children:[(0,O.jsx)(nP,{className:`h-3.5 w-3.5`}),`需改进`]}),n.feedback?(0,O.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>r(n),className:`inline-flex items-center gap-1 rounded-full border border-transparent px-2 py-1 font-medium text-slate-400 transition hover:border-slate-200 hover:text-slate-700 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:border-slate-800 dark:hover:text-slate-200`,children:[(0,O.jsx)(iP,{className:`h-3.5 w-3.5`}),`删除反馈`]}):null,d?(0,O.jsx)(`span`,{className:`text-slate-400`,children:`提交中…`}):null]}),o?(0,O.jsxs)(`div`,{className:`max-w-xl rounded-2xl border border-rose-100 bg-rose-50/60 p-3 shadow-sm dark:border-rose-900/60 dark:bg-rose-950/20`,children:[(0,O.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:`可以补充哪里不准确、缺失或不符合预期。`,className:`min-h-[84px] w-full resize-y rounded-xl border border-rose-100 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition placeholder:text-slate-400 focus:border-rose-300 focus:ring-2 focus:ring-rose-100 dark:border-rose-900/70 dark:bg-slate-950 dark:text-slate-100 dark:focus:border-rose-700 dark:focus:ring-rose-950`}),(0,O.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded-xl px-3 py-1.5 text-xs font-semibold text-slate-500 transition hover:bg-white hover:text-slate-800 dark:text-slate-400 dark:hover:bg-slate-950 dark:hover:text-slate-100`,children:`取消`}),(0,O.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>{i({message:n,rating:`down`,comment:c}),s(!1)},className:`rounded-xl bg-rose-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-rose-500 disabled:cursor-not-allowed disabled:opacity-60`,children:`提交点踩`})]})]}):f===`down`&&n.feedback?.comment?(0,O.jsxs)(`div`,{className:`max-w-xl rounded-xl border border-rose-100 bg-rose-50/50 px-3 py-2 text-xs text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-200`,children:[`反馈:`,n.feedback.comment]}):null,n.feedback?.error?(0,O.jsx)(`div`,{className:`text-xs text-rose-600 dark:text-rose-300`,children:n.feedback.error}):null]}):null}function wJ({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,showAgentHeader:i,message:a,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onRespondToAguiApproval:l,onSubmitFeedback:u,onSubmitAguiAction:d,interactionRecords:f}){if(a.role===`user`)return(0,O.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,O.jsxs)(`div`,{className:`max-w-[80%] rounded-2xl bg-muted px-3 py-2 text-[14px] leading-relaxed text-foreground`,children:[a.attachments?.length?(0,O.jsx)(bJ,{attachments:a.attachments,isMobile:t,onOpenAttachmentPreview:s}):null,a.content]})});if(a.role===`a2ui`&&a.aguiActivity)return(0,O.jsx)(Nq,{surfaceId:a.aguiActivity.surfaceId,messages:a.aguiActivity.messages,onAction:d});let p=n&&r&&!a.content;return(0,O.jsxs)(`div`,{className:`group mx-auto mb-3 w-full max-w-[60rem] px-2 sm:px-4`,children:[i?(0,O.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs text-text-muted`,children:[(0,O.jsx)(dN,{className:`w-3.5 h-3.5`}),(0,O.jsx)(`span`,{children:e})]}):null,a.attachments?.length?(0,O.jsx)(bJ,{attachments:a.attachments,isMobile:t,onOpenAttachmentPreview:s}):null,a.blocks?.length?(0,O.jsx)(rJ,{message:a,isStreaming:n,onRespondToApproval:c,interactionRecords:f,onRespondToAguiApproval:l}):(0,O.jsxs)(O.Fragment,{children:[a.reasoning?(0,O.jsxs)(`details`,{className:`group/details mb-3 overflow-hidden rounded-md border border-slate-200/80 bg-slate-50/60 text-sm text-slate-600 transition-colors open:bg-white dark:border-slate-700/80 dark:bg-slate-900/40 dark:text-slate-300 dark:open:bg-slate-950/30`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 font-medium outline-none marker:hidden`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[p?null:(0,O.jsx)(fN,{className:`h-4 w-4 text-slate-400`}),(0,O.jsx)(`span`,{className:K(`truncate`,p&&`waiting-thinking-text`),"data-testid":p?`legacy-thinking-indicator`:void 0,role:p?`status`:void 0,children:p?`正在思考…`:`思考过程`}),p?null:(0,O.jsx)(`span`,{className:`rounded-full bg-slate-200/70 px-2 py-0.5 text-[11px] font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300`,children:`已完成`})]}),(0,O.jsx)(pN,{className:`h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180`})]}),(0,O.jsx)(`div`,{className:`border-t border-slate-200/70 bg-white/70 dark:border-slate-800 dark:bg-slate-950/20`,children:(0,O.jsx)(`div`,{className:`custom-scrollbar max-h-[min(46vh,28rem)] overflow-y-auto px-4 py-3 text-[14px] leading-7 text-slate-600 dark:text-slate-300 [&_p]:my-2 [&_pre]:my-2`,children:(0,O.jsx)(wq,{content:a.reasoning})})})]}):null,a.tools?Object.values(a.tools).map((e,t)=>(0,O.jsxs)(`details`,{open:e.approvalStatus===`pending`||e.status===`paused`?!0:void 0,className:K(`group/details mb-2 overflow-hidden rounded-md border text-sm transition-colors`,e.status===`paused`?`border-neutral-200/80 bg-neutral-50/25 text-slate-700 dark:border-neutral-900/60 dark:bg-neutral-950/10 dark:text-slate-200`:e.status===`error`?`border-rose-200/80 bg-rose-50/25 text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/10 dark:text-rose-200`:`border-slate-200/80 bg-slate-50/40 text-slate-600 dark:border-slate-700/80 dark:bg-slate-900/30 dark:text-slate-300`),children:[(0,O.jsx)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-3 py-2 font-medium`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`running`?(0,O.jsx)(KN,{className:`h-4 w-4 animate-spin text-slate-500`}):e.status===`paused`?(0,O.jsx)(ZN,{className:`h-4 w-4 text-neutral-500`}):e.status===`error`?(0,O.jsx)(_N,{className:`h-4 w-4 text-rose-500`}):(0,O.jsx)(fN,{className:`h-4 w-4 text-slate-400`}),(0,O.jsxs)(`span`,{children:[e.approvalStatus===`pending`?`等待审批:`:e.approvalStatus===`approved`?`已批准:`:e.approvalStatus===`rejected`?`已拒绝:`:e.approvalStatus===`cancelled`?`已取消:`:e.status===`error`?`工具调用失败:`:`工具调用:`,e.name]})]})}),(0,O.jsxs)(`div`,{className:K(`flex flex-col gap-3 border-t px-3 py-3 font-mono text-[13px] leading-relaxed`,e.status===`paused`?`border-neutral-200/70 dark:border-neutral-900/60`:e.status===`error`?`border-rose-200/70 dark:border-rose-900/60`:`border-slate-200/70 dark:border-slate-800`),children:[e.approvalRequestId?(0,O.jsxs)(`div`,{className:`font-sans text-sm text-slate-700 dark:text-slate-200`,children:[(0,O.jsx)(`div`,{className:`font-medium`,children:e.approvalStatus===`approved`?`已批准该工具调用。`:e.approvalStatus===`rejected`?`已拒绝该工具调用。`:e.approvalStatus===`cancelled`?`已取消该工具调用。`:e.approvalMessage||`该工具调用需要人工确认后继续。`}),e.approvalLevel?(0,O.jsxs)(`div`,{className:K(`mt-2 inline-flex items-center rounded border px-1.5 py-0.5 text-xs font-medium`,gJ(e.approvalLevel)),children:[`审批级别:`,hJ(e.approvalLevel)]}):null,e.serverLabel?(0,O.jsxs)(`div`,{className:`mt-1 text-xs text-neutral-700/80 dark:text-neutral-200/80`,children:[`MCP Server: `,e.serverLabel]}):null,e.approvalStatus===`pending`?(0,O.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,O.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?l?.({interruptId:e.approvalRequestId||``,approve:!0}):c({approvalRequestId:e.approvalRequestId||``,approve:!0,previousResponseId:e.previousResponseId}),className:`inline-flex min-h-8 items-center gap-1.5 rounded-md bg-emerald-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,O.jsx)(fN,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,O.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?l?.({interruptId:e.approvalRequestId||``,approve:!1}):c({approvalRequestId:e.approvalRequestId||``,approve:!1,previousResponseId:e.previousResponseId}),className:`inline-flex min-h-8 items-center gap-1.5 rounded-md border border-slate-300 bg-white px-3 py-1.5 text-xs font-semibold text-slate-600 transition hover:border-rose-300 hover:bg-rose-50 hover:text-rose-600 disabled:cursor-not-allowed disabled:opacity-55 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-300 dark:hover:border-rose-800 dark:hover:bg-rose-950/30 dark:hover:text-rose-300`,children:[(0,O.jsx)(_N,{className:`h-3.5 w-3.5`}),`拒绝`]})]}):(0,O.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-slate-500 dark:text-slate-400`,children:[e.approvalStatus===`approved`?(0,O.jsx)(fN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,O.jsx)(_N,{className:`h-3.5 w-3.5 text-rose-500`}),e.approvalStatus===`approved`?`已批准`:e.approvalStatus===`cancelled`?`已取消`:`已拒绝`]})]}):null,e.args?(0,O.jsx)(SJ,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,O.jsx)(SJ,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,a.tools?Object.values(a.tools).filter(e=>f?.some(t=>t.interactionId===e.approvalRequestId)).map(e=>(0,O.jsx)(qq,{interaction:f.find(t=>t.interactionId===e.approvalRequestId)},`anchor-${e.approvalRequestId}`)):null,(0,O.jsx)(`div`,{className:`w-full break-words`,children:a.content?(0,O.jsx)(wq,{content:a.content}):n&&r&&!a.reasoning&&!a.tools||a.eventType===`optimistic_assistant_placeholder`?(0,O.jsx)(`span`,{className:`relative mt-1 inline-flex h-4 w-4 items-center justify-center`,role:`status`,"aria-label":`正在生成`,children:(0,O.jsx)(`span`,{className:`waiting-generation-breathe h-2.5 w-2.5 rounded-full`})}):null})]}),a.aguiActivities?.map(e=>(0,O.jsx)(Nq,{surfaceId:e.surfaceId,messages:e.messages,onAction:d},e.surfaceId)),(0,O.jsx)(CJ,{isLastMessage:r,isStreaming:n,message:a,onDeleteFeedback:o,onSubmitFeedback:u})]})}function TJ({agentName:e,emptyState:t,isMobile:n,isStreaming:r,activity:i,contextIndicator:a,messages:o,isLoadingInitialHistory:s=!1,onDeleteFeedback:c,onOpenAttachmentPreview:l,onRespondToApproval:u,onRespondToAguiApproval:d,onSubmitFeedback:f,onSubmitAguiAction:p,onStopGeneration:m,onCancelRemote:h,onScrollToBottom:g,checkpoints:_=[],onResumeCheckpoint:y,interactionRecords:b,scrollRef:x,className:S}){let[ee,C]=(0,v.useState)(0),[w,te]=(0,v.useState)(0),[ne,T]=(0,v.useState)(0),[re,ie]=(0,v.useState)(new Map),ae=(0,v.useRef)(re);(0,v.useLayoutEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{C(e.scrollTop),te(e.clientHeight),T(e.scrollHeight)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>t());return n.observe(e),e.firstElementChild instanceof HTMLElement&&n.observe(e.firstElementChild),()=>n.disconnect()},[x]);let oe=(0,v.useMemo)(()=>cJ({items:o,scrollTop:ee,viewportHeight:w,overscan:mJ,defaultItemHeight:pJ,measuredHeights:re,getItemKey:(e,t)=>e?.id||String(t)}),[re,o,ee,w]),se=oe.visibleItems,ce=(0,v.useCallback)((e,t,n)=>{if(!e||!Number.isFinite(t)||t<=0)return;let r=ae.current,i=r.get(e)??pJ;if(i===t)return;let a=new Map(r);a.set(e,t),ae.current=a,ie(a);let o=x.current;o&&n<o.scrollTop&&(o.scrollTop+=t-i,C(o.scrollTop),T(o.scrollHeight))},[x]),le=lJ({scrollHeight:ne,scrollTop:ee,clientHeight:w}),E=uJ({scrollHeight:ne,scrollTop:ee,clientHeight:w});return(0,O.jsxs)(`div`,{ref:x,onScroll:e=>{C(e.currentTarget.scrollTop),te(e.currentTarget.clientHeight),T(e.currentTarget.scrollHeight)},className:K(`custom-scrollbar relative min-h-0 flex-1 overflow-y-auto scroll-smooth`,n?`px-3 py-3`:`px-4 py-5`,S),"data-slot":`message-list`,children:[(0,O.jsx)(`div`,{className:`mx-auto flex w-full max-w-[64rem] flex-col pb-6 sm:pb-8`,children:o.length===0&&s?(0,O.jsx)(yJ,{}):o.length===0?t===void 0?(0,O.jsx)(vJ,{agentName:e}):t:(0,O.jsx)(`div`,{style:{height:oe.totalHeight},className:`relative`,children:se.map(t=>(0,O.jsx)(_J,{messageId:t.item.id||String(t.index),top:t.top,onMeasure:ce,children:t.item.role===`system`?(0,O.jsx)(xJ,{message:t.item}):(0,O.jsx)(wJ,{agentName:e,isMobile:n,isStreaming:r,isLastMessage:t.index===o.length-1,showAgentHeader:!fJ(o[t.index-1],t.item),message:t.item,onDeleteFeedback:c,onOpenAttachmentPreview:l,onRespondToApproval:u,interactionRecords:b,onRespondToAguiApproval:d,onSubmitFeedback:f,onSubmitAguiAction:p})},t.item.id||t.index))})}),(0,O.jsx)(iJ,{}),E?(0,O.jsx)(`button`,{type:`button`,"aria-label":`回到底部`,"data-distance-from-bottom":Math.round(le),onClick:()=>{if(g){g();return}let e=x.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`auto`})},className:`sticky bottom-4 left-1/2 z-20 mx-auto flex h-9 w-9 -translate-x-1/2 items-center justify-center rounded-full border border-border bg-surface text-text-secondary shadow-[0_8px_24px_rgba(15,23,42,0.12)] transition hover:text-text-primary`,title:`回到底部`,children:r?(0,O.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center gap-0.5`,"data-scroll-indicator":`streaming`,children:[0,1,2].map(e=>(0,O.jsx)(`span`,{className:`h-1 w-1 animate-bounce rounded-full bg-current motion-reduce:animate-none`,style:{animationDelay:`${e*120}ms`}},e))}):(0,O.jsx)(pN,{"aria-hidden":`true`,className:`h-5 w-5`,"data-scroll-indicator":`idle`})}):null]})}var EJ=RR,DJ=zR,OJ=v.forwardRef(({className:e,...t},n)=>(0,O.jsx)(BR,{ref:n,className:K(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));OJ.displayName=BR.displayName;var kJ=v.forwardRef(({className:e,children:t,...n},r)=>(0,O.jsxs)(DJ,{children:[(0,O.jsx)(OJ,{}),(0,O.jsxs)(VR,{ref:r,className:K(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...n,children:[t,(0,O.jsxs)(WR,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground`,children:[(0,O.jsx)(cP,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));kJ.displayName=VR.displayName;var AJ=({className:e,...t})=>(0,O.jsx)(`div`,{className:K(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});AJ.displayName=`DialogHeader`;var jJ=({className:e,...t})=>(0,O.jsx)(`div`,{className:K(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});jJ.displayName=`DialogFooter`;var MJ=v.forwardRef(({className:e,...t},n)=>(0,O.jsx)(HR,{ref:n,className:K(`text-lg font-semibold leading-none tracking-tight`,e),...t}));MJ.displayName=HR.displayName;var NJ=v.forwardRef(({className:e,...t},n)=>(0,O.jsx)(UR,{ref:n,className:K(`text-sm text-muted-foreground`,e),...t}));NJ.displayName=UR.displayName;function PJ(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function FJ(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function IJ({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,O.jsx)(EJ,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,O.jsxs)(kJ,{className:K(`gap-0 overflow-hidden border-slate-700 bg-slate-950 p-0 text-slate-100 shadow-2xl [&>button]:right-3 [&>button]:top-3 [&>button]:rounded-md [&>button]:border [&>button]:border-slate-700 [&>button]:bg-slate-900/70 [&>button]:p-1.5 [&>button]:text-slate-200 [&>button]:opacity-100`,t?`left-0 top-0 h-[var(--app-height)] max-h-[var(--app-height)] w-screen max-w-none translate-x-0 translate-y-0 rounded-none border-0`:`max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] rounded-2xl`),style:FJ(t,n),children:[(0,O.jsx)(`div`,{className:`flex items-center gap-3 border-b border-slate-800 px-4 py-3 pr-16`,children:(0,O.jsx)(MJ,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,O.jsx)(`div`,{className:K(`flex items-center justify-center overflow-auto bg-slate-950`,t?`h-full p-4 pb-[calc(var(--safe-area-bottom)+1rem)]`:`max-h-[calc(100vh-7rem)] p-4`),children:e?e.type.startsWith(`image/`)?(0,O.jsx)(`img`,{src:e.url,alt:e.name,className:K(`object-contain`,t?`h-auto max-h-full w-full max-w-full`:`h-auto w-auto max-h-[calc(100vh-9rem)] max-w-[calc(100vw-5rem)]`),style:PJ(t,n),onLoad:e=>{let t=e.currentTarget;i({width:t.naturalWidth,height:t.naturalHeight})}}):(0,O.jsx)(`iframe`,{src:e.url,title:e.name,className:`h-full min-h-[24rem] w-full rounded-xl border border-slate-800 bg-white`}):null})]})})}function LJ(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>0)return t}return null}function RJ(e){return e?LJ(e.context_window_tokens)??LJ(e?.limits?.context_window_tokens):null}function zJ(e){return e?LJ(e.auto_compact_threshold_percentage)??84:84}function BJ({selectedModel:e,contextUsage:t}){let n=t&&(!t.model||t.model===e?.id)?t:null,r=LJ(n?.used_tokens),i=LJ(n?.context_window_tokens),a=i??RJ(e),o={contextWindowTokens:a??void 0,contextWindowSource:a?i?`runtime`:`model`:void 0},s=n?.source===`last_request`?`上次请求输入`:`上下文占用`;if(!r)return{label:`上下文用量暂不可用`,phase:`default`,...o};let c=a?Math.round(r/a*100):void 0;return{label:s,phase:c!==void 0&&c>=zJ(e)?`warning`:`normal`,percent:c,usedTokens:r,...o}}function VJ(e){return e.requestedSessionId===e.activeSessionId&&e.requestToken===e.activeRequestToken}function HJ({agentName:e,emptyState:t,isMobile:n,onDeleteFeedback:r,onSubmitFeedback:i,onRespondToApproval:a,onRespondToAguiApproval:o,onSubmitAguiAction:s,onStopGeneration:c,onCancelRemote:l,checkpointResumeEnabled:u=!1,onResumeCheckpoint:d,onLoadOlderSessionMessages:f,interactionRecords:p,className:m}){let h=Qc(e=>e.messages),g=E(e=>e.currentSessionId),_=E(e=>e.isLoadingSessions),y=k(e=>!!(e.getSessionActivity(g)&&e.isSessionStreaming(g))),b=k(e=>e.getSessionActivity(g)),x=kj(e=>e.getSessionCheckpoints(g)),S=E(e=>g?e.messageHistory[g]:null),ee=_||!!S?.isLoadingInitial,C=E(e=>e.sessions.find(e=>e.SessionId===g)?.ContextUsage),w=We(e=>e.availableModels),te=We(e=>e.selectedModel),ne=ve(e=>e.previewAttachment),T=ve(e=>e.previewImageSize),re=(0,v.useRef)(null),ie=(0,v.useRef)(!0),ae=(0,v.useRef)(!1),oe=(0,v.useRef)(0),se=(0,v.useRef)(y),ce=(0,v.useRef)(!1),le=(0,v.useRef)(null),D=(0,v.useRef)(!0),ue=(0,v.useRef)(``),de=(0,v.useMemo)(()=>w.find(e=>e.id===te)||null,[w,te]),fe=(0,v.useMemo)(()=>BJ({selectedModel:de,contextUsage:C}),[de,C]),pe=(0,v.useCallback)(()=>{let e=re.current;if(!e)return;ie.current=!0,ae.current=!1;let t=e.style.scrollBehavior;e.style.scrollBehavior=`auto`;let n=0,r=0,i=-1,a=()=>{if(re.current===e){if(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)),r=e.scrollHeight===i?r+1:0,i=e.scrollHeight,n+=1,r>=3||n>=12){e.style.scrollBehavior=t;return}requestAnimationFrame(a)}};a()},[]);return(0,v.useEffect)(()=>{se.current=y},[y]),(0,v.useEffect)(()=>{D.current=!0,ie.current=!0,ae.current=!1,oe.current=0,ce.current=!1,le.current=null,ue.current=``},[g]),(0,v.useEffect)(()=>{let e=h.at(-1),t=ue.current;ue.current=String(e?.id||``),e?.role===`user`&&e.id!==t&&!D.current&&pe()},[h,pe]),(0,v.useEffect)(()=>{let e=re.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<oe.current-2;if(oe.current=e.scrollTop,!D.current&&n&&e.scrollTop<200&&g&&S?.hasMore&&!S.isLoadingOlder&&!ce.current&&f){let t=e.scrollHeight,n=g,r=Symbol(n);ce.current=!0,le.current=r,f(n).then(()=>{VJ({requestedSessionId:n,activeSessionId:E.getState().currentSessionId,requestToken:r,activeRequestToken:le.current})&&requestAnimationFrame(()=>{if(!VJ({requestedSessionId:n,activeSessionId:E.getState().currentSessionId,requestToken:r,activeRequestToken:le.current}))return;let e=re.current;if(!e)return;let i=e.scrollHeight-t;e.scrollTop+=i,oe.current=e.scrollTop})}).finally(()=>{le.current===r&&(le.current=null,ce.current=!1)})}if(se.current&&n){ae.current=!0,ie.current=!1;return}if(ae.current){let e=t<=12;ae.current=!e,ie.current=e;return}ie.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[S,g,f]),(0,v.useEffect)(()=>{let e=re.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{!D.current&&!ie.current||(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))});return t.observe(e),e.firstElementChild instanceof HTMLElement&&t.observe(e.firstElementChild),()=>t.disconnect()},[g]),(0,v.useEffect)(()=>{let e=re.current;if(e){if(h.length>0&&D.current){let e=E.getState().currentSessionId,t=re.current,n=t?t.style.scrollBehavior:``;t&&(t.style.scrollBehavior=`auto`,t.scrollTop=t.scrollHeight,oe.current=t.scrollTop);let r=0,i=t?.scrollHeight??-1,a=!1,o=0,s=()=>{let e=re.current;e&&(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))},c=()=>{a||(a=!0,s(),t&&(t.style.scrollBehavior=n),ie.current=!0,ae.current=!1,D.current=!1)},l=()=>{if(a)return;if(E.getState().currentSessionId!==e){a=!0;return}let t=re.current;if(t){if(t.scrollHeight!==i)i=t.scrollHeight,s(),r=0;else if(r+=1,r>=3){c();return}o=requestAnimationFrame(l)}},u=window.setTimeout(c,2e3);return o=requestAnimationFrame(l),()=>{if(cancelAnimationFrame(o),window.clearTimeout(u),E.getState().currentSessionId!==e){c();return}t&&(t.style.scrollBehavior=n)}}ie.current&&(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop)}},[h,y]),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(TJ,{emptyState:t,agentName:e,isMobile:n,isStreaming:y,activity:b,contextIndicator:fe,messages:h,isLoadingInitialHistory:ee,onDeleteFeedback:r,onOpenAttachmentPreview:e=>{ve.getState().setPreviewAttachment(e),ve.getState().setPreviewImageSize(null)},onRespondToApproval:a,onRespondToAguiApproval:o,interactionRecords:p,onScrollToBottom:pe,onSubmitFeedback:i,onSubmitAguiAction:s,onStopGeneration:c,onCancelRemote:l,checkpoints:u?x:[],onResumeCheckpoint:d,scrollRef:re,className:m}),(0,O.jsx)(IJ,{attachment:ne,isMobile:n,previewImageSize:T,onClose:()=>{ve.getState().setPreviewAttachment(null),ve.getState().setPreviewImageSize(null)},onImageLoad:e=>ve.getState().setPreviewImageSize(e)})]})}function UJ({indicator:e,onCompact:t,disabled:n}){let r=(0,v.useRef)(null),[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!i)return;let e=e=>{e.target instanceof Node&&!r.current?.contains(e.target)&&(o.current=!1,a(!1))},t=e=>{e.key===`Escape`&&(o.current=!1,a(!1),r.current?.querySelector(`button`)?.focus())};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,t)}},[i]);let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),d=typeof e.usedTokens==`number`&&Number.isFinite(e.usedTokens)&&e.usedTokens>=0,f=d&&typeof e.percent==`number`&&Number.isFinite(e.percent)?Math.max(0,Math.min(100,e.percent)):void 0,p=async()=>{if(!(!t||s||n)){c(!0),u(``);try{await t(),u(`上下文已压缩`)}catch(e){u(e instanceof Error?e.message:`压缩失败,请重试`)}finally{c(!1)}}};return(0,O.jsxs)(`div`,{ref:r,className:`relative flex h-8 w-8 items-center justify-center`,onPointerEnter:e=>{e.pointerType!==`touch`&&a(!0)},onPointerLeave:()=>{o.current||a(!1)},children:[(0,O.jsx)(`button`,{type:`button`,"aria-label":`上下文用量与压缩`,"aria-expanded":i,onClick:()=>{o.current=!o.current,a(o.current),u(``)},className:K(`flex h-8 w-8 items-center justify-center rounded-full`,e.phase===`warning`?`text-text-primary`:`text-text-muted`),children:(0,O.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,className:s?`animate-pulse`:void 0,style:{display:`block`,flexShrink:0},children:[(0,O.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`var(--ksadk-menu-border, #b8bcb5)`,strokeWidth:`2`}),f!==void 0&&(0,O.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,pathLength:`100`,strokeDasharray:`${f} 100`,transform:`rotate(-90 8 8)`})]})}),(0,O.jsxs)(`div`,{style:{background:`var(--ksadk-menu-background, hsl(var(--popover)))`,borderColor:`var(--ksadk-menu-border, hsl(var(--border)))`,boxShadow:`var(--ksadk-menu-shadow, 0 18px 44px rgba(15, 23, 42, 0.16))`},role:i?`dialog`:void 0,"aria-label":i?`上下文`:void 0,className:K(`absolute bottom-full right-0 z-30 w-60 rounded-xl border border-border bg-background p-4 text-sm text-foreground shadow-lg`,i?`block`:`hidden`),children:[(0,O.jsx)(`p`,{className:K(`font-medium`,s&&`waiting-thinking-text`),children:s?`正在压缩上下文…`:d?e.label:`上下文用量暂不可用`}),d&&(0,O.jsxs)(`p`,{className:`mt-1 text-text-secondary`,children:[`${WJ(e.usedTokens)} tokens`,e.contextWindowTokens?` / ${WJ(e.contextWindowTokens)}`:``]}),e.contextWindowTokens&&(0,O.jsxs)(`p`,{className:`mt-1 text-text-muted`,children:[`模型窗口:`,WJ(e.contextWindowTokens),` tokens`]}),d&&!e.contextWindowTokens&&(0,O.jsx)(`p`,{className:`mt-1 text-text-muted`,children:`模型窗口大小未报告`}),f!==void 0&&(0,O.jsxs)(`p`,{className:`text-text-muted`,children:[f,`% 已使用`]}),i&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>void p(),disabled:!t||s||n,className:`mt-3 w-full rounded-lg border border-border bg-muted px-3 py-2 disabled:opacity-50`,children:s?`正在压缩…`:`压缩上下文`}),(0,O.jsx)(`p`,{className:`mt-2 text-xs text-text-muted`,children:n?`请等待当前运行结束`:t?`压缩模型上下文,保留聊天记录`:`当前会话尚不支持手动压缩`}),l&&(0,O.jsx)(`p`,{role:`status`,className:`mt-2 text-xs`,children:l})]})]})]})}function WJ(e){return new Intl.NumberFormat(`zh-CN`).format(e)}var GJ=[{value:`plan`,label:`计划模式`,description:`先分析并形成可执行计划`,icon:jN},{value:`goal`,label:`设定目标`,description:`朝可验证的停止条件持续推进`,icon:tP}],KJ={plan:`计划模式`,goal:`目标`};function qJ({attachmentsEnabled:e,mode:t,support:n,onSelectMode:r,onUpload:i}){let[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(null),c=GJ.filter(e=>n[e.value]);return(0,v.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]),!e&&c.length===0?null:(0,O.jsxs)(`div`,{ref:s,className:`relative flex min-w-0 items-center gap-1`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-text-secondary transition hover:bg-muted hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,"aria-expanded":a,"aria-haspopup":`menu`,"aria-label":`添加附件或选择执行模式`,title:`添加附件或选择执行模式`,children:(0,O.jsx)(GN,{className:`h-[19px] w-[19px]`})}),t?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:K(`flex h-8 max-w-[8.5rem] items-center gap-1 rounded-xl px-2 text-[12px] transition`,t===`goal`?`bg-neutral-50 text-neutral-700 hover:bg-neutral-100 dark:bg-neutral-950/40 dark:text-neutral-300`:`text-text-secondary hover:bg-muted hover:text-text-primary`),"aria-label":`当前执行模式:${KJ[t]}`,children:[(0,O.jsx)(`span`,{className:`truncate`,children:KJ[t]}),(0,O.jsx)(pN,{className:`h-3.5 w-3.5 shrink-0`})]}):null,a?(0,O.jsxs)(`div`,{role:`menu`,"aria-label":`附件与执行模式`,className:`absolute bottom-[calc(100%+0.6rem)] left-0 z-40 w-[min(18rem,calc(100vw-2rem))] rounded-xl border border-border/80 bg-popover p-1 shadow-[0_10px_24px_rgba(15,23,42,0.12)]`,style:{backgroundColor:`var(--ksadk-popover, #fff)`,borderColor:`var(--ksadk-border, rgba(15, 23, 42, 0.12))`},children:[e?(0,O.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{i(),o(!1)},className:`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition hover:bg-muted/70`,children:[(0,O.jsx)(aP,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,O.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:`上传附件`}),(0,O.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:`添加文件或图片`})]}):null,c.map(e=>{let n=e.icon,i=t===e.value;return(0,O.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":i,onClick:()=>{r(e.value),o(!1)},className:K(`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition`,i?`bg-muted`:`hover:bg-muted/70`),children:[(0,O.jsx)(n,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,O.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:e.label}),(0,O.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),i?(0,O.jsx)(fN,{className:`h-4 w-4 shrink-0 text-text-primary`}):null]},e.value)})]}):null]})}var JJ=[{value:`auto`,label:`自动`},{value:`enabled`,label:`开启`},{value:`disabled`,label:`关闭`}],YJ={auto:`自动`,enabled:`开启`,disabled:`关闭`};function XJ({availableModels:e,selectedModel:t,thinkingEnabled:n,thinkingMode:r,onSelectModel:i,onSelectThinkingMode:a}){let[o,s]=(0,v.useState)(!1),c=(0,v.useRef)(null),l=e.find(e=>e.id===t)?.display_name||t||`选择模型`;return(0,v.useEffect)(()=>{if(!o)return;let e=e=>{c.current&&!c.current.contains(e.target)&&s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]),(0,O.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex h-8 max-w-[15rem] items-center gap-1.5 rounded-xl px-3 text-[13px] text-text-primary transition hover:brightness-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,style:{background:`var(--ksadk-menu-trigger-background, hsl(var(--muted)))`},"aria-expanded":o,"aria-haspopup":`menu`,"aria-label":n?`模型 ${l},推理 ${YJ[r]}`:`模型 ${l}`,title:n?`选择模型与推理设置`:`选择模型`,children:[(0,O.jsx)(`span`,{className:`min-w-0 truncate`,children:l}),n?(0,O.jsx)(`span`,{className:`shrink-0 text-text-muted`,children:YJ[r]}):null,(0,O.jsx)(pN,{className:K(`h-3.5 w-3.5 shrink-0 text-text-muted transition-transform`,o&&`rotate-180`)})]}),o?(0,O.jsxs)(`div`,{role:`menu`,"aria-label":`选择模型`,className:`absolute bottom-[calc(100%+0.65rem)] right-0 z-40 w-[min(17rem,calc(100vw-2rem))] overflow-hidden rounded-2xl border p-1.5`,style:{background:`var(--ksadk-menu-background, hsl(var(--popover)))`,borderColor:`var(--ksadk-menu-border, hsl(var(--border)))`,boxShadow:`var(--ksadk-menu-shadow, 0 18px 44px rgba(15, 23, 42, 0.16))`},children:[(0,O.jsx)(`div`,{className:`px-2.5 pb-1.5 pt-1 text-[11px] font-medium text-text-muted`,children:`模型`}),(0,O.jsx)(`div`,{className:`max-h-[min(45vh,18rem)] overflow-y-auto`,children:e.map(e=>{let n=e.id===t;return(0,O.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":n,onClick:()=>{i(e.id),s(!1)},className:K(`flex w-full items-center gap-2 rounded-xl px-2.5 py-2 text-left text-[13px] transition-colors`,n?`bg-muted text-text-primary`:`text-text-secondary hover:bg-muted hover:text-text-primary`),children:[(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.display_name||e.id}),n?(0,O.jsx)(fN,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}):null]},e.id)})}),n?(0,O.jsx)(`div`,{className:`mt-1 border-t border-border px-1 pt-1.5`,children:(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 pb-1`,children:[(0,O.jsx)(`span`,{className:`text-[11px] font-medium text-text-muted`,children:`推理`}),(0,O.jsx)(`div`,{className:`flex rounded-lg bg-muted p-0.5`,children:JJ.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(e.value),className:K(`rounded-md px-2 py-1 text-[11px] transition-colors`,e.value===r?`bg-card text-text-primary shadow-sm`:`text-text-muted hover:text-text-primary`),children:e.label},e.value))})]})}):null]}):null]})}var ZJ=[{value:`ask`,label:`请求批准`,description:`Agent 请求授权时确认`,icon:kN},{value:`risk`,label:`风险操作需确认`,description:`仅副作用操作`,icon:ZN},{value:`full`,label:`完全访问`,description:`不再确认`,icon:XN}],QJ={ask:`请求批准`,risk:`风险确认`,full:`完全访问`};function $J({approvalPolicy:e}){let[t,n]=(0,v.useState)(!1),r=(0,v.useRef)(null),i=fe(e=>e.permissionMode),a=fe(e=>e.setPermissionMode),o=i===`ask`?kN:i===`full`?XN:ZN,s=(0,v.useMemo)(()=>ZJ.filter(t=>!e||e.Modes.includes(t.value)),[e]);return(0,v.useEffect)(()=>{s.some(e=>e.value===i)||a(e?.DefaultMode||s[0]?.value||`risk`)},[e?.DefaultMode,i,a,s]),(0,v.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),(0,O.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:K(`flex h-8 items-center gap-1.5 rounded-xl px-2.5 text-[13px] transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,i===`full`?`text-amber-600 dark:text-amber-400`:`text-text-secondary hover:text-text-primary`),"aria-expanded":t,"aria-haspopup":`menu`,title:`设置本次会话的工具审批规则`,children:[(0,O.jsx)(o,{className:`h-3.5 w-3.5`}),(0,O.jsx)(`span`,{children:QJ[i]}),(0,O.jsx)(pN,{className:K(`h-3.5 w-3.5 transition-transform`,t&&`rotate-180`)})]}),t?(0,O.jsx)(`div`,{role:`menu`,"aria-label":`工具权限`,className:`absolute bottom-[calc(100%+0.6rem)] left-0 z-30 w-[18rem] rounded-xl border border-border/80 bg-popover p-1 shadow-[0_10px_24px_rgba(15,23,42,0.12)]`,style:{backgroundColor:`var(--ksadk-popover, #fff)`,borderColor:`var(--ksadk-border, rgba(15, 23, 42, 0.12))`},children:s.map(e=>{let t=e.icon,r=e.value===i;return(0,O.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,onClick:()=>{a(e.value),n(!1)},className:K(`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition-colors`,r?`bg-primary/[0.08]`:`hover:bg-muted/75`),children:[(0,O.jsx)(t,{className:K(`h-4 w-4 shrink-0`,r?`text-primary`:`text-text-muted`)}),(0,O.jsx)(`span`,{className:K(`shrink-0 text-[13px] font-medium`,r?`text-text-primary`:`text-text-secondary`),children:e.label}),(0,O.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),r?(0,O.jsx)(fN,{className:`h-4 w-4 shrink-0 text-primary`,"aria-hidden":`true`}):null]},e.value)})}):null]})}function eY({onCompactContext:e,attachments:t,composerContextIndicator:n,composerMaxHeight:r,fileInputRef:i,input:a,isMobile:o,isStreaming:s,attachmentsEnabled:c=!0,approvalEnabled:l=!1,approvalPolicy:u,thinkingEnabled:d=!1,executionMode:f,executionModeSupport:p,queuedDrafts:m,onAppendAttachments:h,onInputChange:g,onSelectExecutionMode:_,onPaste:y,onRemoveAttachment:b,onStopGeneration:x,onCancelRemote:S,onSubmit:ee,textareaRef:C,className:w}){let[te,ne]=(0,v.useState)(!1),T=e?async()=>{ne(!0);try{await e()}finally{ne(!1)}}:void 0,re=f===`goal`?`描述需要持续完成的目标…`:f===`plan`?`描述需要先规划的任务…`:o?`发送消息...`:`发送消息…`,ie=S?`保留恢复点并结束本次执行`:`停止生成`,ae=f===`goal`?!!a.trim():!!(a.trim()||t.length>0),oe=We(e=>e.availableModels),se=We(e=>e.selectedModel),ce=We(e=>e.thinkingMode),le=We(e=>e.setSelectedModel),E=We(e=>e.setThinkingMode),D=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`;return(0,O.jsx)(`div`,{className:K(`relative z-10 flex-shrink-0 bg-background/95 px-3 py-3 backdrop-blur sm:px-4 sm:py-3`,w),"data-slot":`composer`,children:(0,O.jsxs)(`div`,{className:`mx-auto w-full max-w-[64rem]`,children:[te&&(0,O.jsxs)(`div`,{role:`status`,className:`mb-3 flex items-center gap-2 px-2 text-sm text-text-muted`,children:[(0,O.jsx)(DN,{size:16,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`waiting-thinking-text`,children:`正在压缩上下文`})]}),m.length>0?(0,O.jsxs)(`div`,{className:`mb-2 rounded-2xl border border-neutral-200/80 bg-neutral-50/80 px-3 py-2 text-xs text-neutral-900 shadow-sm dark:border-neutral-900/60 dark:bg-neutral-950/30 dark:text-neutral-100`,children:[(0,O.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`span`,{className:`font-semibold`,children:[`发送队列 · `,m.length]}),(0,O.jsx)(`span`,{className:`text-neutral-700/75 dark:text-neutral-200/75`,children:`当前回复完成后依次发送`})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[m.slice(0,3).map((e,t)=>{let n=e.text.trim()||(e.attachments.length>0?`仅附件消息`:`空消息`);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-background/70 px-2 py-1.5`,children:[(0,O.jsx)(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-neutral-100 font-mono text-[10px] text-neutral-700 dark:bg-neutral-900/50 dark:text-neutral-100`,children:t+1}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:n}),e.attachments.length>0?(0,O.jsxs)(`span`,{className:`flex-shrink-0 rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] text-neutral-700 dark:bg-neutral-900/50 dark:text-neutral-100`,children:[e.attachments.length,` 附件`]}):null]},`${t}-${n}-${e.attachments.length}`)}),m.length>3?(0,O.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-neutral-700/80 dark:text-neutral-200/80`,children:[`还有 `,m.length-3,` 条等待发送`]}):null]})]}):null,(0,O.jsx)(`div`,{className:`relative rounded-[var(--chat-composer-radius,28px)] bg-surface shadow-[0_0_0_0.5px_rgba(15,23,42,0.08),0_5px_18px_rgba(15,23,42,0.07)] dark:shadow-[0_0_0_0.5px_rgba(255,255,255,0.06),0_8px_24px_rgba(0,0,0,0.24)]`,children:(0,O.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,O.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),te)return;if(s){S?S():x();return}let n=a.trim();ae&&ee(n,t)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),c&&e.dataTransfer.files&&e.dataTransfer.files.length>0&&h(Array.from(e.dataTransfer.files))},className:`relative flex min-h-[116px] min-w-0 flex-1 flex-col rounded-[var(--chat-composer-radius,28px)] border border-border/55 bg-background px-4 pb-3 pt-3 transition-all focus-within:border-primary/40 focus-within:ring-2 focus-within:ring-primary/15 sm:px-5`,children:[t.length>0?(0,O.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-2`,children:t.map((e,t)=>(0,O.jsxs)(`div`,{className:K(`group relative flex items-center gap-2 rounded-xl border border-border bg-background px-3 py-2 text-xs`,o?`max-w-full`:`max-w-[14rem]`),children:[(0,O.jsx)(`span`,{className:`flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-muted text-text-muted`,children:(0,O.jsx)(VN,{className:`h-3.5 w-3.5`})}),(0,O.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`span`,{className:`block truncate font-medium text-text-primary`,children:e.name}),(0,O.jsx)(`span`,{className:`block text-[10px] text-text-muted`,children:D(e.size)})]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>b(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full border border-border bg-background text-text-muted shadow-sm transition hover:text-rose-500`,"aria-label":`移除附件 ${e.name}`,children:(0,O.jsx)(`span`,{className:`text-[11px] leading-none`,children:`×`})})]},`${e.name}-${e.size}-${t}`))}):null,(0,O.jsx)(`textarea`,{ref:C,rows:1,value:a,onChange:g,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},onPaste:y,placeholder:re,className:K(`custom-scrollbar max-h-[176px] min-h-[62px] w-full resize-none overflow-y-auto border-0 bg-transparent px-0 pb-1 pt-1 text-[15px] leading-6 text-text-primary outline-none placeholder:text-text-muted/60`,o?`text-[16px]`:`text-[14px]`),style:{maxHeight:`${r}px`,overflowY:`auto`}}),(0,O.jsxs)(`div`,{className:`mt-auto flex min-h-8 items-center justify-between gap-2 pt-1.5`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,O.jsx)(`input`,{ref:i,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(h(Array.from(e.target.files)),e.target.value=``)}}),(0,O.jsx)(qJ,{attachmentsEnabled:c,mode:f,support:p,onSelectMode:_,onUpload:()=>i.current?.click()}),l?(0,O.jsx)($J,{approvalPolicy:u}):null]}),(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[n?(0,O.jsx)(UJ,{indicator:n,onCompact:T,disabled:s}):null,oe.length>0?(0,O.jsx)(XJ,{availableModels:oe,selectedModel:se,thinkingEnabled:d,thinkingMode:ce,onSelectModel:le,onSelectThinkingMode:E}):null,(0,O.jsx)(`button`,{type:`submit`,disabled:te||!s&&!ae,className:K(`flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,s||ae?`bg-[#1f1f1f] text-white hover:opacity-80`:`bg-muted text-text-muted/45`),title:s?ie:`发送消息`,children:s?(0,O.jsx)(eP,{className:`h-3.5 w-3.5 fill-current`}):(0,O.jsx)(uN,{className:`h-[18px] w-[18px]`})})]})]})]})})})]})})}function tY(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function nY(e,t){let n=new Map;for(let t of e)n.set(tY(t),t);for(let e of t)n.set(tY(e),e);return Array.from(n.values())}function rY(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function iY({onCompactContext:e,composerMaxHeight:t,submitDraft:n,stopGeneration:r,cancelRemote:i,isMobile:a,attachmentsEnabled:o=!0,approvalEnabled:s=!1,approvalPolicy:c,thinkingEnabled:l=!1,runtimeCapabilityMatrix:u,pendingInteractions:d,onRespondInteraction:f,localCatalog:p,className:m}){let[h,g]=(0,v.useState)(0),[_,y]=(0,v.useState)(),b=ve(e=>e.input),x=ve(e=>e.attachments),S=E(e=>e.currentSessionId),ee=k(e=>!!(e.getSessionActivity(S)&&e.isSessionStreaming(S))),C=ve(e=>e.queuedDrafts),w=E(e=>e.sessions.find(e=>e.SessionId===S)?.ContextUsage),te=We(e=>e.availableModels),ne=We(e=>e.selectedModel),T=We(e=>e.setThinkingMode),re=(0,v.useRef)(null),ie=(0,v.useRef)(null),ae=(0,v.useMemo)(()=>te.find(e=>e.id===ne)||null,[te,ne]),oe=(0,v.useMemo)(()=>BJ({selectedModel:ae,contextUsage:w}),[ae,w]),se=(0,v.useMemo)(()=>({plan:!!u?.plan?.supported,goal:!!u?.goal?.supported}),[u]),ce=_&&se[_]?_:void 0,le=(0,v.useCallback)((e,t)=>{!e&&t.length===0||(ve.getState().setInput(``),ve.getState().setAttachments([]),n(e,t,void 0,void 0,ce),ce===`goal`&&y(void 0))},[ce,n]);(0,v.useEffect)(()=>{ie.current&&(ie.current.style.height=`auto`,ie.current.style.height=`${Math.min(ie.current.scrollHeight,t)}px`)},[b,t]);let D=e=>{ve.getState().setInput(e.target.value),e.target.style.height=`auto`,e.target.style.height=`${Math.min(e.target.scrollHeight,t)}px`},ue=e=>{!o||!e.length||ve.getState().setAttachments(t=>nY(t,e))},de=e=>{if(!o)return;let t=rY(e);t.length&&(e.preventDefault(),e.stopPropagation(),ue(t))},fe=d||[],pe=Math.min(h,Math.max(fe.length-1,0));return(0,v.useEffect)(()=>{l||T(`auto`)},[T,l]),(0,O.jsxs)(`div`,{className:`flex w-full flex-col justify-center`,children:[fe.length>0&&f?(0,O.jsx)(Uq,{interactions:fe,activeIndex:pe,onSelectIndex:g,onRespond:f,localCatalog:p}):null,(0,O.jsx)(eY,{onCompactContext:S?e:void 0,attachments:x,composerContextIndicator:oe,composerMaxHeight:t,fileInputRef:re,input:b,isMobile:a,isStreaming:ee,attachmentsEnabled:o,approvalEnabled:s,approvalPolicy:c,thinkingEnabled:l,executionMode:ce,executionModeSupport:se,queuedDrafts:C,onAppendAttachments:ue,onInputChange:D,onSelectExecutionMode:y,onPaste:de,onRemoveAttachment:e=>ve.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:r,onCancelRemote:i,onSubmit:le,textareaRef:ie,className:m},S||`new-session`)]})}var aY=(0,v.lazy)(()=>J(()=>import(`./NativeTerminalPanel-DPLNV-9q.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function oY({availableModels:e,selectedModel:t,onSelectModel:n,selectedModelLabel:r,modelCatalogLoaded:i,modelSource:a,thinkingEnabled:o,thinkingMode:s,onSelectThinkingMode:c,compact:l=!1}){let u=K(`rounded-full border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition-colors focus:ring-1 focus:ring-blue-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300`,l?`w-full`:`max-w-[13rem]`),d=e.length>1?(0,O.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:u,children:e.map(e=>(0,O.jsx)(`option`,{value:e.id,children:e.display_name||e.id},e.id))}):r?(0,O.jsx)(`span`,{className:K(u,`inline-flex max-w-full items-center`,l?`justify-start`:``),title:a||r,children:(0,O.jsx)(`span`,{className:`truncate`,children:r})}):(0,O.jsx)(`span`,{className:`text-sm text-slate-400`,children:i?`未配置模型`:`Loading models...`}),f=o?(0,O.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:K(u,l?``:`max-w-[9rem]`),title:`控制模型 thinking/reasoning 参数`,children:[(0,O.jsx)(`option`,{value:`auto`,children:`思考自动`}),(0,O.jsx)(`option`,{value:`enabled`,children:`开启思考`}),(0,O.jsx)(`option`,{value:`disabled`,children:`关闭思考`})]}):null;return(0,O.jsxs)(`div`,{className:K(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function sY({agentName:e,currentSessionId:t,isMobile:n,sidebarOpen:r,mobileSidebarOpen:i,onToggleSidebar:a,availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,mobileActionsOpen:h,onMobileActionsOpenChange:g,workspaceEnabled:_,onOpenWorkspace:y,nativeManagementLink:b,nativeTerminal:x,nativeLauncherMode:S=!1}){let[ee,C]=(0,v.useState)(!1),w=!!x?.Enabled,te=n?i?(0,O.jsx)(zN,{className:`h-5 w-5`}):(0,O.jsx)(BN,{className:`h-5 w-5`}):r?(0,O.jsx)(zN,{className:`h-5 w-5`}):(0,O.jsx)(BN,{className:`h-5 w-5`});return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`header`,{className:K(`flex flex-shrink-0 items-center justify-between border-b border-black/[0.06] bg-background/95 px-3 py-2 backdrop-blur dark:border-white/[0.08] dark:bg-background/95 sm:px-4`,n?`pt-[calc(var(--safe-area-top)+0.5rem)]`:`h-12`),children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[S?null:(0,O.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":n?`打开历史记录`:`切换侧边栏`,children:te}),(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base`,children:e}),(0,O.jsx)(`div`,{className:`text-[11px] text-slate-400 dark:text-slate-500`,children:S?`原生运行时入口`:`智能体`})]})]}),n?(0,O.jsx)(`button`,{type:`button`,onClick:()=>g(!0),className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":`打开会话操作`,children:(0,O.jsx)(SN,{className:`h-5 w-5`})}):(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b?(0,O.jsxs)(`a`,{href:b.href,target:`_blank`,rel:`noreferrer`,title:b.title,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(CN,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{children:b.label})]}):null,_?(0,O.jsxs)(`button`,{type:`button`,onClick:y,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(ON,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{children:`Workspace`})]}):null,w?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>C(!0),className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm font-medium leading-none text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,O.jsx)($N,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{children:`TUI`})]}):null,!S&&n?(0,O.jsx)(oY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0}):null,!S&&t?(0,O.jsxs)(`span`,{className:`rounded bg-slate-50 px-2 py-1 text-xs font-mono text-slate-400 dark:bg-slate-800`,children:[`ID: `,t.slice(0,8)]}):null]})]}),n?(0,O.jsx)(qR,{open:h,onOpenChange:g,children:(0,O.jsxs)(YR,{side:`bottom`,className:`rounded-t-[1.75rem] border-slate-200 bg-white px-4 pb-[calc(var(--safe-area-bottom)+1rem)] pt-6 dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsxs)(XR,{className:`text-left`,children:[(0,O.jsx)(ZR,{children:`会话设置`}),(0,O.jsx)(QR,{className:`sr-only`,children:`调整当前会话的模型和 Workspace 操作。`})]}),(0,O.jsxs)(`div`,{className:`mt-6 flex flex-col gap-4`,children:[_?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),y()},className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(ON,{className:`h-4 w-4`}),`工作区文件`]}):null,w?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),C(!0)},className:`inline-flex items-center gap-2 rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-3 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,O.jsx)($N,{className:`h-4 w-4`}),`原生 TUI`]}):null,b?(0,O.jsxs)(`a`,{href:b.href,target:`_blank`,rel:`noreferrer`,title:b.title,onClick:()=>g(!1),className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(CN,{className:`h-4 w-4`}),b.label]}):null,S?(0,O.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm leading-6 text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:`当前运行时对话在原生管理台中进行;这里保留管理入口和 Workspace 文件操作。`}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`模型`}),(0,O.jsx)(oY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`当前会话`}),(0,O.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:t?(0,O.jsx)(`span`,{className:`break-all font-mono`,children:t}):`新对话尚未创建会话 ID`})]})]})]})]})}):null,x&&ee?(0,O.jsx)(v.Suspense,{fallback:null,children:(0,O.jsx)(aY,{capability:x,open:ee,sessionId:t,onClose:()=>C(!1)})}):null]})}var cY=(0,v.lazy)(()=>J(()=>import(`./NativeTerminalPanel-DPLNV-9q.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function lY({productLabel:e=`原生运行时`,nativeManagementLink:t,nativeTerminal:n,workspaceEnabled:r,onOpenWorkspace:i}){let a=!!n?.Enabled,[o,s]=(0,v.useState)(!1);return(0,O.jsxs)(`section`,{className:`flex min-h-0 flex-1 overflow-y-auto bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.12),transparent_34%),linear-gradient(135deg,#f8fafc_0%,#ffffff_48%,#f1f5f9_100%)] px-4 py-8 dark:bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_34%),linear-gradient(135deg,#020617_0%,#0f172a_52%,#111827_100%)] sm:px-8`,children:[(0,O.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col justify-center`,children:(0,O.jsxs)(`div`,{className:`overflow-hidden rounded-[2rem] border border-slate-200/80 bg-white/90 shadow-xl shadow-slate-200/60 backdrop-blur dark:border-slate-800 dark:bg-slate-900/85 dark:shadow-black/30`,children:[(0,O.jsxs)(`div`,{className:`border-b border-slate-200/80 bg-slate-50/80 px-6 py-5 dark:border-slate-800 dark:bg-slate-950/40 sm:px-8`,children:[(0,O.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-sky-200 bg-sky-50 px-3 py-1 text-xs font-medium text-sky-700 dark:border-sky-900/60 dark:bg-sky-950/50 dark:text-sky-300`,children:[(0,O.jsx)(ZN,{className:`h-3.5 w-3.5`}),e,` native runtime`]}),(0,O.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl`,children:`对话请使用原生管理台`}),(0,O.jsx)(`p`,{className:`mt-3 max-w-2xl text-sm leading-6 text-slate-600 dark:text-slate-300 sm:text-base`,children:`当前运行时的对话状态由原生管理台承载。AgentEngine Hosted UI 在这里保留统一入口和 Workspace 文件管理,不重复实现运行时内部已有的复杂对话状态机。`})]}),(0,O.jsxs)(`div`,{className:`grid gap-4 p-6 md:grid-cols-3 sm:p-8`,children:[(0,O.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-slate-950 text-white dark:bg-slate-100 dark:text-slate-950`,children:(0,O.jsx)(IN,{className:`h-5 w-5`})}),(0,O.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生管理台`}),(0,O.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。`}),t?(0,O.jsxs)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer`,title:t.title,className:`mt-5 inline-flex items-center gap-2 rounded-2xl bg-slate-950 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-950 dark:hover:bg-white`,children:[(0,O.jsx)(CN,{className:`h-4 w-4`}),`打开`,t.label]}):(0,O.jsx)(`div`,{className:`mt-5 rounded-2xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm leading-6 text-neutral-800 dark:border-neutral-900/60 dark:bg-neutral-950/30 dark:text-neutral-200`,children:`当前访问模式不开放原生管理入口。需要完整对话体验时,请使用 owner/private 链接或 CLI。`})]}),(0,O.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-300`,children:(0,O.jsx)(ON,{className:`h-5 w-5`})}),(0,O.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`Workspace 文件管理`}),(0,O.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。`}),r?(0,O.jsxs)(`button`,{type:`button`,onClick:i,className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-medium text-slate-800 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:hover:bg-slate-700`,children:[(0,O.jsx)(ON,{className:`h-4 w-4`}),`打开 Workspace`]}):(0,O.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前链接未开放 Workspace 文件管理。Owner 或 private 链接可使用该能力。`})]}),(0,O.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300`,children:(0,O.jsx)($N,{className:`h-5 w-5`})}),(0,O.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生 TUI`}),(0,O.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。`}),a?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-2.5 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,O.jsx)($N,{className:`h-4 w-4`}),`打开 TUI`]}):(0,O.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前运行时未声明可用的浏览器 TUI 能力。`})]})]})]})}),n&&o?(0,O.jsx)(v.Suspense,{fallback:null,children:(0,O.jsx)(cY,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var uY=[],dY=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?dY:uY).push(n+=e[t])})();function fY(e){if(e<768)return!1;for(let t=0,n=uY.length;;){let r=t+n>>1;if(e<uY[r])n=r;else if(e>=dY[r])t=r+1;else return!0;if(t==n)return!1}}function pY(e){return e>=127462&&e<=127487}var mY=8205;function hY(e,t,n=!0,r=!0){return(n?gY:_Y)(e,t,r)}function gY(e,t,n){if(t==e.length)return t;t&&yY(e.charCodeAt(t))&&bY(e.charCodeAt(t-1))&&t--;let r=vY(e,t);for(t+=xY(r);t<e.length;){let i=vY(e,t);if(r==mY||i==mY||n&&fY(i))t+=xY(i),r=i;else if(pY(i)){let n=0,r=t-2;for(;r>=0&&pY(vY(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function _Y(e,t,n){for(;t>0;){let r=gY(e,t-2,n);if(r<t)return r;t--}return 0}function vY(e,t){let n=e.charCodeAt(t);if(!bY(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return yY(r)?(n-55296<<10)+(r-56320)+65536:n}function yY(e){return e>=56320&&e<57344}function bY(e){return e>=55296&&e<56320}function xY(e){return e<65536?1:2}var SY=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=MY(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),wY.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=MY(this,e,t);let n=[];return this.decompose(e,t,n,0),wY.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new OY(this),i=new OY(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new OY(this,e)}iterRange(e,t=this.length){return new kY(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new AY(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new CY(t):wY.from(CY.split(t,[]))}},CY=class e extends SY{constructor(e,t=TY(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new jY(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(DY(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=EY(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=MY(this,t,n);let i=EY(this.text,EY(r.text,DY(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):wY.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
201
201
|
`){[e,t]=MY(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},wY=class e extends SY{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=MY(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
202
202
|
`){[e,t]=MY(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new CY(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof CY&&c&&(n=u[u.length-1])instanceof CY&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new CY(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};SY.empty=new CY([``],0);function TY(e){let t=-1;for(let n of e)t+=n.length+1;return t}function EY(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function DY(e,t,n){return EY(e,[``],t,n)}var OY=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof CY?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof CY?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
203
203
|
`,this;e--}else if(r instanceof CY){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof CY?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},kY=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new OY(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},AY=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(SY.prototype[Symbol.iterator]=function(){return this.iter()},OY.prototype[Symbol.iterator]=kY.prototype[Symbol.iterator]=AY.prototype[Symbol.iterator]=function(){return this});var jY=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function MY(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function NY(e,t,n=!0,r=!0){return hY(e,t,n,r)}function PY(e){return e>=56320&&e<57344}function FY(e){return e>=55296&&e<56320}function IY(e,t){let n=e.charCodeAt(t);if(!FY(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return PY(r)?(n-55296<<10)+(r-56320)+65536:n}function LY(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function RY(e){return e<65536?1:2}var zY=/\r\n?|\n/,BY=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(BY||={}),VY=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){GY(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:qY(this,e)}mapDesc(e,t=!1){return e.empty?this:KY(this,e,t)}mapPos(e,t=-1,n=BY.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=BY.Simple&&c>=e&&(n==BY.TrackDel&&r<e&&c>e||n==BY.TrackBefore&&r<e||n==BY.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},HY=class e extends VY{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return GY(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return KY(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(SY.empty);r.push(a?t.slice(i,i+a):SY.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:qY(this,e,!0)}map(e,t=!1){return e.empty?this:KY(this,e,t,!0)}iterChanges(e,t=!1){GY(this,e,t)}get desc(){return VY.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new JY(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);UY(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;UY(n,e,t),t>0&&WY(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);UY(n,e,-1),UY(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:VY.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&UY(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?SY.of(l.split(r||zY)):l:SY.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&UY(i,e-o,-1),UY(i,s-e,d),WY(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(SY.empty);r[e]=SY.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function UY(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function WY(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(SY.empty);e.push(n)}}function GY(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=SY.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function KY(e,t,n,r=!1){let i=[],a=r?[]:null,o=new JY(e),s=new JY(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);UY(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(UY(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(UY(i,0,o.ins),a&&WY(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;UY(i,t,e<o.i?o.ins:0),a&&e<o.i&&WY(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?HY.createSet(i,a):VY.create(i);else throw Error(`Mismatched change set lengths`)}function qY(e,t,n=!1){let r=[],i=n?[]:null,a=new JY(e),o=new JY(t);for(let e=!1;;)if(a.done&&o.done)return i?HY.createSet(r,i):VY.create(r);else if(a.ins==0)UY(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)UY(r,0,o.ins,e),i&&WY(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;UY(r,t,n,e),i&&n&&WY(i,r,o.text)}else o.ins==-1?(UY(r,a.off?0:a.len,t,e),i&&WY(i,r,a.textBit(t))):(UY(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&WY(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var JY=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?SY.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?SY.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},YY=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return Y.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Y.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return Y.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},Y=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>YY.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return YY.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,i){let a=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!i&&e!=t&&(i=t<e?1:-1),t<e?YY.create(t,e,48|a):YY.create(e,t,(i?i<0?8:16:0)|a)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function XY(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var ZY=0,QY=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=ZY++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:$Y),!!t.static,t.enables)}of(e){return new eX([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new eX(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new eX(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function $Y(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var eX=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=ZY++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||nX(e,c)){let r=t(e);if(a?!tX(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=hX(o,c);if(this.dependencies.every(t=>t instanceof QY?o.facet(t)===e.facet(t):t instanceof aX?o.field(t,!1)==e.field(t,!1):!0)||(a?tX(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function tX(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function nX(e,t){let n=!1;for(let r of t)mX(e,r)&1&&(n=!0);return n}function rX(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=hX(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)mX(e,t);return e.values[o]=s(e),1},update(e,n){if(!nX(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=nX(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&$Y(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var iX=QY.define({static:!0}),aX=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(ZY++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(iX).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(iX),i=n.facet(iX),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,iX.of({field:this,create:e})]}get extension(){return this}},oX={lowest:4,low:3,default:2,high:1,highest:0};function sX(e){return t=>new lX(t,e)}var cX={highest:sX(oX.highest),high:sX(oX.high),default:sX(oX.default),low:sX(oX.low),lowest:sX(oX.lowest)},lX=class{constructor(e,t){this.inner=e,this.prec=t}},uX=class e{of(e){return new dX(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},dX=class{constructor(e,t){this.compartment=e,this.inner=t}},fX=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of pX(t,n,o))e instanceof aX?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,$Y(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>rX(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function pX(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof dX&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof dX){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof lX)a(e.inner,e.prec);else if(e instanceof aX)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof eX)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,oX.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,oX.default),r.reduce((e,t)=>e.concat(t))}function mX(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function hX(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var gX=QY.define(),_X=QY.define({combine:e=>e.some(e=>e),static:!0}),vX=QY.define({combine:e=>e.length?e[0]:void 0,static:!0}),yX=QY.define(),bX=QY.define(),xX=QY.define(),SX=QY.define({combine:e=>e.length?e[0]:!1}),CX=class{constructor(e,t){this.type=e,this.value=t}static define(){return new wX}},wX=class{of(e){return new CX(this,e)}},TX=class{constructor(e){this.map=e}of(e){return new EX(this,e)}},EX=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new TX(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};EX.reconfigure=EX.define(),EX.appendConfig=EX.define();var DX=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&XY(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};DX.time=CX.define(),DX.userEvent=CX.define(),DX.addToHistory=CX.define(),DX.remote=CX.define();function OX(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function kX(e,t,n){let r,i,a;return n?(r=t.changes,i=HY.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:EX.mapEffects(e.effects,r).concat(EX.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function AX(e,t,n){let r=t.selection,i=FX(t.annotations);return t.userEvent&&(i=i.concat(DX.userEvent.of(t.userEvent))),{changes:t.changes instanceof HY?t.changes:HY.of(t.changes||[],n,e.facet(vX)),selection:r&&(r instanceof Y?r:Y.single(r.anchor,r.head)),effects:FX(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function jX(e,t,n){let r=AX(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=kX(r,AX(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=DX.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return NX(n?MX(i):i)}function MX(e){let t=e.startState,n=!0;for(let r of t.facet(yX)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:OX(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=HY.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=DX.create(t,r,e.selection&&e.selection.map(i),EX.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(bX);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof DX?i:Array.isArray(i)&&i.length==1&&i[0]instanceof DX?i[0]:jX(t,FX(i),!1)}return e}function NX(e){let t=e.startState,n=t.facet(xX),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=kX(r,AX(t,a,e.changes.newLength),!0))}return r==e?e:DX.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var PX=[];function FX(e){return e==null?PX:Array.isArray(e)?e:[e]}var IX=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(IX||={}),LX=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,RX;try{RX=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function zX(e){if(RX)return RX.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||LX.test(n)))return!0}return!1}function BX(e){return t=>{if(!/\S/.test(t))return IX.Space;if(zX(t))return IX.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return IX.Word;return IX.Other}}var VX=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)mX(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return mX(this,n),hX(this,n)}update(...e){return jX(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(uX.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(EX.reconfigure)?(n=null,r=e.value):e.is(EX.appendConfig)&&(n=null,r=FX(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=fX.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(_X)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:Y.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=FX(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=EX.mapEffects(a,c).concat(EX.mapEffects(FX(o.effects),l))}return{changes:r,selection:Y.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof HY?t:HY.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return SY.of(t.split(this.facet(e.lineSeparator)||zY))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(mX(this,t),hX(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof aX&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:Y.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=fX.resolve(t.extensions||[],new Map),r=t.doc instanceof SY?t.doc:SY.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||zY)),i=t.selection?t.selection instanceof Y?t.selection:Y.single(t.selection.anchor,t.selection.head):Y.single(0);return XY(i,r.length),n.staticFacet(_X)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
|
|
@@ -209,7 +209,7 @@ $2`),t=t.replace(/([。;;::\.])\s*-(?!-)\s*/g,`$1
|
|
|
209
209
|
`))};if((IZ.mac||IZ.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:SY.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);I1(e,u,Y.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(GZ.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:c$.of(GZ.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=$Z(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to)if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}else r=null,this.revertPending(e.state);if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},x2=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||yQ(e.parent)||document,this.viewState=new X0(this,e.state||VX.create(e)),e.scrollTo&&e.scrollTo.is(s$)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(f$).map(e=>new m$(e));for(let e of this.plugins)e.update(this);this.observer=new g2(this),this.inputState=new H1(this),this.inputState.ensureHandlers(this.plugins),this.docView=new n1(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof DX?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(b0))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=x0(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(VX.phrases)!=this.state.facet(VX.phrases))return this.setState(a);i=D$.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new o$(t.empty?t:Y.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(s$)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=w2.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(T$)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(o2)!=i.state.facet(o2)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(QQ))try{e(i)}catch(e){l$(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!F1(this,u)&&l.force&&vQ(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new X0(this,e),this.plugins=e.facet(f$).map(e=>new m$(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new n1(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(f$),n=e.state.facet(f$);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new m$(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){l$(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0)if(xQ(n||this.win))i=-1,a=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let c=s.map(e=>{try{return e.read(this)}catch(e){return l$(this.state,e),C2}}),l=D$.create(this,this.state,[]),u=!1;l.flags|=o,t?t.flags|=o:t=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),u=this.docView.update(l),u&&this.docViewUpdate());for(let e=0;e<s.length;e++)if(c[e]!=C2)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){l$(this.state,e)}if(u&&this.docView.updateSelection(!0),!l.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let e=((i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-a)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(QQ))e(t)}get themeClasses(){return c2+` `+(this.state.facet(s2)?u2:l2)+` `+this.state.facet(o2)}updateAttrs(){let e=T2(this,h$,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(u$)?`true`:`false`,class:`cm-content`,style:`${IZ.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),T2(this,g$,t);let n=this.observer.ignore(()=>{let n=VZ(this.contentDOM,this.contentAttrs,t),r=VZ(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&(this.announceDOM.textContent=``),n=!1;let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(T$);let t=this.state.facet(e.cspNonce);pZ.mount(this.root,this.styleModules.concat(p2).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return w1(this,e,y1(this,e,t,n))}moveByGroup(e,t){return w1(this,e,y1(this,e,t,t=>b1(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return Y.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return v1(this,e,t,n)}moveVertically(e,t,n){return w1(this,e,x1(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=E1(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),E1(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),a=i[FQ.find(i,e-r.from,-1,t)];return cQ(n,a.dir==TQ.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(r$)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>S2)return WQ(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||IQ(r.isolates,n=S$(this,e))))return r.order;n||=S$(this,e);let r=UQ(e.text,t,n);return this.bidiCache.push(new w2(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||IZ.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{hQ(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return s$.of(new o$(typeof e==`number`?Y.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return s$.of(new o$(Y.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return p$.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return p$.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=pZ.newName(),r=[o2.of(n),T$.of(f2(`.${n}`,e))];return t&&t.dark&&r.push(s2.of(!0)),r}static baseTheme(e){return cX.lowest(T$.of(f2(`.`+c2,e,d2)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&k$.get(t)||k$.get(e))?.root?.view||null}};x2.styleModule=T$,x2.inputHandler=$Q,x2.clipboardInputFilter=t$,x2.clipboardOutputFilter=n$,x2.scrollHandler=a$,x2.focusChangeEffect=e$,x2.perLineTextDirection=r$,x2.exceptionSink=ZQ,x2.updateListener=QQ,x2.editable=u$,x2.mouseSelectionStyle=XQ,x2.dragMovesSelection=YQ,x2.clickAddsSelectionRange=JQ,x2.decorations=_$,x2.blockWrappers=v$,x2.outerDecorations=y$,x2.atomicRanges=b$,x2.bidiIsolatedRanges=x$,x2.cursorScrollMargin=QY.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),x2.scrollMargins=C$,x2.darkTheme=s2,x2.cspNonce=QY.define({combine:e=>e.length?e[0]:``}),x2.contentAttributes=g$,x2.editorAttributes=h$,x2.lineWrapping=x2.contentAttributes.of({class:`cm-lineWrapping`}),x2.announce=EX.define();var S2=4096,C2={},w2=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:TQ.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function T2(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&LZ(a,n)}return n}var E2=IZ.mac?`mac`:IZ.windows?`win`:IZ.linux?`linux`:`key`;function D2(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function O2(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var k2=cX.default(x2.domEventHandlers({keydown(e,t){return R2(M2(t.state),e,t,`editor`)}})),A2=QY.define({enables:k2}),j2=new WeakMap;function M2(e){let t=e.facet(A2),n=j2.get(t);return n||j2.set(t,n=I2(t.reduce((e,t)=>e.concat(t),[]))),n}function N2(e,t,n){return R2(M2(e.state),t,e,n)}var P2=null,F2=4e3;function I2(e,t=E2){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>D2(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=P2={view:t,prefix:n,scope:e};return setTimeout(()=>{P2==r&&(P2=null)},F2),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,L2))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var L2=null;function R2(e,t,n,r){L2=t;let i=SZ(t),a=RY(IY(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;P2&&P2.view==n&&P2.scope==r&&(o=P2.prefix+` `,q1.indexOf(t.keyCode)<0&&(c=!0,P2=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+O2(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(IZ.windows&&t.ctrlKey&&t.altKey)&&!(IZ.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=gZ[t.keyCode])&&p!=i?(d(f[o+O2(p,t,!0)])||t.shiftKey&&(m=_Z[t.keyCode])!=i&&m!=p&&d(f[o+O2(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+O2(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),L2=null,s}var z2=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className?(this.adjust(e),!0):!1}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,this.width!=null&&(e.style.width=this.width+`px`),e.style.height=this.height+`px`}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=B2(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return H2(t,n,r)}};function B2(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==TQ.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function V2(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function H2(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==TQ.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=B2(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=_1(e,r,1),m=_1(e,i,-1),h=p.type==WZ.Text?p:null,g=m.type==WZ.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=V2(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=V2(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):b(p,!1),r=g?y(null,n.to,g):b(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(_(d,t.bottom,f,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==WZ.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new z2(t,e-c.left,n-c.top,Math.max(0,r-e),i-n)}function v({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(_(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,o=-1e9,s=[];function c(t,n,c,l,u){let p=e.coordsAtPos(t,t==r.to?-2:2),m=e.coordsAtPos(c,c==r.from?2:-2);!p||!m||(i=Math.min(p.top,m.top,i),o=Math.max(p.bottom,m.bottom,o),u==TQ.LTR?s.push(a&&n?d:p.left,a&&l?f:m.right):s.push(!a&&l?d:m.left,!a&&n?f:p.right))}let l=t??r.from,u=n??r.to;for(let r of e.visibleRanges)if(r.to>l&&r.from<u)for(let i=Math.max(r.from,l),a=Math.min(r.to,u);;){let r=e.state.doc.lineAt(i);for(let o of e.bidiSpans(r)){let e=o.from+r.from,s=o.to+r.from;if(e>=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function b(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function U2(e,t){return e.constructor==t.constructor&&e.eq(t)}var W2=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement(`div`)),this.dom.classList.add(`cm-layer`),t.above&&this.dom.classList.add(`cm-layer-above`),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute(`aria-hidden`,`true`),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(G2)!=e.state.facet(G2)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(G2);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>!U2(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,IZ.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},G2=QY.define();function K2(e){return[p$.define(t=>new W2(t,e)),G2.of(e)]}var q2=QY.define({combine(e){return HX(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function J2(e={}){return[q2.of(e),X2,Q2,$2,i$.of(!0)]}function Y2(e){return e.startState.facet(q2)!=e.state.facet(q2)}var X2=K2({above:!0,markers(e){let{state:t}=e,n=t.facet(q2),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&IZ.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:Y.cursor(i.head,i.assoc);for(let i of z2.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=Y2(e);return n&&Z2(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){Z2(t.state,e)},class:`cm-cursorLayer`});function Z2(e,t){t.style.animationDuration=e.facet(q2).cursorBlinkRate+`ms`}var Q2=K2({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let n of r)if(!n.empty)for(let r of z2.forRange(e,`cm-selectionBackground`,n))t.push(r);if(IZ.ios&&!n.empty&&e.state.facet(q2).iosSelectionHandles){for(let r of z2.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,Y.cursor(n.from,1)))t.push(r);for(let r of z2.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,Y.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||Y2(e)},class:`cm-selectionLayer`}),$2=cX.highest(x2.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`transparent !important`},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}}})),e4=EX.define({map(e,t){return e==null?null:t.mapPos(e)}}),t4=aX.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(e4)?t.value:e,e)}}),n4=p$.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(t4);n==null?this.cursor!=null&&((t=this.cursor)==null||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement(`div`)),this.cursor.className=`cm-dropCursor`),(e.startState.field(t4)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(t4),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+`px`,this.cursor.style.top=e.top/n+`px`,this.cursor.style.height=e.height/n+`px`):this.cursor.style.left=`-100000px`}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(t4)!=e&&this.view.dispatch({effects:e4.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function r4(){return[t4,n4]}/x/.unicode;function i4(){return o4}var a4=GZ.line({class:`cm-activeLine`}),o4=p$.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(a4.range(i.from)),t=i.from)}return GZ.set(n)}},{decorations:e=>e.decorations}),s4=2e3;function c4(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>s4||n.off>s4||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=s&&a.push(Y.range(n.from+o,n.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=cZ(n.text,o,e.tabSize,!0);if(r<0)a.push(Y.cursor(n.to));else{let t=cZ(n.text,s,e.tabSize);a.push(Y.range(n.from+r,n.from+t))}}}return a}function l4(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function u4(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,a=i>s4?-1:i==r.length?l4(e,t.clientX):sZ(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function d4(e,t){let n=u4(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,a){let o=u4(e,t);if(!o)return r;let s=c4(e.state,n,o);return s.length?a?Y.create(s.concat(r.ranges)):Y.create(s):r}}:null}function f4(e){let t=e?.eventFilter||(e=>e.altKey&&e.button==0);return x2.mouseSelectionStyle.of((e,n)=>t(n)?d4(e,n):null)}var p4={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},m4={style:`cursor: crosshair`};function h4(e={}){let[t,n]=p4[e.key||`Alt`],r=p$.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){(e.keyCode==t||!n(e))&&this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,x2.contentAttributes.of(e=>e.plugin(r)?.isDown?m4:null)]}var g4=`-10000px`,_4=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function v4(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var y4=QY.define({combine:e=>({position:IZ.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||v4})}),b4=new WeakMap,x4=p$.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(y4);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new _4(e,T4,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(y4);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=g4,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(IZ.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else ({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=w$(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(y4).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=g4;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=b4.get(c)??d.bottom-d.top,g=c.offset||w4,_=this.view.textDirection==TQ.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let b=(y?u.top-n.top:n.bottom-u.bottom)-p;if(b<h&&c.resize!==!1){if(b<this.view.defaultLineHeight){l.style.top=g4;continue}b4.set(c,h),l.style.height=(h=b)/i+`px`}else l.style.height&&(l.style.height=``);let x=y?u.top-h-p-g.y:u.bottom+p+g.y,S=v+m;if(c.overlap!==!0)for(let e of a)e.left<S&&e.right>v&&e.top<x+h&&e.bottom>x&&(x=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(x-e.parent.top)/i+`px`,S4(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,S4(l,v/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:x,right:S,bottom:x+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=g4}},{eventObservers:{scroll(){this.maybeMeasure()}}});function S4(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var C4=x2.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),w4={x:0,y:0},T4=QY.define({enables:[x4,C4]});function E4(e,t){let n=e.plugin(x4);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var D4=QY.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function O4(e,t){let n=e.plugin(k4),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var k4=p$.fromClass(class{constructor(e){this.input=e.state.facet(M4),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(D4);this.top=new A4(e,!0,t.topContainer),this.bottom=new A4(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(D4);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new A4(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new A4(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(M4);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>x2.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),A4=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),void 0);return}if(!this.dom){this.dom=document.createElement(`div`),this.dom.className=this.top?`cm-panels cm-panels-top`:`cm-panels cm-panels-bottom`,this.dom.style[this.top?`top`:`bottom`]=`0`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=j4(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=j4(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function j4(e){let t=e.nextSibling;return e.remove(),t}var M4=QY.define({enables:k4});function N4(e,t){let n,r=new Promise(e=>n=e),i=e=>L4(e,t,n);e.state.field(P4,!1)?e.dispatch({effects:F4.of(i)}):e.dispatch({effects:EX.appendConfig.of(P4.init(()=>[i]))});let a=I4.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(P4).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var P4=aX.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(F4)?e=[n.value].concat(e):n.is(I4)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>M4.computeN([e],t=>t.field(e))}),F4=EX.define(),I4=EX.define();function L4(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=CZ(`form`),t.input){let e=CZ(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(CZ(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(CZ(`button`,{class:`cm-button`,type:`submit`},t.submitLabel||`OK`))}let i=r.nodeName==`FORM`?[r]:r.querySelectorAll(`form`);for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener(`keydown`,e=>{e.keyCode==27?(e.preventDefault(),o(null)):e.keyCode==13&&(e.preventDefault(),o(t))}),t.addEventListener(`submit`,e=>{e.preventDefault(),o(t)})}let a=CZ(`div`,r,CZ(`button`,{onclick:()=>o(null),"aria-label":e.state.phrase(`close`),class:`cm-dialog-close`,type:`button`},[`×`]));t.class&&(a.className=t.class),a.classList.add(`cm-dialog`);function o(t){a.contains(a.ownerDocument.activeElement)&&e.focus(),n(t)}return{dom:a,top:t.top,mount:()=>{if(t.focus){let e;e=typeof t.focus==`string`?r.querySelector(t.focus):r.querySelector(`input`)||r.querySelector(`button`),e&&`select`in e?e.select():e&&`focus`in e&&e.focus()}}}}var R4=class extends UX{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};R4.prototype.elementClass=``,R4.prototype.toDOM=void 0,R4.prototype.mapMode=BY.TrackBefore,R4.prototype.startSide=R4.prototype.endSide=-1,R4.prototype.point=!0;var z4=QY.define(),B4=QY.define(),V4={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>JX.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},H4=QY.define();function U4(e){return[G4(),H4.of({...V4,...e})]}var W4=QY.define({combine:e=>e.some(e=>e)});function G4(e){let t=[K4];return e&&e.fixed===!1&&t.push(W4.of(!0)),t}var K4=p$.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement(`div`),this.dom.className=`cm-gutters cm-gutters-before`,this.dom.setAttribute(`aria-hidden`,`true`),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.gutters=e.state.facet(H4).map(t=>new X4(e,t)),this.fixed=!e.state.facet(W4);for(let e of this.gutters)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position=`sticky`),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement(`div`),this.domAfter.className=`cm-gutters cm-gutters-after`,this.domAfter.setAttribute(`aria-hidden`,`true`),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.domAfter.style.position=this.fixed?`sticky`:``,this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+`px`;this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(W4)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?`sticky`:``,this.domAfter&&(this.domAfter.style.position=this.fixed?`sticky`:``)),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=JX.iter(this.view.state.facet(z4),this.view.viewport.from),r=[],i=this.gutters.map(e=>new Y4(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==WZ.Text&&t){J4(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==WZ.Text){J4(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(H4),n=e.state.facet(H4),r=e.docChanged||e.heightChanged||e.viewportChanged||!JX.eq(e.startState.facet(z4),e.state.facet(z4),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new X4(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>x2.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==TQ.LTR?{left:r,right:i}:{right:r,left:i}})});function q4(e){return Array.isArray(e)?e:[e]}function J4(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var Y4=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=JX.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Z4(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];J4(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;r.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(B4)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},X4=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement(`div`),this.dom.className=`cm-gutter`+(this.config.class?` `+this.config.class:``);for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=q4(t.markers(e)),t.initialSpacer&&(this.spacer=new Z4(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+=`visibility: hidden; pointer-events: none`)}update(e){let t=this.markers;if(this.markers=q4(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!JX.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Z4=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement(`div`),this.dom.className=`cm-gutterElement`,this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+`px`),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+`px`:``),Q4(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=i<t.length?t[i++]:null,c=!1;if(s){let e=s.elementClass;e&&(n+=` `+e);for(let e=a;e<this.markers.length;e++)if(this.markers[e].compare(s)){o=e,c=!0;break}}else o=this.markers.length;for(;a<o;){let e=this.markers[a++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!s)break;s.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(s.toDOM(e),r)),c&&a++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function Q4(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}var $4=QY.define(),e3=QY.define(),t3=QY.define({combine(e){return HX(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})}}),n3=class extends R4{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function r3(e,t){return e.state.facet(t3).formatNumber(t,e.state)}var i3=H4.compute([t3],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet($4)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new n3(r3(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(e3)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(t3)!=e.state.facet(t3),initialSpacer(e){return new n3(r3(e,o3(e.state.doc.lines)))},updateSpacer(e,t){let n=r3(t.view,o3(t.view.state.doc.lines));return n==e.number?e:new n3(n)},domEventHandlers:e.facet(t3).domEventHandlers,side:`before`}));function a3(e={}){return[t3.of(e),G4(),i3]}function o3(e){let t=9;for(;t<e;)t=t*10+9;return t}var s3=new class extends R4{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},c3=z4.compute([`selection`],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(s3.range(i)))}return JX.of(t)});function l3(){return c3}var u3=1024,d3=0,f3=class{constructor(e,t){this.from=e,this.to=t}},p3=class{constructor(e={}){this.id=d3++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=g3.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};p3.closedBy=new p3({deserialize:e=>e.split(` `)}),p3.openedBy=new p3({deserialize:e=>e.split(` `)}),p3.group=new p3({deserialize:e=>e.split(` `)}),p3.isolate=new p3({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),p3.contextHash=new p3({perNode:!0}),p3.lookAhead=new p3({perNode:!0}),p3.mounted=new p3({perNode:!0});var m3=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[p3.mounted.id]}},h3=Object.create(null),g3=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):h3,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(p3.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(p3.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};g3.none=new g3(``,Object.create(null),0,8);var _3=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new g3(e.name,r,e.id,e.flags):e)}return new e(n)}},v3=new WeakMap,y3=new WeakMap,b3;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(b3||={});var x3=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=m3.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new F3(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new F3(v3.get(this)||this.topNode);return r.moveTo(e,t),v3.set(this,r._tree),r}get topNode(){return new D3(this,0,0,null)}resolve(e,t=0){let n=T3(v3.get(this)||this.topNode,e,t,!1);return v3.set(this,n),n}resolveInner(e,t=0){let n=T3(y3.get(this)||this.topNode,e,t,!0);return y3.set(this,n),n}resolveStack(e,t=0){return P3(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&b3.IncludeAnonymous)>0;for(let e=this.cursor(a|b3.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:B3(g3.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(g3.none,t,n,r)))}static build(e){return L3(e)}};x3.empty=new x3(g3.none,[],[],0);var S3=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},C3=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return g3.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(w3(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function w3(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function T3(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof D3&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:b3.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof D3&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var E3=class{cursor(e=0){return new F3(this,e)}getChild(e,t=null,n=null){let r=O3(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return O3(this,e,t,n)}resolve(e,t=0){return T3(this,e,t,!1)}resolveInner(e,t=0){return T3(this,e,t,!0)}matchContext(e){return k3(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},D3=class e extends E3{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&b3.EnterBracketed&&l instanceof x3&&(d=m3.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!w3(i,r,u,u+l.length))){if(l instanceof C3){if(a&b3.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new j3(new A3(o,l,t,u),null,e)}else if(a&b3.IncludeAnonymous||!l.type.isAnonymous||I3(l)){let s;if(!(a&b3.IgnoreMounts)&&(s=m3.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&b3.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&b3.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&b3.IgnoreOverlays)&&(i=m3.get(this._tree))&&i.overlay){let a=t-this.from,o=r&b3.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function O3(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function k3(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var A3=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},j3=class e extends E3{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&b3.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new x3(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function M3(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof D3&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new N3(i,n)}var N3=class{constructor(e,t){this.heads=e,this.node=t}get next(){return M3(this.heads)}};function P3(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof D3?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=m3.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new D3(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(T3(o,t,n,!1))}}return i?M3(i):r}var F3=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~b3.EnterBracketed,e instanceof D3)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof D3?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&b3.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&b3.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&b3.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else ({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&b3.IncludeAnonymous||e instanceof C3||!e.type.isAnonymous||I3(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new j3(this.buffer,t,this.stack[e]);return this.bufferNode=new j3(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return k3(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return k3(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function I3(e){return e.children.some(e=>e instanceof C3||!e.type.isAnonymous||I3(e))}function L3(e){let{buffer:t,nodeSet:n,maxBufferLength:r=u3,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new S3(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:ee,size:C}=o,w=l,te=c;if(C<0)if(o.next(),C==-1){let t=i[x];_.push(t),v.push(S-e);return}else if(C==-3){c=x;return}else if(C==-4){l=x;return}else throw RangeError(`Unrecognized record size: ${C}`);let ne=s[x],T,re,ie=S-e;if(ee-S<=r&&(re=h(o.pos-t,y))){let t=new Uint16Array(re.size-re.skip),r=o.pos-re.size,i=t.length;for(;o.pos>r;)i=g(re.start,t,i);T=new C3(t,ee-re.start,n),ie=re.start-e}else{let e=o.pos-C;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=ee;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,w,te),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,w,te),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(ne,te);T=B3(ne,t,n,0,t.length,0,ee-S,e,e)}else T=m(ne,t,n,ee-S,w-ee,te)}_.push(T),v.push(ie)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new C3(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof x3){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(p3.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[p3.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[p3.lookAhead,i];o=o?[e].concat(o):[e]}return new x3(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0)if(n.size==-3||n.size==-4)d+=4;else break scan;else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new x3(s[e.topID],_.reverse(),v.reverse(),y)}var R3=new WeakMap;function z3(e,t){if(!e.isAnonymous||t instanceof C3||t.type!=e)return 1;let n=R3.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof x3)){n=1;break}n+=z3(e,r)}R3.set(t,n)}return n}function B3(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=z3(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=z3(e,t[s]);for(s++;s<i;s++){let n=z3(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(B3(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var V3=class{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof j3?this.setBuffer(e.context.buffer,e.index,t):e instanceof D3&&this.map.set(e.tree,t)}get(e){return e instanceof j3?this.getBuffer(e.context.buffer,e.index):e instanceof D3?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},H3=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},U3=class{startParse(e,t,n){return typeof e==`string`&&(e=new W3(e)),n=n?n.length?n.map(e=>new f3(e.from,e.to)):[new f3(0,0)]:[new f3(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},W3=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};function G3(e){return(t,n,r,i)=>new X3(t,e,n,r,i)}var K3=class{constructor(e,t,n,r,i,a){this.parser=e,this.parse=t,this.overlay=n,this.bracketed=r,this.target=i,this.from=a}};function q3(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var J3=class{constructor(e,t,n,r,i,a,o,s){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=i,this.bracketed=a,this.target=o,this.prev=s,this.depth=0,this.ranges=[]}},Y3=new p3({perNode:!0}),X3=class{constructor(e,t,n,r,i){this.nest=t,this.input=n,this.fragments=r,this.ranges=i,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),this.stoppedAt!=null)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return this.stoppedAt!=null&&(e=new x3(e.type,e.children,e.positions,e.length,e.propValues.concat([[Y3,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[p3.mounted.id]=new m3(t,e.overlay,e.parser,e.bracketed),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new t6(this.fragments),t=null,n=null,r=new F3(new D3(this.baseTree,this.ranges[0].from,0,null),b3.IncludeAnonymous|b3.IgnoreMounts);scan:for(let i,a;;){let o=!0,s;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)o=!1;else if(e.hasNode(r)){if(t){let e=t.mounts.find(e=>e.frag.from<=r.from&&e.frag.to>=r.to&&e.mount.overlay);if(e)for(let n of e.mount.overlay){let i=n.from+e.pos,a=n.to+e.pos;i>=r.from&&a<=r.to&&!t.ranges.some(e=>e.from<a&&e.to>i)&&t.ranges.push({from:i,to:a})}}o=!1}else if(n&&(a=Z3(n.ranges,r.from,r.to)))o=a!=2;else if(!r.type.isAnonymous&&(i=this.nest(r,this.input))&&(r.from<r.to||!i.overlay)){r.tree||($3(r),t&&t.depth++,n&&n.depth++);let a=e.findMounts(r.from,i.parser);if(typeof i.overlay==`function`)t=new J3(i.parser,i.overlay,a,this.inner.length,r.from,!!i.bracketed,r.tree,t);else{let e=n6(this.ranges,i.overlay||(r.from<r.to?[new f3(r.from,r.to)]:[]));e.length&&q3(e),(e.length||!i.overlay)&&this.inner.push(new K3(i.parser,e.length?i.parser.startParse(this.input,i6(a,e),e):i.parser.startParse(``),i.overlay?i.overlay.map(e=>new f3(e.from-r.from,e.to-r.from)):null,!!i.bracketed,r.tree,e.length?e[0].from:r.from)),i.overlay?e.length&&(n={ranges:e,depth:0,prev:n}):o=!1}}else if(t&&(s=t.predicate(r))&&(s===!0&&(s=new f3(r.from,r.to)),s.from<s.to)){let e=t.ranges.length-1;e>=0&&t.ranges[e].to==s.from?t.ranges[e]={from:t.ranges[e].from,to:s.to}:t.ranges.push(s)}if(o&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break scan;if(t&&!--t.depth){let e=n6(this.ranges,t.ranges);e.length&&(q3(e),this.inner.splice(t.index,0,new K3(t.parser,t.parser.startParse(this.input,i6(t.mounts,e),e),t.ranges.map(e=>new f3(e.from-t.start,e.to-t.start)),t.bracketed,t.target,e[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}};function Z3(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function Q3(e,t,n,r,i,a){if(t<n){let o=e.buffer[t+1];r.push(e.slice(t,n,o)),i.push(o-a)}}function $3(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,a=i.children.indexOf(r),o=i.children[a],s=o.buffer,c=[a];function l(e,r,i,a,u,d){let f=n[d],p=[],m=[];Q3(o,e,f,p,m,a);let h=s[f+1],g=s[f+2];c.push(p.length);let _=d?l(f+4,s[f+3],o.set.types[s[f]],h,g-h,d-1):t.toTree();return p.push(_),m.push(h-a),Q3(o,s[f+3],r,p,m,a),new x3(i,p,m,u)}i.children[a]=l(0,s.length,g3.none,0,o.length,n.length-1);for(let t of c){let n=e.tree.children[t],r=e.tree.positions[t];e.yield(new D3(n,r+e.from,t,e._tree))}}var e6=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(b3.IncludeAnonymous|b3.IgnoreMounts)}moveTo(e){let{cursor:t}=this,n=e-this.offset;for(;!this.done&&t.from<n;)if(!(t.to>=e&&t.enter(n,1,b3.IgnoreOverlays|b3.ExcludeBuffers)))if(t.to<=e)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof x3)t=t.children[0];else break}return!1}},t6=class{constructor(e){if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let t=this.curFrag=e[0];this.curTo=t.tree.prop(Y3)??t.to,this.inner=new e6(t.tree,-t.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=e.tree.prop(Y3)??e.to,this.inner=new e6(e.tree,-e.offset)}}findMounts(e,t){let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let r=e.tree?.prop(p3.mounted);if(r&&r.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let i=this.fragments[t];if(i.from>=e.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:e.from-i.offset,mount:r})}}}return n}};function n6(e,t){let n=null,r=t;for(let i=1,a=0;i<e.length;i++){let o=e[i-1].to,s=e[i].from;for(;a<r.length;a++){let e=r[a];if(e.from>=s)break;e.to<=o||(n||(r=n=t.slice()),e.from<o?(n[a]=new f3(e.from,o),e.to>s&&n.splice(a+1,0,new f3(s,e.to))):e.to>s?n[a--]=new f3(s,e.to):n.splice(a--,1))}}return r}function r6(e,t,n,r){let i=0,a=0,o=!1,s=!1,c=-1e9,l=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from,d=a==t.length?1e9:s?t[a].to:t[a].from;if(o!=s){let e=Math.max(c,n),t=Math.min(u,d,r);e<t&&l.push(new f3(e,t))}if(c=Math.min(u,d),c==1e9)break;u==c&&(o?(o=!1,i++):o=!0),d==c&&(s?(s=!1,a++):s=!0)}return l}function i6(e,t){let n=[];for(let{pos:r,mount:i,frag:a}of e){let e=r+(i.overlay?i.overlay[0].from:0),o=e+i.tree.length,s=Math.max(a.from,e),c=Math.min(a.to,o);if(i.overlay){let o=r6(t,i.overlay.map(e=>new f3(e.from+r,e.to+r)),s,c);for(let t=0,r=s;;t++){let s=t==o.length,l=s?c:o[t].from;if(l>r&&n.push(new H3(r,l,i.tree,-e,a.from>=r||a.openStart,a.to<=l||a.openEnd)),s)break;r=o[t].to}}else n.push(new H3(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}var a6=0,o6=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=a6++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new c6(e);return e=>e.modified.indexOf(t)>-1?e:c6.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},s6=0,c6=class e{constructor(e){this.name=e,this.instances=[],this.id=s6++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&l6(n,e.modified));if(r)return r;let i=[],a=new o6(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=u6(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function l6(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function u6(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function d6(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new p6(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return f6.add(t)}var f6=new p3({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new p6(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),p6=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};p6.empty=new p6([],2,null);function m6(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function h6(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function g6(e,t,n,r=0,i=e.length){let a=new _6(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var _6=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=v6(e)||p6.empty,u=h6(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(p3.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function v6(e){let t=e.type.prop(f6);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var X=o6.define,y6=X(),b6=X(),x6=X(b6),S6=X(b6),C6=X(),w6=X(C6),T6=X(C6),E6=X(),D6=X(E6),O6=X(),k6=X(),A6=X(),j6=X(A6),M6=X(),Z={comment:y6,lineComment:X(y6),blockComment:X(y6),docComment:X(y6),name:b6,variableName:X(b6),typeName:x6,tagName:X(x6),propertyName:S6,attributeName:X(S6),className:X(b6),labelName:X(b6),namespace:X(b6),macroName:X(b6),literal:C6,string:w6,docString:X(w6),character:X(w6),attributeValue:X(w6),number:T6,integer:X(T6),float:X(T6),bool:X(C6),regexp:X(C6),escape:X(C6),color:X(C6),url:X(C6),keyword:O6,self:X(O6),null:X(O6),atom:X(O6),unit:X(O6),modifier:X(O6),operatorKeyword:X(O6),controlKeyword:X(O6),definitionKeyword:X(O6),moduleKeyword:X(O6),operator:k6,derefOperator:X(k6),arithmeticOperator:X(k6),logicOperator:X(k6),bitwiseOperator:X(k6),compareOperator:X(k6),updateOperator:X(k6),definitionOperator:X(k6),typeOperator:X(k6),controlOperator:X(k6),punctuation:A6,separator:X(A6),bracket:j6,angleBracket:X(j6),squareBracket:X(j6),paren:X(j6),brace:X(j6),content:E6,heading:D6,heading1:X(D6),heading2:X(D6),heading3:X(D6),heading4:X(D6),heading5:X(D6),heading6:X(D6),contentSeparator:X(E6),list:X(E6),quote:X(E6),emphasis:X(E6),strong:X(E6),link:X(E6),monospace:X(E6),strikethrough:X(E6),inserted:X(),deleted:X(),changed:X(),invalid:X(),meta:M6,documentMeta:X(M6),annotation:X(M6),processingInstruction:X(M6),definition:o6.defineModifier(`definition`),constant:o6.defineModifier(`constant`),function:o6.defineModifier(`function`),standard:o6.defineModifier(`standard`),local:o6.defineModifier(`local`),special:o6.defineModifier(`special`)};for(let e in Z){let t=Z[e];t instanceof o6&&(t.name=e)}m6([{tag:Z.link,class:`tok-link`},{tag:Z.heading,class:`tok-heading`},{tag:Z.emphasis,class:`tok-emphasis`},{tag:Z.strong,class:`tok-strong`},{tag:Z.keyword,class:`tok-keyword`},{tag:Z.atom,class:`tok-atom`},{tag:Z.bool,class:`tok-bool`},{tag:Z.url,class:`tok-url`},{tag:Z.labelName,class:`tok-labelName`},{tag:Z.inserted,class:`tok-inserted`},{tag:Z.deleted,class:`tok-deleted`},{tag:Z.literal,class:`tok-literal`},{tag:Z.string,class:`tok-string`},{tag:Z.number,class:`tok-number`},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],class:`tok-string2`},{tag:Z.variableName,class:`tok-variableName`},{tag:Z.local(Z.variableName),class:`tok-variableName tok-local`},{tag:Z.definition(Z.variableName),class:`tok-variableName tok-definition`},{tag:Z.special(Z.variableName),class:`tok-variableName2`},{tag:Z.definition(Z.propertyName),class:`tok-propertyName tok-definition`},{tag:Z.typeName,class:`tok-typeName`},{tag:Z.namespace,class:`tok-namespace`},{tag:Z.className,class:`tok-className`},{tag:Z.macroName,class:`tok-macroName`},{tag:Z.propertyName,class:`tok-propertyName`},{tag:Z.operator,class:`tok-operator`},{tag:Z.comment,class:`tok-comment`},{tag:Z.meta,class:`tok-meta`},{tag:Z.invalid,class:`tok-invalid`},{tag:Z.punctuation,class:`tok-punctuation`}]);var N6=new p3;function P6(e){return QY.define({combine:e?t=>t.concat(e):void 0})}var F6=new p3,I6=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,VX.prototype.hasOwnProperty(`tree`)||Object.defineProperty(VX.prototype,"tree",{get(){return R6(this)}}),this.parser=t,this.extension=[G6.of(this),VX.languageData.of((e,t,n)=>{let r=L6(e,t,n),i=r.type.prop(N6);if(!i)return[];let a=e.facet(i),o=r.type.prop(F6);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return L6(e,t,n).type.prop(N6)==this.data}findRegions(e){let t=e.facet(G6);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(N6)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(p3.mounted);if(i){if(i.tree.prop(N6)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof x3&&r(i,e.positions[n]+t)}};return r(R6(e),0),n}get allowsNesting(){return!0}};I6.setState=EX.define();function L6(e,t,n){let r=e.facet(G6),i=R6(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,b3.ExcludeBuffers|b3.EnterBracketed))e.type.isTop&&(i=e);return i}var Iie=class e extends I6{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=P6(t.languageData);return new e(n,t.parser.configure({props:[N6.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function R6(e){let t=e.field(I6.state,!1);return t?t.tree:x3.empty}var Lie=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},z6=null,B6=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],x3.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Lie(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=x3.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(H3.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(H3.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=z6;z6=this;try{return e()}finally{z6=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=V6(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=H3.applyChanges(r,e),i=x3.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=V6(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends U3{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=z6;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new x3(g3.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return z6}};function V6(e,t,n){return H3.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var H6=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=B6.create(t.facet(G6).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};I6.state=aX.define({create:H6.init,update(e,t){for(let e of t.effects)if(e.is(I6.setState))return e.value;return t.startState.facet(G6)==t.state.facet(G6)?e.apply(t):H6.init(t.state)}});var U6=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(U6=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var W6=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,Rie=p$.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(I6.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(I6.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=U6(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(I6.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!W6?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>W6&&W6()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:I6.setState.of(new H6(i.context))})),this.chunkBudget>0&&!(s&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>l$(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),G6=QY.define({combine(e){return e.length?e[0]:null},enables:e=>[I6.state,Rie,x2.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),K6=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Q=class e{constructor(e,t,n,r,i,a=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=i,this.support=a,this.loading=null}load(){return this.loading||=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e})}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw RangeError(`Must pass either 'load' or 'support' to LanguageDescription.of`);n=()=>Promise.resolve(r)}return new e(t.name,(t.alias||[]).concat(t.name).map(e=>e.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let n=/\.([^.]+)$/.exec(t);if(n){for(let t of e)if(t.extensions.indexOf(n[1])>-1)return t}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(e=>e==t))return n;if(n)for(let n of e)for(let e of n.alias){let r=t.indexOf(e);if(r>-1&&(e.length>2||!/\w/.test(t[r-1])&&!/\w/.test(t[r+e.length])))return n}return null}},zie=QY.define(),q6=QY.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function J6(e){let t=e.facet(q6);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Y6(e,t){let n=``,r=e.tabSize,i=e.facet(q6)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function X6(e,t){e instanceof VX&&(e=new Z6(e));for(let n of e.state.facet(zie)){let r=n(e,t);if(r!==void 0)return r}let n=R6(e.state);return n.length>=t?Bie(e,n,t):null}var Z6=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=J6(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return sZ(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Q6=new p3;function Bie(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return $6(r,e,n)}function $6(e,t,n){for(let r=e;r;r=r.next){let e=Hie(r.node);if(e)return e(Wie.create(t,n,r))}return 0}function Vie(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Hie(e){let t=e.type.prop(Q6);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(p3.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>e8(e,!0,1,void 0,n&&!Vie(e)?t.from:void 0)}return e.parent==null?Uie:null}function Uie(){return 0}var Wie=class e extends Z6{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Gie(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return $6(this.context.next,this.base,this.pos)}};function Gie(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Kie(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function qie({closing:e,align:t=!0,units:n=1}){return r=>e8(r,t,n,e)}function e8(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?Kie(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var Jie=e=>e.baseIndent;function Yie({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var Xie=200;function Zie(){return VX.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+Xie)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=X6(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=Y6(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var t8=QY.define(),n8=new p3;function Qie(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function $ie(e,t,n){let r=R6(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(a&&i.from<t)break;let s=i.type.prop(n8);if(s&&(i.to<r.length-50||r.length==e.doc.length||!eae(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function eae(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function r8(e,t,n){for(let r of e.facet(t8)){let i=r(e,t,n);if(i)return i}return $ie(e,t,n)}function i8(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var a8=EX.define({map:i8}),o8=EX.define({map:i8});function s8(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}var c8=aX.define({create(){return GZ.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=l8(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(a8)&&!tae(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(p8),i=r?GZ.replace({widget:new oae(r(t.state,n.value))}):g8;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(o8)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=l8(e,t.selection.main.head)),e},provide:e=>x2.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError(`Invalid JSON for fold state`);let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid JSON for fold state`);t.push(g8.range(r,i))}return GZ.set(t,!0)}});function l8(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function u8(e,t,n){var r;let i=null;return(r=e.field(c8,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function tae(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function d8(e,t){return e.field(c8,!1)?t:t.concat(EX.appendConfig.of(m8()))}var nae=e=>{for(let t of s8(e)){let n=r8(e.state,t.from,t.to);if(n)return e.dispatch({effects:d8(e.state,[a8.of(n),f8(e,n)])}),!0}return!1},rae=e=>{if(!e.state.field(c8,!1))return!1;let t=[];for(let n of s8(e)){let r=u8(e.state,n.from,n.to);r&&t.push(o8.of(r),f8(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function f8(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return x2.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var iae=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:nae},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:rae},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=r8(t,i.from,i.to);a&&n.push(a8.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:d8(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(c8,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(o8.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],aae={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},p8=QY.define({combine(e){return HX(e,aae)}});function m8(e){let t=[c8,lae];return e&&t.push(p8.of(e)),t}function h8(e,t){let{state:n}=e,r=n.facet(p8),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=u8(e.state,n.from,n.to);r&&e.dispatch({effects:o8.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement(`span`);return a.textContent=r.placeholderText,a.setAttribute(`aria-label`,n.phrase(`folded code`)),a.title=n.phrase(`unfold`),a.className=`cm-foldPlaceholder`,a.onclick=i,a}var g8=GZ.replace({widget:new class extends UZ{toDOM(e){return h8(e,null)}}}),oae=class extends UZ{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return h8(e,this.value)}},sae={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},_8=class extends R4{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement(`span`);return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?`Fold line`:`Unfold line`),t}};function cae(e={}){let t={...sae,...e},n=new _8(t,!0),r=new _8(t,!1),i=p$.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(G6)!=e.state.facet(G6)||e.startState.field(c8,!1)!=e.state.field(c8,!1)||R6(e.startState)!=R6(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new XX;for(let i of e.viewportLineBlocks){let a=u8(e.state,i.from,i.to)?r:r8(e.state,i.from,i.to)?n:null;a&&t.add(i.from,i.from,a)}return t.finish()}}),{domEventHandlers:a}=t;return[i,U4({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||JX.empty},initialSpacer(){return new _8(t,!1)},domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let r=u8(e.state,t.from,t.to);if(r)return e.dispatch({effects:o8.of(r)}),!0;let i=r8(e.state,t.from,t.to);return i?(e.dispatch({effects:a8.of(i)}),!0):!1}}}),m8()]}var lae=x2.baseTheme({".cm-foldPlaceholder":{backgroundColor:`#eee`,border:`1px solid #ddd`,color:`#888`,borderRadius:`.2em`,margin:`0 1px`,padding:`0 1px`,cursor:`pointer`},".cm-foldGutter span":{padding:`0 1px`,cursor:`pointer`}}),v8=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=pZ.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof I6?e=>e.prop(N6)==a.data:a?e=>e==a:void 0,this.style=m6(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new pZ(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},y8=QY.define(),b8=QY.define({combine(e){return e.length?[e[0]]:null}});function x8(e){let t=e.facet(y8);return t.length?t:e.facet(b8)}function S8(e,t){let n=[dae],r;return e instanceof v8&&(e.module&&n.push(x2.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(b8.of(e)):r?n.push(y8.computeN([x2.darkTheme],t=>t.facet(x2.darkTheme)==(r==`dark`)?[e]:[])):n.push(y8.of(e)),n}var uae=class{constructor(e){this.markCache=Object.create(null),this.tree=R6(e.state),this.decorations=this.buildDeco(e,x8(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=R6(e.state),n=x8(e.state),r=n!=x8(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return GZ.none;let n=new XX;for(let{from:r,to:i}of e.visibleRanges)g6(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=GZ.mark({class:r})))},r,i);return n.finish()}},dae=cX.high(p$.fromClass(uae,{decorations:e=>e.decorations})),fae=v8.define([{tag:Z.meta,color:`#404740`},{tag:Z.link,textDecoration:`underline`},{tag:Z.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strong,fontWeight:`bold`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.keyword,color:`#708`},{tag:[Z.atom,Z.bool,Z.url,Z.contentSeparator,Z.labelName],color:`#219`},{tag:[Z.literal,Z.inserted],color:`#164`},{tag:[Z.string,Z.deleted],color:`#a11`},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],color:`#e40`},{tag:Z.definition(Z.variableName),color:`#00f`},{tag:Z.local(Z.variableName),color:`#30a`},{tag:[Z.typeName,Z.namespace],color:`#085`},{tag:Z.className,color:`#167`},{tag:[Z.special(Z.variableName),Z.macroName],color:`#256`},{tag:Z.definition(Z.propertyName),color:`#00c`},{tag:Z.comment,color:`#940`},{tag:Z.invalid,color:`#f00`}]),pae=x2.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),C8=1e4,w8=`()[]{}`,T8=QY.define({combine(e){return HX(e,{afterCursor:!0,brackets:w8,maxScanDistance:C8,renderMatch:gae})}}),mae=GZ.mark({class:`cm-matchingBracket`}),hae=GZ.mark({class:`cm-nonmatchingBracket`});function gae(e){let t=[],n=e.matched?mae:hae;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function E8(e){let t=[],n=e.facet(T8);for(let r of e.selection.ranges){if(!r.empty)continue;let i=A8(e,r.head,-1,n)||r.head>0&&A8(e,r.head-1,1,n)||n.afterCursor&&(A8(e,r.head,1,n)||r.head<e.doc.length&&A8(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return GZ.set(t,!0)}var _ae=[p$.fromClass(class{constructor(e){this.paused=!1,this.decorations=E8(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=E8(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),pae];function vae(e={}){return[T8.of(e),_ae]}var D8=new p3;function O8(e,t,n){let r=e.prop(t<0?p3.openedBy:p3.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function k8(e){let t=e.type.prop(D8);return t?t(e.node):e}function A8(e,t,n,r={}){let i=r.maxScanDistance||C8,a=r.brackets||w8,o=R6(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=O8(r.type,n,a);if(i&&r.from<r.to){let o=k8(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return yae(e,t,n,r,o,i,a)}}return bae(e,t,n,o,s.type,i,a)}function yae(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=k8(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(O8(u.type,n,o))l++;else if(O8(u.type,-n,o)){if(l==0){let e=k8(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function bae(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i))if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}function j8(e,t,n,r=0,i=0){t??(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let i=r;i<t;i++)e.charCodeAt(i)==9?a+=n-a%n:a++;return a}var M8=class{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(n=typeof e==`string`?t==e:t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=j8(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??j8(this.string,null,this.tabSize)}match(e,t,n){if(typeof e==`string`){let r=e=>n?e.toLowerCase():e;return r(this.string.substr(this.pos,e.length))==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}};function xae(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||Sae,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||L8,mergeTokens:e.mergeTokens!==!1}}function Sae(e){if(typeof e!=`object`)return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}var N8=new WeakMap,Cae=class e extends I6{constructor(e){let t=P6(e.languageData),n=xae(e),r,i=new class extends U3{createParse(e,t,n){return new Tae(r,e,t,n)}};super(t,i,[],e.name),this.topNode=Oae(t,this),r=this,this.streamParser=n,this.stateAfter=new p3({perNode:!0}),this.tokenTable=e.tokenTable?new H8(n.tokenTable):Dae}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=N8.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=P8(this,e.node.tree,e.node.from,e.node.from,t??e.pos),i,a;if(r?(a=r.state,i=r.pos+1):(a=this.streamParser.startState(e.unit),i=e.node.from),e.pos-i>1e4)return null;for(;i<e.pos;){let t=e.state.doc.lineAt(i),r=Math.min(e.pos,t.to);if(t.length){let i=n?n(t.from):-1,o=new M8(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)I8(this.streamParser.token,o,a)}else this.streamParser.blankLine(a,e.unit);if(r==e.pos)break;i=t.to+1}let o=e.lineAt(e.pos);return n&&t==null&&N8.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function P8(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let o=t.children[a],s=n+t.positions[a],c=o instanceof x3&&s<i&&P8(e,o,s,r,i);if(c)return c}return null}function F8(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],c;if(o<r&&s instanceof x3){if(!(c=F8(e,s,n-o,r-o,i)))break;return i?new x3(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function wae(e,t,n,r,i){for(let i of t){let t=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),o=t<=n&&a>n&&P8(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=F8(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?J6(i):4),tree:x3.empty}}var Tae=class{constructor(e,t,n,r){this.lang=e,this.input=t,this.fragments=n,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let i=B6.get(),a=r[0].from,{state:o,tree:s}=wae(e,n,a,this.to,i?.state);this.state=o,this.parsedPos=this.chunkStart=a+s.length;for(let e=0;e<s.children.length;e++)this.chunks.push(s.children[e]),this.chunkPos.push(s.positions[e]);i&&this.parsedPos<i.viewport.from-1e5&&r.some(e=>e.from<=i.viewport.from&&e.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(J6(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=B6.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+512);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
|
|
210
210
|
`&&(t=``);else{let e=t.indexOf(`
|
|
211
211
|
`);e>-1&&(t=t.slice(0,e))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let e=this.rangeIndex;;){let r=this.ranges[e].to;if(r>=n||(t=t.slice(0,r-(n-t.length)),e++,e==this.ranges.length))break;let i=this.ranges[e].from,a=this.lineAfter(i);t+=a,n=i+a.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let r=this.ranges[this.rangeIndex].to,i=e+t;if(n>0?r>i:r>=i)break;let a=this.ranges[++this.rangeIndex].from;t+=a-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,r){let i=4;if(this.ranges.length>1){r=this.skipGapsTo(t,r,1),t+=r;let e=this.chunk.length;r=this.skipGapsTo(n,r,-1),n+=r,i+=this.chunk.length-e}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&a>=0&&this.chunk[a]==e&&this.chunk[a+2]==t?this.chunk[a+2]=n:this.chunk.push(e,t,n,i),r}parseLine(e){let{line:t,end:n}=this.nextLine(),r=0,{streamParser:i}=this.lang,a=new M8(t,e?e.state.tabSize:4,e?J6(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=I8(i.token,a,this.state);if(e&&(r=this.emitToken(this.lang.tokenTable.resolve(e),this.parsedPos+a.start,this.parsedPos+a.pos,r)),a.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=x3.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Eae,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new x3(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new x3(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function I8(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let r=e(t,n);if(t.pos>t.start)return r}throw Error(`Stream parser failed to advance stream.`)}var L8=Object.create(null),R8=[g3.none],Eae=new _3(R8),z8=[],B8=Object.create(null),V8=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])V8[e]=W8(L8,t);var H8=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),V8)}resolve(e){return e?this.table[e]||(this.table[e]=W8(this.extra,e)):0}},Dae=new H8(L8);function U8(e,t){z8.indexOf(e)>-1||(z8.push(e),console.warn(t))}function W8(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||Z[n];r?typeof r==`function`?t.length?t=t.map(r):U8(n,`Modifier ${n} used at start of tag`):t.length?U8(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:U8(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=B8[i];if(a)return a.id;let o=B8[i]=g3.define({id:R8.length,name:r,props:[d6({[r]:n})]});return R8.push(o),o.id}function Oae(e,t){let n=g3.define({id:R8.length,name:`Document`,props:[N6.add(()=>e),Q6.add(()=>e=>t.getIndent(e))],top:!0});return R8.push(n),n}TQ.RTL,TQ.LTR;var kae=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=K8(e.state,n.from);return r.line?Aae(e):r.block?Mae(e):!1};function G8(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Aae=G8(Fae,0),jae=G8(J8,0),Mae=G8((e,t)=>J8(e,t,Pae(t)),0);function K8(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var q8=50;function Nae(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-q8,r),o=e.sliceDoc(i,i+q8),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*q8?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+q8),d=e.sliceDoc(i-q8,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function Pae(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function J8(e,t,n=t.selection.ranges){let r=n.map(e=>K8(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Nae(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function Fae(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=K8(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Y8=CX.define(),Iae=CX.define(),Lae=QY.define(),X8=QY.define({combine(e){return HX(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),Z8=aX.define({create(){return s5.empty},update(e,t){let n=t.state.facet(X8),r=t.annotation(Y8);if(r){let i=t5.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?n5(o,o.length,n.minDepth,i):a5(o,t.startState.selection),new s5(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Iae);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(DX.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=t5.fromTransaction(t),o=t.annotation(DX.time),s=t.annotation(DX.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new s5(e.done.map(t5.fromJSON),e.undone.map(t5.fromJSON))}});function Rae(e={}){return[Z8,X8.of(e),x2.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?$8:e.inputType==`historyRedo`?e5:null;return n?(e.preventDefault(),n(t)):!1}})]}function Q8(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(Z8,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var $8=Q8(0,!1),e5=Q8(1,!1),zae=Q8(0,!0),Bae=Q8(1,!0),t5=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&HY.fromJSON(t.changes),[],t.mapped&&VY.fromJSON(t.mapped),t.startSelection&&Y.fromJSON(t.startSelection),t.selectionsAfter.map(Y.fromJSON))}static fromTransaction(t,n){let r=i5;for(let e of t.startState.facet(Lae)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,i5)}static selection(t){return new e(void 0,i5,void 0,void 0,t)}};function n5(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Vae(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Hae(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function r5(e,t){return e.length?t.length?e.concat(t):e:t}var i5=[],Uae=200;function a5(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Uae));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),n5(e,e.length-1,1e9,n.setSelAfter(r)))}else return[t5.selection([t])]}function Wae(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function o5(e,t){if(!e.length)return e;let n=e.length,r=i5;for(;n;){let i=Gae(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[t5.selection(r)]:i5}function Gae(e,t,n){let r=r5(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):i5,n);if(!e.changes)return t5.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new t5(i,EX.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Kae=/^(input\.type|delete)($|\.)/,s5=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Kae.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Vae(s.changes,t.changes))||r==`input.type.compose`)?n5(o,o.length-1,i.minDepth,new t5(t.changes.compose(s.changes),r5(EX.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,i5)):n5(o,o.length,i.minDepth,t),new e(o,i5,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:i5;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Hae(a[a.length-1],t)?this:new e(a5(this.done,t),this.undone,n,r)}addMapping(t){return new e(o5(this.done,t),o5(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Y8.of({side:e,rest:Wae(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?i5:r.slice(0,r.length-1);return i.mapped&&(n=o5(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Y8.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};s5.empty=new s5(i5,i5);var qae=[{key:`Mod-z`,run:$8,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:e5,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:e5,preventDefault:!0},{key:`Mod-u`,run:zae,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Bae,preventDefault:!0}];function c5(e,t){return Y.create(e.ranges.map(t),e.mainIndex)}function l5(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function u5({state:e,dispatch:t},n){let r=c5(e.selection,n);return r.eq(e.selection,!0)?!1:(t(l5(e,r)),!0)}function d5(e,t){return Y.cursor(t?e.to:e.from)}function f5(e,t){return u5(e,n=>n.empty?e.moveByChar(n,t):d5(n,t))}function p5(e){return e.textDirectionAt(e.state.selection.main.head)==TQ.LTR}var m5=e=>f5(e,!p5(e)),h5=e=>f5(e,p5(e));function g5(e,t){return u5(e,n=>n.empty?e.moveByGroup(n,t):d5(n,t))}var Jae=e=>g5(e,!p5(e)),Yae=e=>g5(e,p5(e));typeof Intl<`u`&&Intl.Segmenter;function Xae(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function _5(e,t,n){let r=R6(e).resolveInner(t.head),i=n?p3.closedBy:p3.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Xae(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?A8(e,r.from,1):A8(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,Y.cursor(s,n?-1:1)}var Zae=e=>u5(e,t=>_5(e.state,t,!p5(e))),Qae=e=>u5(e,t=>_5(e.state,t,p5(e)));function v5(e,t){return u5(e,n=>{if(!n.empty)return d5(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var y5=e=>v5(e,!1),b5=e=>v5(e,!0);function x5(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(x2.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function S5(e,t){let n=x5(e),{state:r}=e,i=c5(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):d5(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=x2.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(l5(r,i),{effects:a}),!0}var C5=e=>S5(e,!1),w5=e=>S5(e,!0);function T5(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=Y.cursor(r.from+n))}return i}var $ae=e=>u5(e,t=>T5(e,t,!0)),eoe=e=>u5(e,t=>T5(e,t,!1)),toe=e=>u5(e,t=>T5(e,t,!p5(e))),noe=e=>u5(e,t=>T5(e,t,p5(e))),roe=e=>u5(e,t=>Y.cursor(e.lineBlockAt(t.head).from,1)),ioe=e=>u5(e,t=>Y.cursor(e.lineBlockAt(t.head).to,-1));function aoe(e,t,n){let r=!1,i=c5(e.selection,t=>{let i=A8(e,t.head,-1)||A8(e,t.head,1)||t.head>0&&A8(e,t.head-1,1)||t.head<e.doc.length&&A8(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?Y.range(t.anchor,a):Y.cursor(a)});return r?(t(l5(e,i)),!0):!1}var ooe=({state:e,dispatch:t})=>aoe(e,t,!1);function E5(e,t){let n=c5(e.state.selection,e=>{let n=t(e);return Y.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(l5(e.state,n)),!0)}function D5(e,t){return E5(e,n=>e.moveByChar(n,t))}var O5=e=>D5(e,!p5(e)),k5=e=>D5(e,p5(e));function A5(e,t){return E5(e,n=>e.moveByGroup(n,t))}var soe=e=>A5(e,!p5(e)),coe=e=>A5(e,p5(e)),loe=e=>E5(e,t=>_5(e.state,t,!p5(e))),uoe=e=>E5(e,t=>_5(e.state,t,p5(e)));function j5(e,t){return E5(e,n=>e.moveVertically(n,t))}var M5=e=>j5(e,!1),N5=e=>j5(e,!0);function P5(e,t){return E5(e,n=>e.moveVertically(n,t,x5(e).height))}var F5=e=>P5(e,!1),I5=e=>P5(e,!0),doe=e=>E5(e,t=>T5(e,t,!0)),foe=e=>E5(e,t=>T5(e,t,!1)),poe=e=>E5(e,t=>T5(e,t,!p5(e))),moe=e=>E5(e,t=>T5(e,t,p5(e))),hoe=e=>E5(e,t=>Y.cursor(e.lineBlockAt(t.head).from)),goe=e=>E5(e,t=>Y.cursor(e.lineBlockAt(t.head).to)),L5=({state:e,dispatch:t})=>(t(l5(e,{anchor:0})),!0),R5=({state:e,dispatch:t})=>(t(l5(e,{anchor:e.doc.length})),!0),z5=({state:e,dispatch:t})=>(t(l5(e,{anchor:e.selection.main.anchor,head:0})),!0),B5=({state:e,dispatch:t})=>(t(l5(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),_oe=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),voe=({state:e,dispatch:t})=>{let n=Y5(e).map(({from:t,to:n})=>Y.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:Y.create(n),userEvent:`select`})),!0},yoe=({state:e,dispatch:t})=>{let n=c5(e.selection,t=>{let n=R6(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return Y.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(l5(e,n)),!0)};function V5(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(l5(n,Y.create(i,i.length-1))),!0)}var boe=e=>V5(e,!1),xoe=e=>V5(e,!0),Soe=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=Y.create([n.main]):n.main.empty||(r=Y.create([Y.cursor(n.main.head)])),r?(t(l5(e,r)),!0):!1};function H5(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=U5(e,o,!1)):o>i&&(n=`delete.forward`,o=U5(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=U5(e,i,!1),a=U5(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:Y.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?x2.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function U5(e,t,n){if(e instanceof x2)for(let r of e.state.facet(x2.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var W5=(e,t,n)=>H5(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=sZ(s,a.tabSize)%J6(a)||J6(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=NY(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=NY(o.text,c-o.from,!1,!1)+o.from);return c}),G5=e=>W5(e,!1,!0),K5=e=>W5(e,!0,!1),q5=(e,t)=>H5(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=NY(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),J5=e=>q5(e,!1),Coe=e=>q5(e,!0),woe=e=>H5(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Toe=e=>H5(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Eoe=e=>H5(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Doe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:SY.of([``,``])},range:Y.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Ooe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:NY(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:NY(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:Y.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Y5(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function X5(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Y5(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(Y.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(Y.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:Y.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var koe=({state:e,dispatch:t})=>X5(e,t,!1),Aoe=({state:e,dispatch:t})=>X5(e,t,!0);function Z5(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Y5(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var joe=({state:e,dispatch:t})=>Z5(e,t,!1),Moe=({state:e,dispatch:t})=>Z5(e,t,!0),Noe=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Y5(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=c5(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Poe(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=R6(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(p3.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Q5=$5(!1),Foe=$5(!0);function $5(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Poe(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Z6(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=X6(s,r);for(c??=sZ(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,Y6(t,c)];return o&&l.push(Y6(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:SY.of(l)},range:Y.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function e7(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:Y.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Ioe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Z6(e,{overrideIndentation:e=>n[e]??-1}),i=e7(e,(t,i,a)=>{let o=X6(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Y6(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},t7=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(e7(e,(t,n)=>{n.push({from:t.from,insert:e.facet(q6)})}),{userEvent:`input.indent`})),!0),n7=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(e7(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=sZ(r,e.tabSize),a=0,o=Y6(e,Math.max(0,i-J6(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Loe=e=>(e.setTabFocusMode(),!0),Roe=[{key:`Ctrl-b`,run:m5,shift:O5,preventDefault:!0},{key:`Ctrl-f`,run:h5,shift:k5},{key:`Ctrl-p`,run:y5,shift:M5},{key:`Ctrl-n`,run:b5,shift:N5},{key:`Ctrl-a`,run:roe,shift:hoe},{key:`Ctrl-e`,run:ioe,shift:goe},{key:`Ctrl-d`,run:K5},{key:`Ctrl-h`,run:G5},{key:`Ctrl-k`,run:woe},{key:`Ctrl-Alt-h`,run:J5},{key:`Ctrl-o`,run:Doe},{key:`Ctrl-t`,run:Ooe},{key:`Ctrl-v`,run:w5}],zoe=[{key:`ArrowLeft`,run:m5,shift:O5,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Jae,shift:soe,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:toe,shift:poe,preventDefault:!0},{key:`ArrowRight`,run:h5,shift:k5,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Yae,shift:coe,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:noe,shift:moe,preventDefault:!0},{key:`ArrowUp`,run:y5,shift:M5,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:L5,shift:z5},{mac:`Ctrl-ArrowUp`,run:C5,shift:F5},{key:`ArrowDown`,run:b5,shift:N5,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:R5,shift:B5},{mac:`Ctrl-ArrowDown`,run:w5,shift:I5},{key:`PageUp`,run:C5,shift:F5},{key:`PageDown`,run:w5,shift:I5},{key:`Home`,run:eoe,shift:foe,preventDefault:!0},{key:`Mod-Home`,run:L5,shift:z5},{key:`End`,run:$ae,shift:doe,preventDefault:!0},{key:`Mod-End`,run:R5,shift:B5},{key:`Enter`,run:Q5,shift:Q5},{key:`Mod-a`,run:_oe},{key:`Backspace`,run:G5,shift:G5,preventDefault:!0},{key:`Delete`,run:K5,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:J5,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Coe,preventDefault:!0},{mac:`Mod-Backspace`,run:Toe,preventDefault:!0},{mac:`Mod-Delete`,run:Eoe,preventDefault:!0}].concat(Roe.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Boe=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Zae,shift:loe},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Qae,shift:uoe},{key:`Alt-ArrowUp`,run:koe},{key:`Shift-Alt-ArrowUp`,run:joe},{key:`Alt-ArrowDown`,run:Aoe},{key:`Shift-Alt-ArrowDown`,run:Moe},{key:`Mod-Alt-ArrowUp`,run:boe},{key:`Mod-Alt-ArrowDown`,run:xoe},{key:`Escape`,run:Soe},{key:`Mod-Enter`,run:Foe},{key:`Alt-l`,mac:`Ctrl-l`,run:voe},{key:`Mod-i`,run:yoe,preventDefault:!0},{key:`Mod-[`,run:n7},{key:`Mod-]`,run:t7},{key:`Mod-Alt-\\`,run:Ioe},{key:`Shift-Mod-k`,run:Noe},{key:`Shift-Mod-\\`,run:ooe},{key:`Mod-/`,run:kae},{key:`Alt-A`,run:jae},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Loe}].concat(zoe),Voe={key:`Tab`,run:t7,shift:n7},Hoe=`#e5c07b`,r7=`#e06c75`,Uoe=`#56b6c2`,Woe=`#ffffff`,i7=`#abb2bf`,a7=`#7d8799`,Goe=`#61afef`,Koe=`#98c379`,o7=`#d19a66`,qoe=`#c678dd`,Joe=`#21252b`,s7=`#2c313a`,c7=`#282c34`,l7=`#353a42`,Yoe=`#3E4451`,u7=`#528bff`,d7=[x2.theme({"&":{color:i7,backgroundColor:c7},".cm-content":{caretColor:u7},".cm-cursor, .cm-dropCursor":{borderLeftColor:u7},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Yoe},".cm-panels":{backgroundColor:Joe,color:i7},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid #457dff`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`#6199ff2f`},".cm-activeLine":{backgroundColor:`#6699ff0b`},".cm-selectionMatch":{backgroundColor:`#aafe661a`},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bad0f847`},".cm-gutters":{backgroundColor:c7,color:a7,border:`none`},".cm-activeLineGutter":{backgroundColor:s7},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:l7},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:l7,borderBottomColor:l7},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:s7,color:i7}}},{dark:!0}),S8(v8.define([{tag:Z.keyword,color:qoe},{tag:[Z.name,Z.deleted,Z.character,Z.propertyName,Z.macroName],color:r7},{tag:[Z.function(Z.variableName),Z.labelName],color:Goe},{tag:[Z.color,Z.constant(Z.name),Z.standard(Z.name)],color:o7},{tag:[Z.definition(Z.name),Z.separator],color:i7},{tag:[Z.typeName,Z.className,Z.number,Z.changed,Z.annotation,Z.modifier,Z.self,Z.namespace],color:Hoe},{tag:[Z.operator,Z.operatorKeyword,Z.url,Z.escape,Z.regexp,Z.link,Z.special(Z.string)],color:Uoe},{tag:[Z.meta,Z.comment],color:a7},{tag:Z.strong,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.link,color:a7,textDecoration:`underline`},{tag:Z.heading,fontWeight:`bold`,color:r7},{tag:[Z.atom,Z.bool,Z.special(Z.variableName)],color:o7},{tag:[Z.processingInstruction,Z.string,Z.inserted],color:Koe},{tag:Z.invalid,color:Woe}]))],f7=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,p7=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(f7(e)):f7,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return IY(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=LY(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=RY(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(p7.prototype[Symbol.iterator]=function(){return this});var m7={from:-1,to:-1,match:/.*/.exec(``),precise:!0},h7=`gm`+(/x/.unicode==null?``:`u`),g7=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=m7,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new y7(e,t,n,r,i);this.re=new RegExp(t,h7+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=b7(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=b7(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},_7=new WeakMap,v7=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=_7.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return _7.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),_7.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},y7=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=m7,this.matchPos=b7(e,r),this.re=new RegExp(t,h7+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=v7.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=b7(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=v7.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(g7.prototype[Symbol.iterator]=y7.prototype[Symbol.iterator]=function(){return this});function Xoe(e){try{return new RegExp(e,h7),!0}catch{return!1}}function b7(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Zoe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=N4(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=Y.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,x2.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},Qoe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},x7=QY.define({combine(e){return HX(e,Qoe,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function $oe(e){let t=[ise,rse];return e&&t.push(x7.of(e)),t}var ese=GZ.mark({class:`cm-selectionMatch`}),tse=GZ.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function S7(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=IX.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=IX.Word)}function nse(e,t,n,r){return e(t.sliceDoc(n,n+1))==IX.Word&&e(t.sliceDoc(r-1,r))==IX.Word}var rse=p$.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(x7),{state:n}=e,r=n.selection;if(r.ranges.length>1)return GZ.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return GZ.none;let e=n.wordAt(i.head);if(!e)return GZ.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return GZ.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(S7(o,n,i.from,i.to)&&nse(o,n,i.from,i.to)))return GZ.none}else if(a=n.sliceDoc(i.from,i.to),!a)return GZ.none}let s=[];for(let r of e.visibleRanges){let e=new p7(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||S7(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(tse.range(r,a)):(r>=i.to||a<=i.from)&&s.push(ese.range(r,a)),s.length>t.maxMatches))return GZ.none}}return GZ.set(s)}},{decorations:e=>e.decorations}),ise=x2.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),ase=({state:e,dispatch:t})=>{let{selection:n}=e,r=Y.create(n.ranges.map(t=>e.wordAt(t.head)||Y.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function ose(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new p7(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new p7(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var sse=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return ase({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=ose(e,r);return i?(t(e.update({selection:e.selection.addRange(Y.range(i.from,i.to),!1),effects:x2.scrollIntoView(i.to)})),!0):!1},C7=QY.define({combine(e){return HX(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new xse(e),scrollToMatch:e=>x2.scrollIntoView(e)})}}),w7=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Xoe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
212
|
-
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new pse(this):new use(this)}getCursor(e,t=0,n){let r=e.doc?e:VX.create({doc:e});return n??=r.doc.length,this.regexp?D7(this,r,t,n):E7(this,r,t,n)}},T7=class{constructor(e){this.spec=e}};function cse(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function E7(e,t,n,r){let i;return e.wholeWord&&(i=lse(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=cse(e.test,t,i)),new p7(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function lse(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(O7(i,n-a))!=IX.Word||t(k7(i,n-a))!=IX.Word)&&(t(k7(i,r-a))!=IX.Word||t(O7(i,r-a))!=IX.Word))}var use=class extends T7{constructor(e){super(e)}nextMatch(e,t,n){let r=E7(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=E7(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=E7(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=E7(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=E7(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function dse(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function D7(e,t,n,r){let i;return e.wholeWord&&(i=fse(t.charCategorizer(t.selection.main.head))),e.test&&(i=dse(e.test,t,i)),new g7(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function O7(e,t){return e.slice(NY(e,t,!1),t)}function k7(e,t){return e.slice(t,NY(e,t))}function fse(e){return(t,n,r)=>!r[0].length||(e(O7(r.input,r.index))!=IX.Word||e(k7(r.input,r.index))!=IX.Word)&&(e(k7(r.input,r.index+r[0].length))!=IX.Word||e(O7(r.input,r.index+r[0].length))!=IX.Word)}var pse=class extends T7{nextMatch(e,t,n){let r=D7(this.spec,e,n,e.doc.length).next();return r.done&&(r=D7(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=D7(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=D7(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=D7(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},A7=EX.define(),j7=EX.define(),M7=aX.define({create(e){return new N7(z7(e).create(),null)},update(e,t){for(let n of t.effects)n.is(A7)?e=new N7(n.value.create(),e.panel):n.is(j7)&&(e=new N7(e.query,n.value?R7:null));return e},provide:e=>M4.from(e,e=>e.panel)}),N7=class{constructor(e,t){this.query=e,this.panel=t}},mse=GZ.mark({class:`cm-searchMatch`}),hse=GZ.mark({class:`cm-searchMatch cm-searchMatch-selected`}),gse=p$.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(M7))}update(e){let t=e.state.field(M7);(t!=e.startState.field(M7)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return GZ.none;let{view:n}=this,r=new XX;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?hse:mse)})}return r.finish()}},{decorations:e=>e.decorations});function P7(e){return t=>{let n=t.state.field(M7,!1);return n&&n.query.spec.valid?e(t,n):H7(t)}}var F7=P7((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=Y.single(r.from,r.to),a=e.state.facet(C7);return e.dispatch({selection:i,effects:[q7(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),V7(e),!0}),I7=P7((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=Y.single(i.from,i.to),o=e.state.facet(C7);return e.dispatch({selection:a,effects:[q7(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),V7(e),!0}),_se=P7((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:Y.create(n.map(e=>Y.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),vse=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new p7(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(Y.range(t.value.from,t.value.to))}return t(e.update({selection:Y.create(a,o),userEvent:`select.search.matches`})),!0},L7=P7((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),u.push(x2.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=Y.single(o.from,o.to).map(d),u.push(q7(e,o)),u.push(n.facet(C7).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),yse=P7((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:x2.announce.of(r),userEvent:`input.replace.all`}),!0});function R7(e){return e.state.facet(C7).createPanel(e)}function z7(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(C7);return new w7({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function B7(e){let t=O4(e,R7);return t&&t.dom.querySelector(`[main-field]`)}function V7(e){let t=B7(e);t&&t==e.root.activeElement&&t.select()}var H7=e=>{let t=e.state.field(M7,!1);if(t&&t.panel){let n=B7(e);if(n&&n!=e.root.activeElement){let r=z7(e.state,t.query.spec);r.valid&&e.dispatch({effects:A7.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[j7.of(!0),t?A7.of(z7(e.state,t.query.spec)):EX.appendConfig.of(Cse)]});return!0},U7=e=>{let t=e.state.field(M7,!1);if(!t||!t.panel)return!1;let n=O4(e,R7);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:j7.of(!1)}),!0},bse=[{key:`Mod-f`,run:H7,scope:`editor search-panel`},{key:`F3`,run:F7,shift:I7,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:F7,shift:I7,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:U7,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:vse},{key:`Mod-Alt-g`,run:Zoe},{key:`Mod-d`,run:sse,preventDefault:!0}],xse=class{constructor(e){this.view=e;let t=this.query=e.state.field(M7).query.spec;this.commit=this.commit.bind(this),this.searchField=CZ(`input`,{value:t.search,placeholder:W7(e,`Find`),"aria-label":W7(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=CZ(`input`,{value:t.replace,placeholder:W7(e,`Replace`),"aria-label":W7(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=CZ(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=CZ(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=CZ(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return CZ(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=CZ(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>F7(e),[W7(e,`next`)]),n(`prev`,()=>I7(e),[W7(e,`previous`)]),n(`select`,()=>_se(e),[W7(e,`all`)]),CZ(`label`,null,[this.caseField,W7(e,`match case`)]),CZ(`label`,null,[this.reField,W7(e,`regexp`)]),CZ(`label`,null,[this.wordField,W7(e,`by word`)]),...e.state.readOnly?[]:[CZ(`br`),this.replaceField,n(`replace`,()=>L7(e),[W7(e,`replace`)]),n(`replaceAll`,()=>yse(e),[W7(e,`replace all`)])],CZ(`button`,{name:`close`,onclick:()=>U7(e),"aria-label":W7(e,`close`),type:`button`},[`×`])])}commit(){let e=new w7({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:A7.of(e)}))}keydown(e){N2(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?I7:F7)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),L7(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(A7)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(C7).top}};function W7(e,t){return e.state.phrase(t)}var G7=30,K7=/[\s\.,:;?!]/;function q7(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-G7),o=Math.min(i,n+G7),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<G7;e++)if(!K7.test(s[e+1])&&K7.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-G7;e--)if(!K7.test(s[e-1])&&K7.test(s[e])){s=s.slice(0,e);break}}return x2.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Sse=x2.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Cse=[M7,cX.low(gse),Sse],J7=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=R6(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search($7(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function Y7(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function wse(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=Y7(t)+Y7(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function X7(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:wse(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function Tse(e,t){return n=>{for(let t=R6(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var Z7=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function Q7(e){return e.selection.main.from}function $7(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var e9=CX.define();function Ese(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:Y.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var t9=new WeakMap;function Dse(e){if(!Array.isArray(e))return e;let t=t9.get(e);return t||t9.set(e,t=X7(e)),t}var n9=EX.define(),r9=EX.define(),Ose=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=IY(e,t),r=RY(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(IY(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=IY(e,0),i=RY(r),a=i==e.length?0:-100;if(r!=t[0])if(r==n[0])a+=-200;else return null;return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=IY(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=RY(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=IY(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=LY(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=RY(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?RY(IY(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},kse=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},i9=QY.define({combine(e){return HX(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Ase,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>a9(e(n),t(n)),optionClass:(e,t)=>n=>a9(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function a9(e,t){return e?t?e+` `+t:e:t}function Ase(e,t,n,r,i,a){let o=e.textDirection==TQ.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var o9=EX.define();function jse(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function s9(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var Mse=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(i9);this.optionContent=jse(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=s9(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:o9.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(i9).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:r9.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=s9(r.length,i,e.state.facet(i9).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=s9(t.options.length,t.selected,this.view.state.facet(i9).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>l$(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&Pse(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(i9).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function Nse(e,t){return n=>new Mse(n,e,t)}function Pse(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function c9(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function Fse(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(i9);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new Z7(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new kse(n):new Ose(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new Z7(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):c9(e.completion)>c9(c)&&(s[s.length-1]=e),c=e.completion}return s}var Ise=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,l9(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=Fse(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(i9).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,l9(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:Use,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},Lse=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(Vse,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(i9),i=(r.override||n.languageDataAt(`autocomplete`,Q7(n)).map(Dse)).map(e=>(this.active.find(t=>t.source==e)||new d9(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(p9));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!Rse(i,this.active)||o?a=Ise.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new d9(e.source,0):e));for(let e of t.effects)e.is(o9)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?zse:Bse}};function Rse(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var zse={"aria-autocomplete":`list`},Bse={};function l9(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var Vse=[];function u9(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(e9);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var d9=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=u9(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(n9))i=new e(i.source,1,n.value);else if(n.is(r9))i=new e(i.source,0);else if(n.is(p9))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Q7(e.state))}},f9=class e extends d9{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=Q7(t.state);if(o>a||!r||n&2&&(Q7(t.startState)==this.from||o<this.limit))return new d9(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return Hse(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new J7(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??Q7(t.state)):new d9(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new d9(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function Hse(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):$7(e,!0).test(i)}var p9=EX.define({map(e,t){return e.map(e=>e.map(t))}}),m9=aX.define({create(){return Lse.start()},update(e,t){return e.update(t)},provide:e=>[T4.from(e,e=>e.tooltip),x2.contentAttributes.from(e,e=>e.attrs)]});function h9(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(m9).active.find(e=>e.source==t.source);return r instanceof f9?(typeof n==`string`?e.dispatch({...Ese(e.state,n,r.from,r.to),annotations:e9.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var Use=Nse(m9,h9);function g9(e,t=`option`){return n=>{let r=n.state.field(m9,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(i9).interactionDelay)return!1;let i=1,a;t==`page`&&(a=E4(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:o9.of(s)}),!0}}var Wse=e=>{let t=e.state.field(m9,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(i9).interactionDelay?!1:h9(e,t.open.options[t.open.selected])},_9=e=>e.state.field(m9,!1)?(e.dispatch({effects:n9.of(!0)}),!0):!1,Gse=e=>{let t=e.state.field(m9,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:r9.of(null)}),!0)},Kse=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},qse=50,Jse=1e3,Yse=p$.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(m9).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(m9),n=e.state.facet(i9);if(!e.selectionSet&&!e.docChanged&&e.startState.field(m9)==t)return;let r=e.transactions.some(e=>{let t=u9(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>qse&&Date.now()-n.time>Jse){for(let e of n.context.abortListeners)try{e()}catch(e){l$(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(n9)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(m9);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(i9).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new J7(t,Q7(t),e.explicit,this.view),r=new Kse(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:r9.of(null)}),l$(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(i9).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(i9),n=this.view.state.field(m9);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=Q7(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new f9(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new d9(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:p9.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(m9,!1);if(t&&t.tooltip&&this.view.state.facet(i9).closeOnBlur){let n=t.open&&E4(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:r9.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:n9.of(!1)}),20),this.composing=0}}}),Xse=typeof navigator==`object`&&/Win/.test(navigator.platform),Zse=cX.highest(x2.domEventHandlers({keydown(e,t){let n=t.state.field(m9,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Xse&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&h9(t,r),!1}})),v9=x2.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),Qse=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},$se=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,BY.TrackDel),r=t.mapPos(this.to,1,BY.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},ece=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(q6);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new $se(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1,c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new Qse(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},tce=GZ.widget({widget:new class extends UZ{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),nce=GZ.mark({class:`cm-snippetField`}),y9=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=GZ.set(e.map(e=>(e.from==e.to?tce:nce).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},b9=EX.define({map(e,t){return e&&e.map(t)}}),rce=EX.define(),x9=aX.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(b9))return n.value;if(n.is(rce)&&e)return new y9(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>x2.decorations.from(e,e=>e?e.deco:GZ.none)});function S9(e,t){return Y.create(e.filter(e=>e.field==t).map(e=>Y.range(e.from,e.to)))}function ice(e){let t=ece.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:s}=e.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:SY.of(a)},scrollIntoView:!0,annotations:n?[e9.of(n),DX.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=S9(o,0)),o.some(e=>e.field>0)){let t=new y9(o,0),n=c.effects=[b9.of(t)];e.state.field(x9,!1)===void 0&&n.push(EX.appendConfig.of([x9,oce,cce,v9]))}e.dispatch(e.state.update(c))}}function C9(e){return({state:t,dispatch:n})=>{let r=t.field(x9,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:S9(r.ranges,i),effects:b9.of(a?null:new y9(r.ranges,i)),scrollIntoView:!0})),!0}}var ace=[{key:`Tab`,run:C9(1),shift:C9(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(x9,!1)?(t(e.update({effects:b9.of(null)})),!0):!1}],w9=QY.define({combine(e){return e.length?e[0]:ace}}),oce=cX.highest(A2.compute([w9],e=>e.facet(w9)));function sce(e,t){return{...t,apply:ice(e)}}var cce=x2.domEventHandlers({mousedown(e,t){let n=t.state.field(x9,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:S9(n.ranges,i.field),effects:b9.of(n.ranges.some(e=>e.field>i.field)?new y9(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),T9={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},E9=EX.define({map(e,t){return t.mapPos(e,-1,BY.TrackAfter)??void 0}}),D9=new class extends UX{};D9.startSide=1,D9.endSide=-1;var O9=aX.define({create(){return JX.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(E9)&&(e=e.update({add:[D9.range(n.value,n.value+1)]}));return e}});function lce(){return[dce,O9]}var k9=`()[]{}<>«»»«[]{}`;function A9(e){for(let t=0;t<16;t+=2)if(k9.charCodeAt(t)==e)return k9.charAt(t+1);return LY(e<128?e:e+1)}function j9(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||T9}var uce=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),dce=x2.inputHandler.of((e,t,n,r)=>{if((uce?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&RY(IY(r,0))==1||t!=i.from||n!=i.to)return!1;let a=pce(e.state,r);return a?(e.dispatch(a),!0):!1}),fce=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=j9(e,e.selection.main.head).brackets||T9.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=mce(e.doc,t.head);for(let i of n)if(i==r&&N9(e.doc,t.head)==A9(IY(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:Y.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function pce(e,t){let n=j9(e,e.selection.main.head),r=n.brackets||T9.brackets;for(let i of r){let a=A9(IY(i,0));if(t==i)return a==i?_ce(e,i,r.indexOf(i+i+i)>-1,n):hce(e,i,a,n.before||T9.before);if(t==a&&M9(e,e.selection.main.from))return gce(e,i,a)}return null}function M9(e,t){let n=!1;return e.field(O9).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function N9(e,t){let n=e.sliceString(t,t+2);return n.slice(0,RY(IY(n,0)))}function mce(e,t){let n=e.sliceString(t-2,t);return RY(IY(n,0))==n.length?n:n.slice(1)}function hce(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:E9.of(a.to+t.length),range:Y.range(a.anchor+t.length,a.head+t.length)};let o=N9(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:E9.of(a.head+t.length),range:Y.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function gce(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&N9(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:Y.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function _ce(e,t,n,r){let i=r.stringPrefixes||T9.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:E9.of(r.to+t.length),range:Y.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=N9(e.doc,o),c;if(s==t){if(P9(e,o))return{changes:{insert:t+t,from:o},effects:E9.of(o+t.length),range:Y.cursor(o+t.length)};if(M9(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:Y.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=F9(e,o-2*t.length,i))>-1&&P9(e,c))return{changes:{insert:t+t+t+t,from:o},effects:E9.of(o+t.length),range:Y.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=IX.Word&&F9(e,o,i)>-1&&!vce(e,o,t,i))return{changes:{insert:t+t,from:o},effects:E9.of(o+t.length),range:Y.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function P9(e,t){let n=R6(e).resolveInner(t+1);return n.parent&&n.from==t}function vce(e,t,n,r){let i=R6(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function F9(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=IX.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=IX.Word)return n}return-1}function yce(e={}){return[Zse,m9,i9.of(e),Yse,L9,v9]}var I9=[{key:`Ctrl-Space`,run:_9},{mac:"Alt-`",run:_9},{mac:`Alt-i`,run:_9},{key:`Escape`,run:Gse},{key:`ArrowDown`,run:g9(!0)},{key:`ArrowUp`,run:g9(!1)},{key:`PageDown`,run:g9(!0,`page`)},{key:`PageUp`,run:g9(!1,`page`)},{key:`Enter`,run:Wse}],L9=cX.highest(A2.computeN([i9],e=>e.facet(i9).defaultKeymap?[I9]:[]));function $(e){return new K6(Cae.define(e))}function R9(e){return J(()=>import(`./dist-ClYUxfeK.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var bce=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return J(()=>import(`./dist-fBO2v5Kt.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return J(()=>import(`./dist-fBO2v5Kt.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return R9(`Cassandra`)}}),Q.of({name:`CSS`,extensions:[`css`],load(){return J(()=>import(`./dist-B2_CVgKv.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([10,8]),import.meta.url)}}),Q.of({name:`Go`,extensions:[`go`],load(){return J(()=>import(`./dist-B3FR1SKK.js`).then(e=>e.go()),__vite__mapDeps([11,8]),import.meta.url)}}),Q.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return J(()=>import(`./dist-DoVSwoDb.js`).then(e=>e.html()),__vite__mapDeps([12,10,8,13]),import.meta.url)}}),Q.of({name:`Java`,extensions:[`java`],load(){return J(()=>import(`./dist-QfkEHOlb.js`).then(e=>e.java()),__vite__mapDeps([14,8]),import.meta.url)}}),Q.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return J(()=>import(`./dist-ufY3F5p6.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return J(()=>import(`./dist-DVCOWtha.js`).then(e=>e.jinja()),__vite__mapDeps([15,12,10,8,13]),import.meta.url)}}),Q.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return J(()=>import(`./dist-CB9iJrvg.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return J(()=>import(`./dist-ufY3F5p6.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`LESS`,extensions:[`less`],load(){return J(()=>import(`./dist-DFD6Qa6T.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return J(()=>import(`./dist-Cf125P_m.js`).then(e=>e.liquid()),__vite__mapDeps([18,12,10,8,13]),import.meta.url)}}),Q.of({name:`MariaDB SQL`,load(){return R9(`MariaSQL`)}}),Q.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return J(()=>import(`./dist-btbmmX5O.js`).then(e=>e.markdown()),__vite__mapDeps([19,12,10,8,13]),import.meta.url)}}),Q.of({name:`MS SQL`,load(){return R9(`MSSQL`)}}),Q.of({name:`MySQL`,load(){return R9(`MySQL`)}}),Q.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return J(()=>import(`./dist-C1NMAY5a.js`).then(e=>e.php()),__vite__mapDeps([20,12,10,8,13]),import.meta.url)}}),Q.of({name:`PLSQL`,extensions:[`pls`],load(){return R9(`PLSQL`)}}),Q.of({name:`PostgreSQL`,load(){return R9(`PostgreSQL`)}}),Q.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return J(()=>import(`./dist-C5_ZAZsG.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return J(()=>import(`./dist-BIr4DSRq.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return J(()=>import(`./dist-D_ctSS2i.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SCSS`,extensions:[`scss`],load(){return J(()=>import(`./dist-D_ctSS2i.js`).then(e=>e.sass()),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SQL`,extensions:[`sql`],load(){return R9(`StandardSQL`)}}),Q.of({name:`SQLite`,load(){return R9(`SQLite`)}}),Q.of({name:`TSX`,extensions:[`tsx`],load(){return J(()=>import(`./dist-ufY3F5p6.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return J(()=>import(`./dist-ufY3F5p6.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return J(()=>import(`./dist-DiixqL0J.js`).then(e=>e.wast()),__vite__mapDeps([24,8]),import.meta.url)}}),Q.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return J(()=>import(`./dist-CFzsn6BG.js`).then(e=>e.xml()),__vite__mapDeps([25,8]),import.meta.url)}}),Q.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return J(()=>import(`./dist-Bj730Ib4.js`).then(e=>e.yaml()),__vite__mapDeps([26,8]),import.meta.url)}}),Q.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return J(()=>import(`./apl-CnwPGSsG.js`).then(e=>$(e.apl)),[],import.meta.url)}}),Q.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return J(()=>import(`./asciiarmor-qTkVPQu6.js`).then(e=>$(e.asciiArmor)),[],import.meta.url)}}),Q.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return J(()=>import(`./asn1-Dr8qZg38.js`).then(e=>$(e.asn1({}))),[],import.meta.url)}}),Q.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return J(()=>import(`./asterisk-Bja0s6e1.js`).then(e=>$(e.asterisk)),[],import.meta.url)}}),Q.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return J(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[],import.meta.url)}}),Q.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return J(()=>import(`./cobol-B_OZ4V-R.js`).then(e=>$(e.cobol)),[],import.meta.url)}}),Q.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.csharp)),[],import.meta.url)}}),Q.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`ClojureScript`,extensions:[`cljs`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return J(()=>import(`./css-CYpP4FRV.js`).then(e=>$(e.gss)),[],import.meta.url)}}),Q.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return J(()=>import(`./cmake-CyVbuzPu.js`).then(e=>$(e.cmake)),[],import.meta.url)}}),Q.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return J(()=>import(`./coffeescript-B2pKbFk8.js`).then(e=>$(e.coffeeScript)),[],import.meta.url)}}),Q.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return J(()=>import(`./commonlisp-CcllspGY.js`).then(e=>$(e.commonLisp)),[],import.meta.url)}}),Q.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return J(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[],import.meta.url)}}),Q.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return J(()=>import(`./python-BqYw9LYJ.js`).then(e=>$(e.cython)),[],import.meta.url)}}),Q.of({name:`Crystal`,extensions:[`cr`],load(){return J(()=>import(`./crystal-M5-qzICs.js`).then(e=>$(e.crystal)),[],import.meta.url)}}),Q.of({name:`D`,extensions:[`d`],load(){return J(()=>import(`./d-BhMjBjQP.js`).then(e=>$(e.d)),[],import.meta.url)}}),Q.of({name:`Dart`,extensions:[`dart`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.dart)),[],import.meta.url)}}),Q.of({name:`diff`,extensions:[`diff`,`patch`],load(){return J(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[],import.meta.url)}}),Q.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return J(()=>import(`./dockerfile-BLkNEvjs.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([27,28]),import.meta.url)}}),Q.of({name:`DTD`,extensions:[`dtd`],load(){return J(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[],import.meta.url)}}),Q.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return J(()=>import(`./dylan-C6jEEEk-.js`).then(e=>$(e.dylan)),[],import.meta.url)}}),Q.of({name:`EBNF`,load(){return J(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[],import.meta.url)}}),Q.of({name:`ECL`,extensions:[`ecl`],load(){return J(()=>import(`./ecl-BSZaIHnp.js`).then(e=>$(e.ecl)),[],import.meta.url)}}),Q.of({name:`edn`,extensions:[`edn`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Eiffel`,extensions:[`e`],load(){return J(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[],import.meta.url)}}),Q.of({name:`Elm`,extensions:[`elm`],load(){return J(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[],import.meta.url)}}),Q.of({name:`Erlang`,extensions:[`erl`],load(){return J(()=>import(`./erlang-DaB2Rkuy.js`).then(e=>$(e.erlang)),[],import.meta.url)}}),Q.of({name:`Esper`,load(){return J(()=>import(`./sql-DcCJ9jop.js`).then(e=>$(e.esper)),[],import.meta.url)}}),Q.of({name:`Factor`,extensions:[`factor`],load(){return J(()=>import(`./factor-D7LVTn2l.js`).then(e=>$(e.factor)),__vite__mapDeps([29,28]),import.meta.url)}}),Q.of({name:`FCL`,load(){return J(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[],import.meta.url)}}),Q.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return J(()=>import(`./forth-Cezjo90N.js`).then(e=>$(e.forth)),[],import.meta.url)}}),Q.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return J(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[],import.meta.url)}}),Q.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[],import.meta.url)}}),Q.of({name:`Gas`,extensions:[`s`],load(){return J(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[],import.meta.url)}}),Q.of({name:`Gherkin`,extensions:[`feature`],load(){return J(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[],import.meta.url)}}),Q.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return J(()=>import(`./groovy-BC3IOsC8.js`).then(e=>$(e.groovy)),[],import.meta.url)}}),Q.of({name:`Haskell`,extensions:[`hs`],load(){return J(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[],import.meta.url)}}),Q.of({name:`Haxe`,extensions:[`hx`],load(){return J(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.haxe)),[],import.meta.url)}}),Q.of({name:`HXML`,extensions:[`hxml`],load(){return J(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.hxml)),[],import.meta.url)}}),Q.of({name:`HTTP`,load(){return J(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[],import.meta.url)}}),Q.of({name:`IDL`,extensions:[`pro`],load(){return J(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[],import.meta.url)}}),Q.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return J(()=>import(`./javascript-9Tg8ixDm.js`).then(e=>$(e.jsonld)),[],import.meta.url)}}),Q.of({name:`Julia`,extensions:[`jl`],load(){return J(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[],import.meta.url)}}),Q.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.kotlin)),[],import.meta.url)}}),Q.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return J(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[],import.meta.url)}}),Q.of({name:`Lua`,extensions:[`lua`],load(){return J(()=>import(`./lua-CiA1ziua.js`).then(e=>$(e.lua)),[],import.meta.url)}}),Q.of({name:`mIRC`,extensions:[`mrc`],load(){return J(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[],import.meta.url)}}),Q.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return J(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[],import.meta.url)}}),Q.of({name:`Modelica`,extensions:[`mo`],load(){return J(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[],import.meta.url)}}),Q.of({name:`MUMPS`,extensions:[`mps`],load(){return J(()=>import(`./mumps-CW_TBmxz.js`).then(e=>$(e.mumps)),[],import.meta.url)}}),Q.of({name:`Mbox`,extensions:[`mbox`],load(){return J(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[],import.meta.url)}}),Q.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return J(()=>import(`./nginx-BMaDbqW3.js`).then(e=>$(e.nginx)),[],import.meta.url)}}),Q.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return J(()=>import(`./nsis-AQ_alPln.js`).then(e=>$(e.nsis)),__vite__mapDeps([30,28]),import.meta.url)}}),Q.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return J(()=>import(`./ntriples-d28e9m0E.js`).then(e=>$(e.ntriples)),[],import.meta.url)}}),Q.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveC)),[],import.meta.url)}}),Q.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveCpp)),[],import.meta.url)}}),Q.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[],import.meta.url)}}),Q.of({name:`Octave`,extensions:[`m`],load(){return J(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[],import.meta.url)}}),Q.of({name:`Oz`,extensions:[`oz`],load(){return J(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[],import.meta.url)}}),Q.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return J(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[],import.meta.url)}}),Q.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return J(()=>import(`./perl-CdEHsPfU.js`).then(e=>$(e.perl)),[],import.meta.url)}}),Q.of({name:`Pig`,extensions:[`pig`],load(){return J(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[],import.meta.url)}}),Q.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return J(()=>import(`./powershell-CzG71I4L.js`).then(e=>$(e.powerShell)),[],import.meta.url)}}),Q.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return J(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[],import.meta.url)}}),Q.of({name:`ProtoBuf`,extensions:[`proto`],load(){return J(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[],import.meta.url)}}),Q.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return J(()=>import(`./pug-Bugr-47h.js`).then(e=>$(e.pug)),__vite__mapDeps([31,32]),import.meta.url)}}),Q.of({name:`Puppet`,extensions:[`pp`],load(){return J(()=>import(`./puppet-B4hC2X4m.js`).then(e=>$(e.puppet)),[],import.meta.url)}}),Q.of({name:`Q`,extensions:[`q`],load(){return J(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[],import.meta.url)}}),Q.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return J(()=>import(`./r-DADKenSm.js`).then(e=>$(e.r)),[],import.meta.url)}}),Q.of({name:`RPM Changes`,load(){return J(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[],import.meta.url)}}),Q.of({name:`RPM Spec`,extensions:[`spec`],load(){return J(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmSpec)),[],import.meta.url)}}),Q.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return J(()=>import(`./ruby-DsYpTuWg.js`).then(e=>$(e.ruby)),[],import.meta.url)}}),Q.of({name:`SAS`,extensions:[`sas`],load(){return J(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[],import.meta.url)}}),Q.of({name:`Scala`,extensions:[`scala`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.scala)),[],import.meta.url)}}),Q.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return J(()=>import(`./scheme-CyDdOh7e.js`).then(e=>$(e.scheme)),[],import.meta.url)}}),Q.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return J(()=>import(`./shell-Du5Qg9im.js`).then(e=>$(e.shell)),[],import.meta.url)}}),Q.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return J(()=>import(`./sieve-BAxa3IjF.js`).then(e=>$(e.sieve)),[],import.meta.url)}}),Q.of({name:`Smalltalk`,extensions:[`st`],load(){return J(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[],import.meta.url)}}),Q.of({name:`Solr`,load(){return J(()=>import(`./solr-BBopId9w.js`).then(e=>$(e.solr)),[],import.meta.url)}}),Q.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[],import.meta.url)}}),Q.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return J(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[],import.meta.url)}}),Q.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return J(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[],import.meta.url)}}),Q.of({name:`Squirrel`,extensions:[`nut`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.squirrel)),[],import.meta.url)}}),Q.of({name:`Stylus`,extensions:[`styl`],load(){return J(()=>import(`./stylus-DLLZ8dgm.js`).then(e=>$(e.stylus)),[],import.meta.url)}}),Q.of({name:`Swift`,extensions:[`swift`],load(){return J(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[],import.meta.url)}}),Q.of({name:`sTeX`,load(){return J(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return J(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return J(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`Tcl`,extensions:[`tcl`],load(){return J(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[],import.meta.url)}}),Q.of({name:`Textile`,extensions:[`textile`],load(){return J(()=>import(`./textile-DWBqthVk.js`).then(e=>$(e.textile)),[],import.meta.url)}}),Q.of({name:`TiddlyWiki`,load(){return J(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[],import.meta.url)}}),Q.of({name:`Tiki wiki`,load(){return J(()=>import(`./tiki-CxVlf5KZ.js`).then(e=>$(e.tiki)),[],import.meta.url)}}),Q.of({name:`TOML`,extensions:[`toml`],load(){return J(()=>import(`./toml-LvoKBwCs.js`).then(e=>$(e.toml)),[],import.meta.url)}}),Q.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return J(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[],import.meta.url)}}),Q.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return J(()=>import(`./ttcn-BePYh-hG.js`).then(e=>$(e.ttcn)),[],import.meta.url)}}),Q.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return J(()=>import(`./ttcn-cfg-CY0aot7Q.js`).then(e=>$(e.ttcnCfg)),[],import.meta.url)}}),Q.of({name:`Turtle`,extensions:[`ttl`],load(){return J(()=>import(`./turtle-BDLWE2cD.js`).then(e=>$(e.turtle)),[],import.meta.url)}}),Q.of({name:`Web IDL`,extensions:[`webidl`],load(){return J(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[],import.meta.url)}}),Q.of({name:`VB.NET`,extensions:[`vb`],load(){return J(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[],import.meta.url)}}),Q.of({name:`VBScript`,extensions:[`vbs`],load(){return J(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[],import.meta.url)}}),Q.of({name:`Velocity`,extensions:[`vtl`],load(){return J(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[],import.meta.url)}}),Q.of({name:`Verilog`,extensions:[`v`],load(){return J(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return J(()=>import(`./vhdl-CMrOq2q1.js`).then(e=>$(e.vhdl)),[],import.meta.url)}}),Q.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return J(()=>import(`./xquery-fj_R-kMw.js`).then(e=>$(e.xQuery)),[],import.meta.url)}}),Q.of({name:`Yacas`,extensions:[`ys`],load(){return J(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[],import.meta.url)}}),Q.of({name:`Z80`,extensions:[`z80`],load(){return J(()=>import(`./z80-CL1naaMV.js`).then(e=>$(e.z80)),[],import.meta.url)}}),Q.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[],import.meta.url)}}),Q.of({name:`Xù`,extensions:[`xu`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[],import.meta.url)}}),Q.of({name:`MsGenny`,extensions:[`msgenny`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[],import.meta.url)}}),Q.of({name:`Vue`,extensions:[`vue`],load(){return J(()=>import(`./dist-DvFK7p5S.js`).then(e=>e.vue()),__vite__mapDeps([33,12,10,8,13]),import.meta.url)}}),Q.of({name:`Angular Template`,load(){return J(()=>import(`./dist-BnaTiyzN.js`).then(e=>e.angular()),__vite__mapDeps([34,12,10,8,13]),import.meta.url)}})];function z9(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function B9(e){return Q.matchFilename(bce,`file${e}`)}function V9({content:e,path:t,readOnly:n=!1,onSave:r,onDirtyChange:i,onContentChange:a,getContentRef:o}){let s=(0,v.useRef)(null),c=(0,v.useRef)(null),l=(0,v.useRef)(new uX),u=(0,v.useRef)(new uX),d=(0,v.useRef)(new uX),f=(0,v.useRef)(!1),p=(0,v.useRef)(r),m=(0,v.useRef)(i),h=(0,v.useRef)(a);(0,v.useEffect)(()=>{p.current=r,m.current=i,h.current=a},[r,i,a]);let g=(0,v.useCallback)(e=>{f.current!==e&&(f.current=e,m.current?.(e))},[]);return(0,v.useEffect)(()=>{if(!s.current)return;let r=document.documentElement.classList.contains(`dark`),i=A2.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new x2({state:VX.create({doc:e,extensions:[a3(),l3(),Rae(),cae(),J2(),r4(),VX.allowMultipleSelections.of(!0),Zie(),S8(fae,{fallback:!0}),vae(),lce(),yce(),f4(),h4(),i4(),$oe(),A2.of([...fce,...Boe,...bse,...qae,...iae,...I9,Voe]),i,x2.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(VX.readOnly.of(n)),l.current.of([]),u.current.of(r?d7:[]),x2.theme({"&":{height:`100%`},".cm-scroller":{overflow:`auto`}})]}),parent:s.current});c.current=a,o&&(o.current=()=>a.state.doc.toString());let f=B9(z9(t));return f&&f.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}),()=>{a.destroy(),c.current=null,o&&(o.current=null)}},[]),(0,v.useEffect)(()=>{let t=c.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),g(!1))},[e,g]),(0,v.useEffect)(()=>{let e=c.current;if(!e)return;let n=B9(z9(t));n?n.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}):e.dispatch({effects:l.current.reconfigure([])})},[t]),(0,v.useEffect)(()=>{let e=c.current;e&&e.dispatch({effects:d.current.reconfigure(VX.readOnly.of(n))})},[n]),(0,v.useEffect)(()=>{let e=new MutationObserver(()=>{let e=c.current;if(!e)return;let t=document.documentElement.classList.contains(`dark`);e.dispatch({effects:u.current.reconfigure(t?d7:[])})});return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]),(0,O.jsx)(`div`,{ref:s,className:`h-full w-full overflow-hidden [&_.cm-editor]:h-full [&_.cm-scroller]:auto`})}function H9({content:e,objectUrl:t,kind:n,filename:r,path:i}){return n===`markdown`?(0,O.jsx)(wq,{content:e||``}):n===`image`&&t?(0,O.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,O.jsx)(`img`,{src:t,alt:r,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n===`pdf`&&t?(0,O.jsx)(`iframe`,{src:t,title:r,className:`h-full w-full border-0`}):(n===`text`||n===`code`)&&e!==null?(0,O.jsx)(V9,{content:e,path:i||r,readOnly:!0,onSave:()=>{},onDirtyChange:()=>{},getContentRef:{current:()=>e||``}}):(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,O.jsx)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:`该文件类型暂不支持在线预览,请直接下载查看。`})})}function U9(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function xce(e){let t=e.endsWith(`/`)?e:`${e}/`;if(typeof window>`u`)return`'self'`;try{return new URL(t,window.location.origin).toString()}catch{return`'self'`}}function W9(...e){return Array.from(new Set(e.filter(e=>!!e))).join(` `)}function Sce(e){let t=e?xce(e):void 0,n=W9(`'unsafe-inline'`,`'unsafe-eval'`,`'self'`,`https:`,t),r=W9(`'self'`,`https:`,t);return[`default-src 'none'`,`script-src ${n}`,`style-src 'unsafe-inline' data: ${r}`,`img-src data: blob: ${r}`,`font-src data: ${r}`,`media-src data: blob: ${r}`,`worker-src blob:`,`connect-src 'none'`,`form-action 'none'`,`base-uri 'self'`].join(`; `)}function Cce(e){try{let t=new URL(e,window.location.href);return[`http:`,`https:`,`mailto:`].includes(t.protocol)}catch{return!1}}function G9(e,t={}){let{channelId:n,basePath:r}=typeof t==`string`?{channelId:t}:t,i=Sce(r),a=`<script>
|
|
212
|
+
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new pse(this):new use(this)}getCursor(e,t=0,n){let r=e.doc?e:VX.create({doc:e});return n??=r.doc.length,this.regexp?D7(this,r,t,n):E7(this,r,t,n)}},T7=class{constructor(e){this.spec=e}};function cse(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function E7(e,t,n,r){let i;return e.wholeWord&&(i=lse(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=cse(e.test,t,i)),new p7(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function lse(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(O7(i,n-a))!=IX.Word||t(k7(i,n-a))!=IX.Word)&&(t(k7(i,r-a))!=IX.Word||t(O7(i,r-a))!=IX.Word))}var use=class extends T7{constructor(e){super(e)}nextMatch(e,t,n){let r=E7(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=E7(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=E7(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=E7(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=E7(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function dse(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function D7(e,t,n,r){let i;return e.wholeWord&&(i=fse(t.charCategorizer(t.selection.main.head))),e.test&&(i=dse(e.test,t,i)),new g7(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function O7(e,t){return e.slice(NY(e,t,!1),t)}function k7(e,t){return e.slice(t,NY(e,t))}function fse(e){return(t,n,r)=>!r[0].length||(e(O7(r.input,r.index))!=IX.Word||e(k7(r.input,r.index))!=IX.Word)&&(e(k7(r.input,r.index+r[0].length))!=IX.Word||e(O7(r.input,r.index+r[0].length))!=IX.Word)}var pse=class extends T7{nextMatch(e,t,n){let r=D7(this.spec,e,n,e.doc.length).next();return r.done&&(r=D7(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=D7(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=D7(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=D7(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},A7=EX.define(),j7=EX.define(),M7=aX.define({create(e){return new N7(z7(e).create(),null)},update(e,t){for(let n of t.effects)n.is(A7)?e=new N7(n.value.create(),e.panel):n.is(j7)&&(e=new N7(e.query,n.value?R7:null));return e},provide:e=>M4.from(e,e=>e.panel)}),N7=class{constructor(e,t){this.query=e,this.panel=t}},mse=GZ.mark({class:`cm-searchMatch`}),hse=GZ.mark({class:`cm-searchMatch cm-searchMatch-selected`}),gse=p$.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(M7))}update(e){let t=e.state.field(M7);(t!=e.startState.field(M7)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return GZ.none;let{view:n}=this,r=new XX;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?hse:mse)})}return r.finish()}},{decorations:e=>e.decorations});function P7(e){return t=>{let n=t.state.field(M7,!1);return n&&n.query.spec.valid?e(t,n):H7(t)}}var F7=P7((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=Y.single(r.from,r.to),a=e.state.facet(C7);return e.dispatch({selection:i,effects:[q7(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),V7(e),!0}),I7=P7((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=Y.single(i.from,i.to),o=e.state.facet(C7);return e.dispatch({selection:a,effects:[q7(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),V7(e),!0}),_se=P7((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:Y.create(n.map(e=>Y.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),vse=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new p7(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(Y.range(t.value.from,t.value.to))}return t(e.update({selection:Y.create(a,o),userEvent:`select.search.matches`})),!0},L7=P7((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),u.push(x2.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=Y.single(o.from,o.to).map(d),u.push(q7(e,o)),u.push(n.facet(C7).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),yse=P7((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:x2.announce.of(r),userEvent:`input.replace.all`}),!0});function R7(e){return e.state.facet(C7).createPanel(e)}function z7(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(C7);return new w7({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function B7(e){let t=O4(e,R7);return t&&t.dom.querySelector(`[main-field]`)}function V7(e){let t=B7(e);t&&t==e.root.activeElement&&t.select()}var H7=e=>{let t=e.state.field(M7,!1);if(t&&t.panel){let n=B7(e);if(n&&n!=e.root.activeElement){let r=z7(e.state,t.query.spec);r.valid&&e.dispatch({effects:A7.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[j7.of(!0),t?A7.of(z7(e.state,t.query.spec)):EX.appendConfig.of(Cse)]});return!0},U7=e=>{let t=e.state.field(M7,!1);if(!t||!t.panel)return!1;let n=O4(e,R7);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:j7.of(!1)}),!0},bse=[{key:`Mod-f`,run:H7,scope:`editor search-panel`},{key:`F3`,run:F7,shift:I7,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:F7,shift:I7,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:U7,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:vse},{key:`Mod-Alt-g`,run:Zoe},{key:`Mod-d`,run:sse,preventDefault:!0}],xse=class{constructor(e){this.view=e;let t=this.query=e.state.field(M7).query.spec;this.commit=this.commit.bind(this),this.searchField=CZ(`input`,{value:t.search,placeholder:W7(e,`Find`),"aria-label":W7(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=CZ(`input`,{value:t.replace,placeholder:W7(e,`Replace`),"aria-label":W7(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=CZ(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=CZ(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=CZ(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return CZ(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=CZ(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>F7(e),[W7(e,`next`)]),n(`prev`,()=>I7(e),[W7(e,`previous`)]),n(`select`,()=>_se(e),[W7(e,`all`)]),CZ(`label`,null,[this.caseField,W7(e,`match case`)]),CZ(`label`,null,[this.reField,W7(e,`regexp`)]),CZ(`label`,null,[this.wordField,W7(e,`by word`)]),...e.state.readOnly?[]:[CZ(`br`),this.replaceField,n(`replace`,()=>L7(e),[W7(e,`replace`)]),n(`replaceAll`,()=>yse(e),[W7(e,`replace all`)])],CZ(`button`,{name:`close`,onclick:()=>U7(e),"aria-label":W7(e,`close`),type:`button`},[`×`])])}commit(){let e=new w7({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:A7.of(e)}))}keydown(e){N2(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?I7:F7)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),L7(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(A7)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(C7).top}};function W7(e,t){return e.state.phrase(t)}var G7=30,K7=/[\s\.,:;?!]/;function q7(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-G7),o=Math.min(i,n+G7),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<G7;e++)if(!K7.test(s[e+1])&&K7.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-G7;e--)if(!K7.test(s[e-1])&&K7.test(s[e])){s=s.slice(0,e);break}}return x2.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Sse=x2.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Cse=[M7,cX.low(gse),Sse],J7=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=R6(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search($7(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function Y7(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function wse(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=Y7(t)+Y7(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function X7(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:wse(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function Tse(e,t){return n=>{for(let t=R6(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var Z7=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function Q7(e){return e.selection.main.from}function $7(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var e9=CX.define();function Ese(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:Y.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var t9=new WeakMap;function Dse(e){if(!Array.isArray(e))return e;let t=t9.get(e);return t||t9.set(e,t=X7(e)),t}var n9=EX.define(),r9=EX.define(),Ose=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=IY(e,t),r=RY(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(IY(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=IY(e,0),i=RY(r),a=i==e.length?0:-100;if(r!=t[0])if(r==n[0])a+=-200;else return null;return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=IY(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=RY(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=IY(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=LY(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=RY(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?RY(IY(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},kse=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},i9=QY.define({combine(e){return HX(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Ase,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>a9(e(n),t(n)),optionClass:(e,t)=>n=>a9(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function a9(e,t){return e?t?e+` `+t:e:t}function Ase(e,t,n,r,i,a){let o=e.textDirection==TQ.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var o9=EX.define();function jse(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function s9(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var Mse=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(i9);this.optionContent=jse(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=s9(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:o9.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(i9).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:r9.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=s9(r.length,i,e.state.facet(i9).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=s9(t.options.length,t.selected,this.view.state.facet(i9).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>l$(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&Pse(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(i9).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function Nse(e,t){return n=>new Mse(n,e,t)}function Pse(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function c9(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function Fse(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(i9);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new Z7(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new kse(n):new Ose(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new Z7(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):c9(e.completion)>c9(c)&&(s[s.length-1]=e),c=e.completion}return s}var Ise=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,l9(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=Fse(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(i9).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,l9(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:Use,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},Lse=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(Vse,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(i9),i=(r.override||n.languageDataAt(`autocomplete`,Q7(n)).map(Dse)).map(e=>(this.active.find(t=>t.source==e)||new d9(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(p9));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!Rse(i,this.active)||o?a=Ise.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new d9(e.source,0):e));for(let e of t.effects)e.is(o9)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?zse:Bse}};function Rse(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var zse={"aria-autocomplete":`list`},Bse={};function l9(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var Vse=[];function u9(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(e9);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var d9=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=u9(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(n9))i=new e(i.source,1,n.value);else if(n.is(r9))i=new e(i.source,0);else if(n.is(p9))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Q7(e.state))}},f9=class e extends d9{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=Q7(t.state);if(o>a||!r||n&2&&(Q7(t.startState)==this.from||o<this.limit))return new d9(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return Hse(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new J7(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??Q7(t.state)):new d9(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new d9(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function Hse(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):$7(e,!0).test(i)}var p9=EX.define({map(e,t){return e.map(e=>e.map(t))}}),m9=aX.define({create(){return Lse.start()},update(e,t){return e.update(t)},provide:e=>[T4.from(e,e=>e.tooltip),x2.contentAttributes.from(e,e=>e.attrs)]});function h9(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(m9).active.find(e=>e.source==t.source);return r instanceof f9?(typeof n==`string`?e.dispatch({...Ese(e.state,n,r.from,r.to),annotations:e9.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var Use=Nse(m9,h9);function g9(e,t=`option`){return n=>{let r=n.state.field(m9,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(i9).interactionDelay)return!1;let i=1,a;t==`page`&&(a=E4(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:o9.of(s)}),!0}}var Wse=e=>{let t=e.state.field(m9,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(i9).interactionDelay?!1:h9(e,t.open.options[t.open.selected])},_9=e=>e.state.field(m9,!1)?(e.dispatch({effects:n9.of(!0)}),!0):!1,Gse=e=>{let t=e.state.field(m9,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:r9.of(null)}),!0)},Kse=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},qse=50,Jse=1e3,Yse=p$.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(m9).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(m9),n=e.state.facet(i9);if(!e.selectionSet&&!e.docChanged&&e.startState.field(m9)==t)return;let r=e.transactions.some(e=>{let t=u9(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>qse&&Date.now()-n.time>Jse){for(let e of n.context.abortListeners)try{e()}catch(e){l$(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(n9)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(m9);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(i9).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new J7(t,Q7(t),e.explicit,this.view),r=new Kse(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:r9.of(null)}),l$(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(i9).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(i9),n=this.view.state.field(m9);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=Q7(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new f9(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new d9(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:p9.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(m9,!1);if(t&&t.tooltip&&this.view.state.facet(i9).closeOnBlur){let n=t.open&&E4(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:r9.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:n9.of(!1)}),20),this.composing=0}}}),Xse=typeof navigator==`object`&&/Win/.test(navigator.platform),Zse=cX.highest(x2.domEventHandlers({keydown(e,t){let n=t.state.field(m9,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Xse&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&h9(t,r),!1}})),v9=x2.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),Qse=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},$se=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,BY.TrackDel),r=t.mapPos(this.to,1,BY.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},ece=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(q6);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new $se(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1,c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new Qse(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},tce=GZ.widget({widget:new class extends UZ{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),nce=GZ.mark({class:`cm-snippetField`}),y9=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=GZ.set(e.map(e=>(e.from==e.to?tce:nce).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},b9=EX.define({map(e,t){return e&&e.map(t)}}),rce=EX.define(),x9=aX.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(b9))return n.value;if(n.is(rce)&&e)return new y9(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>x2.decorations.from(e,e=>e?e.deco:GZ.none)});function S9(e,t){return Y.create(e.filter(e=>e.field==t).map(e=>Y.range(e.from,e.to)))}function ice(e){let t=ece.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:s}=e.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:SY.of(a)},scrollIntoView:!0,annotations:n?[e9.of(n),DX.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=S9(o,0)),o.some(e=>e.field>0)){let t=new y9(o,0),n=c.effects=[b9.of(t)];e.state.field(x9,!1)===void 0&&n.push(EX.appendConfig.of([x9,oce,cce,v9]))}e.dispatch(e.state.update(c))}}function C9(e){return({state:t,dispatch:n})=>{let r=t.field(x9,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:S9(r.ranges,i),effects:b9.of(a?null:new y9(r.ranges,i)),scrollIntoView:!0})),!0}}var ace=[{key:`Tab`,run:C9(1),shift:C9(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(x9,!1)?(t(e.update({effects:b9.of(null)})),!0):!1}],w9=QY.define({combine(e){return e.length?e[0]:ace}}),oce=cX.highest(A2.compute([w9],e=>e.facet(w9)));function sce(e,t){return{...t,apply:ice(e)}}var cce=x2.domEventHandlers({mousedown(e,t){let n=t.state.field(x9,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:S9(n.ranges,i.field),effects:b9.of(n.ranges.some(e=>e.field>i.field)?new y9(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),T9={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},E9=EX.define({map(e,t){return t.mapPos(e,-1,BY.TrackAfter)??void 0}}),D9=new class extends UX{};D9.startSide=1,D9.endSide=-1;var O9=aX.define({create(){return JX.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(E9)&&(e=e.update({add:[D9.range(n.value,n.value+1)]}));return e}});function lce(){return[dce,O9]}var k9=`()[]{}<>«»»«[]{}`;function A9(e){for(let t=0;t<16;t+=2)if(k9.charCodeAt(t)==e)return k9.charAt(t+1);return LY(e<128?e:e+1)}function j9(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||T9}var uce=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),dce=x2.inputHandler.of((e,t,n,r)=>{if((uce?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&RY(IY(r,0))==1||t!=i.from||n!=i.to)return!1;let a=pce(e.state,r);return a?(e.dispatch(a),!0):!1}),fce=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=j9(e,e.selection.main.head).brackets||T9.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=mce(e.doc,t.head);for(let i of n)if(i==r&&N9(e.doc,t.head)==A9(IY(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:Y.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function pce(e,t){let n=j9(e,e.selection.main.head),r=n.brackets||T9.brackets;for(let i of r){let a=A9(IY(i,0));if(t==i)return a==i?_ce(e,i,r.indexOf(i+i+i)>-1,n):hce(e,i,a,n.before||T9.before);if(t==a&&M9(e,e.selection.main.from))return gce(e,i,a)}return null}function M9(e,t){let n=!1;return e.field(O9).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function N9(e,t){let n=e.sliceString(t,t+2);return n.slice(0,RY(IY(n,0)))}function mce(e,t){let n=e.sliceString(t-2,t);return RY(IY(n,0))==n.length?n:n.slice(1)}function hce(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:E9.of(a.to+t.length),range:Y.range(a.anchor+t.length,a.head+t.length)};let o=N9(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:E9.of(a.head+t.length),range:Y.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function gce(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&N9(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:Y.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function _ce(e,t,n,r){let i=r.stringPrefixes||T9.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:E9.of(r.to+t.length),range:Y.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=N9(e.doc,o),c;if(s==t){if(P9(e,o))return{changes:{insert:t+t,from:o},effects:E9.of(o+t.length),range:Y.cursor(o+t.length)};if(M9(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:Y.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=F9(e,o-2*t.length,i))>-1&&P9(e,c))return{changes:{insert:t+t+t+t,from:o},effects:E9.of(o+t.length),range:Y.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=IX.Word&&F9(e,o,i)>-1&&!vce(e,o,t,i))return{changes:{insert:t+t,from:o},effects:E9.of(o+t.length),range:Y.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function P9(e,t){let n=R6(e).resolveInner(t+1);return n.parent&&n.from==t}function vce(e,t,n,r){let i=R6(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function F9(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=IX.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=IX.Word)return n}return-1}function yce(e={}){return[Zse,m9,i9.of(e),Yse,L9,v9]}var I9=[{key:`Ctrl-Space`,run:_9},{mac:"Alt-`",run:_9},{mac:`Alt-i`,run:_9},{key:`Escape`,run:Gse},{key:`ArrowDown`,run:g9(!0)},{key:`ArrowUp`,run:g9(!1)},{key:`PageDown`,run:g9(!0,`page`)},{key:`PageUp`,run:g9(!1,`page`)},{key:`Enter`,run:Wse}],L9=cX.highest(A2.computeN([i9],e=>e.facet(i9).defaultKeymap?[I9]:[]));function $(e){return new K6(Cae.define(e))}function R9(e){return J(()=>import(`./dist-BGIxM2Vg.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var bce=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return J(()=>import(`./dist-1s_bzCxO.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return J(()=>import(`./dist-1s_bzCxO.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return R9(`Cassandra`)}}),Q.of({name:`CSS`,extensions:[`css`],load(){return J(()=>import(`./dist-Bzxnd_qQ.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([10,8]),import.meta.url)}}),Q.of({name:`Go`,extensions:[`go`],load(){return J(()=>import(`./dist-2cBTzdEm.js`).then(e=>e.go()),__vite__mapDeps([11,8]),import.meta.url)}}),Q.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return J(()=>import(`./dist-RXjVy4Wc.js`).then(e=>e.html()),__vite__mapDeps([12,10,8,13]),import.meta.url)}}),Q.of({name:`Java`,extensions:[`java`],load(){return J(()=>import(`./dist-YZwAStAT.js`).then(e=>e.java()),__vite__mapDeps([14,8]),import.meta.url)}}),Q.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return J(()=>import(`./dist-Blo8ntwU.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return J(()=>import(`./dist-DI-Jbiqn.js`).then(e=>e.jinja()),__vite__mapDeps([15,12,10,8,13]),import.meta.url)}}),Q.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return J(()=>import(`./dist-Coj7US2k.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return J(()=>import(`./dist-Blo8ntwU.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`LESS`,extensions:[`less`],load(){return J(()=>import(`./dist-B29N3_Ie.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return J(()=>import(`./dist-C965y3AU.js`).then(e=>e.liquid()),__vite__mapDeps([18,12,10,8,13]),import.meta.url)}}),Q.of({name:`MariaDB SQL`,load(){return R9(`MariaSQL`)}}),Q.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return J(()=>import(`./dist-Ha8Q7H83.js`).then(e=>e.markdown()),__vite__mapDeps([19,12,10,8,13]),import.meta.url)}}),Q.of({name:`MS SQL`,load(){return R9(`MSSQL`)}}),Q.of({name:`MySQL`,load(){return R9(`MySQL`)}}),Q.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return J(()=>import(`./dist-BEABF8oE.js`).then(e=>e.php()),__vite__mapDeps([20,12,10,8,13]),import.meta.url)}}),Q.of({name:`PLSQL`,extensions:[`pls`],load(){return R9(`PLSQL`)}}),Q.of({name:`PostgreSQL`,load(){return R9(`PostgreSQL`)}}),Q.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return J(()=>import(`./dist-CPy8MMAV.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return J(()=>import(`./dist-C60M2KmF.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return J(()=>import(`./dist-ASt3FSxr.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SCSS`,extensions:[`scss`],load(){return J(()=>import(`./dist-ASt3FSxr.js`).then(e=>e.sass()),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SQL`,extensions:[`sql`],load(){return R9(`StandardSQL`)}}),Q.of({name:`SQLite`,load(){return R9(`SQLite`)}}),Q.of({name:`TSX`,extensions:[`tsx`],load(){return J(()=>import(`./dist-Blo8ntwU.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return J(()=>import(`./dist-Blo8ntwU.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return J(()=>import(`./dist-4ml45Gmg.js`).then(e=>e.wast()),__vite__mapDeps([24,8]),import.meta.url)}}),Q.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return J(()=>import(`./dist-CU5pKkyk.js`).then(e=>e.xml()),__vite__mapDeps([25,8]),import.meta.url)}}),Q.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return J(()=>import(`./dist-GOJu-1O3.js`).then(e=>e.yaml()),__vite__mapDeps([26,8]),import.meta.url)}}),Q.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return J(()=>import(`./apl-CnwPGSsG.js`).then(e=>$(e.apl)),[],import.meta.url)}}),Q.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return J(()=>import(`./asciiarmor-qTkVPQu6.js`).then(e=>$(e.asciiArmor)),[],import.meta.url)}}),Q.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return J(()=>import(`./asn1-Dr8qZg38.js`).then(e=>$(e.asn1({}))),[],import.meta.url)}}),Q.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return J(()=>import(`./asterisk-Bja0s6e1.js`).then(e=>$(e.asterisk)),[],import.meta.url)}}),Q.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return J(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[],import.meta.url)}}),Q.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return J(()=>import(`./cobol-B_OZ4V-R.js`).then(e=>$(e.cobol)),[],import.meta.url)}}),Q.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.csharp)),[],import.meta.url)}}),Q.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`ClojureScript`,extensions:[`cljs`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return J(()=>import(`./css-CYpP4FRV.js`).then(e=>$(e.gss)),[],import.meta.url)}}),Q.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return J(()=>import(`./cmake-CyVbuzPu.js`).then(e=>$(e.cmake)),[],import.meta.url)}}),Q.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return J(()=>import(`./coffeescript-B2pKbFk8.js`).then(e=>$(e.coffeeScript)),[],import.meta.url)}}),Q.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return J(()=>import(`./commonlisp-CcllspGY.js`).then(e=>$(e.commonLisp)),[],import.meta.url)}}),Q.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return J(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[],import.meta.url)}}),Q.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return J(()=>import(`./python-BqYw9LYJ.js`).then(e=>$(e.cython)),[],import.meta.url)}}),Q.of({name:`Crystal`,extensions:[`cr`],load(){return J(()=>import(`./crystal-M5-qzICs.js`).then(e=>$(e.crystal)),[],import.meta.url)}}),Q.of({name:`D`,extensions:[`d`],load(){return J(()=>import(`./d-BhMjBjQP.js`).then(e=>$(e.d)),[],import.meta.url)}}),Q.of({name:`Dart`,extensions:[`dart`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.dart)),[],import.meta.url)}}),Q.of({name:`diff`,extensions:[`diff`,`patch`],load(){return J(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[],import.meta.url)}}),Q.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return J(()=>import(`./dockerfile-BLkNEvjs.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([27,28]),import.meta.url)}}),Q.of({name:`DTD`,extensions:[`dtd`],load(){return J(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[],import.meta.url)}}),Q.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return J(()=>import(`./dylan-C6jEEEk-.js`).then(e=>$(e.dylan)),[],import.meta.url)}}),Q.of({name:`EBNF`,load(){return J(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[],import.meta.url)}}),Q.of({name:`ECL`,extensions:[`ecl`],load(){return J(()=>import(`./ecl-BSZaIHnp.js`).then(e=>$(e.ecl)),[],import.meta.url)}}),Q.of({name:`edn`,extensions:[`edn`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Eiffel`,extensions:[`e`],load(){return J(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[],import.meta.url)}}),Q.of({name:`Elm`,extensions:[`elm`],load(){return J(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[],import.meta.url)}}),Q.of({name:`Erlang`,extensions:[`erl`],load(){return J(()=>import(`./erlang-DaB2Rkuy.js`).then(e=>$(e.erlang)),[],import.meta.url)}}),Q.of({name:`Esper`,load(){return J(()=>import(`./sql-DcCJ9jop.js`).then(e=>$(e.esper)),[],import.meta.url)}}),Q.of({name:`Factor`,extensions:[`factor`],load(){return J(()=>import(`./factor-D7LVTn2l.js`).then(e=>$(e.factor)),__vite__mapDeps([29,28]),import.meta.url)}}),Q.of({name:`FCL`,load(){return J(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[],import.meta.url)}}),Q.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return J(()=>import(`./forth-Cezjo90N.js`).then(e=>$(e.forth)),[],import.meta.url)}}),Q.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return J(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[],import.meta.url)}}),Q.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[],import.meta.url)}}),Q.of({name:`Gas`,extensions:[`s`],load(){return J(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[],import.meta.url)}}),Q.of({name:`Gherkin`,extensions:[`feature`],load(){return J(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[],import.meta.url)}}),Q.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return J(()=>import(`./groovy-BC3IOsC8.js`).then(e=>$(e.groovy)),[],import.meta.url)}}),Q.of({name:`Haskell`,extensions:[`hs`],load(){return J(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[],import.meta.url)}}),Q.of({name:`Haxe`,extensions:[`hx`],load(){return J(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.haxe)),[],import.meta.url)}}),Q.of({name:`HXML`,extensions:[`hxml`],load(){return J(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.hxml)),[],import.meta.url)}}),Q.of({name:`HTTP`,load(){return J(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[],import.meta.url)}}),Q.of({name:`IDL`,extensions:[`pro`],load(){return J(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[],import.meta.url)}}),Q.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return J(()=>import(`./javascript-9Tg8ixDm.js`).then(e=>$(e.jsonld)),[],import.meta.url)}}),Q.of({name:`Julia`,extensions:[`jl`],load(){return J(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[],import.meta.url)}}),Q.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.kotlin)),[],import.meta.url)}}),Q.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return J(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[],import.meta.url)}}),Q.of({name:`Lua`,extensions:[`lua`],load(){return J(()=>import(`./lua-CiA1ziua.js`).then(e=>$(e.lua)),[],import.meta.url)}}),Q.of({name:`mIRC`,extensions:[`mrc`],load(){return J(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[],import.meta.url)}}),Q.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return J(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[],import.meta.url)}}),Q.of({name:`Modelica`,extensions:[`mo`],load(){return J(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[],import.meta.url)}}),Q.of({name:`MUMPS`,extensions:[`mps`],load(){return J(()=>import(`./mumps-CW_TBmxz.js`).then(e=>$(e.mumps)),[],import.meta.url)}}),Q.of({name:`Mbox`,extensions:[`mbox`],load(){return J(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[],import.meta.url)}}),Q.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return J(()=>import(`./nginx-BMaDbqW3.js`).then(e=>$(e.nginx)),[],import.meta.url)}}),Q.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return J(()=>import(`./nsis-AQ_alPln.js`).then(e=>$(e.nsis)),__vite__mapDeps([30,28]),import.meta.url)}}),Q.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return J(()=>import(`./ntriples-d28e9m0E.js`).then(e=>$(e.ntriples)),[],import.meta.url)}}),Q.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveC)),[],import.meta.url)}}),Q.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveCpp)),[],import.meta.url)}}),Q.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[],import.meta.url)}}),Q.of({name:`Octave`,extensions:[`m`],load(){return J(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[],import.meta.url)}}),Q.of({name:`Oz`,extensions:[`oz`],load(){return J(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[],import.meta.url)}}),Q.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return J(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[],import.meta.url)}}),Q.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return J(()=>import(`./perl-CdEHsPfU.js`).then(e=>$(e.perl)),[],import.meta.url)}}),Q.of({name:`Pig`,extensions:[`pig`],load(){return J(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[],import.meta.url)}}),Q.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return J(()=>import(`./powershell-CzG71I4L.js`).then(e=>$(e.powerShell)),[],import.meta.url)}}),Q.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return J(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[],import.meta.url)}}),Q.of({name:`ProtoBuf`,extensions:[`proto`],load(){return J(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[],import.meta.url)}}),Q.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return J(()=>import(`./pug-Bugr-47h.js`).then(e=>$(e.pug)),__vite__mapDeps([31,32]),import.meta.url)}}),Q.of({name:`Puppet`,extensions:[`pp`],load(){return J(()=>import(`./puppet-B4hC2X4m.js`).then(e=>$(e.puppet)),[],import.meta.url)}}),Q.of({name:`Q`,extensions:[`q`],load(){return J(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[],import.meta.url)}}),Q.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return J(()=>import(`./r-DADKenSm.js`).then(e=>$(e.r)),[],import.meta.url)}}),Q.of({name:`RPM Changes`,load(){return J(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[],import.meta.url)}}),Q.of({name:`RPM Spec`,extensions:[`spec`],load(){return J(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmSpec)),[],import.meta.url)}}),Q.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return J(()=>import(`./ruby-DsYpTuWg.js`).then(e=>$(e.ruby)),[],import.meta.url)}}),Q.of({name:`SAS`,extensions:[`sas`],load(){return J(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[],import.meta.url)}}),Q.of({name:`Scala`,extensions:[`scala`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.scala)),[],import.meta.url)}}),Q.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return J(()=>import(`./scheme-CyDdOh7e.js`).then(e=>$(e.scheme)),[],import.meta.url)}}),Q.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return J(()=>import(`./shell-Du5Qg9im.js`).then(e=>$(e.shell)),[],import.meta.url)}}),Q.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return J(()=>import(`./sieve-BAxa3IjF.js`).then(e=>$(e.sieve)),[],import.meta.url)}}),Q.of({name:`Smalltalk`,extensions:[`st`],load(){return J(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[],import.meta.url)}}),Q.of({name:`Solr`,load(){return J(()=>import(`./solr-BBopId9w.js`).then(e=>$(e.solr)),[],import.meta.url)}}),Q.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[],import.meta.url)}}),Q.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return J(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[],import.meta.url)}}),Q.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return J(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[],import.meta.url)}}),Q.of({name:`Squirrel`,extensions:[`nut`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.squirrel)),[],import.meta.url)}}),Q.of({name:`Stylus`,extensions:[`styl`],load(){return J(()=>import(`./stylus-DLLZ8dgm.js`).then(e=>$(e.stylus)),[],import.meta.url)}}),Q.of({name:`Swift`,extensions:[`swift`],load(){return J(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[],import.meta.url)}}),Q.of({name:`sTeX`,load(){return J(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return J(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return J(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`Tcl`,extensions:[`tcl`],load(){return J(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[],import.meta.url)}}),Q.of({name:`Textile`,extensions:[`textile`],load(){return J(()=>import(`./textile-DWBqthVk.js`).then(e=>$(e.textile)),[],import.meta.url)}}),Q.of({name:`TiddlyWiki`,load(){return J(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[],import.meta.url)}}),Q.of({name:`Tiki wiki`,load(){return J(()=>import(`./tiki-CxVlf5KZ.js`).then(e=>$(e.tiki)),[],import.meta.url)}}),Q.of({name:`TOML`,extensions:[`toml`],load(){return J(()=>import(`./toml-LvoKBwCs.js`).then(e=>$(e.toml)),[],import.meta.url)}}),Q.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return J(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[],import.meta.url)}}),Q.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return J(()=>import(`./ttcn-BePYh-hG.js`).then(e=>$(e.ttcn)),[],import.meta.url)}}),Q.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return J(()=>import(`./ttcn-cfg-CY0aot7Q.js`).then(e=>$(e.ttcnCfg)),[],import.meta.url)}}),Q.of({name:`Turtle`,extensions:[`ttl`],load(){return J(()=>import(`./turtle-BDLWE2cD.js`).then(e=>$(e.turtle)),[],import.meta.url)}}),Q.of({name:`Web IDL`,extensions:[`webidl`],load(){return J(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[],import.meta.url)}}),Q.of({name:`VB.NET`,extensions:[`vb`],load(){return J(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[],import.meta.url)}}),Q.of({name:`VBScript`,extensions:[`vbs`],load(){return J(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[],import.meta.url)}}),Q.of({name:`Velocity`,extensions:[`vtl`],load(){return J(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[],import.meta.url)}}),Q.of({name:`Verilog`,extensions:[`v`],load(){return J(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return J(()=>import(`./vhdl-CMrOq2q1.js`).then(e=>$(e.vhdl)),[],import.meta.url)}}),Q.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return J(()=>import(`./xquery-fj_R-kMw.js`).then(e=>$(e.xQuery)),[],import.meta.url)}}),Q.of({name:`Yacas`,extensions:[`ys`],load(){return J(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[],import.meta.url)}}),Q.of({name:`Z80`,extensions:[`z80`],load(){return J(()=>import(`./z80-CL1naaMV.js`).then(e=>$(e.z80)),[],import.meta.url)}}),Q.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[],import.meta.url)}}),Q.of({name:`Xù`,extensions:[`xu`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[],import.meta.url)}}),Q.of({name:`MsGenny`,extensions:[`msgenny`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[],import.meta.url)}}),Q.of({name:`Vue`,extensions:[`vue`],load(){return J(()=>import(`./dist-DCeG0nKY.js`).then(e=>e.vue()),__vite__mapDeps([33,12,10,8,13]),import.meta.url)}}),Q.of({name:`Angular Template`,load(){return J(()=>import(`./dist-DzXJwPG5.js`).then(e=>e.angular()),__vite__mapDeps([34,12,10,8,13]),import.meta.url)}})];function z9(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function B9(e){return Q.matchFilename(bce,`file${e}`)}function V9({content:e,path:t,readOnly:n=!1,onSave:r,onDirtyChange:i,onContentChange:a,getContentRef:o}){let s=(0,v.useRef)(null),c=(0,v.useRef)(null),l=(0,v.useRef)(new uX),u=(0,v.useRef)(new uX),d=(0,v.useRef)(new uX),f=(0,v.useRef)(!1),p=(0,v.useRef)(r),m=(0,v.useRef)(i),h=(0,v.useRef)(a);(0,v.useEffect)(()=>{p.current=r,m.current=i,h.current=a},[r,i,a]);let g=(0,v.useCallback)(e=>{f.current!==e&&(f.current=e,m.current?.(e))},[]);return(0,v.useEffect)(()=>{if(!s.current)return;let r=document.documentElement.classList.contains(`dark`),i=A2.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new x2({state:VX.create({doc:e,extensions:[a3(),l3(),Rae(),cae(),J2(),r4(),VX.allowMultipleSelections.of(!0),Zie(),S8(fae,{fallback:!0}),vae(),lce(),yce(),f4(),h4(),i4(),$oe(),A2.of([...fce,...Boe,...bse,...qae,...iae,...I9,Voe]),i,x2.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(VX.readOnly.of(n)),l.current.of([]),u.current.of(r?d7:[]),x2.theme({"&":{height:`100%`},".cm-scroller":{overflow:`auto`}})]}),parent:s.current});c.current=a,o&&(o.current=()=>a.state.doc.toString());let f=B9(z9(t));return f&&f.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}),()=>{a.destroy(),c.current=null,o&&(o.current=null)}},[]),(0,v.useEffect)(()=>{let t=c.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),g(!1))},[e,g]),(0,v.useEffect)(()=>{let e=c.current;if(!e)return;let n=B9(z9(t));n?n.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}):e.dispatch({effects:l.current.reconfigure([])})},[t]),(0,v.useEffect)(()=>{let e=c.current;e&&e.dispatch({effects:d.current.reconfigure(VX.readOnly.of(n))})},[n]),(0,v.useEffect)(()=>{let e=new MutationObserver(()=>{let e=c.current;if(!e)return;let t=document.documentElement.classList.contains(`dark`);e.dispatch({effects:u.current.reconfigure(t?d7:[])})});return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]),(0,O.jsx)(`div`,{ref:s,className:`h-full w-full overflow-hidden [&_.cm-editor]:h-full [&_.cm-scroller]:auto`})}function H9({content:e,objectUrl:t,kind:n,filename:r,path:i}){return n===`markdown`?(0,O.jsx)(wq,{content:e||``}):n===`image`&&t?(0,O.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,O.jsx)(`img`,{src:t,alt:r,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n===`pdf`&&t?(0,O.jsx)(`iframe`,{src:t,title:r,className:`h-full w-full border-0`}):(n===`text`||n===`code`)&&e!==null?(0,O.jsx)(V9,{content:e,path:i||r,readOnly:!0,onSave:()=>{},onDirtyChange:()=>{},getContentRef:{current:()=>e||``}}):(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,O.jsx)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:`该文件类型暂不支持在线预览,请直接下载查看。`})})}function U9(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function xce(e){let t=e.endsWith(`/`)?e:`${e}/`;if(typeof window>`u`)return`'self'`;try{return new URL(t,window.location.origin).toString()}catch{return`'self'`}}function W9(...e){return Array.from(new Set(e.filter(e=>!!e))).join(` `)}function Sce(e){let t=e?xce(e):void 0,n=W9(`'unsafe-inline'`,`'unsafe-eval'`,`'self'`,`https:`,t),r=W9(`'self'`,`https:`,t);return[`default-src 'none'`,`script-src ${n}`,`style-src 'unsafe-inline' data: ${r}`,`img-src data: blob: ${r}`,`font-src data: ${r}`,`media-src data: blob: ${r}`,`worker-src blob:`,`connect-src 'none'`,`form-action 'none'`,`base-uri 'self'`].join(`; `)}function Cce(e){try{let t=new URL(e,window.location.href);return[`http:`,`https:`,`mailto:`].includes(t.protocol)}catch{return!1}}function G9(e,t={}){let{channelId:n,basePath:r}=typeof t==`string`?{channelId:t}:t,i=Sce(r),a=`<script>
|
|
213
213
|
function ksadkScrollToHash(rawHref) {
|
|
214
214
|
if (!rawHref || rawHref === '#') return;
|
|
215
215
|
var rawId = rawHref.slice(1);
|
|
@@ -241,4 +241,4 @@ document.addEventListener('click', function(event) {
|
|
|
241
241
|
}, '*');
|
|
242
242
|
}
|
|
243
243
|
}, true);
|
|
244
|
-
<\/script>`,o=`${`<meta http-equiv="Content-Security-Policy" content="${U9(i)}">`}${r?`<base href="${U9(r)}">`:``}${a}`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,`$&${o}`):`${o}${e}`}function K9(e,t){let n=(0,v.useRef)(null);(0,v.useEffect)(()=>(n.current=n=>{if(n.source!==e.current?.contentWindow||n.data?.type!==`ksadk:linkClick`||t&&n.data?.channelId!==t)return;let r=n.data?.href;typeof r==`string`&&r&&Cce(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function wce({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let o=(0,v.useRef)(null),s=(0,v.useId)(),[c,l]=(0,v.useState)(`preview`),u=_t(t),d=gt(t),f=(0,v.useCallback)(()=>G9(e,{basePath:u,channelId:s}),[e,u,s]),[p,m]=(0,v.useState)(f());(0,v.useEffect)(()=>{let e=setTimeout(()=>{m(f())},300);return()=>clearTimeout(e)},[f]),K9(o,s);let h=(0,v.useCallback)(()=>{let e=new Blob([p],{type:`text/html;charset=utf-8`}),t=URL.createObjectURL(e),n=window.open(t,`_blank`,`noopener,noreferrer`);window.setTimeout(()=>URL.revokeObjectURL(t),3e4),n||window.open(d,`_blank`,`noopener,noreferrer`)},[d,p]);return a?(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700`,children:[(0,O.jsxs)(`button`,{onClick:()=>l(`editor`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,O.jsx)(vN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,O.jsxs)(`button`,{onClick:()=>l(`preview`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,O.jsx)(wN,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,O.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,O.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`})]}):c===`editor`?(0,O.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,O.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,O.jsxs)(`button`,{onClick:()=>l(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(wN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,O.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,O.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`}),(0,O.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex gap-1.5`,children:[(0,O.jsxs)(`button`,{onClick:h,className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,title:`在新窗口中打开当前预览`,children:[(0,O.jsx)(CN,{className:`h-3.5 w-3.5`}),`新窗口`]}),(0,O.jsxs)(`button`,{onClick:()=>l(`editor`),className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(vN,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function q9(e){e.current&&clearTimeout(e.current)}function Tce({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let[o,s]=(0,v.useState)(`editor`),[c,l]=(0,v.useState)(e),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>(q9(u),u.current=setTimeout(()=>l(e),300),()=>q9(u)),[e]),a?(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200/30 px-2 py-1.5 dark:border-slate-700/30`,children:[(0,O.jsxs)(`button`,{onClick:()=>s(`editor`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,O.jsx)(vN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,O.jsxs)(`button`,{onClick:()=>s(`preview`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,O.jsx)(wN,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,O.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,O.jsx)(wq,{content:c})})]}):o===`editor`?(0,O.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,O.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,O.jsxs)(`button`,{onClick:()=>s(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(wN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,O.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,O.jsx)(wq,{content:c})}),(0,O.jsxs)(`button`,{onClick:()=>s(`editor`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(vN,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var Ece=`/agentengine/api/v1/GetWorkspaceFileContent`,Dce=4e3;function J9(e){let t=mt(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function Oce(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Y9(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`0 B`:t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}var kce=[{label:`Markdown`,detail:`.md .markdown .mdx`},{label:`代码/文本`,detail:`.py .js .ts .tsx .json .yaml .log .txt`},{label:`图片`,detail:`PNG JPG GIF WebP SVG`},{label:`PDF`,detail:`.pdf`},{label:`表格文本`,detail:`CSV TSV`}];function Ace(e){return gt(e)}function X9({label:e,showSupportedTypes:t=!1}){return(0,O.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center`,children:(0,O.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:[(0,O.jsx)(`div`,{children:e}),t?(0,O.jsxs)(`div`,{className:`mt-4 text-left`,children:[(0,O.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.12em] text-slate-400`,children:`支持在线预览`}),(0,O.jsx)(`div`,{className:`mt-2 grid gap-2`,children:kce.map(e=>(0,O.jsxs)(`div`,{className:`rounded-xl border border-slate-200 bg-white px-3 py-2 dark:border-slate-800 dark:bg-slate-950`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium text-slate-700 dark:text-slate-200`,children:e.label}),(0,O.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-slate-400`,children:e.detail})]},e.label))}),(0,O.jsx)(`div`,{className:`mt-3 text-xs leading-5 text-slate-400`,children:`Word、Excel、PPT 当前不支持在线预览,可下载后查看。`})]}):null]})})}function Z9({agentId:e,capability:t,open:n,onClose:r,isFullscreen:i=!1,onToggleFullscreen:a,isMobile:o=!1,api:s}){let c=(0,v.useRef)(null),l=(0,v.useRef)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(`.`),[m,h]=(0,v.useState)([]),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(!1),[ee,C]=(0,v.useState)(``),[w,te]=(0,v.useState)(null),[ne,T]=(0,v.useState)(null),[re,ie]=(0,v.useState)(!1),[ae,oe]=(0,v.useState)(!1),se=(0,v.useRef)(null),ce=(0,v.useRef)(null),le=(0,v.useRef)(`selection`),E=(0,v.useRef)(Dt()),D=(0,v.useMemo)(()=>m.find(e=>e.Path===w)??null,[m,w]),ue=(0,v.useMemo)(()=>D?Tt({path:D.Path,mimeType:D.MimeType}):null,[D]),de=(0,v.useCallback)(()=>re?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[re]),fe=t.ContentPath||Ece,pe=t.RootLabel||`Workspace`,me=pe?`${pe.charAt(0).toUpperCase()}${pe.slice(1)}`:`Workspace`,he=yt(f),ge=(0,v.useCallback)(()=>{l.current&&=(URL.revokeObjectURL(l.current),null)},[]);(0,v.useEffect)(()=>()=>ge(),[ge]);let _e=(0,v.useCallback)(async(t,n={})=>{let r=!!n.background;r?b(!0):_(!0),r||C(``);try{let n=await s.listWorkspaceFiles(e,t,!1),i=mt(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),le.current=r?`background-refresh`:`selection`,te(e=>{if(e){let t=a.find(t=>t.Path===e);if(t&&t.Type===`file`)return e}return a.find(e=>e.Type===`file`)?.Path??null})}catch(e){console.error(`Failed to load workspace entries:`,e),r||C(e instanceof Error?e.message:String(e))}finally{r?b(!1):_(!1)}},[e,s]);(0,v.useEffect)(()=>{!n||u||(d(!0),_e(`.`))},[u,_e,n]),(0,v.useEffect)(()=>{if(!n||re||!u)return;let e=window.setInterval(()=>{_e(f,{background:!0})},Dce);return()=>window.clearInterval(e)},[f,re,u,_e,n]);let ve=(0,v.useCallback)(async t=>{let n=E.current.next(t.Path),r=Ct({path:t.Path,mimeType:t.MimeType});if(ce.current=t.Path,r===`unsupported`){ge(),T({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}ge(),T({path:t.Path,kind:r,status:`loading`,mimeType:t.MimeType??void 0});try{let r=await s.getWorkspaceFileContent(e,t.Path,{asText:!1});if(!E.current.isCurrent(n))return;if(r instanceof Blob){let e=t.MimeType||``,i=Ct({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,T({path:t.Path,kind:i,status:`ready`,mimeType:e,objectUrl:n});return}let a=await r.text();if(!E.current.isCurrent(n))return;let o=Ct({path:t.Path,mimeType:e});T({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=Ct({path:t.Path,mimeType:e});T({path:t.Path,kind:n,status:`ready`,mimeType:e,content:r})}}catch(e){if(!E.current.isCurrent(n))return;console.error(`Failed to preview workspace file:`,e),T({path:t.Path,kind:r,status:`error`,mimeType:t.MimeType??void 0,error:e instanceof Error?e.message:String(e)})}},[e,s,ge]);(0,v.useEffect)(()=>{if(!D||D.Type!==`file`){ge(),T(null),ie(!1),ce.current=null;return}if(le.current===`background-refresh`&&ce.current===D.Path){le.current=`selection`;return}le.current=`selection`,ve(D)},[ge,ve,D]);let ye=async n=>{if(!(!n||n.length===0)){S(!0),C(``);try{for(let r of Array.from(n)){if(r.size>t.MaxUploadBytes)throw Error(`文件 ${r.name} 超过上传上限`);let n=vt(f)?r.name:`${f}/${r.name}`,i=new FormData;i.append(`file`,r),i.append(`AgentId`,e),i.append(`Path`,n),await s.addWorkspaceFile(i)}await _e(f)}catch(e){console.error(`Failed to upload workspace files:`,e),C(e instanceof Error?e.message:String(e))}finally{c.current&&(c.current.value=``),S(!1)}}},be=async n=>{if(!t.SupportsDelete)return;let r=mt(n.Path);if(window.confirm(`删除 ${r} ?`)){C(``);try{await s.deleteWorkspaceFile(e,r),w&&mt(w)===r&&(te(null),ie(!1)),await _e(n.Type===`directory`&&(mt(f)===r||mt(f).startsWith(`${r}/`))?J9(r):f)}catch(e){console.error(`Failed to delete workspace file:`,e),C(e instanceof Error?e.message:String(e))}}},xe=()=>!D||D.Type!==`file`?(0,O.jsx)(X9,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!ne||ne.path!==D.Path||ne.status===`loading`?(0,O.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center`,children:(0,O.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-sm text-slate-500 shadow-sm dark:border-slate-800 dark:bg-slate-900 dark:text-slate-400`,children:[(0,O.jsx)(MN,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):ne.status===`error`?(0,O.jsx)(X9,{label:ne.error||`文件预览加载失败。`}):ne.kind===`markdown`?(0,O.jsx)(Tce,{content:ne.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se,isMobile:o}):ne.kind===`image`&&ne.objectUrl?(0,O.jsx)(H9,{content:null,objectUrl:ne.objectUrl,kind:`image`,filename:D.Name,mimeType:ne.mimeType||``}):ne.kind===`pdf`&&ne.objectUrl?(0,O.jsx)(H9,{content:null,objectUrl:ne.objectUrl,kind:`pdf`,filename:D.Name,mimeType:ne.mimeType||``}):ne.kind===`html`?(0,O.jsx)(wce,{content:ne.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se,isMobile:o,agentId:e,contentPath:fe}):ne.kind===`text`||ne.kind===`code`?(0,O.jsx)(V9,{content:ne.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se}):(0,O.jsx)(H9,{content:null,kind:`unsupported`,filename:D.Name,mimeType:ne.mimeType||``}),Se=async t=>{if(D){oe(!0),C(``);try{let n=new Blob([t],{type:D.MimeType||`text/plain`}),r=new FormData;r.append(`file`,n,D.Name),r.append(`AgentId`,e),r.append(`Path`,D.Path),await s.addWorkspaceFile(r),E.current.invalidate(),ie(!1),T(e=>e&&e.path===D.Path?{...e,content:t}:e),ce.current=D.Path,await _e(f,{background:!0})}catch(e){console.error(`Failed to save workspace file:`,e),C(e instanceof Error?e.message:String(e))}finally{oe(!1)}}},Ce=D?.Type===`file`&&ne?.path===D.Path&&ne.status===`ready`&&(ne.kind===`text`||ne.kind===`code`||ne.kind===`html`||ne.kind===`markdown`),we=D?.Type===`file`&&ne?.path===D.Path&&ne.status===`ready`&&ne.kind===`pdf`;return(0,O.jsxs)(`div`,{className:`flex h-full min-h-[22rem] w-full min-w-0 flex-col bg-white text-slate-800 dark:bg-slate-950 dark:text-slate-200`,children:[(0,O.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center gap-3 border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,O.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:me}),(0,O.jsx)(`div`,{className:`hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block`}),(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`flex-shrink-0 text-xs text-slate-400`,children:`当前目录`}),(0,O.jsx)(`div`,{className:`custom-scrollbar max-w-[min(42vw,34rem)] overflow-x-auto whitespace-nowrap rounded-md bg-slate-50 px-2 py-1 font-mono text-[11px] text-slate-600 dark:bg-slate-900 dark:text-slate-300`,title:`${he},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,children:he})]}),(0,O.jsx)(`div`,{className:`hidden truncate text-[11px] text-slate-400 xl:block`,children:`工作区内相对路径,不是宿主机绝对路径。`})]}),(0,O.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[(0,O.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void ye(e.target.files)}),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>c.current?.click(),disabled:x,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-300 dark:hover:bg-slate-900`,title:`上传文件,上限 ${Math.floor(t.MaxUploadBytes/(1024*1024))}MB`,children:[(0,O.jsx)(aP,{className:`h-3.5 w-3.5`}),x?`上传中`:`上传`]}),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{let e=new URLSearchParams({Path:f}).toString();window.open(`/agentengine/api/v1/ExportWorkspaceZip?${e}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-900`,title:`导出当前目录为 ZIP`,children:[(0,O.jsx)(RN,{className:`h-3.5 w-3.5`}),`导出`]}),a?(0,O.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":i?`退出全屏`:`全屏查看 Workspace`,title:i?`退出全屏`:`全屏查看`,children:i?(0,O.jsx)(LN,{className:`h-4 w-4`}):(0,O.jsx)(NN,{className:`h-4 w-4`})}):null,r?(0,O.jsx)(`button`,{type:`button`,onClick:()=>{de()&&r?.()},className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":`关闭 Workspace`,title:`关闭`,children:(0,O.jsx)(cP,{className:`h-4 w-4`})}):null]})]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,O.jsxs)(`div`,{className:`flex w-full flex-col border-b border-slate-200/30 dark:border-slate-800/40 md:w-[13.5rem] md:border-b-0 md:border-r`,children:[(0,O.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-3 dark:border-slate-800/40`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-slate-900 dark:text-slate-100`,children:`文件`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-slate-400`,children:[(0,O.jsxs)(`span`,{children:[m.length,` 项`]}),y?(0,O.jsx)(qN,{className:`h-3 w-3 animate-spin`,"aria-label":`正在同步 Workspace 目录`}):null]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>{de()&&_e(J9(f))},disabled:g||vt(f),className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`返回上级目录`,children:(0,O.jsx)(uN,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>{de()&&_e(f)},disabled:g,className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`刷新目录`,children:(0,O.jsx)(qN,{className:`h-4 w-4 ${g?`animate-spin`:``}`})})]})]}),ee?(0,O.jsx)(`div`,{className:`mt-3 rounded-xl border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-600 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-300`,children:ee}):null]}),(0,O.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:!u&&!n?(0,O.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`打开面板后加载 workspace 文件。`}):g?(0,O.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`正在加载目录...`}):m.length===0?(0,O.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`当前目录为空。`}):(0,O.jsx)(`div`,{className:`space-y-0.5`,children:m.map(e=>{let n=Ct({path:e.Path,mimeType:e.MimeType}),r=w===e.Path,i=e.Type===`file`?Ace(e.Path):``;return(0,O.jsxs)(`div`,{title:e.Path,className:K(`group flex items-center gap-1 rounded-lg px-1.5 py-1 transition`,r?`bg-slate-100 text-slate-950 dark:bg-slate-800 dark:text-slate-50`:`text-slate-700 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-900`),children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){_e(e.Path);return}w!==e.Path&&!de()||te(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,O.jsx)(`div`,{className:K(`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md`,r?`text-slate-900 dark:text-slate-50`:`text-slate-400 dark:text-slate-500`),children:e.Type===`directory`?(0,O.jsx)(ON,{className:`h-3.5 w-3.5`}):n===`image`?(0,O.jsx)(AN,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,O.jsx)(TN,{className:`h-3.5 w-3.5`}):(0,O.jsx)(DN,{className:`h-3.5 w-3.5`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`div`,{className:`truncate text-[13px] leading-5`,children:e.Name}),(0,O.jsx)(`div`,{className:K(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:Y9(e.SizeBytes)})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100`,children:[e.Type===`file`?(0,O.jsx)(`a`,{href:i,download:e.Name,className:K(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`下载`,children:(0,O.jsx)(bN,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,O.jsx)(`button`,{type:`button`,onClick:()=>void be(e),className:K(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`删除`,children:(0,O.jsx)(iP,{className:`h-3.5 w-3.5`})}):null]})]},e.Path)})})})]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,O.jsx)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:D?(0,O.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:D.Name}),(0,O.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-slate-400`,children:D.Path}),(0,O.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-400`,children:[Y9(D.SizeBytes),D.MimeType?` · ${D.MimeType}`:``,D.ModifiedAt?` · ${Oce(D.ModifiedAt)}`:``]})]}),ue===`text`||ue===`code`||ue===`html`||ue===`markdown`?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{let e=se.current;e&&Se(e())},disabled:!re||ae,className:K(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition`,re&&!ae?`bg-blue-600 text-white hover:bg-blue-700`:`text-slate-400 dark:text-slate-500 cursor-not-allowed`),children:[(0,O.jsx)(JN,{className:`h-3.5 w-3.5`}),ae?`保存中`:re?`保存`:`已保存`]}):null]}):(0,O.jsxs)(`div`,{className:`w-full`,children:[(0,O.jsx)(`div`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100`,children:`文件预览`}),(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-slate-500 dark:text-slate-400`,children:`选择左侧文件后可在此查看内容。`})]})}),(0,O.jsx)(`div`,{className:K(`custom-scrollbar min-h-0 flex-1`,we||Ce?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:xe()})]})]})]})}function jce({agentId:e,capability:t,workspacePanelOpen:n,workspacePanelWidth:r,workspacePanelFullscreen:i,isMobile:a,workspaceEnabled:o,workspaceFiles:s,workspacePanelPresentation:c,closeWorkspacePanel:l,handleWorkspacePanelResizeStart:u,api:d}){let f=c.renderMode===`inline`,p=c.renderMode===`sheet`;return!o||!s?null:(0,O.jsxs)(O.Fragment,{children:[f?(0,O.jsxs)(O.Fragment,{children:[n&&!i?(0,O.jsx)(`div`,{role:`separator`,"aria-label":`调整 Workspace 宽度`,"aria-orientation":`vertical`,onPointerDown:u,className:`hidden h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-blue-200/60 dark:hover:bg-blue-900/50 md:block`}):null,(0,O.jsx)(`aside`,{style:n&&!i?{width:`${r}px`}:void 0,className:K(i?`fixed inset-0 z-40 flex h-[var(--app-height)] w-screen overflow-hidden bg-white dark:bg-slate-950`:`hidden h-full flex-shrink-0 overflow-hidden bg-white transition-[width] duration-200 ease-out dark:bg-slate-950 md:flex`,n?`border-l border-slate-200/30 dark:border-slate-800/40`:`w-0 border-l border-transparent`),children:n?(0,O.jsx)(Z9,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>ve.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,O.jsx)(qR,{open:n,onOpenChange:e=>{e||ve.getState().setWorkspacePanelFullscreen(!1),ve.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,O.jsxs)(YR,{side:c.side,showOverlay:c.showOverlay,onInteractOutside:e=>{c.preventOutsideClose&&e.preventDefault()},showCloseButton:!1,className:K(`border-slate-200 bg-white p-0 dark:border-slate-800 dark:bg-slate-950`,a?`h-[70vh] rounded-t-[1.75rem]`:`h-[calc(100vh-1.5rem)] w-[min(72rem,calc(100vw-1.5rem))] max-w-[calc(100vw-1.5rem)] rounded-l-[1.5rem] border-l shadow-2xl`),children:[(0,O.jsx)(ZR,{className:`sr-only`,children:`Workspace 文件`}),(0,O.jsx)(QR,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,O.jsx)(Z9,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}var Q9=new Kc,Mce=v.lazy(()=>J(()=>import(`./ArtifactsPanel-CGbWlMNh.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url)),Nce=v.lazy(()=>J(()=>import(`./NativeTerminalPanel-zvL-WpAn.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Pce(e={}){let t=e.apiAdapter||Q9,[n,r]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=new AbortController;return t.getAgentUiBootstrap(void 0,{signal:e.signal}).then(n=>{e.signal.aborted||r({api:t,data:n})}).catch(()=>{e.signal.aborted||r({api:t,data:void 0})}),()=>e.abort()},[t]),!n||n.api!==t)return(0,O.jsx)(he,{});let i=n.data?.AuthorizationScopeKey;return(0,O.jsx)(ge,{authorizationScopeKey:e.authorizationScopeKey??(typeof i==`string`&&i?i:void 0),children:(0,O.jsx)(Fce,{...e,bootstrapData:n.data})})}function Fce({apiAdapter:e,initialSurface:t=`chat`,routeShell:n,bootstrapData:r}){let i=e||Q9,a=He(e=>e.agentId),o=E(e=>e.currentSessionId),s=k(e=>e.isStreaming),c=ve(e=>e.sidebarOpen),l=ve(e=>e.mobileSidebarOpen),u=ve(e=>e.mobileActionsOpen),d=He(e=>e.agentName),f=We(e=>e.selectedModel),p=We(e=>e.availableModels),m=We(e=>e.modelSource),h=We(e=>e.modelCatalogLoaded),g=We(e=>e.thinkingMode),_=fe(e=>e.permissionMode),y=He(e=>e.agentFramework),b=He(e=>e.workspaceFiles),x=He(e=>e.accessMode),S=He(e=>e.status),ee=He(e=>e.errorMessage),C=ve(e=>e.workspacePanelOpen),w=ve(e=>e.workspacePanelWidth),te=ve(e=>e.workspacePanelFullscreen),ne=He(e=>e.apiFormats),T=He(e=>e.capabilities),re=rt(e=>e.visible&&!!e.content),ie=(0,v.useRef)([]),ae=(0,v.useRef)(null),{isMobile:oe,viewportHeight:se}=qt(),ce=st({isMobile:oe,viewportHeight:se}),{fetchSessions:le,loadMoreSessions:D,loadSession:ue,followAcceptedInteraction:de,loadOlderSessionMessages:pe,createNewSession:me,adoptCreatedSession:he,waitForPendingSessionCreation:ge,deleteSession:_e,currentSessionIdRef:ye,agentIdRef:be,runSubscriptionAbortRef:xe}=QM({agentId:a,currentSessionId:o,isMobile:oe,uiCapabilities:T,api:i,resetCompaction:()=>{},disconnectRun:()=>ae.current?.()}),Se=(0,v.useCallback)(e=>{if(!e)return;let t=()=>{E.getState().clearSessionMessageHistory(e),le(be.current,e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[be,le]),Ce=p.find(e=>e.id===f)||null,{submitDraft:we,stopGeneration:Te,disconnectRun:Ee,resumeCheckpoint:De,submitAguiAction:Oe,respondToAguiApproval:ke}=rM({agentId:a,currentSessionId:o,agentFramework:y,apiFormats:ne,selectedModel:f,selectedModelMetadata:Ce,thinkingMode:g,permissionMode:_,uiCapabilities:T,isMobile:oe,api:i,currentSessionIdRef:ye,agentIdRef:be,queuedDraftRef:ie,onRunSettled:Se,onSessionCreated:e=>he(e,!0),waitForPendingSessionCreation:ge});(0,v.useEffect)(()=>{ae.current=Ee},[Ee]);let Ae=(0,v.useCallback)(()=>{let e=ye.current;xe.current?.abort(),k.getState().stopActivity(),k.getState().stopSessionActivity(e),Te()},[ye,xe,Te]),je=(0,v.useCallback)(async()=>{let e=ye.current,t=k.getState(),n=t.getSessionActivity(e)?.runId||t.currentRunId||``;if(e&&n)try{await i.cancelRun(a,e,n),k.getState().stopSessionActivity(e,`取消请求已发送,后台运行会停在最近 checkpoint。`)}catch(t){console.warn(`[App] cancelRun failed:`,t),k.getState().updateActivity({sessionId:e,status:`failed`,phase:`取消请求失败`,detail:t instanceof Error?t.message:String(t),countEvent:!1})}Se(e)},[i,a,ye,Se]),{submitResponseFeedback:Me,deleteResponseFeedback:Ne,respondToApproval:Pe}=mM({agentId:a,currentSessionId:o,isStreaming:s,api:i,submitDraft:we}),Fe=(0,v.useRef)(Pe),Ie=(0,v.useRef)(ke);(0,v.useEffect)(()=>{Fe.current=Pe,Ie.current=ke},[Pe,ke]);let{pending:Le,records:Re,respond:ze,localCatalog:Ve}=hM({agentId:a,getAgentId:()=>be.current,currentSessionId:o,api:i,interactionV1Enabled:!!T.InteractionV1,onAcceptedInteraction:de,legacyResponsesApproval:(e,t)=>{Fe.current({approvalRequestId:e,approve:t})},legacyAguiResume:(e,t,n)=>Ie.current({interruptId:e,approve:t===`resolved`})});Zc({fetchSessions:le},void 0,i,r),(0,v.useEffect)(()=>{be.current=a,Pt(a,o)},[a,o,be]),(0,v.useEffect)(()=>{oe?ve.getState().setWorkspacePanelFullscreen(!1):(ve.getState().setMobileSidebarOpen(!1),ve.getState().setMobileActionsOpen(!1))},[oe]),(0,v.useEffect)(()=>{C||ve.getState().setWorkspacePanelFullscreen(!1)},[C]),(0,v.useEffect)(()=>()=>{xe.current?.abort()},[xe]);let Ue=Be(T),Ge=!!T.Thinking,Ke=Ot({workspaceFiles:b,accessMode:x}),qe=Et({isMobile:oe}),Je=Vt({capability:T.NativeDashboard,agentFramework:y,accessMode:x,origin:window.location.origin}),Ye=!Ue,Xe=y===`openclaw`?`OpenClaw`:y===`hermes`?`Hermes`:`原生运行时`,Ze=Ce?.display_name||f||``,Qe=!oe&&c&&Ue,$e=(0,v.useRef)(!1),[et,tt]=(0,v.useState)(t===`tui`),nt=et&&!!T.NativeTerminal?.Enabled;(0,v.useEffect)(()=>{$e.current||t!==`workspace`||!Ke||($e.current=!0,ve.getState().setWorkspacePanelOpen(!0),ve.getState().setWorkspacePanelFullscreen(!0))},[t,Ke]);let it=()=>{ve.getState().setWorkspacePanelFullscreen(!1),ve.getState().setWorkspacePanelOpen(!1)};if(S!==`ready`){let e=S===`auth-required`,t=(0,O.jsx)(`div`,{className:`ksadk-web`,children:(0,O.jsx)(`div`,{className:`fixed inset-0 flex h-[var(--app-height)] min-h-[var(--app-height)] items-center justify-center bg-slate-50 px-6 font-sans text-slate-800 dark:bg-slate-950 dark:text-slate-100`,children:(0,O.jsxs)(`div`,{className:`w-full max-w-lg rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-blue-50 text-xl text-blue-600 dark:bg-blue-950/50`,children:S===`loading`?`…`:`↗`}),(0,O.jsx)(`h1`,{className:`text-xl font-semibold`,children:S===`loading`?`正在连接 Agent`:e?`需要有效的访问链接`:`Agent 暂时无法连接`}),S===`loading`?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-slate-500 dark:text-slate-400`,children:[ee,e?` 请从 AgentEngine 控制台重新打开 Dashboard,或使用 agentengine dashboard open 获取临时链接。`:``]}),(0,O.jsx)(`button`,{type:`button`,className:`mt-6 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-blue-500`,onClick:()=>window.location.reload(),children:`重新加载`})]})]})})});return n?(0,O.jsx)(n,{children:t}):t}let at=(0,O.jsx)(`div`,{className:`ksadk-web`,children:(0,O.jsxs)(`div`,{className:`fixed inset-0 flex h-[var(--app-height)] min-h-[var(--app-height)] overflow-hidden bg-white font-sans text-slate-800 dark:bg-slate-900 dark:text-slate-200`,children:[(0,O.jsx)(Hne,{uiCapabilities:T,createNewSession:me,deleteSession:_e,loadSession:ue,loadMoreSessions:D}),(0,O.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,O.jsx)(sY,{agentName:d,currentSessionId:o,nativeLauncherMode:Ye,isMobile:oe,sidebarOpen:c,mobileSidebarOpen:l,onToggleSidebar:()=>{oe?ve.getState().toggleMobileSidebar():ve.getState().toggleSidebar()},availableModels:p,selectedModel:f,onSelectModel:e=>{We.getState().setSelectedModel(e),oe&&ve.getState().setMobileActionsOpen(!1)},selectedModelLabel:Ze,modelCatalogLoaded:h,modelSource:m,thinkingEnabled:Ge,thinkingMode:g,onSelectThinkingMode:e=>We.getState().setThinkingMode(Ut(e)),mobileActionsOpen:u,onMobileActionsOpenChange:e=>ve.getState().setMobileActionsOpen(e),workspaceEnabled:Ke,onOpenWorkspace:()=>ve.getState().setWorkspacePanelOpen(!0),nativeManagementLink:Je,nativeTerminal:T.NativeTerminal}),Ye?(0,O.jsx)(lY,{productLabel:Xe,nativeManagementLink:Je,nativeTerminal:T.NativeTerminal,workspaceEnabled:Ke,onOpenWorkspace:()=>ve.getState().setWorkspacePanelOpen(!0)}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(HJ,{agentName:d,isMobile:oe,onDeleteFeedback:Ne,onSubmitFeedback:Me,onRespondToApproval:Pe,onRespondToAguiApproval:ke,onSubmitAguiAction:Oe,onStopGeneration:Ae,onCancelRemote:T.StopRun?je:void 0,checkpointResumeEnabled:T.RunLifecycle.Enabled&&T.RunLifecycle.Checkpoints&&T.RunLifecycle.CheckpointResume,onResumeCheckpoint:De,onLoadOlderSessionMessages:pe,interactionRecords:Re}),(0,O.jsx)(iY,{onCompactContext:T.ContextCompaction&&i.compactSession?async()=>{if(!(!o||!i.compactSession)){if((await i.compactSession(a,o)).Status!==`completed`)throw Error(`运行时尚未确认压缩完成`);await le(a,o)}}:void 0,composerMaxHeight:ce,submitDraft:we,stopGeneration:Ae,cancelRemote:T.StopRun?je:void 0,isMobile:oe,attachmentsEnabled:T.Attachments!==!1,approvalEnabled:!!T.Approval&&T.ApprovalPolicy?.RuntimeOverride!==!1,approvalPolicy:T.ApprovalPolicy,thinkingEnabled:Ge,runtimeCapabilityMatrix:T.RuntimeCapabilityMatrix,pendingInteractions:Le,onRespondInteraction:e=>{ze(e)},localCatalog:Ve})]})]}),(0,O.jsx)(jce,{agentId:a,capability:b,workspacePanelOpen:C,workspacePanelWidth:w,workspacePanelFullscreen:te,isMobile:oe,workspaceEnabled:Ke,workspaceFiles:b,workspacePanelPresentation:qe,closeWorkspacePanel:it,handleWorkspacePanelResizeStart:e=>{if(te||oe)return;e.preventDefault();let t=e.clientX,n=w,r=Ue&&Qe?280:0,i=document.body.style.cursor,a=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let o=e=>{let i=n+t-e.clientX;ve.getState().setWorkspacePanelWidth(El(i,window.innerWidth,r))},s=()=>{document.body.style.cursor=i,document.body.style.userSelect=a,window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},api:i}),re&&(0,O.jsx)(v.Suspense,{fallback:null,children:(0,O.jsx)(Mce,{})}),nt?(0,O.jsx)(v.Suspense,{fallback:null,children:(0,O.jsx)(Nce,{capability:T.NativeTerminal,open:!0,sessionId:o,onClose:()=>tt(!1)})}):null]})});return n?(0,O.jsx)(n,{children:at}):at}function Ice(){return(0,O.jsx)(Pce,{})}function Lce(e){let t=e instanceof Error?e.message:String(e||``);return/loading chunk|chunkloaderror|failed to fetch dynamically imported module|error loading dynamically imported module|importing a module script failed/i.test(t)}var $9=`agentengine-ui:chunk-reload-attempted`,Rce=class extends v.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){if(console.error(`UI 渲染错误:`,e,t),Lce(e))try{window.sessionStorage.getItem($9)||(window.sessionStorage.setItem($9,String(Date.now())),window.location.reload())}catch{window.location.reload()}}handleReload=()=>{try{window.sessionStorage.removeItem($9)}catch{}this.setState({hasError:!1,error:null}),window.location.reload()};render(){return this.state.hasError?(0,O.jsx)(`div`,{className:`flex h-screen w-screen items-center justify-center bg-slate-50 dark:bg-slate-900`,children:(0,O.jsxs)(`div`,{className:`max-w-md rounded-2xl border border-red-200 bg-white p-8 text-center shadow-lg dark:border-red-900 dark:bg-slate-950`,children:[(0,O.jsx)(`div`,{className:`mb-4 text-4xl`,children:`⚠`}),(0,O.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-red-600 dark:text-red-400`,children:`页面渲染出错`}),(0,O.jsx)(`p`,{className:`mb-6 text-sm text-slate-600 dark:text-slate-400`,children:this.state.error?.message||`发生了未知错误,请刷新页面重试。`}),(0,O.jsx)(`button`,{onClick:this.handleReload,className:`rounded-lg bg-blue-600 px-6 py-2.5 text-sm font-medium text-white transition hover:bg-blue-700`,children:`刷新页面`})]})}):this.props.children}};function zce(){let e=ve(e=>e.toasts),t=ve(e=>e.dismissToast);return(0,v.useEffect)(()=>{if(!e.length)return;let n=e[0],r=3e3-(Date.now()-n.createdAt);if(r<=0){t(n.id);return}let i=setTimeout(()=>t(n.id),r);return()=>clearTimeout(i)},[e,t]),e.length?(0,O.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-4 py-3 text-sm shadow-lg transition-all ${e.variant===`error`?`bg-red-600 text-white`:`bg-slate-800 text-white dark:bg-slate-200 dark:text-slate-900`}`,children:[(0,O.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,O.jsx)(`button`,{onClick:()=>t(e.id),className:`shrink-0 rounded p-0.5 opacity-70 hover:opacity-100`,children:(0,O.jsx)(cP,{size:14})})]},e.id))}):null}y.createRoot(document.getElementById(`root`)).render((0,O.jsxs)(Rce,{children:[(0,O.jsx)(Ice,{}),(0,O.jsx)(zce,{})]}));export{fB as $,p3 as A,VX as B,F6 as C,o as Ct,Z as D,d6 as E,x3 as F,mq as G,sZ as H,G3 as I,JW as J,QK as K,x2 as L,g3 as M,V3 as N,u3 as O,U3 as P,FH as Q,A2 as R,N6 as S,p as St,o6 as T,l as Tt,oJ as U,cX as V,J as W,WH as X,GU as Y,GH as Z,Qie as _,yN as _t,Tse as a,Tz as at,Q6 as b,rt as bt,I6 as c,Une as ct,B6 as d,iP as dt,aB as et,D8 as f,$N as ft,Jie as g,bN as gt,qie as h,wN as ht,X7 as i,Dz as it,_3 as j,b3 as k,Q as l,K as lt,P6 as m,GN as mt,K9 as n,are as nt,sce as o,iz as ot,Yie as p,qN as pt,YK as q,J7 as r,Ez as rt,Iie as s,Wne as st,G9 as t,Jz as tt,K6 as u,cP as ut,n8 as v,fN as vt,R6 as w,s as wt,q6 as x,me as xt,t8 as y,cN as yt,Y as z};
|
|
244
|
+
<\/script>`,o=`${`<meta http-equiv="Content-Security-Policy" content="${U9(i)}">`}${r?`<base href="${U9(r)}">`:``}${a}`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,`$&${o}`):`${o}${e}`}function K9(e,t){let n=(0,v.useRef)(null);(0,v.useEffect)(()=>(n.current=n=>{if(n.source!==e.current?.contentWindow||n.data?.type!==`ksadk:linkClick`||t&&n.data?.channelId!==t)return;let r=n.data?.href;typeof r==`string`&&r&&Cce(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function wce({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let o=(0,v.useRef)(null),s=(0,v.useId)(),[c,l]=(0,v.useState)(`preview`),u=_t(t),d=gt(t),f=(0,v.useCallback)(()=>G9(e,{basePath:u,channelId:s}),[e,u,s]),[p,m]=(0,v.useState)(f());(0,v.useEffect)(()=>{let e=setTimeout(()=>{m(f())},300);return()=>clearTimeout(e)},[f]),K9(o,s);let h=(0,v.useCallback)(()=>{let e=new Blob([p],{type:`text/html;charset=utf-8`}),t=URL.createObjectURL(e),n=window.open(t,`_blank`,`noopener,noreferrer`);window.setTimeout(()=>URL.revokeObjectURL(t),3e4),n||window.open(d,`_blank`,`noopener,noreferrer`)},[d,p]);return a?(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700`,children:[(0,O.jsxs)(`button`,{onClick:()=>l(`editor`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,O.jsx)(vN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,O.jsxs)(`button`,{onClick:()=>l(`preview`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,O.jsx)(wN,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,O.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,O.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`})]}):c===`editor`?(0,O.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,O.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,O.jsxs)(`button`,{onClick:()=>l(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(wN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,O.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,O.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`}),(0,O.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex gap-1.5`,children:[(0,O.jsxs)(`button`,{onClick:h,className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,title:`在新窗口中打开当前预览`,children:[(0,O.jsx)(CN,{className:`h-3.5 w-3.5`}),`新窗口`]}),(0,O.jsxs)(`button`,{onClick:()=>l(`editor`),className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(vN,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function q9(e){e.current&&clearTimeout(e.current)}function Tce({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let[o,s]=(0,v.useState)(`editor`),[c,l]=(0,v.useState)(e),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>(q9(u),u.current=setTimeout(()=>l(e),300),()=>q9(u)),[e]),a?(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200/30 px-2 py-1.5 dark:border-slate-700/30`,children:[(0,O.jsxs)(`button`,{onClick:()=>s(`editor`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,O.jsx)(vN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,O.jsxs)(`button`,{onClick:()=>s(`preview`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,O.jsx)(wN,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,O.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,O.jsx)(wq,{content:c})})]}):o===`editor`?(0,O.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,O.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,O.jsxs)(`button`,{onClick:()=>s(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(wN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,O.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,O.jsx)(wq,{content:c})}),(0,O.jsxs)(`button`,{onClick:()=>s(`editor`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,O.jsx)(vN,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var Ece=`/agentengine/api/v1/GetWorkspaceFileContent`,Dce=4e3;function J9(e){let t=mt(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function Oce(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Y9(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`0 B`:t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}var kce=[{label:`Markdown`,detail:`.md .markdown .mdx`},{label:`代码/文本`,detail:`.py .js .ts .tsx .json .yaml .log .txt`},{label:`图片`,detail:`PNG JPG GIF WebP SVG`},{label:`PDF`,detail:`.pdf`},{label:`表格文本`,detail:`CSV TSV`}];function Ace(e){return gt(e)}function X9({label:e,showSupportedTypes:t=!1}){return(0,O.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center`,children:(0,O.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:[(0,O.jsx)(`div`,{children:e}),t?(0,O.jsxs)(`div`,{className:`mt-4 text-left`,children:[(0,O.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.12em] text-slate-400`,children:`支持在线预览`}),(0,O.jsx)(`div`,{className:`mt-2 grid gap-2`,children:kce.map(e=>(0,O.jsxs)(`div`,{className:`rounded-xl border border-slate-200 bg-white px-3 py-2 dark:border-slate-800 dark:bg-slate-950`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium text-slate-700 dark:text-slate-200`,children:e.label}),(0,O.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-slate-400`,children:e.detail})]},e.label))}),(0,O.jsx)(`div`,{className:`mt-3 text-xs leading-5 text-slate-400`,children:`Word、Excel、PPT 当前不支持在线预览,可下载后查看。`})]}):null]})})}function Z9({agentId:e,capability:t,open:n,onClose:r,isFullscreen:i=!1,onToggleFullscreen:a,isMobile:o=!1,api:s}){let c=(0,v.useRef)(null),l=(0,v.useRef)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(`.`),[m,h]=(0,v.useState)([]),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(!1),[ee,C]=(0,v.useState)(``),[w,te]=(0,v.useState)(null),[ne,T]=(0,v.useState)(null),[re,ie]=(0,v.useState)(!1),[ae,oe]=(0,v.useState)(!1),se=(0,v.useRef)(null),ce=(0,v.useRef)(null),le=(0,v.useRef)(`selection`),E=(0,v.useRef)(Dt()),D=(0,v.useMemo)(()=>m.find(e=>e.Path===w)??null,[m,w]),ue=(0,v.useMemo)(()=>D?Tt({path:D.Path,mimeType:D.MimeType}):null,[D]),de=(0,v.useCallback)(()=>re?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[re]),fe=t.ContentPath||Ece,pe=t.RootLabel||`Workspace`,me=pe?`${pe.charAt(0).toUpperCase()}${pe.slice(1)}`:`Workspace`,he=yt(f),ge=(0,v.useCallback)(()=>{l.current&&=(URL.revokeObjectURL(l.current),null)},[]);(0,v.useEffect)(()=>()=>ge(),[ge]);let _e=(0,v.useCallback)(async(t,n={})=>{let r=!!n.background;r?b(!0):_(!0),r||C(``);try{let n=await s.listWorkspaceFiles(e,t,!1),i=mt(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),le.current=r?`background-refresh`:`selection`,te(e=>{if(e){let t=a.find(t=>t.Path===e);if(t&&t.Type===`file`)return e}return a.find(e=>e.Type===`file`)?.Path??null})}catch(e){console.error(`Failed to load workspace entries:`,e),r||C(e instanceof Error?e.message:String(e))}finally{r?b(!1):_(!1)}},[e,s]);(0,v.useEffect)(()=>{!n||u||(d(!0),_e(`.`))},[u,_e,n]),(0,v.useEffect)(()=>{if(!n||re||!u)return;let e=window.setInterval(()=>{_e(f,{background:!0})},Dce);return()=>window.clearInterval(e)},[f,re,u,_e,n]);let ve=(0,v.useCallback)(async t=>{let n=E.current.next(t.Path),r=Ct({path:t.Path,mimeType:t.MimeType});if(ce.current=t.Path,r===`unsupported`){ge(),T({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}ge(),T({path:t.Path,kind:r,status:`loading`,mimeType:t.MimeType??void 0});try{let r=await s.getWorkspaceFileContent(e,t.Path,{asText:!1});if(!E.current.isCurrent(n))return;if(r instanceof Blob){let e=t.MimeType||``,i=Ct({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,T({path:t.Path,kind:i,status:`ready`,mimeType:e,objectUrl:n});return}let a=await r.text();if(!E.current.isCurrent(n))return;let o=Ct({path:t.Path,mimeType:e});T({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=Ct({path:t.Path,mimeType:e});T({path:t.Path,kind:n,status:`ready`,mimeType:e,content:r})}}catch(e){if(!E.current.isCurrent(n))return;console.error(`Failed to preview workspace file:`,e),T({path:t.Path,kind:r,status:`error`,mimeType:t.MimeType??void 0,error:e instanceof Error?e.message:String(e)})}},[e,s,ge]);(0,v.useEffect)(()=>{if(!D||D.Type!==`file`){ge(),T(null),ie(!1),ce.current=null;return}if(le.current===`background-refresh`&&ce.current===D.Path){le.current=`selection`;return}le.current=`selection`,ve(D)},[ge,ve,D]);let ye=async n=>{if(!(!n||n.length===0)){S(!0),C(``);try{for(let r of Array.from(n)){if(r.size>t.MaxUploadBytes)throw Error(`文件 ${r.name} 超过上传上限`);let n=vt(f)?r.name:`${f}/${r.name}`,i=new FormData;i.append(`file`,r),i.append(`AgentId`,e),i.append(`Path`,n),await s.addWorkspaceFile(i)}await _e(f)}catch(e){console.error(`Failed to upload workspace files:`,e),C(e instanceof Error?e.message:String(e))}finally{c.current&&(c.current.value=``),S(!1)}}},be=async n=>{if(!t.SupportsDelete)return;let r=mt(n.Path);if(window.confirm(`删除 ${r} ?`)){C(``);try{await s.deleteWorkspaceFile(e,r),w&&mt(w)===r&&(te(null),ie(!1)),await _e(n.Type===`directory`&&(mt(f)===r||mt(f).startsWith(`${r}/`))?J9(r):f)}catch(e){console.error(`Failed to delete workspace file:`,e),C(e instanceof Error?e.message:String(e))}}},xe=()=>!D||D.Type!==`file`?(0,O.jsx)(X9,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!ne||ne.path!==D.Path||ne.status===`loading`?(0,O.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center`,children:(0,O.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-sm text-slate-500 shadow-sm dark:border-slate-800 dark:bg-slate-900 dark:text-slate-400`,children:[(0,O.jsx)(MN,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):ne.status===`error`?(0,O.jsx)(X9,{label:ne.error||`文件预览加载失败。`}):ne.kind===`markdown`?(0,O.jsx)(Tce,{content:ne.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se,isMobile:o}):ne.kind===`image`&&ne.objectUrl?(0,O.jsx)(H9,{content:null,objectUrl:ne.objectUrl,kind:`image`,filename:D.Name,mimeType:ne.mimeType||``}):ne.kind===`pdf`&&ne.objectUrl?(0,O.jsx)(H9,{content:null,objectUrl:ne.objectUrl,kind:`pdf`,filename:D.Name,mimeType:ne.mimeType||``}):ne.kind===`html`?(0,O.jsx)(wce,{content:ne.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se,isMobile:o,agentId:e,contentPath:fe}):ne.kind===`text`||ne.kind===`code`?(0,O.jsx)(V9,{content:ne.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se}):(0,O.jsx)(H9,{content:null,kind:`unsupported`,filename:D.Name,mimeType:ne.mimeType||``}),Se=async t=>{if(D){oe(!0),C(``);try{let n=new Blob([t],{type:D.MimeType||`text/plain`}),r=new FormData;r.append(`file`,n,D.Name),r.append(`AgentId`,e),r.append(`Path`,D.Path),await s.addWorkspaceFile(r),E.current.invalidate(),ie(!1),T(e=>e&&e.path===D.Path?{...e,content:t}:e),ce.current=D.Path,await _e(f,{background:!0})}catch(e){console.error(`Failed to save workspace file:`,e),C(e instanceof Error?e.message:String(e))}finally{oe(!1)}}},Ce=D?.Type===`file`&&ne?.path===D.Path&&ne.status===`ready`&&(ne.kind===`text`||ne.kind===`code`||ne.kind===`html`||ne.kind===`markdown`),we=D?.Type===`file`&&ne?.path===D.Path&&ne.status===`ready`&&ne.kind===`pdf`;return(0,O.jsxs)(`div`,{className:`flex h-full min-h-[22rem] w-full min-w-0 flex-col bg-white text-slate-800 dark:bg-slate-950 dark:text-slate-200`,children:[(0,O.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center gap-3 border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,O.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:me}),(0,O.jsx)(`div`,{className:`hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block`}),(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`flex-shrink-0 text-xs text-slate-400`,children:`当前目录`}),(0,O.jsx)(`div`,{className:`custom-scrollbar max-w-[min(42vw,34rem)] overflow-x-auto whitespace-nowrap rounded-md bg-slate-50 px-2 py-1 font-mono text-[11px] text-slate-600 dark:bg-slate-900 dark:text-slate-300`,title:`${he},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,children:he})]}),(0,O.jsx)(`div`,{className:`hidden truncate text-[11px] text-slate-400 xl:block`,children:`工作区内相对路径,不是宿主机绝对路径。`})]}),(0,O.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[(0,O.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void ye(e.target.files)}),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>c.current?.click(),disabled:x,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-300 dark:hover:bg-slate-900`,title:`上传文件,上限 ${Math.floor(t.MaxUploadBytes/(1024*1024))}MB`,children:[(0,O.jsx)(aP,{className:`h-3.5 w-3.5`}),x?`上传中`:`上传`]}),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{let e=new URLSearchParams({Path:f}).toString();window.open(`/agentengine/api/v1/ExportWorkspaceZip?${e}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-900`,title:`导出当前目录为 ZIP`,children:[(0,O.jsx)(RN,{className:`h-3.5 w-3.5`}),`导出`]}),a?(0,O.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":i?`退出全屏`:`全屏查看 Workspace`,title:i?`退出全屏`:`全屏查看`,children:i?(0,O.jsx)(LN,{className:`h-4 w-4`}):(0,O.jsx)(NN,{className:`h-4 w-4`})}):null,r?(0,O.jsx)(`button`,{type:`button`,onClick:()=>{de()&&r?.()},className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":`关闭 Workspace`,title:`关闭`,children:(0,O.jsx)(cP,{className:`h-4 w-4`})}):null]})]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,O.jsxs)(`div`,{className:`flex w-full flex-col border-b border-slate-200/30 dark:border-slate-800/40 md:w-[13.5rem] md:border-b-0 md:border-r`,children:[(0,O.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-3 dark:border-slate-800/40`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-slate-900 dark:text-slate-100`,children:`文件`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-slate-400`,children:[(0,O.jsxs)(`span`,{children:[m.length,` 项`]}),y?(0,O.jsx)(qN,{className:`h-3 w-3 animate-spin`,"aria-label":`正在同步 Workspace 目录`}):null]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>{de()&&_e(J9(f))},disabled:g||vt(f),className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`返回上级目录`,children:(0,O.jsx)(uN,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>{de()&&_e(f)},disabled:g,className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`刷新目录`,children:(0,O.jsx)(qN,{className:`h-4 w-4 ${g?`animate-spin`:``}`})})]})]}),ee?(0,O.jsx)(`div`,{className:`mt-3 rounded-xl border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-600 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-300`,children:ee}):null]}),(0,O.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:!u&&!n?(0,O.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`打开面板后加载 workspace 文件。`}):g?(0,O.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`正在加载目录...`}):m.length===0?(0,O.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`当前目录为空。`}):(0,O.jsx)(`div`,{className:`space-y-0.5`,children:m.map(e=>{let n=Ct({path:e.Path,mimeType:e.MimeType}),r=w===e.Path,i=e.Type===`file`?Ace(e.Path):``;return(0,O.jsxs)(`div`,{title:e.Path,className:K(`group flex items-center gap-1 rounded-lg px-1.5 py-1 transition`,r?`bg-slate-100 text-slate-950 dark:bg-slate-800 dark:text-slate-50`:`text-slate-700 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-900`),children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){_e(e.Path);return}w!==e.Path&&!de()||te(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,O.jsx)(`div`,{className:K(`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md`,r?`text-slate-900 dark:text-slate-50`:`text-slate-400 dark:text-slate-500`),children:e.Type===`directory`?(0,O.jsx)(ON,{className:`h-3.5 w-3.5`}):n===`image`?(0,O.jsx)(AN,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,O.jsx)(TN,{className:`h-3.5 w-3.5`}):(0,O.jsx)(DN,{className:`h-3.5 w-3.5`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`div`,{className:`truncate text-[13px] leading-5`,children:e.Name}),(0,O.jsx)(`div`,{className:K(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:Y9(e.SizeBytes)})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100`,children:[e.Type===`file`?(0,O.jsx)(`a`,{href:i,download:e.Name,className:K(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`下载`,children:(0,O.jsx)(bN,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,O.jsx)(`button`,{type:`button`,onClick:()=>void be(e),className:K(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`删除`,children:(0,O.jsx)(iP,{className:`h-3.5 w-3.5`})}):null]})]},e.Path)})})})]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,O.jsx)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:D?(0,O.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:D.Name}),(0,O.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-slate-400`,children:D.Path}),(0,O.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-400`,children:[Y9(D.SizeBytes),D.MimeType?` · ${D.MimeType}`:``,D.ModifiedAt?` · ${Oce(D.ModifiedAt)}`:``]})]}),ue===`text`||ue===`code`||ue===`html`||ue===`markdown`?(0,O.jsxs)(`button`,{type:`button`,onClick:()=>{let e=se.current;e&&Se(e())},disabled:!re||ae,className:K(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition`,re&&!ae?`bg-blue-600 text-white hover:bg-blue-700`:`text-slate-400 dark:text-slate-500 cursor-not-allowed`),children:[(0,O.jsx)(JN,{className:`h-3.5 w-3.5`}),ae?`保存中`:re?`保存`:`已保存`]}):null]}):(0,O.jsxs)(`div`,{className:`w-full`,children:[(0,O.jsx)(`div`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100`,children:`文件预览`}),(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-slate-500 dark:text-slate-400`,children:`选择左侧文件后可在此查看内容。`})]})}),(0,O.jsx)(`div`,{className:K(`custom-scrollbar min-h-0 flex-1`,we||Ce?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:xe()})]})]})]})}function jce({agentId:e,capability:t,workspacePanelOpen:n,workspacePanelWidth:r,workspacePanelFullscreen:i,isMobile:a,workspaceEnabled:o,workspaceFiles:s,workspacePanelPresentation:c,closeWorkspacePanel:l,handleWorkspacePanelResizeStart:u,api:d}){let f=c.renderMode===`inline`,p=c.renderMode===`sheet`;return!o||!s?null:(0,O.jsxs)(O.Fragment,{children:[f?(0,O.jsxs)(O.Fragment,{children:[n&&!i?(0,O.jsx)(`div`,{role:`separator`,"aria-label":`调整 Workspace 宽度`,"aria-orientation":`vertical`,onPointerDown:u,className:`hidden h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-blue-200/60 dark:hover:bg-blue-900/50 md:block`}):null,(0,O.jsx)(`aside`,{style:n&&!i?{width:`${r}px`}:void 0,className:K(i?`fixed inset-0 z-40 flex h-[var(--app-height)] w-screen overflow-hidden bg-white dark:bg-slate-950`:`hidden h-full flex-shrink-0 overflow-hidden bg-white transition-[width] duration-200 ease-out dark:bg-slate-950 md:flex`,n?`border-l border-slate-200/30 dark:border-slate-800/40`:`w-0 border-l border-transparent`),children:n?(0,O.jsx)(Z9,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>ve.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,O.jsx)(qR,{open:n,onOpenChange:e=>{e||ve.getState().setWorkspacePanelFullscreen(!1),ve.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,O.jsxs)(YR,{side:c.side,showOverlay:c.showOverlay,onInteractOutside:e=>{c.preventOutsideClose&&e.preventDefault()},showCloseButton:!1,className:K(`border-slate-200 bg-white p-0 dark:border-slate-800 dark:bg-slate-950`,a?`h-[70vh] rounded-t-[1.75rem]`:`h-[calc(100vh-1.5rem)] w-[min(72rem,calc(100vw-1.5rem))] max-w-[calc(100vw-1.5rem)] rounded-l-[1.5rem] border-l shadow-2xl`),children:[(0,O.jsx)(ZR,{className:`sr-only`,children:`Workspace 文件`}),(0,O.jsx)(QR,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,O.jsx)(Z9,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}var Q9=new Kc,Mce=v.lazy(()=>J(()=>import(`./ArtifactsPanel-CbUDzOQO.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url)),Nce=v.lazy(()=>J(()=>import(`./NativeTerminalPanel-DPLNV-9q.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Pce(e={}){let t=e.apiAdapter||Q9,[n,r]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=new AbortController;return t.getAgentUiBootstrap(void 0,{signal:e.signal}).then(n=>{e.signal.aborted||r({api:t,data:n})}).catch(()=>{e.signal.aborted||r({api:t,data:void 0})}),()=>e.abort()},[t]),!n||n.api!==t)return(0,O.jsx)(he,{});let i=n.data?.AuthorizationScopeKey;return(0,O.jsx)(ge,{authorizationScopeKey:e.authorizationScopeKey??(typeof i==`string`&&i?i:void 0),children:(0,O.jsx)(Fce,{...e,bootstrapData:n.data})})}function Fce({apiAdapter:e,initialSurface:t=`chat`,routeShell:n,bootstrapData:r}){let i=e||Q9,a=He(e=>e.agentId),o=E(e=>e.currentSessionId),s=k(e=>e.isStreaming),c=ve(e=>e.sidebarOpen),l=ve(e=>e.mobileSidebarOpen),u=ve(e=>e.mobileActionsOpen),d=He(e=>e.agentName),f=We(e=>e.selectedModel),p=We(e=>e.availableModels),m=We(e=>e.modelSource),h=We(e=>e.modelCatalogLoaded),g=We(e=>e.thinkingMode),_=fe(e=>e.permissionMode),y=He(e=>e.agentFramework),b=He(e=>e.workspaceFiles),x=He(e=>e.accessMode),S=He(e=>e.status),ee=He(e=>e.errorMessage),C=ve(e=>e.workspacePanelOpen),w=ve(e=>e.workspacePanelWidth),te=ve(e=>e.workspacePanelFullscreen),ne=He(e=>e.apiFormats),T=He(e=>e.capabilities),re=rt(e=>e.visible&&!!e.content),ie=(0,v.useRef)([]),ae=(0,v.useRef)(null),{isMobile:oe,viewportHeight:se}=qt(),ce=st({isMobile:oe,viewportHeight:se}),{fetchSessions:le,loadMoreSessions:D,loadSession:ue,followAcceptedInteraction:de,loadOlderSessionMessages:pe,createNewSession:me,adoptCreatedSession:he,waitForPendingSessionCreation:ge,deleteSession:_e,currentSessionIdRef:ye,agentIdRef:be,runSubscriptionAbortRef:xe}=QM({agentId:a,currentSessionId:o,isMobile:oe,uiCapabilities:T,api:i,resetCompaction:()=>{},disconnectRun:()=>ae.current?.()}),Se=(0,v.useCallback)(e=>{if(!e)return;let t=()=>{E.getState().clearSessionMessageHistory(e),le(be.current,e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[be,le]),Ce=p.find(e=>e.id===f)||null,{submitDraft:we,stopGeneration:Te,disconnectRun:Ee,resumeCheckpoint:De,submitAguiAction:Oe,respondToAguiApproval:ke}=rM({agentId:a,currentSessionId:o,agentFramework:y,apiFormats:ne,selectedModel:f,selectedModelMetadata:Ce,thinkingMode:g,permissionMode:_,uiCapabilities:T,isMobile:oe,api:i,currentSessionIdRef:ye,agentIdRef:be,queuedDraftRef:ie,onRunSettled:Se,onSessionCreated:e=>he(e,!0),waitForPendingSessionCreation:ge});(0,v.useEffect)(()=>{ae.current=Ee},[Ee]);let Ae=(0,v.useCallback)(()=>{let e=ye.current;xe.current?.abort(),k.getState().stopActivity(),k.getState().stopSessionActivity(e),Te()},[ye,xe,Te]),je=(0,v.useCallback)(async()=>{let e=ye.current,t=k.getState(),n=t.getSessionActivity(e)?.runId||t.currentRunId||``;if(e&&n)try{await i.cancelRun(a,e,n),k.getState().stopSessionActivity(e,`取消请求已发送,后台运行会停在最近 checkpoint。`)}catch(t){console.warn(`[App] cancelRun failed:`,t),k.getState().updateActivity({sessionId:e,status:`failed`,phase:`取消请求失败`,detail:t instanceof Error?t.message:String(t),countEvent:!1})}Se(e)},[i,a,ye,Se]),{submitResponseFeedback:Me,deleteResponseFeedback:Ne,respondToApproval:Pe}=mM({agentId:a,currentSessionId:o,isStreaming:s,api:i,submitDraft:we}),Fe=(0,v.useRef)(Pe),Ie=(0,v.useRef)(ke);(0,v.useEffect)(()=>{Fe.current=Pe,Ie.current=ke},[Pe,ke]);let{pending:Le,records:Re,respond:ze,localCatalog:Ve}=hM({agentId:a,getAgentId:()=>be.current,currentSessionId:o,api:i,interactionV1Enabled:!!T.InteractionV1,onAcceptedInteraction:de,legacyResponsesApproval:(e,t)=>{Fe.current({approvalRequestId:e,approve:t})},legacyAguiResume:(e,t,n)=>Ie.current({interruptId:e,approve:t===`resolved`})});Zc({fetchSessions:le},void 0,i,r),(0,v.useEffect)(()=>{be.current=a,Pt(a,o)},[a,o,be]),(0,v.useEffect)(()=>{oe?ve.getState().setWorkspacePanelFullscreen(!1):(ve.getState().setMobileSidebarOpen(!1),ve.getState().setMobileActionsOpen(!1))},[oe]),(0,v.useEffect)(()=>{C||ve.getState().setWorkspacePanelFullscreen(!1)},[C]),(0,v.useEffect)(()=>()=>{xe.current?.abort()},[xe]);let Ue=Be(T),Ge=!!T.Thinking,Ke=Ot({workspaceFiles:b,accessMode:x}),qe=Et({isMobile:oe}),Je=Vt({capability:T.NativeDashboard,agentFramework:y,accessMode:x,origin:window.location.origin}),Ye=!Ue,Xe=y===`openclaw`?`OpenClaw`:y===`hermes`?`Hermes`:`原生运行时`,Ze=Ce?.display_name||f||``,Qe=!oe&&c&&Ue,$e=(0,v.useRef)(!1),[et,tt]=(0,v.useState)(t===`tui`),nt=et&&!!T.NativeTerminal?.Enabled;(0,v.useEffect)(()=>{$e.current||t!==`workspace`||!Ke||($e.current=!0,ve.getState().setWorkspacePanelOpen(!0),ve.getState().setWorkspacePanelFullscreen(!0))},[t,Ke]);let it=()=>{ve.getState().setWorkspacePanelFullscreen(!1),ve.getState().setWorkspacePanelOpen(!1)};if(S!==`ready`){let e=S===`auth-required`,t=(0,O.jsx)(`div`,{className:`ksadk-web`,children:(0,O.jsx)(`div`,{className:`fixed inset-0 flex h-[var(--app-height)] min-h-[var(--app-height)] items-center justify-center bg-slate-50 px-6 font-sans text-slate-800 dark:bg-slate-950 dark:text-slate-100`,children:(0,O.jsxs)(`div`,{className:`w-full max-w-lg rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm dark:border-slate-800 dark:bg-slate-900`,children:[(0,O.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-blue-50 text-xl text-blue-600 dark:bg-blue-950/50`,children:S===`loading`?`…`:`↗`}),(0,O.jsx)(`h1`,{className:`text-xl font-semibold`,children:S===`loading`?`正在连接 Agent`:e?`需要有效的访问链接`:`Agent 暂时无法连接`}),S===`loading`?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-slate-500 dark:text-slate-400`,children:[ee,e?` 请从 AgentEngine 控制台重新打开 Dashboard,或使用 agentengine dashboard open 获取临时链接。`:``]}),(0,O.jsx)(`button`,{type:`button`,className:`mt-6 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-blue-500`,onClick:()=>window.location.reload(),children:`重新加载`})]})]})})});return n?(0,O.jsx)(n,{children:t}):t}let at=(0,O.jsx)(`div`,{className:`ksadk-web`,children:(0,O.jsxs)(`div`,{className:`fixed inset-0 flex h-[var(--app-height)] min-h-[var(--app-height)] overflow-hidden bg-white font-sans text-slate-800 dark:bg-slate-900 dark:text-slate-200`,children:[(0,O.jsx)(Hne,{uiCapabilities:T,createNewSession:me,deleteSession:_e,loadSession:ue,loadMoreSessions:D}),(0,O.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,O.jsx)(sY,{agentName:d,currentSessionId:o,nativeLauncherMode:Ye,isMobile:oe,sidebarOpen:c,mobileSidebarOpen:l,onToggleSidebar:()=>{oe?ve.getState().toggleMobileSidebar():ve.getState().toggleSidebar()},availableModels:p,selectedModel:f,onSelectModel:e=>{We.getState().setSelectedModel(e),oe&&ve.getState().setMobileActionsOpen(!1)},selectedModelLabel:Ze,modelCatalogLoaded:h,modelSource:m,thinkingEnabled:Ge,thinkingMode:g,onSelectThinkingMode:e=>We.getState().setThinkingMode(Ut(e)),mobileActionsOpen:u,onMobileActionsOpenChange:e=>ve.getState().setMobileActionsOpen(e),workspaceEnabled:Ke,onOpenWorkspace:()=>ve.getState().setWorkspacePanelOpen(!0),nativeManagementLink:Je,nativeTerminal:T.NativeTerminal}),Ye?(0,O.jsx)(lY,{productLabel:Xe,nativeManagementLink:Je,nativeTerminal:T.NativeTerminal,workspaceEnabled:Ke,onOpenWorkspace:()=>ve.getState().setWorkspacePanelOpen(!0)}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(HJ,{agentName:d,isMobile:oe,onDeleteFeedback:Ne,onSubmitFeedback:Me,onRespondToApproval:Pe,onRespondToAguiApproval:ke,onSubmitAguiAction:Oe,onStopGeneration:Ae,onCancelRemote:T.StopRun?je:void 0,checkpointResumeEnabled:T.RunLifecycle.Enabled&&T.RunLifecycle.Checkpoints&&T.RunLifecycle.CheckpointResume,onResumeCheckpoint:De,onLoadOlderSessionMessages:pe,interactionRecords:Re}),(0,O.jsx)(iY,{onCompactContext:T.ContextCompaction&&i.compactSession?async()=>{if(!(!o||!i.compactSession)){if((await i.compactSession(a,o)).Status!==`completed`)throw Error(`运行时尚未确认压缩完成`);await le(a,o)}}:void 0,composerMaxHeight:ce,submitDraft:we,stopGeneration:Ae,cancelRemote:T.StopRun?je:void 0,isMobile:oe,attachmentsEnabled:T.Attachments!==!1,approvalEnabled:!!T.Approval&&T.ApprovalPolicy?.RuntimeOverride!==!1,approvalPolicy:T.ApprovalPolicy,thinkingEnabled:Ge,runtimeCapabilityMatrix:T.RuntimeCapabilityMatrix,pendingInteractions:Le,onRespondInteraction:e=>{ze(e)},localCatalog:Ve})]})]}),(0,O.jsx)(jce,{agentId:a,capability:b,workspacePanelOpen:C,workspacePanelWidth:w,workspacePanelFullscreen:te,isMobile:oe,workspaceEnabled:Ke,workspaceFiles:b,workspacePanelPresentation:qe,closeWorkspacePanel:it,handleWorkspacePanelResizeStart:e=>{if(te||oe)return;e.preventDefault();let t=e.clientX,n=w,r=Ue&&Qe?280:0,i=document.body.style.cursor,a=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let o=e=>{let i=n+t-e.clientX;ve.getState().setWorkspacePanelWidth(El(i,window.innerWidth,r))},s=()=>{document.body.style.cursor=i,document.body.style.userSelect=a,window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},api:i}),re&&(0,O.jsx)(v.Suspense,{fallback:null,children:(0,O.jsx)(Mce,{})}),nt?(0,O.jsx)(v.Suspense,{fallback:null,children:(0,O.jsx)(Nce,{capability:T.NativeTerminal,open:!0,sessionId:o,onClose:()=>tt(!1)})}):null]})});return n?(0,O.jsx)(n,{children:at}):at}function Ice(){return(0,O.jsx)(Pce,{})}function Lce(e){let t=e instanceof Error?e.message:String(e||``);return/loading chunk|chunkloaderror|failed to fetch dynamically imported module|error loading dynamically imported module|importing a module script failed/i.test(t)}var $9=`agentengine-ui:chunk-reload-attempted`,Rce=class extends v.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){if(console.error(`UI 渲染错误:`,e,t),Lce(e))try{window.sessionStorage.getItem($9)||(window.sessionStorage.setItem($9,String(Date.now())),window.location.reload())}catch{window.location.reload()}}handleReload=()=>{try{window.sessionStorage.removeItem($9)}catch{}this.setState({hasError:!1,error:null}),window.location.reload()};render(){return this.state.hasError?(0,O.jsx)(`div`,{className:`flex h-screen w-screen items-center justify-center bg-slate-50 dark:bg-slate-900`,children:(0,O.jsxs)(`div`,{className:`max-w-md rounded-2xl border border-red-200 bg-white p-8 text-center shadow-lg dark:border-red-900 dark:bg-slate-950`,children:[(0,O.jsx)(`div`,{className:`mb-4 text-4xl`,children:`⚠`}),(0,O.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-red-600 dark:text-red-400`,children:`页面渲染出错`}),(0,O.jsx)(`p`,{className:`mb-6 text-sm text-slate-600 dark:text-slate-400`,children:this.state.error?.message||`发生了未知错误,请刷新页面重试。`}),(0,O.jsx)(`button`,{onClick:this.handleReload,className:`rounded-lg bg-blue-600 px-6 py-2.5 text-sm font-medium text-white transition hover:bg-blue-700`,children:`刷新页面`})]})}):this.props.children}};function zce(){let e=ve(e=>e.toasts),t=ve(e=>e.dismissToast);return(0,v.useEffect)(()=>{if(!e.length)return;let n=e[0],r=3e3-(Date.now()-n.createdAt);if(r<=0){t(n.id);return}let i=setTimeout(()=>t(n.id),r);return()=>clearTimeout(i)},[e,t]),e.length?(0,O.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-4 py-3 text-sm shadow-lg transition-all ${e.variant===`error`?`bg-red-600 text-white`:`bg-slate-800 text-white dark:bg-slate-200 dark:text-slate-900`}`,children:[(0,O.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,O.jsx)(`button`,{onClick:()=>t(e.id),className:`shrink-0 rounded p-0.5 opacity-70 hover:opacity-100`,children:(0,O.jsx)(cP,{size:14})})]},e.id))}):null}y.createRoot(document.getElementById(`root`)).render((0,O.jsxs)(Rce,{children:[(0,O.jsx)(Ice,{}),(0,O.jsx)(zce,{})]}));export{fB as $,p3 as A,VX as B,F6 as C,o as Ct,Z as D,d6 as E,x3 as F,mq as G,sZ as H,G3 as I,JW as J,QK as K,x2 as L,g3 as M,V3 as N,u3 as O,U3 as P,FH as Q,A2 as R,N6 as S,p as St,o6 as T,l as Tt,oJ as U,cX as V,J as W,WH as X,GU as Y,GH as Z,Qie as _,yN as _t,Tse as a,Tz as at,Q6 as b,rt as bt,I6 as c,Une as ct,B6 as d,iP as dt,aB as et,D8 as f,$N as ft,Jie as g,bN as gt,qie as h,wN as ht,X7 as i,Dz as it,_3 as j,b3 as k,Q as l,K as lt,P6 as m,GN as mt,K9 as n,are as nt,sce as o,iz as ot,Yie as p,qN as pt,YK as q,J7 as r,Ez as rt,Iie as s,Wne as st,G9 as t,Jz as tt,K6 as u,cP as ut,n8 as v,fN as vt,R6 as w,s as wt,q6 as x,me as xt,t8 as y,cN as yt,Y as z};
|