@kingsoftcloud/ksadk-web 0.3.0 → 0.3.2
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 +138 -0
- package/RELEASE_PROVENANCE.json +7 -0
- package/dist-ksadk/assets/{ArtifactsPanel-Cjnqt-8W.js → ArtifactsPanel-DSU1sWD_.js} +1 -1
- package/dist-ksadk/assets/{CodeBlock-BqyqZfuB.js → CodeBlock-DOH6MVcn.js} +4 -4
- package/dist-ksadk/assets/{MathMessageMarkdown-BpH7jiFM.js → MathMessageMarkdown-BL8my1R2.js} +4 -4
- package/dist-ksadk/assets/MathMessageMarkdown-BorAY7qD.css +1 -0
- package/dist-ksadk/assets/MermaidBlock-Dz4IP-Tx.js +312 -0
- package/dist-ksadk/assets/NativeTerminalPanel-DUrK0JpZ.js +1 -0
- package/dist-ksadk/assets/abnfDiagram-VCTEODGH-g20pFzNV.js +1 -0
- package/dist-ksadk/assets/arc-C4FzinUA.js +1 -0
- package/dist-ksadk/assets/architecture-7GRP2DOG-DjKratdf.js +1 -0
- package/dist-ksadk/assets/architectureDiagram-5GKGNRK7-DpIqL5h4.js +36 -0
- package/dist-ksadk/assets/blockDiagram-NRAW4CY4-BjkljTNz.js +129 -0
- package/dist-ksadk/assets/c4Diagram-UCG6FXSJ-Dk_ieq2X.js +38 -0
- package/dist-ksadk/assets/channel-4cQHKtx1.js +1 -0
- package/dist-ksadk/assets/chunk-2Q5K7J3B-DmgWkESh.js +1 -0
- package/dist-ksadk/assets/{chunk-FMBD7UC4-BGhvzDYt.js → chunk-5VM5RSS4-BVHAchFb.js} +1 -1
- package/dist-ksadk/assets/{chunk-ND2GUHAM-D98vPd-E.js → chunk-F27PBJKO-C-ipQzuS.js} +1 -1
- package/dist-ksadk/assets/chunk-G27WJ6UU-C2EyJbIK.js +231 -0
- package/dist-ksadk/assets/{chunk-4BX2VUAB-CsWIQRhc.js → chunk-JWPE2WC7-vYvVJb_M.js} +1 -1
- package/dist-ksadk/assets/chunk-LCL6LL3I-BcI6ysPT.js +206 -0
- package/dist-ksadk/assets/chunk-POPQ4Y6H-C030x_Z1.js +1 -0
- package/dist-ksadk/assets/chunk-RHFEMEQ7-yyGpsz4n.js +168 -0
- package/dist-ksadk/assets/chunk-SVP7TREG-BLTlmMU7.js +88 -0
- package/dist-ksadk/assets/chunk-XXDRQBXY-C_32ArgP.js +1 -0
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-DLFd9Xi0.js +1 -0
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-DLFd9Xi0.js +1 -0
- package/dist-ksadk/assets/{cose-bilkent-S5V4N54A-CX3yotHq.js → cose-bilkent-JH36ORCC-9YQYwdl0.js} +1 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-DjEM48Qp.js +1 -0
- package/dist-ksadk/assets/cynefinDiagram-5FMLGOSQ-ErLF5N13.js +62 -0
- package/dist-ksadk/assets/cytoscape.esm-CyCl8rPi.js +321 -0
- package/dist-ksadk/assets/dagre-3AP2YEHR-DFiQF-6f.js +4 -0
- package/dist-ksadk/assets/dagre-BuhGnRI1.js +1 -0
- package/dist-ksadk/assets/diagram-S7CK7UJ4-Bt1v8-GC.js +30 -0
- package/dist-ksadk/assets/diagram-UQ7AKVKN-DSCxJdBK.js +41 -0
- package/dist-ksadk/assets/diagram-VSXAHHWV-DHfYwp_9.js +3 -0
- package/dist-ksadk/assets/diagram-VX7I27RA-DdzD-4Le.js +24 -0
- package/dist-ksadk/assets/diagram-Z3DM3KII-Du-nAJ9F.js +24 -0
- package/dist-ksadk/assets/{dist-D82mtD2s.js → dist-8hqcx0sU.js} +1 -1
- package/dist-ksadk/assets/dist-B7seoj3d.js +1 -0
- package/dist-ksadk/assets/{dist-DHn6nBzr.js → dist-BE7bu-DL.js} +1 -1
- package/dist-ksadk/assets/{dist-eoW6tZXA.js → dist-BVDffZ0U.js} +1 -1
- package/dist-ksadk/assets/{dist-C2xjE7cO.js → dist-BX8z72IC.js} +1 -1
- package/dist-ksadk/assets/{dist-CgF3fj15.js → dist-Bf2M8m3N.js} +1 -1
- package/dist-ksadk/assets/{dist-Bs-jQcRX.js → dist-BjU6y-A2.js} +1 -1
- package/dist-ksadk/assets/{dist-Djgl2wVZ.js → dist-BytlxIDT.js} +1 -1
- package/dist-ksadk/assets/{dist-CVQRZjPu.js → dist-CSh_DE14.js} +1 -1
- package/dist-ksadk/assets/{dist-6CVKuTAe.js → dist-CXYYBw3_.js} +1 -1
- package/dist-ksadk/assets/{dist-DlzCRy0S.js → dist-C_wsv-Qd.js} +1 -1
- package/dist-ksadk/assets/{dist-DF06ORQo.js → dist-ClxGviKw.js} +1 -1
- package/dist-ksadk/assets/{dist-Cf23NY4L.js → dist-CttYUqzS.js} +1 -1
- package/dist-ksadk/assets/{dist-ivOya1LD.js → dist-DNp6rLRA.js} +1 -1
- package/dist-ksadk/assets/{dist-BibcG1V9.js → dist-DUX-id_F.js} +1 -1
- package/dist-ksadk/assets/{dist-BUHRxvDG.js → dist-DmldrHd_.js} +1 -1
- package/dist-ksadk/assets/{dist-BZ9n9AjO.js → dist-DnfXs8Vn.js} +2 -2
- package/dist-ksadk/assets/{dist-DqNnNFrw.js → dist-Dq9gLD7L.js} +1 -1
- package/dist-ksadk/assets/{dist-CGcp2ex8.js → dist-W-TIVntx.js} +1 -1
- package/dist-ksadk/assets/{dist-Cwt7koer.js → dist-dDdADKFA.js} +1 -1
- package/dist-ksadk/assets/{dist-C7-3jInC.js → dist-dydu68Fl.js} +1 -1
- package/dist-ksadk/assets/{dist-C99THtIA.js → dist-ngtN0DJB.js} +1 -1
- package/dist-ksadk/assets/ebnfDiagram-PWID7BFC-Da9C9NO1.js +1 -0
- package/dist-ksadk/assets/erDiagram-SSCWMZ5O-EAGqqR79.js +99 -0
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-CMgMaJrC.js +1 -0
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-BBKL0x3P.js +1 -0
- package/dist-ksadk/assets/ganttDiagram-EL5Y4UJY-DqJsKb59.js +292 -0
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-Dw63mrhw.js +1 -0
- package/dist-ksadk/assets/gitGraphDiagram-WWUBYQGX-B6g4dtDi.js +106 -0
- package/dist-ksadk/assets/index-8ipRcQ-M.js +240 -0
- package/dist-ksadk/assets/index-ByFCqjlh.css +2 -0
- package/dist-ksadk/assets/info-A6RAGUB7-B6iAblII.js +1 -0
- package/dist-ksadk/assets/infoDiagram-RXCK75RN-Djm_nbd5.js +2 -0
- package/dist-ksadk/assets/{ishikawaDiagram-YF4QCWOH-DLOHGvWw.js → ishikawaDiagram-5VMMS53U-DWya9SG2.js} +6 -6
- package/dist-ksadk/assets/{journeyDiagram-JHISSGLW-BIzKeejT.js → journeyDiagram-EYS64GPL-DutxhSNI.js} +6 -6
- package/dist-ksadk/assets/{kanban-definition-UN3LZRKU-BWHoFSw2.js → kanban-definition-3QL26DDD-DJdOF8Fm.js} +10 -10
- package/dist-ksadk/assets/katex-vFWytM5c.js +257 -0
- package/dist-ksadk/assets/{linear-CvMBw9cA.js → linear-BHjG8b-J.js} +1 -1
- package/dist-ksadk/assets/mermaid-parser.core-KGSy4jWT.js +166 -0
- package/dist-ksadk/assets/{mindmap-definition-RKZ34NQL-CSAQxEAe.js → mindmap-definition-FBJOCRG2-9-HC88D4.js} +29 -29
- package/dist-ksadk/assets/packet-AYTQ26CC-BOYAipuq.js +1 -0
- package/dist-ksadk/assets/pegDiagram-XKGWAZYB-DrEZd4fD.js +1 -0
- package/dist-ksadk/assets/pie-WAS4IAKB-Ctq0Kbku.js +1 -0
- package/dist-ksadk/assets/pieDiagram-E7YTZNPT-DpjqOFFp.js +39 -0
- package/dist-ksadk/assets/{quadrantDiagram-W4KKPZXB-CxIR4JXI.js → quadrantDiagram-AXDQQJYC-BiNhgOXX.js} +6 -6
- package/dist-ksadk/assets/radar-RG4KPBEZ-DN0-ul_0.js +1 -0
- package/dist-ksadk/assets/railroad-74A4TZTK-C6cC_to0.js +1 -0
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-BimjIuRc.js +1 -0
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-CvY65ABq.js +1 -0
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-D72Iq_Tv.js +1 -0
- package/dist-ksadk/assets/railroadDiagram-O6MQD6OU-_Y3Ojg6G.js +1 -0
- package/dist-ksadk/assets/requirementDiagram-EFPCY7ZU-DeCFdg9K.js +84 -0
- package/dist-ksadk/assets/{sankeyDiagram-5OEKKPKP-DpGa6EAV.js → sankeyDiagram-P5KCCOFB-CPH75rhw.js} +7 -7
- package/dist-ksadk/assets/{sequenceDiagram-3UESZ5HK-NTKNGGe5.js → sequenceDiagram-WJ2MYXX4-OEpQQdr4.js} +10 -10
- package/dist-ksadk/assets/sizeCapture-X5ZJPWSS-heUErzhI.js +1 -0
- package/dist-ksadk/assets/stateDiagram-HBIQ2CUA-DvA3jSMB.js +1 -0
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-BgQY03nz.js +1 -0
- package/dist-ksadk/assets/swimlanes-XN3QIQJK-CR-dfN_t.js +1 -0
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-DLVw3q5Q.js +8 -0
- package/dist-ksadk/assets/{timeline-definition-PNZ67QCA-jqoYs3jQ.js → timeline-definition-24CTP7MA-DAVJf1TX.js} +7 -7
- package/dist-ksadk/assets/treeView-Q6P3EWNA-BMpO0wsB.js +1 -0
- package/dist-ksadk/assets/treemap-WGGIJYW6-Et0aqzU3.js +1 -0
- package/dist-ksadk/assets/vennDiagram-4TSXK5OY-DwM8eDkh.js +34 -0
- package/dist-ksadk/assets/wardley-WFR3VGLG-CbY0mhpl.js +1 -0
- package/dist-ksadk/assets/wardleyDiagram-VM6X3IG4-DZL-Zz2t.js +78 -0
- package/dist-ksadk/assets/xychartDiagram-S5SC5T6Z-Dy6Yh_hu.js +7 -0
- package/dist-ksadk/index.html +2 -2
- package/dist-lib/App.d.ts.map +1 -1
- package/dist-lib/{ArtifactsPanel-BAfHt4bC.js → ArtifactsPanel-DDCKcvaL.js} +1 -1
- package/dist-lib/{CodeBlock-Cbl6cxYC.js → CodeBlock-BS9DcS5a.js} +3 -3
- package/dist-lib/{MathMessageMarkdown-DbMSeHQa.js → MathMessageMarkdown-CpCcJFjZ.js} +2 -2
- package/dist-lib/{NativeTerminalPanel-BTPHqbvY.js → NativeTerminalPanel-CDqCdIly.js} +14 -6
- package/dist-lib/{WorkspacePanelContainer-Iy0LhhgG.js → WorkspacePanelContainer-DzbAkIfx.js} +1746 -913
- package/dist-lib/api/client.d.ts.map +1 -1
- package/dist-lib/api/events.d.ts +7 -0
- package/dist-lib/api/events.d.ts.map +1 -1
- package/dist-lib/api/run.d.ts +32 -0
- package/dist-lib/api/run.d.ts.map +1 -1
- package/dist-lib/api/session.d.ts +10 -1
- package/dist-lib/api/session.d.ts.map +1 -1
- package/dist-lib/capabilities-njdklP3r.js +200 -0
- package/dist-lib/capabilities.js +1 -1
- package/dist-lib/components/chat/ChatComposer.d.ts +9 -1
- package/dist-lib/components/chat/ChatComposer.d.ts.map +1 -1
- package/dist-lib/components/chat/ChatMessageList.d.ts +4 -1
- package/dist-lib/components/chat/ChatMessageList.d.ts.map +1 -1
- package/dist-lib/components/chat/ChatSidebar.d.ts.map +1 -1
- package/dist-lib/components/chat/ConnectedComposer.d.ts +13 -2
- package/dist-lib/components/chat/ConnectedComposer.d.ts.map +1 -1
- package/dist-lib/components/chat/ConnectedMessageList.d.ts +2 -1
- package/dist-lib/components/chat/ConnectedMessageList.d.ts.map +1 -1
- package/dist-lib/components/chat/ExecutionModeMenu.d.ts +12 -0
- package/dist-lib/components/chat/ExecutionModeMenu.d.ts.map +1 -0
- package/dist-lib/components/chat/InteractionA2uiSurface.d.ts +14 -0
- package/dist-lib/components/chat/InteractionA2uiSurface.d.ts.map +1 -0
- package/dist-lib/components/chat/InteractionHistoryAnchor.d.ts +12 -0
- package/dist-lib/components/chat/InteractionHistoryAnchor.d.ts.map +1 -0
- package/dist-lib/components/chat/InteractionSchemaForm.d.ts +14 -0
- package/dist-lib/components/chat/InteractionSchemaForm.d.ts.map +1 -0
- package/dist-lib/components/chat/InteractionTray.d.ts +23 -0
- package/dist-lib/components/chat/InteractionTray.d.ts.map +1 -0
- package/dist-lib/components/chat/ModelSettingsMenu.d.ts +13 -0
- package/dist-lib/components/chat/ModelSettingsMenu.d.ts.map +1 -0
- package/dist-lib/components/chat/PermissionMenu.d.ts.map +1 -1
- package/dist-lib/components/chat/ProcessingBlocksView.d.ts +4 -1
- package/dist-lib/components/chat/ProcessingBlocksView.d.ts.map +1 -1
- package/dist-lib/components/chat/schema-fields.d.ts +13 -0
- package/dist-lib/components/chat/schema-fields.d.ts.map +1 -0
- package/dist-lib/components/chat/types.d.ts +8 -0
- package/dist-lib/components/chat/types.d.ts.map +1 -1
- package/dist-lib/components/native/NativeTerminalPanel.d.ts.map +1 -1
- package/dist-lib/components.js +3 -3
- package/dist-lib/core/api/facade.d.ts +26 -1
- package/dist-lib/core/api/facade.d.ts.map +1 -1
- package/dist-lib/core/api/types.d.ts +29 -1
- package/dist-lib/core/api/types.d.ts.map +1 -1
- package/dist-lib/core/interaction/a2ui-validate.d.ts +21 -0
- package/dist-lib/core/interaction/a2ui-validate.d.ts.map +1 -0
- package/dist-lib/core/interaction/adapters/agui.d.ts +23 -0
- package/dist-lib/core/interaction/adapters/agui.d.ts.map +1 -0
- package/dist-lib/core/interaction/adapters/normalize.d.ts +29 -0
- package/dist-lib/core/interaction/adapters/normalize.d.ts.map +1 -0
- package/dist-lib/core/interaction/adapters/responses.d.ts +25 -0
- package/dist-lib/core/interaction/adapters/responses.d.ts.map +1 -0
- package/dist-lib/core/interaction/adapters/session-events.d.ts +17 -0
- package/dist-lib/core/interaction/adapters/session-events.d.ts.map +1 -0
- package/dist-lib/core/interaction/client.d.ts +63 -0
- package/dist-lib/core/interaction/client.d.ts.map +1 -0
- package/dist-lib/core/interaction/index.d.ts +41 -0
- package/dist-lib/core/interaction/index.d.ts.map +1 -0
- package/dist-lib/core/interaction/store.d.ts +0 -0
- package/dist-lib/core/interaction/store.d.ts.map +1 -0
- package/dist-lib/core/interaction/types.d.ts +91 -0
- package/dist-lib/core/interaction/types.d.ts.map +1 -0
- package/dist-lib/core/run/dispatcher.d.ts.map +1 -1
- package/dist-lib/core/run/engine.d.ts +24 -1
- package/dist-lib/core/run/engine.d.ts.map +1 -1
- package/dist-lib/core/run/types.d.ts +32 -0
- package/dist-lib/core/run/types.d.ts.map +1 -1
- package/dist-lib/core/stream/index.d.ts +2 -0
- package/dist-lib/core/stream/index.d.ts.map +1 -1
- package/dist-lib/core/stream/kernel-events.d.ts +56 -0
- package/dist-lib/core/stream/kernel-events.d.ts.map +1 -0
- package/dist-lib/core/stream/responses-protocol.d.ts +7 -0
- package/dist-lib/core/stream/responses-protocol.d.ts.map +1 -1
- package/dist-lib/core/stream/runtime-items.d.ts +174 -0
- package/dist-lib/core/stream/runtime-items.d.ts.map +1 -0
- package/dist-lib/core/stream/types.d.ts +4 -0
- package/dist-lib/core/stream/types.d.ts.map +1 -1
- package/dist-lib/hooks/useBootstrap.d.ts +1 -0
- package/dist-lib/hooks/useBootstrap.d.ts.map +1 -1
- package/dist-lib/hooks/useInteractions.d.ts +34 -0
- package/dist-lib/hooks/useInteractions.d.ts.map +1 -0
- package/dist-lib/hooks/useRunAgent.d.ts +8 -6
- package/dist-lib/hooks/useRunAgent.d.ts.map +1 -1
- package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
- package/dist-lib/public/runtime.d.ts +7 -0
- package/dist-lib/public/runtime.d.ts.map +1 -1
- package/dist-lib/runtime.js +2393 -1157
- package/dist-lib/stores/bootstrap.d.ts +4 -0
- package/dist-lib/stores/bootstrap.d.ts.map +1 -1
- package/dist-lib/stores/streaming.d.ts +8 -0
- package/dist-lib/stores/streaming.d.ts.map +1 -1
- package/dist-lib/stores/ui.d.ts +8 -14
- package/dist-lib/stores/ui.d.ts.map +1 -1
- package/dist-lib/styles.css +1 -1
- package/dist-lib/types/agent-control.d.ts +93 -0
- package/dist-lib/types/agent-control.d.ts.map +1 -0
- package/dist-lib/types/capabilities.d.ts +7 -0
- package/dist-lib/types/capabilities.d.ts.map +1 -1
- package/dist-lib/types/runtime-capability-matrix.d.ts +15 -0
- package/dist-lib/types/runtime-capability-matrix.d.ts.map +1 -0
- package/dist-lib/utils/capabilities.d.ts.map +1 -1
- package/dist-lib/utils/feedback.d.ts +0 -1
- package/dist-lib/utils/feedback.d.ts.map +1 -1
- package/dist-lib/utils/responses-stream.d.ts +2 -1
- package/dist-lib/utils/responses-stream.d.ts.map +1 -1
- package/dist-lib/utils/session-event-history.d.ts +54 -0
- package/dist-lib/utils/session-event-history.d.ts.map +1 -0
- package/dist-lib/utils/session-events.d.ts +8 -0
- package/dist-lib/utils/session-events.d.ts.map +1 -1
- package/dist-lib/utils/session-list.d.ts +1 -0
- package/dist-lib/utils/session-list.d.ts.map +1 -1
- package/package.json +4 -1
- package/dist-ksadk/assets/MathMessageMarkdown-DeYh8QPr.css +0 -1
- package/dist-ksadk/assets/MermaidBlock-DWuxETaJ.js +0 -303
- package/dist-ksadk/assets/NativeTerminalPanel-MDTopWMO.js +0 -1
- package/dist-ksadk/assets/arc-CFKwSk_B.js +0 -1
- package/dist-ksadk/assets/architecture-7EHR7CIX-CynqOWjZ.js +0 -1
- package/dist-ksadk/assets/architectureDiagram-3BPJPVTR-Dej8jX8c.js +0 -36
- package/dist-ksadk/assets/blockDiagram-GPEHLZMM-1F64jqvy.js +0 -132
- package/dist-ksadk/assets/c4Diagram-AAUBKEIU-9q7AUAKb.js +0 -10
- package/dist-ksadk/assets/channel-iUGv2N24.js +0 -1
- package/dist-ksadk/assets/chunk-2J33WTMH-6qgwJm7Q.js +0 -1
- package/dist-ksadk/assets/chunk-55IACEB6-BK8paA20.js +0 -1
- package/dist-ksadk/assets/chunk-727SXJPM-B-JEhy7h.js +0 -206
- package/dist-ksadk/assets/chunk-AQP2D5EJ-DYBvMHAa.js +0 -231
- package/dist-ksadk/assets/chunk-QZHKN3VN-YQIEXeF6.js +0 -1
- package/dist-ksadk/assets/classDiagram-4FO5ZUOK-CDAUuoXK.js +0 -1
- package/dist-ksadk/assets/classDiagram-v2-Q7XG4LA2-CDAUuoXK.js +0 -1
- package/dist-ksadk/assets/cytoscape.esm-DelgaX4f.js +0 -321
- package/dist-ksadk/assets/dagre-BM42HDAG-C7TguAWo.js +0 -4
- package/dist-ksadk/assets/dagre-Bx709z4p.js +0 -1
- package/dist-ksadk/assets/diagram-2AECGRRQ-Dd17_kws.js +0 -43
- package/dist-ksadk/assets/diagram-5GNKFQAL-DVIClIil.js +0 -10
- package/dist-ksadk/assets/diagram-KO2AKTUF-Df_3gYQa.js +0 -3
- package/dist-ksadk/assets/diagram-LMA3HP47-BhLk6ZtA.js +0 -24
- package/dist-ksadk/assets/diagram-OG6HWLK6-D4GNGvuu.js +0 -24
- package/dist-ksadk/assets/dist-DyvYLMW9.js +0 -1
- package/dist-ksadk/assets/erDiagram-TEJ5UH35-CnfRcY2M.js +0 -85
- package/dist-ksadk/assets/eventmodeling-FCH6USID-ChYO-ijM.js +0 -1
- package/dist-ksadk/assets/flowDiagram-I6XJVG4X-DGaJjGNJ.js +0 -162
- package/dist-ksadk/assets/ganttDiagram-6RSMTGT7-DpCoB2g9.js +0 -292
- package/dist-ksadk/assets/gitGraph-WXDBUCRP-BN_0Fk-j.js +0 -1
- package/dist-ksadk/assets/gitGraphDiagram-PVQCEYII-9IKVFBVT.js +0 -106
- package/dist-ksadk/assets/graphlib-B8gBHxth.js +0 -1
- package/dist-ksadk/assets/index-QSwCHuB8.js +0 -177
- package/dist-ksadk/assets/index-jOPmTOZH.css +0 -2
- package/dist-ksadk/assets/info-J43DQDTF-Cp6o3vId.js +0 -1
- package/dist-ksadk/assets/infoDiagram-5YYISTIA-CYIIsb8y.js +0 -2
- package/dist-ksadk/assets/katex-DATssjp1.js +0 -265
- package/dist-ksadk/assets/mermaid-parser.core-mGAcEwcq.js +0 -161
- package/dist-ksadk/assets/packet-YPE3B663-wQzct3cT.js +0 -1
- package/dist-ksadk/assets/pie-LRSECV5Y-BgTQiv-9.js +0 -1
- package/dist-ksadk/assets/pieDiagram-4H26LBE5-By-ra07M.js +0 -30
- package/dist-ksadk/assets/radar-GUYGQ44K-BIq5fXsn.js +0 -1
- package/dist-ksadk/assets/requirementDiagram-4Y6WPE33-DpW90iu3.js +0 -84
- package/dist-ksadk/assets/stateDiagram-AJRCARHV-DGpd9yFG.js +0 -1
- package/dist-ksadk/assets/stateDiagram-v2-BHNVJYJU-B3o579IQ.js +0 -1
- package/dist-ksadk/assets/treeView-BLDUP644-Dqi-E0EM.js +0 -1
- package/dist-ksadk/assets/treemap-LRROVOQU-ClQP9CJ9.js +0 -1
- package/dist-ksadk/assets/vennDiagram-CIIHVFJN-l3Z7-wbP.js +0 -34
- package/dist-ksadk/assets/wardley-L42UT6IY-8XLvnNIs.js +0 -1
- package/dist-ksadk/assets/wardleyDiagram-YWT4CUSO-BR54GPmr.js +0 -78
- package/dist-ksadk/assets/xychartDiagram-2RQKCTM6-SkiH8GsK.js +0 -7
- package/dist-lib/capabilities-CxHZ869f.js +0 -133
- package/dist-lib/components/chat/MenuChip.d.ts +0 -19
- package/dist-lib/components/chat/MenuChip.d.ts.map +0 -1
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MathMessageMarkdown-BpH7jiFM.js","./CodeBlock-BqyqZfuB.js","./MermaidBlock-DWuxETaJ.js","./katex-DATssjp1.js","./MathMessageMarkdown-DeYh8QPr.css","./NativeTerminalPanel-MDTopWMO.js","./NativeTerminalPanel-CHOd7Rch.css","./dist-DHn6nBzr.js","./dist-DlzCRy0S.js","./dist-BUHRxvDG.js","./dist-DyvYLMW9.js","./dist-CVQRZjPu.js","./dist-Bs-jQcRX.js","./dist-BZ9n9AjO.js","./dist-D82mtD2s.js","./dist-C2xjE7cO.js","./dist-eoW6tZXA.js","./dist-ivOya1LD.js","./dist-C99THtIA.js","./dist-Cf23NY4L.js","./dist-6CVKuTAe.js","./dist-Cwt7koer.js","./dist-BibcG1V9.js","./dist-C7-3jInC.js","./dist-DF06ORQo.js","./dist-CgF3fj15.js","./dist-CGcp2ex8.js","./dockerfile-BLkNEvjs.js","./simple-mode-DRpGK0lJ.js","./factor-D7LVTn2l.js","./nsis-AQ_alPln.js","./pug-Bugr-47h.js","./javascript-9Tg8ixDm.js","./dist-DqNnNFrw.js","./dist-Djgl2wVZ.js"])))=>i.map(i=>d[i]);
|
|
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,ee||(ee=!0,re());else{var t=n(l);t!==null&&oe(x,t.startTime-e)}}var ee=!1,te=-1,S=5,C=-1;function ne(){return g?!0:!(e.unstable_now()-C<S)}function w(){if(g=!1,ee){var t=e.unstable_now();C=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(te),te=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ne());){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&&oe(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?re():ee=!1}}}var re;if(typeof y==`function`)re=function(){y(w)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=w,re=function(){ae.postMessage(null)}}else re=function(){_(w,0)};function oe(t,n){te=_(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`):S=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(te),te=-1):h=!0,oe(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,ee||(ee=!0,re()))),r},e.unstable_shouldYield=ne,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 ee=Array.isArray;function te(){}var S={H:null,A:null,T:null,S:null},C=Object.prototype.hasOwnProperty;function ne(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function w(e,t){return ne(e.type,t,e.props)}function re(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ie(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ae=/\/+/g;function oe(e,t){return typeof e==`object`&&e&&e.key!=null?ie(``+e.key):t.toString(36)}function se(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(te,te):(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 ce(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,ce(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+oe(e,0):a,ee(o)?(i=``,c!=null&&(i=c.replace(ae,`$&/`)+`/`),ce(o,r,i,``,function(e){return e})):o!=null&&(re(o)&&(o=w(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ae,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(ee(e))for(var u=0;u<e.length;u++)a=e[u],s=l+oe(a,u),c+=ce(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+oe(a,u++),c+=ce(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ce(se(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 le(e,t,n){if(e==null)return e;var r=[],i=0;return ce(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ue(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 T=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)},E={map:le,forEach:function(e,t,n){le(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return le(e,function(){t++}),t},toArray:function(e){return le(e,function(e){return e})||[]},only:function(e){if(!re(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=E,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=S,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return S.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)!C.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 ne(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)C.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 ne(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=re,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ue}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=S.T,n={};S.T=n;try{var r=e(),i=S.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(te,T)}catch(e){T(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),S.T=t}},e.unstable_useCacheRefresh=function(){return S.H.useCacheRefresh()},e.use=function(e){return S.H.use(e)},e.useActionState=function(e,t,n){return S.H.useActionState(e,t,n)},e.useCallback=function(e,t){return S.H.useCallback(e,t)},e.useContext=function(e){return S.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return S.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return S.H.useEffect(e,t)},e.useEffectEvent=function(e){return S.H.useEffectEvent(e)},e.useId=function(){return S.H.useId()},e.useImperativeHandle=function(e,t,n){return S.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return S.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return S.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return S.H.useMemo(e,t)},e.useOptimistic=function(e,t){return S.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return S.H.useReducer(e,t,n)},e.useRef=function(e){return S.H.useRef(e)},e.useState=function(e){return S.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return S.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return S.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`),ee=Symbol.for(`react.consumer`),te=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),ne=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),re=Symbol.for(`react.lazy`),ie=Symbol.for(`react.activity`),ae=Symbol.for(`react.memo_cache_sentinel`),oe=Symbol.iterator;function se(e){return typeof e!=`object`||!e?null:(e=oe&&e[oe]||e[`@@iterator`],typeof e==`function`?e:null)}var ce=Symbol.for(`react.client.reference`);function le(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ce?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 C:return`Suspense`;case ne:return`SuspenseList`;case ie:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case te:return e.displayName||`Context`;case ee:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?le(e.type)||`Memo`:t;case re:t=e._payload,e=e._init;try{return le(e(t))}catch{}}return null}var ue=Array.isArray,T=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,de={pending:!1,data:null,method:null,action:null},fe=[],pe=-1;function me(e){return{current:e}}function he(e){0>pe||(e.current=fe[pe],fe[pe]=null,pe--)}function ge(e,t){pe++,fe[pe]=e.current,e.current=t}var _e=me(null),ve=me(null),ye=me(null),be=me(null);function xe(e,t){switch(ge(ye,t),ge(ve,e),ge(_e,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?rf(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=rf(t),e=af(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}he(_e),ge(_e,e)}function Se(){he(_e),he(ve),he(ye)}function D(e){e.memoizedState!==null&&ge(be,e);var t=_e.current,n=af(t,e.type);t!==n&&(ge(ve,e),ge(_e,n))}function Ce(e){ve.current===e&&(he(_e),he(ve)),be.current===e&&(he(be),fp._currentValue=de)}var we,Te;function Ee(e){if(we===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);we=t&&t[1]||``,Te=-1<e.stack.indexOf(`
|
|
3
|
-
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
|
-
`+we+e+Te}var De=!1;function Oe(e,t){if(!e||De)return``;De=!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(`
|
|
5
|
-
`),l=s.split(`
|
|
6
|
-
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
7
|
-
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{De=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Ee(n):``}function ke(e,t){switch(e.tag){case 26:case 27:case 5:return Ee(e.type);case 16:return Ee(`Lazy`);case 13:return e.child!==t&&t!==null?Ee(`Suspense Fallback`):Ee(`Suspense`);case 19:return Ee(`SuspenseList`);case 0:case 15:return Oe(e.type,!1);case 11:return Oe(e.type.render,!1);case 1:return Oe(e.type,!0);case 31:return Ee(`Activity`);default:return``}}function Ae(e){try{var t=``,n=null;do t+=ke(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
8
|
-
Error generating stack: `+e.message+`
|
|
9
|
-
`+e.stack}}var je=Object.prototype.hasOwnProperty,Me=t.unstable_scheduleCallback,Ne=t.unstable_cancelCallback,Pe=t.unstable_shouldYield,Fe=t.unstable_requestPaint,Ie=t.unstable_now,Le=t.unstable_getCurrentPriorityLevel,Re=t.unstable_ImmediatePriority,ze=t.unstable_UserBlockingPriority,Be=t.unstable_NormalPriority,Ve=t.unstable_LowPriority,He=t.unstable_IdlePriority,Ue=t.log,We=t.unstable_setDisableYieldValue,Ge=null,Ke=null;function qe(e){if(typeof Ue==`function`&&We(e),Ke&&typeof Ke.setStrictMode==`function`)try{Ke.setStrictMode(Ge,e)}catch{}}var Je=Math.clz32?Math.clz32:Ze,Ye=Math.log,Xe=Math.LN2;function Ze(e){return e>>>=0,e===0?32:31-(Ye(e)/Xe|0)|0}var Qe=256,$e=262144,et=4194304;function tt(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function nt(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=tt(n))):i=tt(o):i=tt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=tt(n))):i=tt(o)):i=tt(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function rt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function it(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function at(){var e=et;return et<<=1,!(et&62914560)&&(et=4194304),e}function ot(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function st(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ct(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Je(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&<(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function lt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Je(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function ut(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Je(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function dt(e,t){var n=t&-t;return n=n&42?1:ft(n),(n&(e.suspendedLanes|t))===0?n:0}function ft(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function pt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function mt(){var e=E.p;return e===0?(e=window.event,e===void 0?32:Op(e.type)):e}function ht(e,t){var n=E.p;try{return E.p=e,t()}finally{E.p=n}}var gt=Math.random().toString(36).slice(2),_t=`__reactFiber$`+gt,vt=`__reactProps$`+gt,yt=`__reactContainer$`+gt,bt=`__reactEvents$`+gt,xt=`__reactListeners$`+gt,St=`__reactHandles$`+gt,Ct=`__reactResources$`+gt,wt=`__reactMarker$`+gt;function Tt(e){delete e[_t],delete e[vt],delete e[bt],delete e[xt],delete e[St]}function Et(e){var t=e[_t];if(t)return t;for(var n=e.parentNode;n;){if(t=n[yt]||n[_t]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Df(e);e!==null;){if(n=e[_t])return n;e=Df(e)}return t}e=n,n=e.parentNode}return null}function Dt(e){if(e=e[_t]||e[yt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Ot(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function kt(e){var t=e[Ct];return t||=e[Ct]={hoistableStyles:new Map,hoistableScripts:new Map},t}function At(e){e[wt]=!0}var jt=new Set,Mt={};function Nt(e,t){Pt(e,t),Pt(e+`Capture`,t)}function Pt(e,t){for(Mt[e]=t,e=0;e<t.length;e++)jt.add(t[e])}var Ft=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),It={},Lt={};function Rt(e){return je.call(Lt,e)?!0:je.call(It,e)?!1:Ft.test(e)?Lt[e]=!0:(It[e]=!0,!1)}function zt(e,t,n){if(Rt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Bt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Vt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Ht(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Ut(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Wt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Gt(e){if(!e._valueTracker){var t=Ut(e)?`checked`:`value`;e._valueTracker=Wt(e,t,``+e[t])}}function Kt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Ut(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function qt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Jt=/[\n"\\]/g;function Yt(e){return e.replace(Jt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Xt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Ht(t)):e.value!==``+Ht(t)&&(e.value=``+Ht(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Qt(e,o,Ht(n)):Qt(e,o,Ht(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Ht(s):e.removeAttribute(`name`)}function Zt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Gt(e);return}n=n==null?``:``+Ht(n),t=t==null?n:``+Ht(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Gt(e)}function Qt(e,t,n){t===`number`&&qt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function $t(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Ht(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function en(e,t,n){if(t!=null&&(t=``+Ht(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Ht(n)}function tn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(ue(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Ht(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Gt(e)}function nn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var rn=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function an(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||rn.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function on(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&an(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&an(e,o,t[o])}function sn(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var cn=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),ln=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function un(e){return ln.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function dn(){}var fn=null;function pn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var mn=null,hn=null;function gn(e){var t=Dt(e);if(t&&(e=t.stateNode)){var n=e[vt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Xt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Yt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[vt]||null;if(!a)throw Error(i(90));Xt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Kt(r)}break a;case`textarea`:en(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&$t(e,!!n.multiple,t,!1)}}}var _n=!1;function vn(e,t,n){if(_n)return e(t,n);_n=!0;try{return e(t)}finally{if(_n=!1,(mn!==null||hn!==null)&&(Nu(),mn&&(t=mn,e=hn,hn=mn=null,gn(t),e)))for(t=0;t<e.length;t++)gn(e[t])}}function yn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[vt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var bn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),xn=!1;if(bn)try{var Sn={};Object.defineProperty(Sn,"passive",{get:function(){xn=!0}}),window.addEventListener(`test`,Sn,Sn),window.removeEventListener(`test`,Sn,Sn)}catch{xn=!1}var O=null,Cn=null,k=null;function wn(){if(k)return k;var e,t=Cn,n=t.length,r,i=`value`in O?O.value:O.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return k=i.slice(e,1<r?1-r:void 0)}function Tn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function En(){return!0}function Dn(){return!1}function On(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?En:Dn,this.isPropagationStopped=Dn,this}return m(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=En)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=En)},persist:function(){},isPersistent:En}),t}var A={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},kn=On(A),An=m({},A,{view:0,detail:0}),jn=On(An),Mn,Nn,Pn,Fn=m({},An,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Kn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Pn&&(Pn&&e.type===`mousemove`?(Mn=e.screenX-Pn.screenX,Nn=e.screenY-Pn.screenY):Nn=Mn=0,Pn=e),Mn)},movementY:function(e){return`movementY`in e?e.movementY:Nn}}),In=On(Fn),Ln=On(m({},Fn,{dataTransfer:0})),Rn=On(m({},An,{relatedTarget:0})),zn=On(m({},A,{animationName:0,elapsedTime:0,pseudoElement:0})),Bn=On(m({},A,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Vn=On(m({},A,{data:0})),Hn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Un={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Wn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Gn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Wn[e])?!!t[e]:!1}function Kn(){return Gn}var qn=On(m({},An,{key:function(e){if(e.key){var t=Hn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Tn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Un[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Kn,charCode:function(e){return e.type===`keypress`?Tn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Tn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Jn=On(m({},Fn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Yn=On(m({},An,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Kn})),Xn=On(m({},A,{propertyName:0,elapsedTime:0,pseudoElement:0})),Zn=On(m({},Fn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Qn=On(m({},A,{newState:0,oldState:0})),$n=[9,13,27,32],er=bn&&`CompositionEvent`in window,tr=null;bn&&`documentMode`in document&&(tr=document.documentMode);var nr=bn&&`TextEvent`in window&&!tr,rr=bn&&(!er||tr&&8<tr&&11>=tr),ir=` `,ar=!1;function or(e,t){switch(e){case`keyup`:return $n.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function sr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var cr=!1;function lr(e,t){switch(e){case`compositionend`:return sr(t);case`keypress`:return t.which===32?(ar=!0,ir):null;case`textInput`:return e=t.data,e===ir&&ar?null:e;default:return null}}function ur(e,t){if(cr)return e===`compositionend`||!er&&or(e,t)?(e=wn(),k=Cn=O=null,cr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return rr&&t.locale!==`ko`?null:t.data;default:return null}}var dr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function fr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!dr[e.type]:t===`textarea`}function pr(e,t,n,r){mn?hn?hn.push(r):hn=[r]:mn=r,t=Vd(t,`onChange`),0<t.length&&(n=new kn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var mr=null,hr=null;function gr(e){Nd(e,0)}function _r(e){if(Kt(Ot(e)))return e}function vr(e,t){if(e===`change`)return t}var yr=!1;if(bn){var br;if(bn){var xr=`oninput`in document;if(!xr){var Sr=document.createElement(`div`);Sr.setAttribute(`oninput`,`return;`),xr=typeof Sr.oninput==`function`}br=xr}else br=!1;yr=br&&(!document.documentMode||9<document.documentMode)}function Cr(){mr&&(mr.detachEvent(`onpropertychange`,wr),hr=mr=null)}function wr(e){if(e.propertyName===`value`&&_r(hr)){var t=[];pr(t,hr,e,pn(e)),vn(gr,t)}}function Tr(e,t,n){e===`focusin`?(Cr(),mr=t,hr=n,mr.attachEvent(`onpropertychange`,wr)):e===`focusout`&&Cr()}function Er(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return _r(hr)}function Dr(e,t){if(e===`click`)return _r(t)}function Or(e,t){if(e===`input`||e===`change`)return _r(t)}function kr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Ar=typeof Object.is==`function`?Object.is:kr;function jr(e,t){if(Ar(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!je.call(t,i)||!Ar(e[i],t[i]))return!1}return!0}function Mr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Nr(e,t){var n=Mr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Mr(n)}}function Pr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Pr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Fr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=qt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=qt(e.document)}return t}function Ir(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Lr=bn&&`documentMode`in document&&11>=document.documentMode,Rr=null,zr=null,Br=null,Vr=!1;function Hr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Vr||Rr==null||Rr!==qt(r)||(r=Rr,`selectionStart`in r&&Ir(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Br&&jr(Br,r)||(Br=r,r=Vd(zr,`onSelect`),0<r.length&&(t=new kn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Rr)))}function Ur(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Wr={animationend:Ur(`Animation`,`AnimationEnd`),animationiteration:Ur(`Animation`,`AnimationIteration`),animationstart:Ur(`Animation`,`AnimationStart`),transitionrun:Ur(`Transition`,`TransitionRun`),transitionstart:Ur(`Transition`,`TransitionStart`),transitioncancel:Ur(`Transition`,`TransitionCancel`),transitionend:Ur(`Transition`,`TransitionEnd`)},Gr={},Kr={};bn&&(Kr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Wr.animationend.animation,delete Wr.animationiteration.animation,delete Wr.animationstart.animation),`TransitionEvent`in window||delete Wr.transitionend.transition);function qr(e){if(Gr[e])return Gr[e];if(!Wr[e])return e;var t=Wr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Kr)return Gr[e]=t[n];return e}var Jr=qr(`animationend`),Yr=qr(`animationiteration`),Xr=qr(`animationstart`),Zr=qr(`transitionrun`),Qr=qr(`transitionstart`),$r=qr(`transitioncancel`),j=qr(`transitionend`),ei=new Map,ti=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);ti.push(`scrollEnd`);function ni(e,t){ei.set(e,t),Nt(t,[e])}var ri=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)},ii=[],ai=0,oi=0;function si(){for(var e=ai,t=oi=ai=0;t<e;){var n=ii[t];ii[t++]=null;var r=ii[t];ii[t++]=null;var i=ii[t];ii[t++]=null;var a=ii[t];if(ii[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&di(n,i,a)}}function ci(e,t,n,r){ii[ai++]=e,ii[ai++]=t,ii[ai++]=n,ii[ai++]=r,oi|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function li(e,t,n,r){return ci(e,t,n,r),fi(e)}function ui(e,t){return ci(e,null,null,t),fi(e)}function di(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Je(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function fi(e){if(50<wu)throw wu=0,Tu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var pi={};function mi(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function hi(e,t,n,r){return new mi(e,t,n,r)}function gi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function _i(e,t){var n=e.alternate;return n===null?(n=hi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function vi(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function yi(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)gi(e)&&(s=1);else if(typeof e==`string`)s=rp(e,n,_e.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case ie:return e=hi(31,n,t,a),e.elementType=ie,e.lanes=o,e;case y:return bi(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=hi(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case C:return e=hi(13,n,t,a),e.elementType=C,e.lanes=o,e;case ne:return e=hi(19,n,t,a),e.elementType=ne,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case te:s=10;break a;case ee:s=9;break a;case S:s=11;break a;case w:s=14;break a;case re:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=hi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function bi(e,t,n,r){return e=hi(7,e,r,t),e.lanes=n,e}function xi(e,t,n){return e=hi(6,e,null,t),e.lanes=n,e}function Si(e){var t=hi(18,null,null,0);return t.stateNode=e,t}function Ci(e,t,n){return t=hi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var wi=new WeakMap;function Ti(e,t){if(typeof e==`object`&&e){var n=wi.get(e);return n===void 0?(t={value:e,source:t,stack:Ae(t)},wi.set(e,t),t):n}return{value:e,source:t,stack:Ae(t)}}var Ei=[],Di=0,Oi=null,ki=0,Ai=[],ji=0,Mi=null,Ni=1,Pi=``;function Fi(e,t){Ei[Di++]=ki,Ei[Di++]=Oi,Oi=e,ki=t}function Ii(e,t,n){Ai[ji++]=Ni,Ai[ji++]=Pi,Ai[ji++]=Mi,Mi=e;var r=Ni;e=Pi;var i=32-Je(r)-1;r&=~(1<<i),n+=1;var a=32-Je(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Ni=1<<32-Je(t)+i|n<<i|r,Pi=a+e}else Ni=1<<a|n<<i|r,Pi=e}function Li(e){e.return!==null&&(Fi(e,1),Ii(e,1,0))}function Ri(e){for(;e===Oi;)Oi=Ei[--Di],Ei[Di]=null,ki=Ei[--Di],Ei[Di]=null;for(;e===Mi;)Mi=Ai[--ji],Ai[ji]=null,Pi=Ai[--ji],Ai[ji]=null,Ni=Ai[--ji],Ai[ji]=null}function zi(e,t){Ai[ji++]=Ni,Ai[ji++]=Pi,Ai[ji++]=Mi,Ni=t.id,Pi=t.overflow,Mi=e}var Bi=null,Vi=null,Hi=!1,Ui=null,Wi=!1,Gi=Error(i(519));function Ki(e){throw Zi(Ti(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Gi}function M(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[_t]=e,t[vt]=r,n){case`dialog`:Pd(`cancel`,t),Pd(`close`,t);break;case`iframe`:case`object`:case`embed`:Pd(`load`,t);break;case`video`:case`audio`:for(n=0;n<jd.length;n++)Pd(jd[n],t);break;case`source`:Pd(`error`,t);break;case`img`:case`image`:case`link`:Pd(`error`,t),Pd(`load`,t);break;case`details`:Pd(`toggle`,t);break;case`input`:Pd(`invalid`,t),Zt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Pd(`invalid`,t);break;case`textarea`:Pd(`invalid`,t),tn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||qd(t.textContent,n)?(r.popover!=null&&(Pd(`beforetoggle`,t),Pd(`toggle`,t)),r.onScroll!=null&&Pd(`scroll`,t),r.onScrollEnd!=null&&Pd(`scrollend`,t),r.onClick!=null&&(t.onclick=dn),t=!0):t=!1,t||Ki(e,!0)}function qi(e){for(Bi=e.return;Bi;)switch(Bi.tag){case 5:case 31:case 13:Wi=!1;return;case 27:case 3:Wi=!0;return;default:Bi=Bi.return}}function Ji(e){if(e!==Bi)return!1;if(!Hi)return qi(e),Hi=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||of(e.type,e.memoizedProps)),n=!n),n&&Vi&&Ki(e),qi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Vi=Ef(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Vi=Ef(e)}else t===27?(t=Vi,mf(e.type)?(e=Tf,Tf=null,Vi=e):Vi=t):Vi=Bi?wf(e.stateNode.nextSibling):null;return!0}function Yi(){Vi=Bi=null,Hi=!1}function Xi(){var e=Ui;return e!==null&&(L===null?L=e:L.push.apply(L,e),Ui=null),e}function Zi(e){Ui===null?Ui=[e]:Ui.push(e)}var Qi=me(null),$i=null,ea=null;function ta(e,t,n){ge(Qi,t._currentValue),t._currentValue=n}function na(e){e._currentValue=Qi.current,he(Qi)}function ra(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function ia(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),ra(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),ra(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function aa(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Ar(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===be.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[fp]:e.push(fp))}a=a.return}e!==null&&ia(t,e,n,r),t.flags|=262144}function oa(e){for(e=e.firstContext;e!==null;){if(!Ar(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function sa(e){$i=e,ea=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ca(e){return ua($i,e)}function la(e,t){return $i===null&&sa(e),ua(e,t)}function ua(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ea===null){if(e===null)throw Error(i(308));ea=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ea=ea.next=t;return n}var da=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},fa=t.unstable_scheduleCallback,pa=t.unstable_NormalPriority,ma={$$typeof:te,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ha(){return{controller:new da,data:new Map,refCount:0}}function ga(e){e.refCount--,e.refCount===0&&fa(pa,function(){e.controller.abort()})}var _a=null,va=0,ya=0,ba=null;function xa(e,t){if(_a===null){var n=_a=[];va=0,ya=Td(),ba={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return va++,t.then(Sa,Sa),t}function Sa(){if(--va===0&&_a!==null){ba!==null&&(ba.status=`fulfilled`);var e=_a;_a=null,ya=0,ba=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Ca(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var wa=T.S;T.S=function(e,t){pu=Ie(),typeof t==`object`&&t&&typeof t.then==`function`&&xa(e,t),wa!==null&&wa(e,t)};var Ta=me(null);function Ea(){var e=Ta.current;return e===null?Zl.pooledCache:e}function Da(e,t){t===null?ge(Ta,Ta.current):ge(Ta,t.pool)}function Oa(){var e=Ea();return e===null?null:{parent:ma._currentValue,pool:e}}var ka=Error(i(460)),Aa=Error(i(474)),ja=Error(i(542)),Ma={then:function(){}};function Na(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Pa(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(dn,dn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ra(e),e;default:if(typeof t.status==`string`)t.then(dn,dn);else{if(e=Zl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ra(e),e}throw Ia=t,ka}}function Fa(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Ia=e,ka):e}}var Ia=null;function La(){if(Ia===null)throw Error(i(459));var e=Ia;return Ia=null,e}function Ra(e){if(e===ka||e===ja)throw Error(i(483))}var za=null,Ba=0;function Va(e){var t=Ba;return Ba+=1,za===null&&(za=[]),Pa(za,e,t)}function Ha(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ua(e,t){throw t.$$typeof===g?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Wa(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=_i(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=xi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===re&&Fa(i)===t.type)?(t=a(t,n.props),Ha(t,n),t.return=e,t):(t=yi(n.type,n.key,n.props,null,e.mode,r),Ha(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Ci(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=bi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=xi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=yi(t.type,t.key,t.props,null,e.mode,n),Ha(n,t),n.return=e,n;case v:return t=Ci(t,e.mode,n),t.return=e,t;case re:return t=Fa(t),f(e,t,n)}if(ue(t)||se(t))return t=bi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Va(t),n);if(t.$$typeof===te)return f(e,la(e,t),n);Ua(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case re:return n=Fa(n),p(e,t,n,r)}if(ue(n)||se(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Va(n),r);if(n.$$typeof===te)return p(e,t,la(e,n),r);Ua(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case re:return r=Fa(r),m(e,t,n,r,i)}if(ue(r)||se(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Va(r),i);if(r.$$typeof===te)return m(e,t,n,la(t,r),i);Ua(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Hi&&Fi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Hi&&Fi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Hi&&Fi(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Hi&&Fi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Hi&&Fi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Hi&&Fi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===re&&Fa(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ha(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=bi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=yi(o.type,o.key,o.props,null,e.mode,c),Ha(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=Ci(o,e.mode,c),c.return=e,e=c}return s(e);case re:return o=Fa(o),b(e,r,o,c)}if(ue(o))return h(e,r,o,c);if(se(o)){if(l=se(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Va(o),c);if(o.$$typeof===te)return b(e,r,la(e,o),c);Ua(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=xi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ba=0;var i=b(e,t,n,r);return za=null,i}catch(t){if(t===ka||t===ja)throw t;var a=hi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ga=Wa(!0),Ka=Wa(!1),qa=!1;function Ja(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ya(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Xa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Za(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Xl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=fi(e),di(e,null,n),t}return ci(e,r,t,n),fi(e)}function Qa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ut(e,n)}}function $a(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var eo=!1;function to(){if(eo){var e=ba;if(e!==null)throw e}}function no(e,t,n,r){eo=!1;var i=e.updateQueue;qa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?($l&f)===f:(r&f)===f){f!==0&&f===ya&&(eo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:qa=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),I|=o,e.lanes=o,e.memoizedState=d}}function ro(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function io(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)ro(n[e],t)}var ao=me(null),oo=me(0);function so(e,t){e=F,ge(oo,e),ge(ao,t),F=e|t.baseLanes}function co(){ge(oo,F),ge(ao,ao.current)}function lo(){F=oo.current,he(ao),he(oo)}var uo=me(null),fo=null;function po(e){var t=e.alternate;ge(vo,vo.current&1),ge(uo,e),fo===null&&(t===null||ao.current!==null||t.memoizedState!==null)&&(fo=e)}function mo(e){ge(vo,vo.current),ge(uo,e),fo===null&&(fo=e)}function ho(e){e.tag===22?(ge(vo,vo.current),ge(uo,e),fo===null&&(fo=e)):go(e)}function go(){ge(vo,vo.current),ge(uo,uo.current)}function _o(e){he(uo),fo===e&&(fo=null),he(vo)}var vo=me(0);function yo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||xf(n)||Sf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var bo=0,xo=null,So=null,Co=null,wo=!1,To=!1,Eo=!1,Do=0,Oo=0,ko=null,Ao=0;function jo(){throw Error(i(321))}function Mo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ar(e[n],t[n]))return!1;return!0}function No(e,t,n,r,i,a){return bo=a,xo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,T.H=e===null||e.memoizedState===null?Xs:Zs,Eo=!1,a=n(r,i),Eo=!1,To&&(a=Fo(t,n,r,i)),Po(e),a}function Po(e){T.H=Ys;var t=So!==null&&So.next!==null;if(bo=0,Co=So=xo=null,wo=!1,Oo=0,ko=null,t)throw Error(i(300));e===null||mc||(e=e.dependencies,e!==null&&oa(e)&&(mc=!0))}function Fo(e,t,n,r){xo=e;var a=0;do{if(To&&(ko=null),Oo=0,To=!1,25<=a)throw Error(i(301));if(a+=1,Co=So=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}T.H=Qs,o=t(n,r)}while(To);return o}function Io(){var e=T.H,t=e.useState()[0];return t=typeof t.then==`function`?Uo(t):t,e=e.useState()[0],(So===null?null:So.memoizedState)!==e&&(xo.flags|=1024),t}function Lo(){var e=Do!==0;return Do=0,e}function Ro(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function zo(e){if(wo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}wo=!1}bo=0,Co=So=xo=null,To=!1,Oo=Do=0,ko=null}function Bo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Co===null?xo.memoizedState=Co=e:Co=Co.next=e,Co}function Vo(){if(So===null){var e=xo.alternate;e=e===null?null:e.memoizedState}else e=So.next;var t=Co===null?xo.memoizedState:Co.next;if(t!==null)Co=t,So=e;else{if(e===null)throw xo.alternate===null?Error(i(467)):Error(i(310));So=e,e={memoizedState:So.memoizedState,baseState:So.baseState,baseQueue:So.baseQueue,queue:So.queue,next:null},Co===null?xo.memoizedState=Co=e:Co=Co.next=e}return Co}function Ho(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Uo(e){var t=Oo;return Oo+=1,ko===null&&(ko=[]),e=Pa(ko,e,t),t=xo,(Co===null?t.memoizedState:Co.next)===null&&(t=t.alternate,T.H=t===null||t.memoizedState===null?Xs:Zs),e}function Wo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Uo(e);if(e.$$typeof===te)return ca(e)}throw Error(i(438,String(e)))}function Go(e){var t=null,n=xo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=xo.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Ho(),xo.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=ae;return t.index++,n}function Ko(e,t){return typeof t==`function`?t(e):t}function qo(e){return Jo(Vo(),So,e)}function Jo(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(bo&f)===f:($l&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===ya&&(d=!0);else if((bo&p)===p){u=u.next,p===ya&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,xo.lanes|=p,I|=p;f=u.action,Eo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,xo.lanes|=f,I|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Ar(o,e.memoizedState)&&(mc=!0,d&&(n=ba,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Yo(e){var t=Vo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Ar(o,t.memoizedState)||(mc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Xo(e,t,n){var r=xo,a=Vo(),o=Hi;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Ar((So||a).memoizedState,n);if(s&&(a.memoizedState=n,mc=!0),a=a.queue,xs($o.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||Co!==null&&Co.memoizedState.tag&1){if(r.flags|=2048,gs(9,{destroy:void 0},Qo.bind(null,r,a,n,t),null),Zl===null)throw Error(i(349));o||bo&127||Zo(r,t,n)}return n}function Zo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=xo.updateQueue,t===null?(t=Ho(),xo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Qo(e,t,n,r){t.value=n,t.getSnapshot=r,es(t)&&ts(e)}function $o(e,t,n){return n(function(){es(t)&&ts(e)})}function es(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ar(e,n)}catch{return!0}}function ts(e){var t=ui(e,2);t!==null&&Ou(t,e,2)}function ns(e){var t=Bo();if(typeof e==`function`){var n=e;if(e=n(),Eo){qe(!0);try{n()}finally{qe(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ko,lastRenderedState:e},t}function rs(e,t,n,r){return e.baseState=n,Jo(e,So,typeof r==`function`?r:Ko)}function is(e,t,n,r,a){if(Ks(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};T.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,as(t,o)):(o.next=n.next,t.pending=n.next=o)}}function as(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=T.T,o={};T.T=o;try{var s=n(i,r),c=T.S;c!==null&&c(o,s),os(e,t,s)}catch(n){cs(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),T.T=a}}else try{a=n(i,r),os(e,t,a)}catch(n){cs(e,t,n)}}function os(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){ss(e,t,n)},function(n){return cs(e,t,n)}):ss(e,t,n)}function ss(e,t,n){t.status=`fulfilled`,t.value=n,ls(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,as(e,n)))}function cs(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,ls(t),t=t.next;while(t!==r)}e.action=null}function ls(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function us(e,t){return t}function ds(e,t){if(Hi){var n=Zl.formState;if(n!==null){a:{var r=xo;if(Hi){if(Vi){b:{for(var i=Vi,a=Wi;i.nodeType!==8;){if(!a){i=null;break b}if(i=wf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Vi=wf(i.nextSibling),r=i.data===`F!`;break a}}Ki(r)}r=!1}r&&(t=n[0])}}return n=Bo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:t},n.queue=r,n=Us.bind(null,xo,r),r.dispatch=n,r=ns(!1),a=Gs.bind(null,xo,!1,r.queue),r=Bo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=is.bind(null,xo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function fs(e){return ps(Vo(),So,e)}function ps(e,t,n){if(t=Jo(e,t,us)[0],e=qo(Ko)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Uo(t)}catch(e){throw e===ka?ja:e}else r=t;t=Vo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(xo.flags|=2048,gs(9,{destroy:void 0},ms.bind(null,i,n),null)),[r,a,e]}function ms(e,t){e.action=t}function hs(e){var t=Vo(),n=So;if(n!==null)return ps(t,n,e);Vo(),t=t.memoizedState,n=Vo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function gs(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=xo.updateQueue,t===null&&(t=Ho(),xo.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function _s(){return Vo().memoizedState}function vs(e,t,n,r){var i=Bo();xo.flags|=e,i.memoizedState=gs(1|t,{destroy:void 0},n,r===void 0?null:r)}function ys(e,t,n,r){var i=Vo();r=r===void 0?null:r;var a=i.memoizedState.inst;So!==null&&r!==null&&Mo(r,So.memoizedState.deps)?i.memoizedState=gs(t,a,n,r):(xo.flags|=e,i.memoizedState=gs(1|t,a,n,r))}function bs(e,t){vs(8390656,8,e,t)}function xs(e,t){ys(2048,8,e,t)}function Ss(e){xo.flags|=4;var t=xo.updateQueue;if(t===null)t=Ho(),xo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Cs(e){var t=Vo().memoizedState;return Ss({ref:t,nextImpl:e}),function(){if(Xl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function ws(e,t){return ys(4,2,e,t)}function Ts(e,t){return ys(4,4,e,t)}function Es(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Ds(e,t,n){n=n==null?null:n.concat([e]),ys(4,4,Es.bind(null,t,e),n)}function Os(){}function ks(e,t){var n=Vo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Mo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function As(e,t){var n=Vo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Mo(t,r[1]))return r[0];if(r=e(),Eo){qe(!0);try{e()}finally{qe(!1)}}return n.memoizedState=[r,t],r}function js(e,t,n){return n===void 0||bo&1073741824&&!($l&261930)?e.memoizedState=t:(e.memoizedState=n,e=Du(),xo.lanes|=e,I|=e,n)}function Ms(e,t,n,r){return Ar(n,t)?n:ao.current===null?!(bo&42)||bo&1073741824&&!($l&261930)?(mc=!0,e.memoizedState=n):(e=Du(),xo.lanes|=e,I|=e,t):(e=js(e,n,r),Ar(e,t)||(mc=!0),e)}function Ns(e,t,n,r,i){var a=E.p;E.p=a!==0&&8>a?a:8;var o=T.T,s={};T.T=s,Gs(e,!1,t,n);try{var c=i(),l=T.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ws(e,t,Ca(c,r),Eu(e)):Ws(e,t,r,Eu(e))}catch(n){Ws(e,t,{then:function(){},status:`rejected`,reason:n},Eu())}finally{E.p=a,o!==null&&s.types!==null&&(o.types=s.types),T.T=o}}function Ps(){}function Fs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Is(e).queue;Ns(e,a,t,de,n===null?Ps:function(){return Ls(e),n(r)})}function Is(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:de,baseState:de,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ko,lastRenderedState:de},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ko,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ls(e){var t=Is(e);t.next===null&&(t=e.alternate.memoizedState),Ws(e,t.next.queue,{},Eu())}function Rs(){return ca(fp)}function zs(){return Vo().memoizedState}function Bs(){return Vo().memoizedState}function Vs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Eu();e=Xa(n);var r=Za(t,e,n);r!==null&&(Ou(r,t,n),Qa(r,t,n)),t={cache:ha()},e.payload=t;return}t=t.return}}function Hs(e,t,n){var r=Eu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ks(e)?qs(t,n):(n=li(e,t,n,r),n!==null&&(Ou(n,e,r),Js(n,t,r)))}function Us(e,t,n){Ws(e,t,n,Eu())}function Ws(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ks(e))qs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Ar(s,o))return ci(e,t,i,0),Zl===null&&si(),!1}catch{}if(n=li(e,t,i,r),n!==null)return Ou(n,e,r),Js(n,t,r),!0}return!1}function Gs(e,t,n,r){if(r={lane:2,revertLane:Td(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ks(e)){if(t)throw Error(i(479))}else t=li(e,n,r,2),t!==null&&Ou(t,e,2)}function Ks(e){var t=e.alternate;return e===xo||t!==null&&t===xo}function qs(e,t){To=wo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Js(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ut(e,n)}}var Ys={readContext:ca,use:Wo,useCallback:jo,useContext:jo,useEffect:jo,useImperativeHandle:jo,useLayoutEffect:jo,useInsertionEffect:jo,useMemo:jo,useReducer:jo,useRef:jo,useState:jo,useDebugValue:jo,useDeferredValue:jo,useTransition:jo,useSyncExternalStore:jo,useId:jo,useHostTransitionStatus:jo,useFormState:jo,useActionState:jo,useOptimistic:jo,useMemoCache:jo,useCacheRefresh:jo};Ys.useEffectEvent=jo;var Xs={readContext:ca,use:Wo,useCallback:function(e,t){return Bo().memoizedState=[e,t===void 0?null:t],e},useContext:ca,useEffect:bs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),vs(4194308,4,Es.bind(null,t,e),n)},useLayoutEffect:function(e,t){return vs(4194308,4,e,t)},useInsertionEffect:function(e,t){vs(4,2,e,t)},useMemo:function(e,t){var n=Bo();t=t===void 0?null:t;var r=e();if(Eo){qe(!0);try{e()}finally{qe(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Bo();if(n!==void 0){var i=n(t);if(Eo){qe(!0);try{n(t)}finally{qe(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Hs.bind(null,xo,e),[r.memoizedState,e]},useRef:function(e){var t=Bo();return e={current:e},t.memoizedState=e},useState:function(e){e=ns(e);var t=e.queue,n=Us.bind(null,xo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Os,useDeferredValue:function(e,t){return js(Bo(),e,t)},useTransition:function(){var e=ns(!1);return e=Ns.bind(null,xo,e.queue,!0,!1),Bo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=xo,a=Bo();if(Hi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Zl===null)throw Error(i(349));$l&127||Zo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,bs($o.bind(null,r,o,e),[e]),r.flags|=2048,gs(9,{destroy:void 0},Qo.bind(null,r,o,n,t),null),n},useId:function(){var e=Bo(),t=Zl.identifierPrefix;if(Hi){var n=Pi,r=Ni;n=(r&~(1<<32-Je(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Do++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Ao++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Rs,useFormState:ds,useActionState:ds,useOptimistic:function(e){var t=Bo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Gs.bind(null,xo,!0,n),n.dispatch=t,[e,t]},useMemoCache:Go,useCacheRefresh:function(){return Bo().memoizedState=Vs.bind(null,xo)},useEffectEvent:function(e){var t=Bo(),n={impl:e};return t.memoizedState=n,function(){if(Xl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Zs={readContext:ca,use:Wo,useCallback:ks,useContext:ca,useEffect:xs,useImperativeHandle:Ds,useInsertionEffect:ws,useLayoutEffect:Ts,useMemo:As,useReducer:qo,useRef:_s,useState:function(){return qo(Ko)},useDebugValue:Os,useDeferredValue:function(e,t){return Ms(Vo(),So.memoizedState,e,t)},useTransition:function(){var e=qo(Ko)[0],t=Vo().memoizedState;return[typeof e==`boolean`?e:Uo(e),t]},useSyncExternalStore:Xo,useId:zs,useHostTransitionStatus:Rs,useFormState:fs,useActionState:fs,useOptimistic:function(e,t){return rs(Vo(),So,e,t)},useMemoCache:Go,useCacheRefresh:Bs};Zs.useEffectEvent=Cs;var Qs={readContext:ca,use:Wo,useCallback:ks,useContext:ca,useEffect:xs,useImperativeHandle:Ds,useInsertionEffect:ws,useLayoutEffect:Ts,useMemo:As,useReducer:Yo,useRef:_s,useState:function(){return Yo(Ko)},useDebugValue:Os,useDeferredValue:function(e,t){var n=Vo();return So===null?js(n,e,t):Ms(n,So.memoizedState,e,t)},useTransition:function(){var e=Yo(Ko)[0],t=Vo().memoizedState;return[typeof e==`boolean`?e:Uo(e),t]},useSyncExternalStore:Xo,useId:zs,useHostTransitionStatus:Rs,useFormState:hs,useActionState:hs,useOptimistic:function(e,t){var n=Vo();return So===null?(n.baseState=e,[e,n.queue.dispatch]):rs(n,So,e,t)},useMemoCache:Go,useCacheRefresh:Bs};Qs.useEffectEvent=Cs;function $s(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:m({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var ec={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Eu(),i=Xa(r);i.payload=t,n!=null&&(i.callback=n),t=Za(e,i,r),t!==null&&(Ou(t,e,r),Qa(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Eu(),i=Xa(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Za(e,i,r),t!==null&&(Ou(t,e,r),Qa(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Eu(),r=Xa(n);r.tag=2,t!=null&&(r.callback=t),t=Za(e,r,n),t!==null&&(Ou(t,e,n),Qa(t,e,n))}};function tc(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!jr(n,r)||!jr(i,a):!0}function nc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&ec.enqueueReplaceState(t,t.state,null)}function rc(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=m({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function ic(e){ri(e)}function ac(e){console.error(e)}function oc(e){ri(e)}function sc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function cc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function lc(e,t,n){return n=Xa(n),n.tag=3,n.payload={element:null},n.callback=function(){sc(e,t)},n}function uc(e){return e=Xa(e),e.tag=3,e}function dc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){cc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){cc(t,n,r),typeof i!=`function`&&(gu===null?gu=new Set([this]):gu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function fc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&aa(t,n,a,!0),n=uo.current,n!==null){switch(n.tag){case 31:case 13:return fo===null?Bu():n.alternate===null&&au===0&&(au=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Ma?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),ad(e,r,a)),!1;case 22:return n.flags|=65536,r===Ma?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),ad(e,r,a)),!1}throw Error(i(435,n.tag))}return ad(e,r,a),Bu(),!1}if(Hi)return t=uo.current,t===null?(r!==Gi&&(t=Error(i(423),{cause:r}),Zi(Ti(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Ti(r,n),a=lc(e.stateNode,r,a),$a(e,a),au!==4&&(au=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Gi&&(e=Error(i(422),{cause:r}),Zi(Ti(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Ti(o,n),uu===null?uu=[o]:uu.push(o),au!==4&&(au=2),t===null)return!0;r=Ti(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=lc(n.stateNode,r,e),$a(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(gu===null||!gu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=uc(a),dc(a,e,n,r),$a(n,a),!1}n=n.return}while(n!==null);return!1}var pc=Error(i(461)),mc=!1;function hc(e,t,n,r){t.child=e===null?Ka(t,null,n,r):Ga(t,e.child,n,r)}function gc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return sa(t),r=No(e,t,n,o,a,i),s=Lo(),e!==null&&!mc?(Ro(e,t,i),zc(e,t,i)):(Hi&&s&&Li(t),t.flags|=1,hc(e,t,r,i),t.child)}function _c(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!gi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,vc(e,t,a,r,i)):(e=yi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Bc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?jr:n,n(o,r)&&e.ref===t.ref)return zc(e,t,i)}return t.flags|=1,e=_i(a,r),e.ref=t.ref,e.return=t,t.child=e}function vc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(jr(a,r)&&e.ref===t.ref)if(mc=!1,t.pendingProps=r=a,Bc(e,i))e.flags&131072&&(mc=!0);else return t.lanes=e.lanes,zc(e,t,i)}return N(e,t,n,r,i)}function yc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return xc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Da(t,a===null?null:a.cachePool),a===null?co():so(t,a),ho(t);else return r=t.lanes=536870912,xc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Da(t,null),co(),go(t)):(Da(t,a.cachePool),so(t,a),go(t),t.memoizedState=null);return hc(e,t,i,n),t.child}function bc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function xc(e,t,n,r,i){var a=Ea();return a=a===null?null:{parent:ma._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Da(t,null),co(),ho(t),e!==null&&aa(e,t,r,!0),t.childLanes=i,null}function Sc(e,t){return t=Pc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Cc(e,t,n){return Ga(t,e.child,null,n),e=Sc(t,t.pendingProps),e.flags|=2,_o(t),t.memoizedState=null,e}function wc(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Hi){if(r.mode===`hidden`)return e=Sc(t,r),t.lanes=536870912,bc(null,e);if(mo(t),(e=Vi)?(e=bf(e,Wi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Mi===null?null:{id:Ni,overflow:Pi},retryLane:536870912,hydrationErrors:null},n=Si(e),n.return=t,t.child=n,Bi=t,Vi=null)):e=null,e===null)throw Ki(t);return t.lanes=536870912,null}return Sc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(mo(t),a)if(t.flags&256)t.flags&=-257,t=Cc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(mc||aa(e,t,n,!1),a=(n&e.childLanes)!==0,mc||a){if(r=Zl,r!==null&&(s=dt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,ui(e,s),Ou(r,e,s),pc;Bu(),t=Cc(e,t,n)}else e=o.treeContext,Vi=wf(s.nextSibling),Bi=t,Hi=!0,Ui=null,Wi=!1,e!==null&&zi(t,e),t=Sc(t,r),t.flags|=4096;return t}return e=_i(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Tc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function N(e,t,n,r,i){return sa(t),n=No(e,t,n,r,void 0,i),r=Lo(),e!==null&&!mc?(Ro(e,t,i),zc(e,t,i)):(Hi&&r&&Li(t),t.flags|=1,hc(e,t,n,i),t.child)}function Ec(e,t,n,r,i,a){return sa(t),t.updateQueue=null,n=Fo(t,r,n,i),Po(e),r=Lo(),e!==null&&!mc?(Ro(e,t,a),zc(e,t,a)):(Hi&&r&&Li(t),t.flags|=1,hc(e,t,n,a),t.child)}function Dc(e,t,n,r,i){if(sa(t),t.stateNode===null){var a=pi,o=n.contextType;typeof o==`object`&&o&&(a=ca(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=ec,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Ja(t),o=n.contextType,a.context=typeof o==`object`&&o?ca(o):pi,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&($s(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&ec.enqueueReplaceState(a,a.state,null),no(t,r,a,i),to(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=rc(n,s);a.props=c;var l=a.context,u=n.contextType;o=pi,typeof u==`object`&&u&&(o=ca(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&nc(t,a,r,o),qa=!1;var f=t.memoizedState;a.state=f,no(t,r,a,i),to(),l=t.memoizedState,s||f!==l||qa?(typeof d==`function`&&($s(t,n,d,r),l=t.memoizedState),(c=qa||tc(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Ya(e,t),o=t.memoizedProps,u=rc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=pi,typeof l==`object`&&l&&(c=ca(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&nc(t,a,r,c),qa=!1,f=t.memoizedState,a.state=f,no(t,r,a,i),to();var p=t.memoizedState;o!==d||f!==p||qa||e!==null&&e.dependencies!==null&&oa(e.dependencies)?(typeof s==`function`&&($s(t,n,s,r),p=t.memoizedState),(u=qa||tc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&oa(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Tc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Ga(t,e.child,null,i),t.child=Ga(t,null,n,i)):hc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=zc(e,t,i),e}function Oc(e,t,n,r){return Yi(),t.flags|=256,hc(e,t,n,r),t.child}var kc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ac(e){return{baseLanes:e,cachePool:Oa()}}function jc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=cu),e}function Mc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(vo.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Hi){if(a?po(t):go(t),(e=Vi)?(e=bf(e,Wi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Mi===null?null:{id:Ni,overflow:Pi},retryLane:536870912,hydrationErrors:null},n=Si(e),n.return=t,t.child=n,Bi=t,Vi=null)):e=null,e===null)throw Ki(t);return Sf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(go(t),a=t.mode,c=Pc({mode:`hidden`,children:c},a),r=bi(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=Ac(n),r.childLanes=jc(e,s,n),t.memoizedState=kc,bc(null,r)):(po(t),Nc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(po(t),t.flags&=-257,t=Fc(e,t,n)):t.memoizedState===null?(go(t),c=r.fallback,a=t.mode,r=Pc({mode:`visible`,children:r.children},a),c=bi(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Ga(t,e.child,null,n),r=t.child,r.memoizedState=Ac(n),r.childLanes=jc(e,s,n),t.memoizedState=kc,t=bc(null,r)):(go(t),t.child=e.child,t.flags|=128,t=null);else if(po(t),Sf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Zi({value:r,source:null,stack:null}),t=Fc(e,t,n)}else if(mc||aa(e,t,n,!1),s=(n&e.childLanes)!==0,mc||s){if(s=Zl,s!==null&&(r=dt(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,ui(e,r),Ou(s,e,r),pc;xf(c)||Bu(),t=Fc(e,t,n)}else xf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Vi=wf(c.nextSibling),Bi=t,Hi=!0,Ui=null,Wi=!1,e!==null&&zi(t,e),t=Nc(t,r.children),t.flags|=4096);return t}return a?(go(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=_i(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=bi(c,a,n,null),c.flags|=2):c=_i(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,bc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=Ac(n):(a=c.cachePool,a===null?a=Oa():(l=ma._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=jc(e,s,n),t.memoizedState=kc,bc(e.child,r)):(po(t),n=e.child,e=n.sibling,n=_i(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function Nc(e,t){return t=Pc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Pc(e,t){return e=hi(22,e,null,t),e.lanes=0,e}function Fc(e,t,n){return Ga(t,e.child,null,n),e=Nc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Ic(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ra(e.return,t,n)}function Lc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Rc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=vo.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,ge(vo,o),hc(e,t,r,n),r=Hi?ki:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Ic(e,n,t);else if(e.tag===19)Ic(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&yo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Lc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&yo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Lc(t,!0,n,null,a,r);break;case`together`:Lc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function zc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),I|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(aa(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=_i(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=_i(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Bc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&oa(e))):!0}function Vc(e,t,n){switch(t.tag){case 3:xe(t,t.stateNode.containerInfo),ta(t,ma,e.memoizedState.cache),Yi();break;case 27:case 5:D(t);break;case 4:xe(t,t.stateNode.containerInfo);break;case 10:ta(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,mo(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(po(t),e=zc(e,t,n),e===null?null:e.sibling):Mc(e,t,n):(po(t),t.flags|=128,null);po(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(aa(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Rc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ge(vo,vo.current),r)break;return null;case 22:return t.lanes=0,yc(e,t,n,t.pendingProps);case 24:ta(t,ma,e.memoizedState.cache)}return zc(e,t,n)}function Hc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)mc=!0;else{if(!Bc(e,n)&&!(t.flags&128))return mc=!1,Vc(e,t,n);mc=!!(e.flags&131072)}else mc=!1,Hi&&t.flags&1048576&&Ii(t,ki,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Fa(t.elementType),t.type=e,typeof e==`function`)gi(e)?(r=rc(e,r),t.tag=1,t=Dc(null,t,e,r,n)):(t.tag=0,t=N(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===S){t.tag=11,t=gc(null,t,e,r,n);break a}else if(a===w){t.tag=14,t=_c(null,t,e,r,n);break a}}throw t=le(e)||e,Error(i(306,t,``))}}return t;case 0:return N(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=rc(r,t.pendingProps),Dc(e,t,r,a,n);case 3:a:{if(xe(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Ya(e,t),no(t,r,null,n);var s=t.memoizedState;if(r=s.cache,ta(t,ma,r),r!==o.cache&&ia(t,[ma],n,!0),to(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Oc(e,t,r,n);break a}else if(r!==a){a=Ti(Error(i(424)),t),Zi(a),t=Oc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Vi=wf(e.firstChild),Bi=t,Hi=!0,Ui=null,Wi=!0,n=Ka(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Yi(),r===a){t=zc(e,t,n);break a}hc(e,t,r,n)}t=t.child}return t;case 26:return Tc(e,t),e===null?(n=Gf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Hi||(n=t.type,e=t.pendingProps,r=nf(ye.current).createElement(n),r[_t]=t,r[vt]=e,Xd(r,n,e),At(r),t.stateNode=r):t.memoizedState=Gf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return D(t),e===null&&Hi&&(r=t.stateNode=Of(t.type,t.pendingProps,ye.current),Bi=t,Wi=!0,a=Vi,mf(t.type)?(Tf=a,Vi=wf(r.firstChild)):Vi=a),hc(e,t,t.pendingProps.children,n),Tc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Hi&&((a=r=Vi)&&(r=vf(r,t.type,t.pendingProps,Wi),r===null?a=!1:(t.stateNode=r,Bi=t,Vi=wf(r.firstChild),Wi=!1,a=!0)),a||Ki(t)),D(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,of(a,o)?r=null:s!==null&&of(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=No(e,t,Io,null,null,n),fp._currentValue=a),Tc(e,t),hc(e,t,r,n),t.child;case 6:return e===null&&Hi&&((e=n=Vi)&&(n=yf(n,t.pendingProps,Wi),n===null?e=!1:(t.stateNode=n,Bi=t,Vi=null,e=!0)),e||Ki(t)),null;case 13:return Mc(e,t,n);case 4:return xe(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ga(t,null,r,n):hc(e,t,r,n),t.child;case 11:return gc(e,t,t.type,t.pendingProps,n);case 7:return hc(e,t,t.pendingProps,n),t.child;case 8:return hc(e,t,t.pendingProps.children,n),t.child;case 12:return hc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,ta(t,t.type,r.value),hc(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,sa(t),a=ca(a),r=r(a),t.flags|=1,hc(e,t,r,n),t.child;case 14:return _c(e,t,t.type,t.pendingProps,n);case 15:return vc(e,t,t.type,t.pendingProps,n);case 19:return Rc(e,t,n);case 31:return wc(e,t,n);case 22:return yc(e,t,n,t.pendingProps);case 24:return sa(t),r=ca(ma),e===null?(a=Ea(),a===null&&(a=Zl,o=ha(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Ja(t),ta(t,ma,a)):((e.lanes&n)!==0&&(Ya(e,t),no(t,null,null,n),to()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,ta(t,ma,r),r!==a.cache&&ia(t,[ma],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),ta(t,ma,r))),hc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Uc(e){e.flags|=4}function Wc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Lu())e.flags|=8192;else throw Ia=Ma,Aa}else e.flags&=-16777217}function Gc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!ip(t))if(Lu())e.flags|=8192;else throw Ia=Ma,Aa}function Kc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:at(),e.lanes|=t,lu|=t)}function qc(e,t){if(!Hi)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Jc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Yc(e,t,n){var r=t.pendingProps;switch(Ri(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Jc(t),null;case 1:return Jc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),na(ma),Se(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Ji(t)?Uc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Xi())),Jc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Uc(t),o===null?(Jc(t),Wc(t,a,null,r,n)):(Jc(t),Gc(t,o))):o?o===e.memoizedState?(Jc(t),t.flags&=-16777217):(Uc(t),Jc(t),Gc(t,o)):(e=e.memoizedProps,e!==r&&Uc(t),Jc(t),Wc(t,a,e,r,n)),null;case 27:if(Ce(t),n=ye.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Uc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Jc(t),null}e=_e.current,Ji(t)?M(t,e):(e=Of(a,r,n),t.stateNode=e,Uc(t))}return Jc(t),null;case 5:if(Ce(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Uc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Jc(t),null}if(o=_e.current,Ji(t))M(t,o);else{var s=nf(ye.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[_t]=t,o[vt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Xd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Uc(t)}}return Jc(t),Wc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Uc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ye.current,Ji(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Bi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[_t]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||qd(e.nodeValue,n)),e||Ki(t,!0)}else e=nf(e).createTextNode(r),e[_t]=t,t.stateNode=e}return Jc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ji(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[_t]=t}else Yi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Jc(t),e=!1}else n=Xi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(_o(t),t):(_o(t),null);if(t.flags&128)throw Error(i(558))}return Jc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Ji(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[_t]=t}else Yi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Jc(t),a=!1}else a=Xi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(_o(t),t):(_o(t),null)}return _o(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Kc(t,t.updateQueue),Jc(t),null);case 4:return Se(),e===null&&Ld(t.stateNode.containerInfo),Jc(t),null;case 10:return na(t.type),Jc(t),null;case 19:if(he(vo),r=t.memoizedState,r===null)return Jc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)qc(r,!1);else{if(au!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=yo(e),o!==null){for(t.flags|=128,qc(r,!1),e=o.updateQueue,t.updateQueue=e,Kc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)vi(n,e),n=n.sibling;return ge(vo,vo.current&1|2),Hi&&Fi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ie()>mu&&(t.flags|=128,a=!0,qc(r,!1),t.lanes=4194304)}else{if(!a)if(e=yo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Kc(t,e),qc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Hi)return Jc(t),null}else 2*Ie()-r.renderingStartTime>mu&&n!==536870912&&(t.flags|=128,a=!0,qc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Jc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ie(),e.sibling=null,n=vo.current,ge(vo,a?n&1|2:n&1),Hi&&Fi(t,r.treeForkCount),e);case 22:case 23:return _o(t),lo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Jc(t),t.subtreeFlags&6&&(t.flags|=8192)):Jc(t),n=t.updateQueue,n!==null&&Kc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&he(Ta),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),na(ma),Jc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Xc(e,t){switch(Ri(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return na(ma),Se(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ce(t),null;case 31:if(t.memoizedState!==null){if(_o(t),t.alternate===null)throw Error(i(340));Yi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(_o(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Yi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return he(vo),null;case 4:return Se(),null;case 10:return na(t.type),null;case 22:case 23:return _o(t),lo(),e!==null&&he(Ta),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return na(ma),null;case 25:return null;default:return null}}function Zc(e,t){switch(Ri(t),t.tag){case 3:na(ma),Se();break;case 26:case 27:case 5:Ce(t);break;case 4:Se();break;case 31:t.memoizedState!==null&&_o(t);break;case 13:_o(t);break;case 19:he(vo);break;case 10:na(t.type);break;case 22:case 23:_o(t),lo(),e!==null&&he(Ta);break;case 24:na(ma)}}function Qc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){id(t,t.return,e)}}function $c(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){id(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){id(t,t.return,e)}}function el(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{io(t,n)}catch(t){id(e,e.return,t)}}}function tl(e,t,n){n.props=rc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){id(e,t,n)}}function nl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){id(e,t,n)}}function rl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){id(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){id(e,t,n)}else n.current=null}function il(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){id(e,e.return,t)}}function al(e,t,n){try{var r=e.stateNode;Zd(r,e.type,n,t),r[vt]=t}catch(t){id(e,e.return,t)}}function ol(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&mf(e.type)||e.tag===4}function sl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||ol(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&mf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function cl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=dn));else if(r!==4&&(r===27&&mf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(cl(e,t,n),e=e.sibling;e!==null;)cl(e,t,n),e=e.sibling}function ll(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&mf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(ll(e,t,n),e=e.sibling;e!==null;)ll(e,t,n),e=e.sibling}function ul(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Xd(t,r,n),t[_t]=e,t[vt]=n}catch(t){id(e,e.return,t)}}var dl=!1,fl=!1,pl=!1,ml=typeof WeakSet==`function`?WeakSet:Set,P=null;function hl(e,t){if(e=e.containerInfo,ef=xp,e=Fr(e),Ir(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(tf={focusedElem:e,selectionRange:n},xp=!1,P=t;P!==null;)if(t=P,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,P=e;else for(;P!==null;){switch(t=P,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=rc(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){id(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)_f(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:_f(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,P=e;break}P=t.return}}function gl(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:jl(e,n),r&4&&Qc(5,n);break;case 1:if(jl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){id(n,n.return,e)}else{var i=rc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){id(n,n.return,e)}}r&64&&el(n),r&512&&nl(n,n.return);break;case 3:if(jl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{io(e,t)}catch(e){id(n,n.return,e)}}break;case 27:t===null&&r&4&&ul(n);case 26:case 5:jl(e,n),t===null&&r&4&&il(n),r&512&&nl(n,n.return);break;case 12:jl(e,n);break;case 31:jl(e,n),r&4&&Sl(e,n);break;case 13:jl(e,n),r&4&&Cl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=cd.bind(null,n),Cf(e,n))));break;case 22:if(r=n.memoizedState!==null||dl,!r){t=t!==null&&t.memoizedState!==null||fl,i=dl;var a=fl;dl=r,(fl=t)&&!a?Nl(e,n,(n.subtreeFlags&8772)!=0):jl(e,n),dl=i,fl=a}break;case 30:break;default:jl(e,n)}}function _l(e){var t=e.alternate;t!==null&&(e.alternate=null,_l(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Tt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var vl=null,yl=!1;function bl(e,t,n){for(n=n.child;n!==null;)xl(e,t,n),n=n.sibling}function xl(e,t,n){if(Ke&&typeof Ke.onCommitFiberUnmount==`function`)try{Ke.onCommitFiberUnmount(Ge,n)}catch{}switch(n.tag){case 26:fl||rl(n,t),bl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:fl||rl(n,t);var r=vl,i=yl;mf(n.type)&&(vl=n.stateNode,yl=!1),bl(e,t,n),kf(n.stateNode),vl=r,yl=i;break;case 5:fl||rl(n,t);case 6:if(r=vl,i=yl,vl=null,bl(e,t,n),vl=r,yl=i,vl!==null)if(yl)try{(vl.nodeType===9?vl.body:vl.nodeName===`HTML`?vl.ownerDocument.body:vl).removeChild(n.stateNode)}catch(e){id(n,t,e)}else try{vl.removeChild(n.stateNode)}catch(e){id(n,t,e)}break;case 18:vl!==null&&(yl?(e=vl,hf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),qp(e)):hf(vl,n.stateNode));break;case 4:r=vl,i=yl,vl=n.stateNode.containerInfo,yl=!0,bl(e,t,n),vl=r,yl=i;break;case 0:case 11:case 14:case 15:$c(2,n,t),fl||$c(4,n,t),bl(e,t,n);break;case 1:fl||(rl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&tl(n,t,r)),bl(e,t,n);break;case 21:bl(e,t,n);break;case 22:fl=(r=fl)||n.memoizedState!==null,bl(e,t,n),fl=r;break;default:bl(e,t,n)}}function Sl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{qp(e)}catch(e){id(t,t.return,e)}}}function Cl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{qp(e)}catch(e){id(t,t.return,e)}}function wl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new ml),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new ml),t;default:throw Error(i(435,e.tag))}}function Tl(e,t){var n=wl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=ld.bind(null,e,t);t.then(r,r)}})}function El(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(mf(c.type)){vl=c.stateNode,yl=!1;break a}break;case 5:vl=c.stateNode,yl=!1;break a;case 3:case 4:vl=c.stateNode.containerInfo,yl=!0;break a}c=c.return}if(vl===null)throw Error(i(160));xl(o,s,a),vl=null,yl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Ol(t,e),t=t.sibling}var Dl=null;function Ol(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:El(t,e),kl(e),r&4&&($c(3,e,e.return),Qc(3,e),$c(5,e,e.return));break;case 1:El(t,e),kl(e),r&512&&(fl||n===null||rl(n,n.return)),r&64&&dl&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=Dl;if(El(t,e),kl(e),r&512&&(fl||n===null||rl(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[wt]||o[_t]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Xd(o,r,n),o[_t]=e,At(o),r=o;break a;case`link`:var s=tp(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Xd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=tp(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Xd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[_t]=e,At(o),r=o}e.stateNode=r}else np(a,e.type,e.stateNode);else e.stateNode=z(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&al(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?np(a,e.type,e.stateNode):z(a,r,e.memoizedProps))}break;case 27:El(t,e),kl(e),r&512&&(fl||n===null||rl(n,n.return)),n!==null&&r&4&&al(e,e.memoizedProps,n.memoizedProps);break;case 5:if(El(t,e),kl(e),r&512&&(fl||n===null||rl(n,n.return)),e.flags&32){a=e.stateNode;try{nn(a,``)}catch(t){id(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,al(e,a,n===null?a:n.memoizedProps)),r&1024&&(pl=!0);break;case 6:if(El(t,e),kl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){id(e,e.return,t)}}break;case 3:if(ep=null,a=Dl,Dl=Mf(t.containerInfo),El(t,e),Dl=a,kl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{qp(t.containerInfo)}catch(t){id(e,e.return,t)}pl&&(pl=!1,Al(e));break;case 4:r=Dl,Dl=Mf(e.stateNode.containerInfo),El(t,e),kl(e),Dl=r;break;case 12:El(t,e),kl(e);break;case 31:El(t,e),kl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,Tl(e,r)));break;case 13:El(t,e),kl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(fu=Ie()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,Tl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=dl,d=fl;if(dl=u||a,fl=d||l,El(t,e),fl=d,dl=u,kl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||dl||fl||Ml(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){id(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){id(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?gf(m,!0):gf(l.stateNode,!1)}catch(e){id(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,Tl(e,n))));break;case 19:El(t,e),kl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,Tl(e,r)));break;case 30:break;case 21:break;default:El(t,e),kl(e)}}function kl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(ol(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;ll(e,sl(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(nn(o,``),n.flags&=-33),ll(e,sl(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;cl(e,sl(e),s);break;default:throw Error(i(161))}}catch(t){id(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Al(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Al(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function jl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)gl(e,t.alternate,t),t=t.sibling}function Ml(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:$c(4,t,t.return),Ml(t);break;case 1:rl(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&tl(t,t.return,n),Ml(t);break;case 27:kf(t.stateNode);case 26:case 5:rl(t,t.return),Ml(t);break;case 22:t.memoizedState===null&&Ml(t);break;case 30:Ml(t);break;default:Ml(t)}e=e.sibling}}function Nl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:Nl(i,a,n),Qc(4,a);break;case 1:if(Nl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){id(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)ro(c[i],s)}catch(e){id(r,r.return,e)}}n&&o&64&&el(a),nl(a,a.return);break;case 27:ul(a);case 26:case 5:Nl(i,a,n),n&&r===null&&o&4&&il(a),nl(a,a.return);break;case 12:Nl(i,a,n);break;case 31:Nl(i,a,n),n&&o&4&&Sl(i,a);break;case 13:Nl(i,a,n),n&&o&4&&Cl(i,a);break;case 22:a.memoizedState===null&&Nl(i,a,n),nl(a,a.return);break;case 30:break;default:Nl(i,a,n)}t=t.sibling}}function Pl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&ga(n))}function Fl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ga(e))}function Il(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Ll(e,t,n,r),t=t.sibling}function Ll(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Il(e,t,n,r),i&2048&&Qc(9,t);break;case 1:Il(e,t,n,r);break;case 3:Il(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ga(e)));break;case 12:if(i&2048){Il(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){id(t,t.return,e)}}else Il(e,t,n,r);break;case 31:Il(e,t,n,r);break;case 13:Il(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Il(e,t,n,r):(a._visibility|=2,Rl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?Il(e,t,n,r):zl(e,t),i&2048&&Pl(o,t);break;case 24:Il(e,t,n,r),i&2048&&Fl(t.alternate,t);break;default:Il(e,t,n,r)}}function Rl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Rl(a,o,s,c,i),Qc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Rl(a,o,s,c,i)):u._visibility&2?Rl(a,o,s,c,i):zl(a,o),i&&l&2048&&Pl(o.alternate,o);break;case 24:Rl(a,o,s,c,i),i&&l&2048&&Fl(o.alternate,o);break;default:Rl(a,o,s,c,i)}t=t.sibling}}function zl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:zl(n,r),i&2048&&Pl(r.alternate,r);break;case 24:zl(n,r),i&2048&&Fl(r.alternate,r);break;default:zl(n,r)}t=t.sibling}}var Bl=8192;function Vl(e,t,n){if(e.subtreeFlags&Bl)for(e=e.child;e!==null;)Hl(e,t,n),e=e.sibling}function Hl(e,t,n){switch(e.tag){case 26:Vl(e,t,n),e.flags&Bl&&e.memoizedState!==null&&ap(n,Dl,e.memoizedState,e.memoizedProps);break;case 5:Vl(e,t,n);break;case 3:case 4:var r=Dl;Dl=Mf(e.stateNode.containerInfo),Vl(e,t,n),Dl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Bl,Bl=16777216,Vl(e,t,n),Bl=r):Vl(e,t,n));break;default:Vl(e,t,n)}}function Ul(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Wl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];P=r,ql(r,e)}Ul(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Gl(e),e=e.sibling}function Gl(e){switch(e.tag){case 0:case 11:case 15:Wl(e),e.flags&2048&&$c(9,e,e.return);break;case 3:Wl(e);break;case 12:Wl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Kl(e)):Wl(e);break;default:Wl(e)}}function Kl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];P=r,ql(r,e)}Ul(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:$c(8,t,t.return),Kl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Kl(t));break;default:Kl(t)}e=e.sibling}}function ql(e,t){for(;P!==null;){var n=P;switch(n.tag){case 0:case 11:case 15:$c(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:ga(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,P=r;else a:for(n=e;P!==null;){r=P;var i=r.sibling,a=r.return;if(_l(r),r===n){P=null;break a}if(i!==null){i.return=a,P=i;break a}P=a}}}var Jl={getCacheForType:function(e){var t=ca(ma),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return ca(ma).controller.signal}},Yl=typeof WeakMap==`function`?WeakMap:Map,Xl=0,Zl=null,Ql=null,$l=0,eu=0,tu=null,nu=!1,ru=!1,iu=!1,F=0,au=0,I=0,ou=0,su=0,cu=0,lu=0,uu=null,L=null,du=!1,fu=0,pu=0,mu=1/0,hu=null,gu=null,_u=0,vu=null,yu=null,bu=0,xu=0,Su=null,Cu=null,wu=0,Tu=null;function Eu(){return Xl&2&&$l!==0?$l&-$l:T.T===null?mt():Td()}function Du(){if(cu===0)if(!($l&536870912)||Hi){var e=$e;$e<<=1,!($e&3932160)&&($e=262144),cu=e}else cu=536870912;return e=uo.current,e!==null&&(e.flags|=32),cu}function Ou(e,t,n){(e===Zl&&(eu===2||eu===9)||e.cancelPendingCommit!==null)&&(Fu(e,0),Mu(e,$l,cu,!1)),st(e,n),(!(Xl&2)||e!==Zl)&&(e===Zl&&(!(Xl&2)&&(ou|=n),au===4&&Mu(e,$l,cu,!1)),_d(e))}function ku(e,t,n){if(Xl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||rt(e,t),a=r?Uu(e,t):Vu(e,t,!0),o=r;do{if(a===0){ru&&!r&&Mu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!ju(n)){a=Vu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=uu;var l=c.current.memoizedState.isDehydrated;if(l&&(Fu(c,s).flags|=256),s=Vu(c,s,!1),s!==2){if(iu&&!l){c.errorRecoveryDisabledLanes|=o,ou|=o,a=4;break a}o=L,L=a,o!==null&&(L===null?L=o:L.push.apply(L,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Fu(e,0),Mu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:Mu(r,t,cu,!nu);break a;case 2:L=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=fu+300-Ie(),10<a)){if(Mu(r,t,cu,!nu),nt(r,0,!0)!==0)break a;bu=t,r.timeoutHandle=lf(Au.bind(null,r,n,L,hu,du,t,cu,ou,lu,nu,o,`Throttled`,-0,0),a);break a}Au(r,n,L,hu,du,t,cu,ou,lu,nu,o,null,-0,0)}}break}while(1);_d(e)}function Au(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:dn},Hl(t,a,d);var m=(a&62914560)===a?fu-Ie():(a&4194048)===a?pu-Ie():0;if(m=sp(d,m),m!==null){bu=a,e.cancelPendingCommit=m(Xu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Mu(e,a,o,!l);return}}Xu(e,t,a,n,r,i,o,s,c)}function ju(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Ar(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Mu(e,t,n,r){t&=~su,t&=~ou,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Je(i),o=1<<a;r[a]=-1,i&=~o}n!==0&<(e,n,t)}function Nu(){return Xl&6?!0:(vd(0,!1),!1)}function Pu(){if(Ql!==null){if(eu===0)var e=Ql.return;else e=Ql,ea=$i=null,zo(e),za=null,Ba=0,e=Ql;for(;e!==null;)Zc(e.alternate,e),e=e.return;Ql=null}}function Fu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,uf(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),bu=0,Pu(),Zl=e,Ql=n=_i(e.current,null),$l=t,eu=0,tu=null,nu=!1,ru=rt(e,t),iu=!1,lu=cu=su=ou=I=au=0,L=uu=null,du=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Je(r),a=1<<i;t|=e[i],r&=~a}return F=t,si(),n}function Iu(e,t){xo=null,T.H=Ys,t===ka||t===ja?(t=La(),eu=3):t===Aa?(t=La(),eu=4):eu=t===pc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,tu=t,Ql===null&&(au=1,sc(e,Ti(t,e.current)))}function Lu(){var e=uo.current;return e===null?!0:($l&4194048)===$l?fo===null:($l&62914560)===$l||$l&536870912?e===fo:!1}function Ru(){var e=T.H;return T.H=Ys,e===null?Ys:e}function zu(){var e=T.A;return T.A=Jl,e}function Bu(){au=4,nu||($l&4194048)!==$l&&uo.current!==null||(ru=!0),!(I&134217727)&&!(ou&134217727)||Zl===null||Mu(Zl,$l,cu,!1)}function Vu(e,t,n){var r=Xl;Xl|=2;var i=Ru(),a=zu();(Zl!==e||$l!==t)&&(hu=null,Fu(e,t)),t=!1;var o=au;a:do try{if(eu!==0&&Ql!==null){var s=Ql,c=tu;switch(eu){case 8:Pu(),o=6;break a;case 3:case 2:case 9:case 6:uo.current===null&&(t=!0);var l=eu;if(eu=0,tu=null,qu(e,s,c,l),n&&ru){o=0;break a}break;default:l=eu,eu=0,tu=null,qu(e,s,c,l)}}Hu(),o=au;break}catch(t){Iu(e,t)}while(1);return t&&e.shellSuspendCounter++,ea=$i=null,Xl=r,T.H=i,T.A=a,Ql===null&&(Zl=null,$l=0,si()),o}function Hu(){for(;Ql!==null;)Gu(Ql)}function Uu(e,t){var n=Xl;Xl|=2;var r=Ru(),a=zu();Zl!==e||$l!==t?(hu=null,mu=Ie()+500,Fu(e,t)):ru=rt(e,t);a:do try{if(eu!==0&&Ql!==null){t=Ql;var o=tu;b:switch(eu){case 1:eu=0,tu=null,qu(e,t,o,1);break;case 2:case 9:if(Na(o)){eu=0,tu=null,Ku(t);break}t=function(){eu!==2&&eu!==9||Zl!==e||(eu=7),_d(e)},o.then(t,t);break a;case 3:eu=7;break a;case 4:eu=5;break a;case 7:Na(o)?(eu=0,tu=null,Ku(t)):(eu=0,tu=null,qu(e,t,o,7));break;case 5:var s=null;switch(Ql.tag){case 26:s=Ql.memoizedState;case 5:case 27:var c=Ql;if(s?ip(s):c.stateNode.complete){eu=0,tu=null;var l=c.sibling;if(l!==null)Ql=l;else{var u=c.return;u===null?Ql=null:(Ql=u,Ju(u))}break b}}eu=0,tu=null,qu(e,t,o,5);break;case 6:eu=0,tu=null,qu(e,t,o,6);break;case 8:Pu(),au=6;break a;default:throw Error(i(462))}}Wu();break}catch(t){Iu(e,t)}while(1);return ea=$i=null,T.H=r,T.A=a,Xl=n,Ql===null?(Zl=null,$l=0,si(),au):0}function Wu(){for(;Ql!==null&&!Pe();)Gu(Ql)}function Gu(e){var t=Hc(e.alternate,e,F);e.memoizedProps=e.pendingProps,t===null?Ju(e):Ql=t}function Ku(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Ec(n,t,t.pendingProps,t.type,void 0,$l);break;case 11:t=Ec(n,t,t.pendingProps,t.type.render,t.ref,$l);break;case 5:zo(t);default:Zc(n,t),t=Ql=vi(t,F),t=Hc(n,t,F)}e.memoizedProps=e.pendingProps,t===null?Ju(e):Ql=t}function qu(e,t,n,r){ea=$i=null,zo(t),za=null,Ba=0;var i=t.return;try{if(fc(e,i,t,n,$l)){au=1,sc(e,Ti(n,e.current)),Ql=null;return}}catch(t){if(i!==null)throw Ql=i,t;au=1,sc(e,Ti(n,e.current)),Ql=null;return}t.flags&32768?(Hi||r===1?e=!0:ru||$l&536870912?e=!1:(nu=e=!0,(r===2||r===9||r===3||r===6)&&(r=uo.current,r!==null&&r.tag===13&&(r.flags|=16384))),Yu(t,e)):Ju(t)}function Ju(e){var t=e;do{if(t.flags&32768){Yu(t,nu);return}e=t.return;var n=Yc(t.alternate,t,F);if(n!==null){Ql=n;return}if(t=t.sibling,t!==null){Ql=t;return}Ql=t=e}while(t!==null);au===0&&(au=5)}function Yu(e,t){do{var n=Xc(e.alternate,e);if(n!==null){n.flags&=32767,Ql=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Ql=e;return}Ql=e=n}while(e!==null);au=6,Ql=null}function Xu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do td();while(_u!==0);if(Xl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=oi,ct(e,n,o,s,c,l),e===Zl&&(Ql=Zl=null,$l=0),yu=t,vu=e,bu=n,xu=o,Su=a,Cu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,ud(Be,function(){return nd(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=T.T,T.T=null,a=E.p,E.p=2,s=Xl,Xl|=4;try{hl(e,t,n)}finally{Xl=s,E.p=a,T.T=r}}_u=1,Zu(),Qu(),$u()}}function Zu(){if(_u===1){_u=0;var e=vu,t=yu,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=T.T,T.T=null;var r=E.p;E.p=2;var i=Xl;Xl|=4;try{Ol(t,e);var a=tf,o=Fr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&Pr(s.ownerDocument.documentElement,s)){if(c!==null&&Ir(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Nr(s,h),v=Nr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}xp=!!ef,tf=ef=null}finally{Xl=i,E.p=r,T.T=n}}e.current=t,_u=2}}function Qu(){if(_u===2){_u=0;var e=vu,t=yu,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=T.T,T.T=null;var r=E.p;E.p=2;var i=Xl;Xl|=4;try{gl(e,t.alternate,t)}finally{Xl=i,E.p=r,T.T=n}}_u=3}}function $u(){if(_u===4||_u===3){_u=0,Fe();var e=vu,t=yu,n=bu,r=Cu;t.subtreeFlags&10256||t.flags&10256?_u=5:(_u=0,yu=vu=null,ed(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(gu=null),pt(n),t=t.stateNode,Ke&&typeof Ke.onCommitFiberRoot==`function`)try{Ke.onCommitFiberRoot(Ge,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=T.T,i=E.p,E.p=2,T.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{T.T=t,E.p=i}}bu&3&&td(),_d(e),i=e.pendingLanes,n&261930&&i&42?e===Tu?wu++:(wu=0,Tu=e):wu=0,vd(0,!1)}}function ed(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,ga(t)))}function td(){return Zu(),Qu(),$u(),nd()}function nd(){if(_u!==5)return!1;var e=vu,t=xu;xu=0;var n=pt(bu),r=T.T,a=E.p;try{E.p=32>n?32:n,T.T=null,n=Su,Su=null;var o=vu,s=bu;if(_u=0,yu=vu=null,bu=0,Xl&6)throw Error(i(331));var c=Xl;if(Xl|=4,Gl(o.current),Ll(o,o.current,s,n),Xl=c,vd(0,!1),Ke&&typeof Ke.onPostCommitFiberRoot==`function`)try{Ke.onPostCommitFiberRoot(Ge,o)}catch{}return!0}finally{E.p=a,T.T=r,ed(e,t)}}function rd(e,t,n){t=Ti(n,t),t=lc(e.stateNode,t,2),e=Za(e,t,2),e!==null&&(st(e,2),_d(e))}function id(e,t,n){if(e.tag===3)rd(e,e,n);else for(;t!==null;){if(t.tag===3){rd(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(gu===null||!gu.has(r))){e=Ti(n,e),n=uc(2),r=Za(t,n,2),r!==null&&(dc(n,r,t,e),st(r,2),_d(r));break}}t=t.return}}function ad(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Yl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(iu=!0,i.add(n),e=od.bind(null,e,t,n),t.then(e,e))}function od(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Zl===e&&($l&n)===n&&(au===4||au===3&&($l&62914560)===$l&&300>Ie()-fu?!(Xl&2)&&Fu(e,0):su|=n,lu===$l&&(lu=0)),_d(e)}function sd(e,t){t===0&&(t=at()),e=ui(e,t),e!==null&&(st(e,t),_d(e))}function cd(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),sd(e,n)}function ld(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),sd(e,n)}function ud(e,t){return Me(e,t)}var dd=null,fd=null,pd=!1,md=!1,hd=!1,gd=0;function _d(e){e!==fd&&e.next===null&&(fd===null?dd=fd=e:fd=fd.next=e),md=!0,pd||(pd=!0,wd())}function vd(e,t){if(!hd&&md){hd=!0;do for(var n=!1,r=dd;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Je(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Cd(r,a))}else a=$l,a=nt(r,r===Zl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||rt(r,a)||(n=!0,Cd(r,a));r=r.next}while(n);hd=!1}}function yd(){bd()}function bd(){md=pd=!1;var e=0;gd!==0&&cf()&&(e=gd);for(var t=Ie(),n=null,r=dd;r!==null;){var i=r.next,a=xd(r,t);a===0?(r.next=null,n===null?dd=i:n.next=i,i===null&&(fd=n)):(n=r,(e!==0||a&3)&&(md=!0)),r=i}_u!==0&&_u!==5||vd(e,!1),gd!==0&&(gd=0)}function xd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Je(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=it(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Zl,n=$l,n=nt(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(eu===2||eu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Ne(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||rt(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Ne(r),pt(n)){case 2:case 8:n=ze;break;case 32:n=Be;break;case 268435456:n=He;break;default:n=Be}return r=Sd.bind(null,e),n=Me(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Ne(r),e.callbackPriority=2,e.callbackNode=null,2}function Sd(e,t){if(_u!==0&&_u!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(td()&&e.callbackNode!==n)return null;var r=$l;return r=nt(e,e===Zl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(ku(e,r,t),xd(e,Ie()),e.callbackNode!=null&&e.callbackNode===n?Sd.bind(null,e):null)}function Cd(e,t){if(td())return null;ku(e,t,!0)}function wd(){ff(function(){Xl&6?Me(Re,yd):bd()})}function Td(){if(gd===0){var e=ya;e===0&&(e=Qe,Qe<<=1,!(Qe&261888)&&(Qe=256)),gd=e}return gd}function Ed(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:un(``+e)}function Dd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function Od(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Ed((i[vt]||null).action),o=r.submitter;o&&(t=(t=o[vt]||null)?Ed(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new kn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(gd!==0){var e=o?Dd(i,o):new FormData(i);Fs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?Dd(i,o):new FormData(i),Fs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var kd=0;kd<ti.length;kd++){var Ad=ti[kd];ni(Ad.toLowerCase(),`on`+(Ad[0].toUpperCase()+Ad.slice(1)))}ni(Jr,`onAnimationEnd`),ni(Yr,`onAnimationIteration`),ni(Xr,`onAnimationStart`),ni(`dblclick`,`onDoubleClick`),ni(`focusin`,`onFocus`),ni(`focusout`,`onBlur`),ni(Zr,`onTransitionRun`),ni(Qr,`onTransitionStart`),ni($r,`onTransitionCancel`),ni(j,`onTransitionEnd`),Pt(`onMouseEnter`,[`mouseout`,`mouseover`]),Pt(`onMouseLeave`,[`mouseout`,`mouseover`]),Pt(`onPointerEnter`,[`pointerout`,`pointerover`]),Pt(`onPointerLeave`,[`pointerout`,`pointerover`]),Nt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Nt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Nt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Nt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Nt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Nt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var jd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Md=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(jd));function Nd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){ri(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){ri(e)}i.currentTarget=null,a=c}}}}function Pd(e,t){var n=t[bt];n===void 0&&(n=t[bt]=new Set);var r=e+`__bubble`;n.has(r)||(Rd(t,e,2,!1),n.add(r))}function Fd(e,t,n){var r=0;t&&(r|=4),Rd(n,e,r,t)}var Id=`_reactListening`+Math.random().toString(36).slice(2);function Ld(e){if(!e[Id]){e[Id]=!0,jt.forEach(function(t){t!==`selectionchange`&&(Md.has(t)||Fd(t,!1,e),Fd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Id]||(t[Id]=!0,Fd(`selectionchange`,!1,t))}}function Rd(e,t,n,r){switch(Op(t)){case 2:var i=Sp;break;case 8:i=Cp;break;default:i=wp}n=i.bind(null,t,n,e),i=void 0,!xn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function zd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=Et(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}vn(function(){var r=a,i=pn(n),s=[];a:{var c=ei.get(e);if(c!==void 0){var l=kn,u=e;switch(e){case`keypress`:if(Tn(n)===0)break a;case`keydown`:case`keyup`:l=qn;break;case`focusin`:u=`focus`,l=Rn;break;case`focusout`:u=`blur`,l=Rn;break;case`beforeblur`:case`afterblur`:l=Rn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=In;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Ln;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Yn;break;case Jr:case Yr:case Xr:l=zn;break;case j:l=Xn;break;case`scroll`:case`scrollend`:l=jn;break;case`wheel`:l=Zn;break;case`copy`:case`cut`:case`paste`:l=Bn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Jn;break;case`toggle`:case`beforetoggle`:l=Qn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=yn(m,p),g!=null&&d.push(Bd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==fn&&(u=n.relatedTarget||n.fromElement)&&(Et(u)||u[yt]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?Et(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=In,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Jn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:Ot(l),h=u==null?c:Ot(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,Et(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Hd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Ud(s,c,l,d,!1),u!==null&&f!==null&&Ud(s,f,u,d,!0)}}a:{if(c=r?Ot(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=vr;else if(fr(c))if(yr)v=Or;else{v=Er;var y=Tr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&sn(r.elementType)&&(v=vr):v=Dr;if(v&&=v(e,r)){pr(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Qt(c,`number`,c.value)}switch(y=r?Ot(r):window,e){case`focusin`:(fr(y)||y.contentEditable===`true`)&&(Rr=y,zr=r,Br=null);break;case`focusout`:Br=zr=Rr=null;break;case`mousedown`:Vr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Vr=!1,Hr(s,n,i);break;case`selectionchange`:if(Lr)break;case`keydown`:case`keyup`:Hr(s,n,i)}var b;if(er)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else cr?or(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(rr&&n.locale!==`ko`&&(cr||x!==`onCompositionStart`?x===`onCompositionEnd`&&cr&&(b=wn()):(O=i,Cn=`value`in O?O.value:O.textContent,cr=!0)),y=Vd(r,x),0<y.length&&(x=new Vn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=sr(n),b!==null&&(x.data=b)))),(b=nr?lr(e,n):ur(e,n))&&(x=Vd(r,`onBeforeInput`),0<x.length&&(y=new Vn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),Od(s,e,r,n,i)}Nd(s,t)})}function Bd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Vd(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=yn(e,n),i!=null&&r.unshift(Bd(e,i,a)),i=yn(e,t),i!=null&&r.push(Bd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Hd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Ud(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=yn(n,a),l!=null&&o.unshift(Bd(n,l,c))):i||(l=yn(n,a),l!=null&&o.push(Bd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Wd=/\r\n?/g,Gd=/\u0000|\uFFFD/g;function Kd(e){return(typeof e==`string`?e:``+e).replace(Wd,`
|
|
10
|
-
`).replace(Gd,``)}function qd(e,t){return t=Kd(t),Kd(e)===t}function Jd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||nn(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&nn(e,``+r);break;case`className`:Bt(e,`class`,r);break;case`tabIndex`:Bt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Bt(e,n,r);break;case`style`:on(e,r,o);break;case`data`:if(t!==`object`){Bt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=un(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Jd(e,t,`name`,a.name,a,null),Jd(e,t,`formEncType`,a.formEncType,a,null),Jd(e,t,`formMethod`,a.formMethod,a,null),Jd(e,t,`formTarget`,a.formTarget,a,null)):(Jd(e,t,`encType`,a.encType,a,null),Jd(e,t,`method`,a.method,a,null),Jd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=un(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=dn);break;case`onScroll`:r!=null&&Pd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Pd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=un(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Pd(`beforetoggle`,e),Pd(`toggle`,e),zt(e,`popover`,r);break;case`xlinkActuate`:Vt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Vt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Vt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Vt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Vt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Vt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:zt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=cn.get(n)||n,zt(e,n,r))}}function Yd(e,t,n,r,a,o){switch(n){case`style`:on(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?nn(e,r):(typeof r==`number`||typeof r==`bigint`)&&nn(e,``+r);break;case`onScroll`:r!=null&&Pd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Pd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=dn);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!Mt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[vt]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):zt(e,n,r)}}}function Xd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Pd(`error`,e),Pd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Jd(e,t,o,s,n,null)}}a&&Jd(e,t,`srcSet`,n.srcSet,n,null),r&&Jd(e,t,`src`,n.src,n,null);return;case`input`:Pd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Jd(e,t,r,d,n,null)}}Zt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Pd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Jd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&$t(e,!!r,n,!0):$t(e,!!r,t,!1);return;case`textarea`:for(s in Pd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Jd(e,t,s,c,n,null)}tn(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Jd(e,t,l,r,n,null)}return;case`dialog`:Pd(`beforetoggle`,e),Pd(`toggle`,e),Pd(`cancel`,e),Pd(`close`,e);break;case`iframe`:case`object`:Pd(`load`,e);break;case`video`:case`audio`:for(r=0;r<jd.length;r++)Pd(jd[r],e);break;case`image`:Pd(`error`,e),Pd(`load`,e);break;case`details`:Pd(`toggle`,e);break;case`embed`:case`source`:case`link`:Pd(`error`,e),Pd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Jd(e,t,u,r,n,null)}return;default:if(sn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Yd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Jd(e,t,c,r,n,null))}function Zd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Jd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Jd(e,t,p,m,r,f)}}Xt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Jd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Jd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?$t(e,!!n,n?[]:``,!1):$t(e,!!n,t,!0)):$t(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Jd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Jd(e,t,s,a,r,o)}en(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Jd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Jd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Jd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Jd(e,t,u,p,r,m)}return;default:if(sn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Yd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Yd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Jd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Jd(e,t,f,p,r,m)}function Qd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function $d(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Qd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Qd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var ef=null,tf=null;function nf(e){return e.nodeType===9?e:e.ownerDocument}function rf(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function af(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function of(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var sf=null;function cf(){var e=window.event;return e&&e.type===`popstate`?e===sf?!1:(sf=e,!0):(sf=null,!1)}var lf=typeof setTimeout==`function`?setTimeout:void 0,uf=typeof clearTimeout==`function`?clearTimeout:void 0,df=typeof Promise==`function`?Promise:void 0,ff=typeof queueMicrotask==`function`?queueMicrotask:df===void 0?lf:function(e){return df.resolve(null).then(e).catch(pf)};function pf(e){setTimeout(function(){throw e})}function mf(e){return e===`head`}function hf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),qp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)kf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,kf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[wt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&kf(e.ownerDocument.body);n=i}while(n);qp(t)}function gf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function _f(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:_f(n),Tt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function vf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[wt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=wf(e.nextSibling),e===null)break}return null}function yf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=wf(e.nextSibling),e===null))return null;return e}function bf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=wf(e.nextSibling),e===null))return null;return e}function xf(e){return e.data===`$?`||e.data===`$~`}function Sf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function Cf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function wf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var Tf=null;function Ef(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return wf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function Df(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function Of(e,t,n){switch(t=nf(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function kf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Tt(e)}var Af=new Map,jf=new Set;function Mf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Nf=E.d;E.d={f:Pf,r:Ff,D:Rf,C:zf,L:Bf,m:Vf,X:Uf,S:Hf,M:Wf};function Pf(){var e=Nf.f(),t=Nu();return e||t}function Ff(e){var t=Dt(e);t!==null&&t.tag===5&&t.type===`form`?Ls(t):Nf.r(e)}var If=typeof document>`u`?null:document;function Lf(e,t,n){var r=If;if(r&&typeof t==`string`&&t){var i=Yt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),jf.has(i)||(jf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Xd(t,`link`,e),At(t),r.head.appendChild(t)))}}function Rf(e){Nf.D(e),Lf(`dns-prefetch`,e,null)}function zf(e,t){Nf.C(e,t),Lf(`preconnect`,e,t)}function Bf(e,t,n){Nf.L(e,t,n);var r=If;if(r&&e&&t){var i=`link[rel="preload"][as="`+Yt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Yt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Yt(n.imageSizes)+`"]`)):i+=`[href="`+Yt(e)+`"]`;var a=i;switch(t){case`style`:a=R(e);break;case`script`:a=Yf(e)}Af.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Af.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Kf(a))||t===`script`&&r.querySelector(Xf(a))||(t=r.createElement(`link`),Xd(t,`link`,e),At(t),r.head.appendChild(t)))}}function Vf(e,t){Nf.m(e,t);var n=If;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Yt(r)+`"][href="`+Yt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Yf(e)}if(!Af.has(a)&&(e=m({rel:`modulepreload`,href:e},t),Af.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Xf(a)))return}r=n.createElement(`link`),Xd(r,`link`,e),At(r),n.head.appendChild(r)}}}function Hf(e,t,n){Nf.S(e,t,n);var r=If;if(r&&e){var i=kt(r).hoistableStyles,a=R(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Kf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Af.get(a))&&Qf(e,n);var c=o=r.createElement(`link`);At(c),Xd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Zf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Uf(e,t){Nf.X(e,t);var n=If;if(n&&e){var r=kt(n).hoistableScripts,i=Yf(e),a=r.get(i);a||(a=n.querySelector(Xf(i)),a||(e=m({src:e,async:!0},t),(t=Af.get(i))&&$f(e,t),a=n.createElement(`script`),At(a),Xd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Wf(e,t){Nf.M(e,t);var n=If;if(n&&e){var r=kt(n).hoistableScripts,i=Yf(e),a=r.get(i);a||(a=n.querySelector(Xf(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=Af.get(i))&&$f(e,t),a=n.createElement(`script`),At(a),Xd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Gf(e,t,n,r){var a=(a=ye.current)?Mf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=R(n.href),n=kt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=R(n.href);var o=kt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Kf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),Af.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Af.set(e,n),o||Jf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Yf(n),n=kt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function R(e){return`href="`+Yt(e)+`"`}function Kf(e){return`link[rel="stylesheet"][`+e+`]`}function qf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Jf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Xd(t,`link`,n),At(t),e.head.appendChild(t))}function Yf(e){return`[src="`+Yt(e)+`"]`}function Xf(e){return`script[async]`+e}function z(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Yt(n.href)+`"]`);if(r)return t.instance=r,At(r),r;var a=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),At(r),Xd(r,`style`,a),Zf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=R(n.href);var o=e.querySelector(Kf(a));if(o)return t.state.loading|=4,t.instance=o,At(o),o;r=qf(n),(a=Af.get(a))&&Qf(r,a),o=(e.ownerDocument||e).createElement(`link`),At(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Xd(o,`link`,r),t.state.loading|=4,Zf(o,n.precedence,e),t.instance=o;case`script`:return o=Yf(n.src),(a=e.querySelector(Xf(o)))?(t.instance=a,At(a),a):(r=n,(a=Af.get(o))&&(r=m({},n),$f(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),At(a),Xd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Zf(r,n.precedence,e));return t.instance}function Zf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Qf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function $f(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var ep=null;function tp(e,t,n){if(ep===null){var r=new Map,i=ep=new Map;i.set(n,r)}else i=ep,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[wt]||a[_t]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function np(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function rp(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function ip(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function ap(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=R(r.href),a=t.querySelector(Kf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=cp.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,At(a);return}a=t.ownerDocument||t,r=qf(r),(i=Af.get(i))&&Qf(r,i),a=a.createElement(`link`),At(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Xd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=cp.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var op=0;function sp(e,t){return e.stylesheets&&e.count===0&&up(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&up(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&op===0&&(op=62500*$d());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&up(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>op?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function cp(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)up(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var lp=null;function up(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,lp=new Map,t.forEach(dp,e),lp=null,cp.call(e))}function dp(e,t){if(!(t.state.loading&4)){var n=lp.get(e);if(n)var r=n.get(null);else{n=new Map,lp.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=cp.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var fp={$$typeof:te,Provider:null,Consumer:null,_currentValue:de,_currentValue2:de,_threadCount:0};function pp(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ot(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ot(0),this.hiddenUpdates=ot(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function mp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new pp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=hi(3,null,null,t),e.current=a,a.stateNode=e,t=ha(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Ja(a),e}function hp(e){return e?(e=pi,e):pi}function gp(e,t,n,r,i,a){i=hp(i),r.context===null?r.context=i:r.pendingContext=i,r=Xa(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Za(e,r,t),n!==null&&(Ou(n,e,t),Qa(n,e,t))}function _p(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function vp(e,t){_p(e,t),(e=e.alternate)&&_p(e,t)}function yp(e){if(e.tag===13||e.tag===31){var t=ui(e,67108864);t!==null&&Ou(t,e,67108864),vp(e,67108864)}}function bp(e){if(e.tag===13||e.tag===31){var t=Eu();t=ft(t);var n=ui(e,t);n!==null&&Ou(n,e,t),vp(e,t)}}var xp=!0;function Sp(e,t,n,r){var i=T.T;T.T=null;var a=E.p;try{E.p=2,wp(e,t,n,r)}finally{E.p=a,T.T=i}}function Cp(e,t,n,r){var i=T.T;T.T=null;var a=E.p;try{E.p=8,wp(e,t,n,r)}finally{E.p=a,T.T=i}}function wp(e,t,n,r){if(xp){var i=Tp(r);if(i===null)zd(e,t,r,Ep,n),Lp(e,r);else if(zp(i,e,t,n,r))r.stopPropagation();else if(Lp(e,r),t&4&&-1<Ip.indexOf(e)){for(;i!==null;){var a=Dt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=tt(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Je(o);s.entanglements[1]|=c,o&=~c}_d(a),!(Xl&6)&&(mu=Ie()+500,vd(0,!1))}}break;case 31:case 13:s=ui(a,2),s!==null&&Ou(s,a,2),Nu(),vp(a,2)}if(a=Tp(r),a===null&&zd(e,t,r,Ep,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else zd(e,t,r,null,n)}}function Tp(e){return e=pn(e),Dp(e)}var Ep=null;function Dp(e){if(Ep=null,e=Et(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ep=e,null}function Op(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Le()){case Re:return 2;case ze:return 8;case Be:case Ve:return 32;case He:return 268435456;default:return 32}default:return 32}}var kp=!1,Ap=null,jp=null,Mp=null,Np=new Map,Pp=new Map,Fp=[],Ip=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Lp(e,t){switch(e){case`focusin`:case`focusout`:Ap=null;break;case`dragenter`:case`dragleave`:jp=null;break;case`mouseover`:case`mouseout`:Mp=null;break;case`pointerover`:case`pointerout`:Np.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Pp.delete(t.pointerId)}}function Rp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Dt(t),t!==null&&yp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function zp(e,t,n,r,i){switch(t){case`focusin`:return Ap=Rp(Ap,e,t,n,r,i),!0;case`dragenter`:return jp=Rp(jp,e,t,n,r,i),!0;case`mouseover`:return Mp=Rp(Mp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Np.set(a,Rp(Np.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Pp.set(a,Rp(Pp.get(a)||null,e,t,n,r,i)),!0}return!1}function Bp(e){var t=Et(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,ht(e.priority,function(){bp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,ht(e.priority,function(){bp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Vp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Tp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);fn=r,n.target.dispatchEvent(r),fn=null}else return t=Dt(n),t!==null&&yp(t),e.blockedOn=n,!1;t.shift()}return!0}function Hp(e,t,n){Vp(e)&&n.delete(t)}function Up(){kp=!1,Ap!==null&&Vp(Ap)&&(Ap=null),jp!==null&&Vp(jp)&&(jp=null),Mp!==null&&Vp(Mp)&&(Mp=null),Np.forEach(Hp),Pp.forEach(Hp)}function Wp(e,n){e.blockedOn===n&&(e.blockedOn=null,kp||(kp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Up)))}var Gp=null;function Kp(e){Gp!==e&&(Gp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Gp===e&&(Gp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Dp(r||n)===null)continue;break}var a=Dt(n);a!==null&&(e.splice(t,3),t-=3,Fs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function qp(e){function t(t){return Wp(t,e)}Ap!==null&&Wp(Ap,e),jp!==null&&Wp(jp,e),Mp!==null&&Wp(Mp,e),Np.forEach(t),Pp.forEach(t);for(var n=0;n<Fp.length;n++){var r=Fp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Fp.length&&(n=Fp[0],n.blockedOn===null);)Bp(n),n.blockedOn===null&&Fp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[vt]||null;if(typeof a==`function`)o||Kp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[vt]||null)s=o.formAction;else if(Dp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Kp(n)}}}function Jp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Yp(e){this._internalRoot=e}Xp.prototype.render=Yp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;gp(n,Eu(),e,t,null,null)},Xp.prototype.unmount=Yp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;gp(e.current,2,null,e,null,null),Nu(),t[yt]=null}};function Xp(e){this._internalRoot=e}Xp.prototype.unstable_scheduleHydration=function(e){if(e){var t=mt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Fp.length&&t!==0&&t<Fp[n].priority;n++);Fp.splice(n,0,e),n===0&&Bp(e)}};var Zp=n.version;if(Zp!==`19.2.4`)throw Error(i(527,Zp,`19.2.4`));E.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var Qp={bundleType:0,version:`19.2.4`,rendererPackageName:`react-dom`,currentDispatcherRef:T,reconcilerVersion:`19.2.4`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var $p=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$p.isDisabled&&$p.supportsFiber)try{Ge=$p.inject(Qp),Ke=$p}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=ic,s=ac,c=oc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=mp(e,1,!1,null,null,n,r,null,o,s,c,Jp),e[yt]=t.current,Ld(e),new Yp(t)}})),_=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=g()})),v=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},y=(e=>e?v(e):v),b=l(p(),1),x=e=>e;function ee(e,t=x){let n=b.useSyncExternalStore(e.subscribe,b.useCallback(()=>t(e.getState()),[e,t]),b.useCallback(()=>t(e.getInitialState()),[e,t]));return b.useDebugValue(n),n}var te=e=>{let t=y(e),n=e=>ee(t,e);return Object.assign(n,t),n},S=(e=>e?te(e):te),C=l(_(),1);function ne(e,t){return typeof t==`function`?t(e):t}var w=S()(e=>({sidebarOpen:!0,mobileSidebarOpen:!1,mobileActionsOpen:!1,workspacePanelOpen:!1,workspacePanelWidth:820,workspacePanelFullscreen:!1,input:``,attachments:[],previewAttachment:null,previewImageSize:null,queuedDrafts:[],toasts:[],toggleSidebar:()=>e(e=>({sidebarOpen:!e.sidebarOpen})),setSidebarOpen:t=>e({sidebarOpen:t}),toggleMobileSidebar:()=>e(e=>({mobileSidebarOpen:!e.mobileSidebarOpen})),setMobileSidebarOpen:t=>e({mobileSidebarOpen:t}),toggleMobileActions:()=>e(e=>({mobileActionsOpen:!e.mobileActionsOpen})),setMobileActionsOpen:t=>e({mobileActionsOpen:t}),setWorkspacePanelOpen:t=>e({workspacePanelOpen:t}),setWorkspacePanelWidth:t=>e({workspacePanelWidth:t}),setWorkspacePanelFullscreen:t=>e({workspacePanelFullscreen:t}),setInput:t=>e({input:t}),setAttachments:t=>e(e=>({attachments:ne(e.attachments,t)})),setPreviewAttachment:t=>e({previewAttachment:t}),setPreviewImageSize:t=>e({previewImageSize:t}),setQueuedDrafts:t=>e(e=>({queuedDrafts:ne(e.queuedDrafts,t)})),pushToast:(t,n=`info`)=>e(e=>({toasts:[...e.toasts,{id:String(Date.now()+Math.random()),message:t,variant:n,createdAt:Date.now()}]})),dismissToast:t=>e(e=>({toasts:e.toasts.filter(e=>e.id!==t)}))})),re=[`responses`,`chat_completions`],ie=new Map([[`openclaw`,`OpenClaw`],[`hermes`,`Hermes`]]);function ae(e){return String(e||``).trim().toLowerCase()}function oe(...e){for(let t of e){let e=ae(t);if(e)return e}return``}function se(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function ce(e){if(!Array.isArray(e))return re;let t=e.filter(e=>e===`responses`||e===`chat_completions`);return t.length>0?t:re}function le(e,t){return typeof e==`boolean`?e:t}function ue(e){return Array.isArray(e)?e.map(e=>se(e)).filter(e=>typeof e.name==`string`&&e.name.trim()).map(e=>{let t={...e,name:e.name.trim(),group:typeof e.group==`string`?e.group:``,risk_level:typeof e.risk_level==`string`?e.risk_level:`low`,requires_approval:!!e.requires_approval,side_effects:Array.isArray(e.side_effects)?e.side_effects.filter(e=>typeof e==`string`):[],enabled:le(e.enabled,!0)};return typeof e.description==`string`&&(t.description=e.description),t}):[]}function T(e){let t=se(e),n=Array.isArray(t.Modes)?t.Modes.filter(e=>[`ask`,`risk`,`full`].includes(e)):[`ask`,`risk`,`full`],r=n.length>0?[...new Set(n)]:[`ask`,`risk`,`full`];return{Modes:r,DefaultMode:r.includes(t.DefaultMode)?t.DefaultMode:`risk`,RuntimeOverride:le(t.RuntimeOverride,!0)}}function E(e){return Array.isArray(e)?e.flatMap(e=>{let t=se(e),n=String(t.Protocol||``).trim().toLowerCase(),r=String(t.Endpoint||``).trim();if(![`ag-ui`,`responses`].includes(n)||!r.startsWith(`/`))return[];let i=se(t.Capabilities);return[{Protocol:n,Runtime:String(t.Runtime||``).trim(),Endpoint:r,Version:String(t.Version||``).trim(),Capabilities:{A2UI:!!i.A2UI,Interrupt:!!i.Interrupt,Cancel:!!i.Cancel}}]}):[]}function de(e){let t=e?.Data||e||{},n=se(t.Capabilities),r=se(t.HostedRuntime),i=oe(t.Agent?.Framework,r.Framework,r.Type),a=ie.get(i)||``,o=ce(t.ApiFormats||n.HostedChat?.ApiFormats),s=i!==`openclaw`,c=!!a,l=!!a,u=se(n.HostedChat),d=se(n.NativeDashboard),f=se(n.NativeTerminal),p=se(n.RunLifecycle),m=se(t.HostedChat),h=E(u.Transports||m.Transports),g=String(u.PreferredTransport||m.PreferredTransport||`responses`).trim().toLowerCase(),_=h.some(e=>e.Protocol===g)?g:`responses`,v=le(u.Enabled,s),y=le(d.Enabled,c),b=le(f.Enabled,l),x=le(p.Enabled,v);return{...n,HostedChat:{Enabled:v,ApiFormats:ce(u.ApiFormats||o),PreferredTransport:_,Transports:h},NativeDashboard:{Enabled:y,Href:typeof d.Href==`string`?d.Href:y?`/`:null,Label:typeof d.Label==`string`?d.Label:y?`管理平台`:null},NativeTerminal:{Enabled:b,Mode:typeof f.Mode==`string`?f.Mode:b?`tui`:null,Protocol:typeof f.Protocol==`string`?f.Protocol:`ks-terminal.v1`,Path:typeof f.Path==`string`?f.Path:`/_ksadk/terminal/ws`},RunLifecycle:{Enabled:x,Resume:le(p.Resume,x),Abort:le(p.Abort,x),Checkpoints:le(p.Checkpoints,!1),CheckpointResume:le(p.CheckpointResume,!1),CheckpointResumePreview:le(p.CheckpointResumePreview,!1)},ApprovalPolicy:T(n.ApprovalPolicy),BuiltinTools:ue(n.BuiltinTools)}}function fe(e){return de({Data:{Capabilities:e}}).HostedChat.Enabled}function pe(e,t={}){let n=de({Data:{Capabilities:e}}).HostedChat,r=n.Transports.find(e=>e.Protocol===n.PreferredTransport),i=n.Transports.find(e=>e.Protocol===`responses`);return t.requireResumableRun&&i?i:r||i||{Protocol:`responses`,Runtime:`ksadk`,Endpoint:`/v1/responses`,Version:`v1`,Capabilities:{A2UI:!1,Interrupt:!1,Cancel:!1}}}var me=S()(e=>({agentId:`default-agent`,agentName:`Agent`,agentFramework:``,capabilities:de({}),apiFormats:[`responses`,`chat_completions`],accessMode:`Owner`,workspaceFiles:null,setAgentId:t=>e({agentId:t}),setAgentName:t=>e({agentName:t}),setAgentFramework:t=>e({agentFramework:t}),setCapabilities:t=>e({capabilities:t}),setApiFormats:t=>e({apiFormats:t}),setAccessMode:t=>e({accessMode:t}),setWorkspaceFiles:t=>e({workspaceFiles:t})}));function he(e,t){let n=new Map;for(let t of e)t?.id&&n.set(t.id,t);for(let e of t)e?.id&&n.set(e.id,{...n.get(e.id)||{},...e});return Array.from(n.values()).sort((e,t)=>e.id.localeCompare(t.id))}var ge=S()(e=>({availableModels:[],selectedModel:``,modelSource:``,modelCatalogLoaded:!1,thinkingMode:`auto`,upsertModels:t=>e(e=>({availableModels:he(e.availableModels,t)})),setSelectedModel:t=>e({selectedModel:t}),setModelSource:t=>e({modelSource:t}),setModelCatalogLoaded:t=>e({modelCatalogLoaded:t}),setThinkingMode:t=>e({thinkingMode:t})})),_e=`ksadk.web.permission-mode`;function ve(){try{let e=globalThis.localStorage?.getItem(_e);return e===`ask`||e===`full`||e===`risk`?e:`risk`}catch{return`risk`}}function ye(e){try{globalThis.localStorage?.setItem(_e,e)}catch{}}var be=S()(e=>({permissionMode:ve(),setPermissionMode:t=>{ye(t),e({permissionMode:t})}})),xe=e=>Object.keys(e).length>0,Se=(e,t)=>{let n={...e};return delete n[t],n},D=S()((e,t)=>({isStreaming:!1,currentRunId:``,stopRequested:!1,activity:null,sessionActivities:{},sessionStreaming:{},banner:null,lastSeqId:0,activeInvocationId:``,setStreaming:t=>e({isStreaming:t}),setBanner:t=>e({banner:t?{...t,createdAt:Date.now()}:null}),setLastSeqId:t=>e({lastSeqId:t}),setActiveInvocationId:t=>e({activeInvocationId:t}),setSessionStreaming:(t,n)=>e(e=>{let r=String(t||``);if(!r)return{isStreaming:n};let i=Se(e.sessionStreaming,r),a=n?{...i,[r]:!0}:i;return{sessionStreaming:a,isStreaming:xe(a)}}),isSessionStreaming:e=>{let n=String(e||``);return!!(n&&t().sessionStreaming[n])},getSessionActivity:e=>{let n=String(e||``);return n&&t().sessionActivities[n]||null},setCurrentRunId:t=>e({currentRunId:t}),requestStop:()=>e({stopRequested:!0}),beginActivity:t=>e({stopRequested:!1,activity:{runId:t.runId,source:t.source||`run`,status:t.status||`running`,phase:t.phase,detail:t.detail,startedAt:Date.now(),lastEventAt:Date.now(),eventCount:0}}),updateActivity:t=>e(e=>{let n=String(t.sessionId||``),r=n?e.sessionActivities[n]:e.activity,i=r?{...r,source:t.source||r.source,status:t.status||r.status,phase:t.phase||r.phase,detail:t.detail===void 0?r.detail:t.detail,lastEventAt:Date.now(),eventCount:r.eventCount+(t.countEvent===!1?0:1)}:{source:t.source||`run`,status:t.status||`running`,phase:t.phase||`正在运行`,detail:t.detail,startedAt:Date.now(),lastEventAt:Date.now(),eventCount:t.countEvent===!1?0:1};return n?{isStreaming:xe(e.sessionStreaming),sessionActivities:{...e.sessionActivities,[n]:i},activity:i}:{activity:i}}),stopActivity:t=>e(e=>({isStreaming:!1,stopRequested:!0,activity:e.activity?{...e.activity,status:`stopped`,phase:`已断开输出流`,detail:t||`前端已断开本次输出流;后台运行可稍后通过会话记录继续查看。`,lastEventAt:Date.now()}:null})),stopSessionActivity:(t,n)=>e(e=>{let r=String(t||``);if(!r)return{};let i=e.sessionActivities[r];if(!i)return{};let a={...i,status:`stopped`,phase:`已断开输出流`,detail:n||`前端已断开本次输出流;后台运行可稍后通过会话记录继续查看。`,lastEventAt:Date.now()},o={...e.sessionActivities,[r]:a},s=Se(e.sessionStreaming,r);return{isStreaming:xe(s),activity:a,sessionActivities:o,sessionStreaming:s}}),clearActivity:()=>e({activity:null}),clearSessionActivity:t=>e(e=>{let n=String(t||``);if(!n)return{};let{[n]:r,...i}=e.sessionActivities,a=Se(e.sessionStreaming,n);return{sessionActivities:i,sessionStreaming:a,isStreaming:xe(a),activity:e.activity===r?null:e.activity}}),resetRun:()=>e({isStreaming:!1,currentRunId:``,stopRequested:!1,activity:null,sessionActivities:{},sessionStreaming:{},lastSeqId:0,activeInvocationId:``})}));function Ce(e=new Set,t=[]){let n=new Set(e);for(let e of t){let t=Number(e);Number.isFinite(t)&&t>0&&n.add(t)}return new Set(Array.from(n).sort((e,t)=>e-t))}function we({sessionsLength:e=0,total:t=0,page:n=0,pageSize:r=30,loadedPages:i=new Set}={}){let a=Math.max(0,Number(t)||0),o=Math.max(0,Number(e)||0);return{total:a,page:Math.max(0,Number(n)||0),pageSize:Math.max(1,Number(r)||30),loadedPages:Ce(i),hasMore:o<a}}function Te({total:e=0,pageSize:t=30,loadedPages:n=new Set}={}){let r=Math.max(0,Number(e)||0),i=Math.max(1,Number(t)||30);if(r<=0)return null;let a=Math.ceil(r/i);for(let e=1;e<=a;e+=1)if(!n.has(e))return e;return null}function Ee(e){let t=e.UpdatedAt;if(typeof t==`string`){let e=Date.parse(t);return Number.isNaN(e)?0:e}return typeof t==`number`&&Number.isFinite(t)?t>1e11?t:t*1e3:0}var De=`ksadk.pinnedSessionIds`;function Oe(){try{let e=globalThis.localStorage?.getItem(De),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function ke(e){try{globalThis.localStorage?.setItem(De,JSON.stringify(e))}catch{}}function Ae(e,t){let n=new Set(t);return e.slice().sort((e,t)=>{let r=+!!n.has(e.SessionId),i=+!!n.has(t.SessionId);return r===i?Ee(t)-Ee(e):i-r})}function je(e,t,n){let r=new Map;for(let t of e)t?.SessionId&&r.set(t.SessionId,t);for(let e of t)e?.SessionId&&r.set(e.SessionId,{...r.get(e.SessionId)||{},...e});return Ae(Array.from(r.values()),n)}var Me=S()(e=>({sessions:[],currentSessionId:null,sessionsAgentId:``,sessionsTotal:0,sessionsPage:0,sessionsPageSize:30,loadedPages:new Set,hasMoreSessions:!1,isLoadingSessions:!0,pinnedSessionIds:Oe(),messageHistory:{},setSessions:t=>e(e=>({sessions:Ae(t,e.pinnedSessionIds)})),setCurrentSessionId:t=>e({currentSessionId:t}),upsertSessions:(t,n)=>e(e=>{let r=je(n?.replace?[]:e.sessions,t,e.pinnedSessionIds),i=n?.page??e.sessionsPage,a=n?.pageSize??e.sessionsPageSize,o=n?.total??Math.max(e.sessionsTotal,r.length),s=n?.replace?Ce(new Set,[i]):Ce(e.loadedPages,[i]),c=we({sessionsLength:r.length,total:o,page:i,pageSize:a,loadedPages:s});return{sessions:r,sessionsAgentId:n?.agentId??e.sessionsAgentId,sessionsTotal:c.total,sessionsPage:c.page,sessionsPageSize:c.pageSize,loadedPages:c.loadedPages,hasMoreSessions:c.hasMore}}),removeSession:t=>e(e=>{let n=e.sessions.filter(e=>e.SessionId!==t),r=Math.max(0,e.sessionsTotal-1);return{sessions:n,sessionsTotal:r,hasMoreSessions:we({sessionsLength:n.length,total:r,page:e.sessionsPage,pageSize:e.sessionsPageSize,loadedPages:e.loadedPages}).hasMore,pinnedSessionIds:e.pinnedSessionIds.filter(e=>e!==t)}}),setLoadingSessions:t=>e({isLoadingSessions:t}),resetSessionPagination:t=>e({sessions:[],sessionsAgentId:t,sessionsTotal:0,sessionsPage:0,loadedPages:new Set,hasMoreSessions:!1,isLoadingSessions:!1}),togglePinnedSession:t=>e(e=>{let n=new Set(e.pinnedSessionIds);n.has(t)?n.delete(t):n.add(t);let r=Array.from(n);return ke(r),{pinnedSessionIds:r,sessions:Ae(e.sessions,r)}}),setSessionMessageHistory:(t,n)=>e(e=>({messageHistory:{...e.messageHistory,[t]:{nextCursor:n.nextCursor,hasMore:n.hasMore,isLoadingInitial:!1,isLoadingOlder:n.isLoadingOlder??!1}}})),setSessionInitialMessageHistoryLoading:(t,n)=>e(e=>{let r=e.messageHistory[t];return{messageHistory:{...e.messageHistory,[t]:{nextCursor:r?.nextCursor??null,hasMore:r?.hasMore??!1,isLoadingInitial:n,isLoadingOlder:r?.isLoadingOlder??!1}}}}),setSessionMessageHistoryLoading:(t,n)=>e(e=>{let r=e.messageHistory[t];return r?{messageHistory:{...e.messageHistory,[t]:{...r,isLoadingOlder:n}}}:{}}),clearSessionMessageHistory:t=>e(e=>{if(!t)return{messageHistory:{}};let n={...e.messageHistory};return delete n[t],{messageHistory:n}})})),Ne=S()(e=>({content:null,type:`html`,visible:!1,show:(t,n=`html`)=>e({content:t,type:n,visible:!0}),hide:()=>e({visible:!1}),setContent:(t,n)=>e(e=>({content:t,type:n??e.type}))})),Pe=.28;function Fe(e,t=768){return Number(e)<=t}function Ie({isMobile:e,desktopSidebarOpen:t,mobileSidebarOpen:n}){return{desktopSidebarVisible:!e&&!!t,mobileDrawerVisible:!!(e&&n)}}function Le({isMobile:e,viewportHeight:t,desktopMaxHeight:n=160}){if(!e)return n;let r=Number(t);if(!Number.isFinite(r)||r<=0)return n;let i=Math.floor(r*Pe);return Math.max(120,Math.min(n,i))}var Re=`/_ksadk/workspace/v1/files`,ze=new Set([`.md`,`.markdown`,`.mdx`]),Be=new Set([`.pdf`]),Ve=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.svg`,`.bmp`,`.ico`]),He=new Set(`.txt,.log,.json,.yaml,.yml,.xml,.html,.css,.js,.jsx,.ts,.tsx,.py,.sh,.sql,.csv,.tsv,.toml,.ini,.env,.lock,.conf,.c,.cc,.cpp,.go,.java,.rs`.split(`,`)),Ue=new Set([`application/json`,`application/ld+json`,`application/xml`,`application/javascript`,`application/x-javascript`,`application/typescript`,`application/x-sh`,`application/x-yaml`,`application/yaml`,`text/csv`,`text/tab-separated-values`]);function We(e){let t=String(e||``).trim().replace(/\\/g,`/`);if(!t||t===`/`)return`.`;let n=[];for(let e of t.split(`/`)){let t=e.trim();if(!(!t||t===`.`)){if(t===`..`){n.length>0&&n.pop();continue}n.push(t)}}return n.length>0?n.join(`/`):`.`}function Ge(e){let t=We(e);return t===`.`?``:t.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Ke(e){let t=Ge(e);return t?`${Re}/${t}`:Re}function qe(e){let t=We(e);if(t===`.`||!t.includes(`/`))return`${Re}/`;let n=Ge(t.substring(0,t.lastIndexOf(`/`)));return n?`${Re}/${n}/`:`${Re}/`}function Je(e){return We(e)===`.`}function Ye(e){let t=We(e);return t===`.`?`/`:`/${t}`}function Xe(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n).toLowerCase():``}function Ze(e){return String(e||``).split(`;`)[0].trim().toLowerCase()}var Qe=new Set([`.html`,`.htm`]);function $e({path:e,mimeType:t}){let n=Xe(e),r=Ze(t);return r===`text/html`||Qe.has(n)?`html`:r===`text/markdown`||ze.has(n)?`markdown`:r===`application/pdf`||Be.has(n)?`pdf`:r.startsWith(`image/`)||Ve.has(n)?`image`:r.startsWith(`text/`)||Ue.has(r)||He.has(n)?`text`:`unsupported`}var et=new Set([`.txt`,`.log`,`.csv`,`.tsv`,`.env`,`.ini`,`.conf`,`.lock`]);function tt({path:e,mimeType:t}){let n=Xe(e),r=Ze(t);return Qe.has(n)||r===`text/html`?`html`:r===`text/markdown`||ze.has(n)?`markdown`:r===`application/pdf`||Be.has(n)||r.startsWith(`image/`)||Ve.has(n)?null:et.has(n)||r===`text/plain`?`text`:r.startsWith(`text/`)||Ue.has(r)||He.has(n)?`code`:null}function nt({isMobile:e}){return e?{renderMode:`sheet`,modal:!0,showOverlay:!0,preventOutsideClose:!1,side:`bottom`}:{renderMode:`inline`,modal:!1,showOverlay:!1,preventOutsideClose:!0,side:`right`}}function rt(){let e=0;return{next(t){return e+=1,{path:t,version:e}},invalidate(){e+=1},isCurrent(t){return!!t&&t.version===e}}}function it({workspaceFiles:e,accessMode:t}){if(!e?.Enabled)return!1;let n=String(t||``).trim().toLowerCase();return n===`owner`||n===`private`}var at=`ksadk:webui:selected-session:`;function ot(e){return String(e||``).trim()||`default-agent`}function st(e){if(e&&typeof e.getItem==`function`)return e;try{if(typeof window<`u`&&window.localStorage)return window.localStorage}catch{}return null}function ct(e){return`${at}${ot(e)}`}function lt(e,t){let n=st(t);if(!n)return null;try{return String(n.getItem(ct(e))||``).trim()||null}catch{return null}}function ut(e,t,n){let r=st(n);if(!r)return;let i=ct(e),a=String(t||``).trim();try{if(a){r.setItem(i,a);return}r.removeItem(i)}catch{}}function dt(e,t){if(!Array.isArray(e)||e.length===0)return null;let n=String(t||``).trim();if(n&&e.some(e=>String(e?.SessionId||``).trim()===n))return n;for(let t of e){let e=String(t?.SessionId||``).trim();if(e)return e}return null}var ft=new Map([[`openclaw`,`OpenClaw`],[`hermes`,`Hermes`]]);function pt(e){return String(e||``).trim().toLowerCase()}function mt(e){return String(e||``).trim().toLowerCase()}function ht(e){try{return new URL(`/`,e).toString()}catch{return`/`}}function gt({capability:e,agentFramework:t,accessMode:n,origin:r}){let i=pt(n);if(i!==`owner`&&i!==`private`||!e?.Enabled)return null;let a=ft.get(mt(t))||`运行时`;return{href:typeof e.Href==`string`&&e.Href?new URL(e.Href,ht(r)).toString():ht(r),label:typeof e.Label==`string`&&e.Label?e.Label:`管理平台`,title:`打开 ${a} 原生管理平台`}}var _t=new Set([`auto`,`enabled`,`disabled`]);function vt(e){let t=String(e||``).trim().toLowerCase();return _t.has(t)?t:`auto`}function yt(e){let t=vt(e);if(t===`disabled`)return{thinking:{type:`disabled`}};if(t===`enabled`)return{thinking:{type:`enabled`}}}function bt(){return typeof window>`u`?900:Math.round(window.visualViewport?.height||window.innerHeight||900)}function xt(){return typeof window>`u`?{isMobile:!1,viewportHeight:900}:{isMobile:Fe(window.innerWidth,768),viewportHeight:bt()}}function St(){let[e,t]=(0,b.useState)(()=>xt());return(0,b.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: 768px)`),n=()=>{t(xt())};n();let r=typeof e.addEventListener==`function`?(e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)):(e.addListener(n),()=>e.removeListener(n));return window.addEventListener(`resize`,n),window.visualViewport?.addEventListener(`resize`,n),()=>{r(),window.removeEventListener(`resize`,n),window.visualViewport?.removeEventListener(`resize`,n)}},[]),e}var Ct=class extends Error{code;detail;constructor(e,t,n){super(t),this.name=`ApiError`,this.code=e,this.detail=n}},wt=class extends Error{constructor(e=`请求已取消`){super(e),this.name=`CancelledError`}},Tt=`/agentengine/api/v1`;async function Et(e){let t;try{t=await e.json()}catch{throw new Ct(-2,`响应格式异常`)}if(!e.ok)throw new Ct(e.status,t?.Message||`HTTP ${e.status}`,t);if(t?.Code!==void 0&&t.Code!==0)throw new Ct(t.Code,t.Message||`请求失败`,t);return t.Data}function Dt(e){throw e instanceof DOMException&&e.name===`AbortError`?new wt:e}async function Ot(e,t,n){let r;try{r=await fetch(`${Tt}/${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t),signal:n?.signal})}catch(e){throw Dt(e)}return Et(r)}async function kt(e,t,n){let r;try{r=await fetch(`${Tt}/${e}`,{method:`POST`,body:t,signal:n?.signal})}catch(e){throw Dt(e)}return Et(r)}async function At(e,t,n){let r=new URLSearchParams(t).toString(),i=r?`${Tt}/${e}?${r}`:`${Tt}/${e}`,a;try{a=await fetch(i,{signal:n?.signal})}catch(e){throw Dt(e)}if(!a.ok)throw new Ct(a.status,`资源获取失败: ${a.statusText}`);try{return n?.asText?await a.text():await a.blob()}catch{throw new Ct(-3,`文件读取失败`)}}async function jt(e,t,n){let r;try{r=await fetch(`${Tt}/${e}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`text/event-stream`},body:JSON.stringify(t),signal:n?.signal})}catch(e){throw Dt(e)}if(!r.ok)throw new Ct(r.status,`流式请求失败: ${r.statusText}`);if(!r.body)throw new Ct(-1,`无法获取响应流`);return r.body}async function Mt(e,t,n){let r=new URLSearchParams(t).toString(),i=r?`${Tt}/${e}?${r}`:`${Tt}/${e}`,a;try{a=await fetch(i,{headers:{Accept:`text/event-stream`},signal:n?.signal})}catch(e){throw Dt(e)}if(!a.ok)throw new Ct(a.status,`流式订阅失败: ${a.statusText}`);if(!a.body)throw new Ct(-1,`无法获取响应流`);return a.body}async function Nt(){return Ot(`GetAgentUiBootstrap`,{})}async function Pt(e){return Ot(`ListAgentModels`,{AgentId:e})}function Ft(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`]}async function It(e){try{let t=await Pt(e),n=t?.Models;Array.isArray(n)&&ge.getState().upsertModels(n);let r=t;r?.Current&&!ge.getState().selectedModel&&ge.getState().setSelectedModel(String(r.Current)),r?.Source&&ge.getState().setModelSource(String(r.Source))}catch(e){console.error(`Failed to fetch models:`,e)}finally{ge.getState().setModelCatalogLoaded(!0)}}function Lt(e){(0,b.useEffect)(()=>{(async()=>{try{let t=await Nt(),n=t,r=n?.Agent,i=String(r?.AgentId||`default-agent`);if(me.getState().setAgentId(i),r?.Name){let e=String(r.Name);me.getState().setAgentName(e),document.title=e}let a=String(r?.Framework||``).trim().toLowerCase();me.getState().setAgentFramework(a);let o=de(t);me.getState().setCapabilities(o),me.getState().setApiFormats(Ft(o.HostedChat.ApiFormats)),me.getState().setAccessMode(String(n?.AccessMode||`Owner`));let s=o.WorkspaceFiles&&n?.WorkspaceFiles?n.WorkspaceFiles:null;me.getState().setWorkspaceFiles(s),s||w.getState().setWorkspacePanelOpen(!1),fe(o)&&e.fetchSessions(i,lt(i));let c=n?.Model;c?.id&&(ge.getState().setSelectedModel(c.id),ge.getState().upsertModels([c]),ge.getState().setModelSource(c.source||``)),It(i)}catch(t){console.error(`Failed to fetch bootstrap:`,t),me.getState().setCapabilities(de({Data:{Agent:{Framework:``},ApiFormats:[`responses`,`chat_completions`],Capabilities:{}}})),e.fetchSessions(`default-agent`,lt(`default-agent`)),It(`default-agent`)}})()},[])}var Rt=S()(e=>({messages:[],setMessages:t=>e({messages:t}),patchMessages:t=>e(e=>({messages:t(e.messages)}))}));function zt(){return{toolNames:new Map,toolArguments:new Map,callIds:new Map,currentResponseId:``}}function Bt(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 Vt(e){return e==null?``:typeof e==`string`?e:typeof e==`object`?JSON.stringify(e,null,2):String(e)}function Ht(...e){for(let t of e){let e=Bt(t);if(e)return e}return``}function Ut(e,t){return String(e?.id||e?.item_id||e?.call_id||t?.item_id||t?.call_id||t?.output_index||``)}function Wt(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 Gt(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 Kt(e){if(!e||typeof e!=`object`)return``;let t=Bt(e.content);return Ht(e.output_text,e.text,e.summary_text,e.summary,e.delta,t)}function qt(e){let t=e?.response&&typeof e.response==`object`?e.response:e,n=Ht(t?.output_text,t?.text);if(n)return n;let r=Array.isArray(t?.output)?t.output:[];for(let e of r){let t=Kt(e);if(t)return t}return``}function Jt(e){let t=e?.response&&typeof e.response==`object`?e.response:e;return Array.isArray(t?.output)?t.output:[]}function Yt(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 Xt({data:e,state:t,status:n}){let r=e?.item||e?.output_item||e||{},i=String(r.type||``).trim(),a=Ut(r,e);if(i===`function_call`){let e=Gt(t,a,r),i=Vt(r.arguments??r.args??r.input);return Wt(t,a,r,e,i),[{type:`tool_upsert`,name:e,args:i,status:n}]}if(i===`function_call_output`)return[{type:`tool_result`,name:Gt(t,a,r),output:Vt(r.output??r.result??r.content)}];if(i===`mcp_approval_request`)return[{type:`tool_upsert`,name:String(r.name||`approval`),args:Vt(r.arguments??r.args),status:`paused`,approvalRequestId:String(r.id||r.approval_request_id||``),previousResponseId:String(e?.response_id||t.currentResponseId||``),serverLabel:String(r.server_label||``)}];if(i===`reasoning`||i===`reasoning_summary`||i===`reasoning_summary_text`){let e=Kt(r);return e?[{type:`reasoning_delta`,text:e}]:[]}if(i===`message`){let e=Kt(r);return e?[{type:n===`completed`?`text_final`:`text_delta`,text:e}]:[]}return[]}function Zt({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:Vt(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:Vt(t?.output??t?.result)}];if(r===`response.output_item.added`)return Xt({data:t,state:n,status:`running`});if(r===`response.output_item.done`)return Xt({data:t,state:n,status:`completed`});if(r===`response.function_call_arguments.delta`){let e=String(t?.item_id||t?.call_id||``),r=Gt(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=Gt(n,e,t),i=Vt(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=Ht(t?.delta,t?.text);return e?[{type:`reasoning_delta`,text:e}]:[]}if(r===`response.output_text.delta`){let e=Ht(t?.delta,t?.text);return e?[{type:`text_delta`,text:e}]:[]}if(r===`response.output_text.done`){let e=Ht(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||``),n=Ht(t?.delta?.text,t?.delta,t?.text);return n?e.includes(`reasoning`)?[{type:`reasoning_delta`,text:n}]:[{type:`text_delta`,text:n}]:[]}if(r===`response.completed`){let e=qt(t),r=Jt(t).flatMap(e=>Xt({data:{...t,item:e},state:n,status:`completed`})),i=r.some(e=>e.type===`text_final`);return[...r,...e&&!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=Yt(t?.interrupt_info),r=String(e.approval_request_id||e.id||``),i=String(t?.response_id||n.currentResponseId||``),a=e.approval_requests&&typeof e.approval_requests==`object`?e.approval_requests:e,o=Array.isArray(a.action_requests)?a.action_requests:[];return o.length>0?o.map(e=>({type:`tool_upsert`,name:String(e?.name||`tool`),args:JSON.stringify(e?.args??{}),status:`paused`,approvalRequestId:r,previousResponseId:i})):[{type:`approval_request`,approvalRequestId:r,previousResponseId:i}]}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 Qt=class{id=`responses`;createState(){return zt()}parse(e,t){return Zt({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 $t(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 en(e){return e&&typeof e==`object`?e:{}}function tn(e){let t=en(e).choices,n=en(Array.isArray(t)?t[0]:null),r=en(n.delta),i=en(n.message);return{content:$t(r.content),reasoning:$t(r.reasoning_content),finalText:$t(i.content)}}var nn=class{id=`chat_completions`;createState(){return{}}parse(e){let t=e.data;if(typeof t!=`object`||!t)return[];let n=tn(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}},rn=new Map;rn.set(`responses`,new Qt),rn.set(`chat_completions`,new nn);function an(e){return rn.get(e)||rn.get(`responses`)}function on(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 sn(e){let t=[],n=e.trim();if(!n)return t;let r=n.split(`
|
|
11
|
-
`);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(`
|
|
12
|
-
`).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 cn(e){let t=e.split(`
|
|
13
|
-
|
|
14
|
-
`);return{chunks:t,remainder:t.pop()||``}}function ln(e){return e instanceof Error?e.message:String(e)}var un=l(h(),1),dn=1280;function fn(e){let{apiFormats:t}=e;return t.includes(`responses`)?`responses`:t.includes(`chat_completions`)?`chat_completions`:`responses`}function pn(e,t,n){let r=Math.min(dn,Math.max(420,t-n-360));return Math.min(Math.max(e,420),r)}var mn=[];for(let e=0;e<256;++e)mn.push((e+256).toString(16).slice(1));function hn(e,t=0){return(mn[e[t+0]]+mn[e[t+1]]+mn[e[t+2]]+mn[e[t+3]]+`-`+mn[e[t+4]]+mn[e[t+5]]+`-`+mn[e[t+6]]+mn[e[t+7]]+`-`+mn[e[t+8]]+mn[e[t+9]]+`-`+mn[e[t+10]]+mn[e[t+11]]+mn[e[t+12]]+mn[e[t+13]]+mn[e[t+14]]+mn[e[t+15]]).toLowerCase()}var gn,_n=new Uint8Array(16);function vn(){if(!gn){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);gn=crypto.getRandomValues.bind(crypto)}return gn(_n)}var yn={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function bn(e,t,n){if(yn.randomUUID&&!t&&!e)return yn.randomUUID();e||={};let r=e.random??e.rng?.()??vn();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return hn(r)}var xn;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(xn||={});var Sn;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Sn||={});var O=xn.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Cn=e=>{switch(typeof e){case`undefined`:return O.undefined;case`string`:return O.string;case`number`:return Number.isNaN(e)?O.nan:O.number;case`boolean`:return O.boolean;case`function`:return O.function;case`bigint`:return O.bigint;case`symbol`:return O.symbol;case`object`:return Array.isArray(e)?O.array:e===null?O.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?O.promise:typeof Map<`u`&&e instanceof Map?O.map:typeof Set<`u`&&e instanceof Set?O.set:typeof Date<`u`&&e instanceof Date?O.date:O.object;default:return O.unknown}},k=xn.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),wn=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,xn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};wn.create=e=>new wn(e);var Tn=(e,t)=>{let n;switch(e.code){case k.invalid_type:n=e.received===O.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case k.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,xn.jsonStringifyReplacer)}`;break;case k.unrecognized_keys:n=`Unrecognized key(s) in object: ${xn.joinValues(e.keys,`, `)}`;break;case k.invalid_union:n=`Invalid input`;break;case k.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${xn.joinValues(e.options)}`;break;case k.invalid_enum_value:n=`Invalid enum value. Expected ${xn.joinValues(e.options)}, received '${e.received}'`;break;case k.invalid_arguments:n=`Invalid function arguments`;break;case k.invalid_return_type:n=`Invalid function return type`;break;case k.invalid_date:n=`Invalid date`;break;case k.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:xn.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case k.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case k.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case k.custom:n=`Invalid input`;break;case k.invalid_intersection_types:n=`Intersection results could not be merged`;break;case k.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case k.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,xn.assertNever(e)}return{message:n}},En=Tn;function Dn(){return En}var On=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function A(e,t){let n=Dn(),r=On({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Tn?void 0:Tn].filter(e=>!!e)});e.common.issues.push(r)}var kn=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return An;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return An;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},An=Object.freeze({status:`aborted`}),jn=e=>({status:`dirty`,value:e}),Mn=e=>({status:`valid`,value:e}),Nn=e=>e.status===`aborted`,Pn=e=>e.status===`dirty`,Fn=e=>e.status===`valid`,In=e=>typeof Promise<`u`&&e instanceof Promise,Ln;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(Ln||={});var Rn=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},zn=(e,t)=>{if(Fn(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new wn(e.common.issues);return this._error=t,this._error}}};function Bn(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var Vn=class{get description(){return this._def.description}_getType(e){return Cn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Cn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new kn,ctx:{common:e.parent.common,data:e.data,parsedType:Cn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(In(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Cn(e)};return zn(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Cn(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Fn(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Fn(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Cn(e)},r=this._parse({data:e,path:n.path,parent:n});return zn(n,await(In(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:k.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Wr({schema:this,typeName:$r.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return Gr.create(this,this._def)}nullable(){return Kr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Tr.create(this)}promise(){return Ur.create(this,this._def)}or(e){return Or.create([this,e],this._def)}and(e){return Mr.create(this,e,this._def)}transform(e){return new Wr({...Bn(this._def),schema:this,typeName:$r.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new qr({...Bn(this._def),innerType:this,defaultValue:t,typeName:$r.ZodDefault})}brand(){return new Xr({typeName:$r.ZodBranded,type:this,...Bn(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Jr({...Bn(this._def),innerType:this,catchValue:t,typeName:$r.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Zr.create(this,e)}readonly(){return Qr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Hn=/^c[^\s-]{8,}$/i,Un=/^[0-9a-z]+$/,Wn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Gn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Kn=/^[a-z0-9_-]{21}$/i,qn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Jn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Yn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Xn=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,Zn,Qn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,$n=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,er=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,tr=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,rr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ir=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,ar=RegExp(`^${ir}$`);function or(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function sr(e){return RegExp(`^${or(e)}$`)}function cr(e){let t=`${ir}T${or(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function lr(e,t){return!!((t===`v4`||!t)&&Qn.test(e)||(t===`v6`||!t)&&er.test(e))}function ur(e,t){if(!qn.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function dr(e,t){return!!((t===`v4`||!t)&&$n.test(e)||(t===`v6`||!t)&&tr.test(e))}var fr=class e extends Vn{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==O.string){let t=this._getOrReturnCtx(e);return A(t,{code:k.invalid_type,expected:O.string,received:t.parsedType}),An}let t=new kn,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),A(n,{code:k.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),A(n,{code:k.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?A(n,{code:k.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&A(n,{code:k.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Yn.test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`email`,code:k.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)Zn||=new RegExp(Xn,`u`),Zn.test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`emoji`,code:k.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Gn.test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`uuid`,code:k.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Kn.test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`nanoid`,code:k.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Hn.test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`cuid`,code:k.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Un.test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`cuid2`,code:k.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Wn.test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`ulid`,code:k.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),A(n,{validation:`url`,code:k.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`regex`,code:k.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),A(n,{code:k.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),A(n,{code:k.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),A(n,{code:k.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?cr(r).test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{code:k.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?ar.test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{code:k.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?sr(r).test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{code:k.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Jn.test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`duration`,code:k.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?lr(e.data,r.version)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`ip`,code:k.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?ur(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`jwt`,code:k.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?dr(e.data,r.version)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`cidr`,code:k.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?nr.test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`base64`,code:k.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?rr.test(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{validation:`base64url`,code:k.invalid_string,message:r.message}),t.dirty()):xn.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:k.invalid_string,...Ln.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...Ln.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...Ln.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...Ln.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...Ln.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...Ln.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...Ln.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...Ln.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...Ln.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...Ln.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...Ln.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...Ln.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...Ln.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...Ln.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Ln.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...Ln.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...Ln.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...Ln.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...Ln.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...Ln.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...Ln.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...Ln.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...Ln.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...Ln.errToObj(t)})}nonempty(e){return this.min(1,Ln.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};fr.create=e=>new fr({checks:[],typeName:$r.ZodString,coerce:e?.coerce??!1,...Bn(e)});function pr(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var mr=class e extends Vn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==O.number){let t=this._getOrReturnCtx(e);return A(t,{code:k.invalid_type,expected:O.number,received:t.parsedType}),An}let t,n=new kn;for(let r of this._def.checks)r.kind===`int`?xn.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),A(t,{code:k.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),A(t,{code:k.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),A(t,{code:k.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?pr(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),A(t,{code:k.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),A(t,{code:k.not_finite,message:r.message}),n.dirty()):xn.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Ln.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Ln.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Ln.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Ln.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Ln.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:Ln.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:Ln.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:Ln.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:Ln.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:Ln.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Ln.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:Ln.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:Ln.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:Ln.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&xn.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};mr.create=e=>new mr({checks:[],typeName:$r.ZodNumber,coerce:e?.coerce||!1,...Bn(e)});var hr=class e extends Vn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==O.bigint)return this._getInvalidInput(e);let t,n=new kn;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),A(t,{code:k.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),A(t,{code:k.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),A(t,{code:k.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):xn.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return A(t,{code:k.invalid_type,expected:O.bigint,received:t.parsedType}),An}gte(e,t){return this.setLimit(`min`,e,!0,Ln.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Ln.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Ln.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Ln.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Ln.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:Ln.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:Ln.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:Ln.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:Ln.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Ln.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};hr.create=e=>new hr({checks:[],typeName:$r.ZodBigInt,coerce:e?.coerce??!1,...Bn(e)});var gr=class extends Vn{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==O.boolean){let t=this._getOrReturnCtx(e);return A(t,{code:k.invalid_type,expected:O.boolean,received:t.parsedType}),An}return Mn(e.data)}};gr.create=e=>new gr({typeName:$r.ZodBoolean,coerce:e?.coerce||!1,...Bn(e)});var _r=class e extends Vn{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==O.date){let t=this._getOrReturnCtx(e);return A(t,{code:k.invalid_type,expected:O.date,received:t.parsedType}),An}if(Number.isNaN(e.data.getTime()))return A(this._getOrReturnCtx(e),{code:k.invalid_date}),An;let t=new kn,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),A(n,{code:k.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),A(n,{code:k.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):xn.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:Ln.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:Ln.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};_r.create=e=>new _r({checks:[],coerce:e?.coerce||!1,typeName:$r.ZodDate,...Bn(e)});var vr=class extends Vn{_parse(e){if(this._getType(e)!==O.symbol){let t=this._getOrReturnCtx(e);return A(t,{code:k.invalid_type,expected:O.symbol,received:t.parsedType}),An}return Mn(e.data)}};vr.create=e=>new vr({typeName:$r.ZodSymbol,...Bn(e)});var yr=class extends Vn{_parse(e){if(this._getType(e)!==O.undefined){let t=this._getOrReturnCtx(e);return A(t,{code:k.invalid_type,expected:O.undefined,received:t.parsedType}),An}return Mn(e.data)}};yr.create=e=>new yr({typeName:$r.ZodUndefined,...Bn(e)});var br=class extends Vn{_parse(e){if(this._getType(e)!==O.null){let t=this._getOrReturnCtx(e);return A(t,{code:k.invalid_type,expected:O.null,received:t.parsedType}),An}return Mn(e.data)}};br.create=e=>new br({typeName:$r.ZodNull,...Bn(e)});var xr=class extends Vn{constructor(){super(...arguments),this._any=!0}_parse(e){return Mn(e.data)}};xr.create=e=>new xr({typeName:$r.ZodAny,...Bn(e)});var Sr=class extends Vn{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Mn(e.data)}};Sr.create=e=>new Sr({typeName:$r.ZodUnknown,...Bn(e)});var Cr=class extends Vn{_parse(e){let t=this._getOrReturnCtx(e);return A(t,{code:k.invalid_type,expected:O.never,received:t.parsedType}),An}};Cr.create=e=>new Cr({typeName:$r.ZodNever,...Bn(e)});var wr=class extends Vn{_parse(e){if(this._getType(e)!==O.undefined){let t=this._getOrReturnCtx(e);return A(t,{code:k.invalid_type,expected:O.void,received:t.parsedType}),An}return Mn(e.data)}};wr.create=e=>new wr({typeName:$r.ZodVoid,...Bn(e)});var Tr=class e extends Vn{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==O.array)return A(t,{code:k.invalid_type,expected:O.array,received:t.parsedType}),An;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(A(t,{code:e?k.too_big:k.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(A(t,{code:k.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(A(t,{code:k.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new Rn(t,e,t.path,n)))).then(e=>kn.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Rn(t,e,t.path,n)));return kn.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:Ln.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:Ln.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:Ln.toString(n)}})}nonempty(e){return this.min(1,e)}};Tr.create=(e,t)=>new Tr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:$r.ZodArray,...Bn(t)});function Er(e){if(e instanceof Dr){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Gr.create(Er(r))}return new Dr({...e._def,shape:()=>t})}else if(e instanceof Tr)return new Tr({...e._def,type:Er(e.element)});else if(e instanceof Gr)return Gr.create(Er(e.unwrap()));else if(e instanceof Kr)return Kr.create(Er(e.unwrap()));else if(e instanceof Nr)return Nr.create(e.items.map(e=>Er(e)));else return e}var Dr=class e extends Vn{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=xn.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==O.object){let t=this._getOrReturnCtx(e);return A(t,{code:k.invalid_type,expected:O.object,received:t.parsedType}),An}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Cr&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new Rn(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Cr){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(A(n,{code:k.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new Rn(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>kn.mergeObjectSync(t,e)):kn.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return Ln.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:Ln.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:$r.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of xn.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of xn.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Er(this)}partial(t){let n={};for(let e of xn.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of xn.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Gr;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Br(xn.objectKeys(this.shape))}};Dr.create=(e,t)=>new Dr({shape:()=>e,unknownKeys:`strip`,catchall:Cr.create(),typeName:$r.ZodObject,...Bn(t)}),Dr.strictCreate=(e,t)=>new Dr({shape:()=>e,unknownKeys:`strict`,catchall:Cr.create(),typeName:$r.ZodObject,...Bn(t)}),Dr.lazycreate=(e,t)=>new Dr({shape:e,unknownKeys:`strip`,catchall:Cr.create(),typeName:$r.ZodObject,...Bn(t)});var Or=class extends Vn{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new wn(e.ctx.common.issues));return A(t,{code:k.invalid_union,unionErrors:n}),An}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new wn(e));return A(t,{code:k.invalid_union,unionErrors:i}),An}}get options(){return this._def.options}};Or.create=(e,t)=>new Or({options:e,typeName:$r.ZodUnion,...Bn(t)});var kr=e=>e instanceof Rr?kr(e.schema):e instanceof Wr?kr(e.innerType()):e instanceof zr?[e.value]:e instanceof Vr?e.options:e instanceof Hr?xn.objectValues(e.enum):e instanceof qr?kr(e._def.innerType):e instanceof yr?[void 0]:e instanceof br?[null]:e instanceof Gr?[void 0,...kr(e.unwrap())]:e instanceof Kr?[null,...kr(e.unwrap())]:e instanceof Xr||e instanceof Qr?kr(e.unwrap()):e instanceof Jr?kr(e._def.innerType):[],Ar=class e extends Vn{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.object)return A(t,{code:k.invalid_type,expected:O.object,received:t.parsedType}),An;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(A(t,{code:k.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),An)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=kr(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:$r.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Bn(r)})}};function jr(e,t){let n=Cn(e),r=Cn(t);if(e===t)return{valid:!0,data:e};if(n===O.object&&r===O.object){let n=xn.objectKeys(t),r=xn.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=jr(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===O.array&&r===O.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=jr(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===O.date&&r===O.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Mr=class extends Vn{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Nn(e)||Nn(r))return An;let i=jr(e.value,r.value);return i.valid?((Pn(e)||Pn(r))&&t.dirty(),{status:t.value,value:i.data}):(A(n,{code:k.invalid_intersection_types}),An)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Mr.create=(e,t,n)=>new Mr({left:e,right:t,typeName:$r.ZodIntersection,...Bn(n)});var Nr=class e extends Vn{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==O.array)return A(n,{code:k.invalid_type,expected:O.array,received:n.parsedType}),An;if(n.data.length<this._def.items.length)return A(n,{code:k.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),An;!this._def.rest&&n.data.length>this._def.items.length&&(A(n,{code:k.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new Rn(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>kn.mergeArray(t,e)):kn.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Nr.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Nr({items:e,typeName:$r.ZodTuple,rest:null,...Bn(t)})};var Pr=class e extends Vn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==O.object)return A(n,{code:k.invalid_type,expected:O.object,received:n.parsedType}),An;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Rn(n,e,n.path,e)),value:a._parse(new Rn(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?kn.mergeObjectAsync(t,r):kn.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Vn?new e({keyType:t,valueType:n,typeName:$r.ZodRecord,...Bn(r)}):new e({keyType:fr.create(),valueType:t,typeName:$r.ZodRecord,...Bn(n)})}},Fr=class extends Vn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==O.map)return A(n,{code:k.invalid_type,expected:O.map,received:n.parsedType}),An;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Rn(n,e,n.path,[a,`key`])),value:i._parse(new Rn(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return An;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return An;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Fr.create=(e,t,n)=>new Fr({valueType:t,keyType:e,typeName:$r.ZodMap,...Bn(n)});var Ir=class e extends Vn{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==O.set)return A(n,{code:k.invalid_type,expected:O.set,received:n.parsedType}),An;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(A(n,{code:k.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(A(n,{code:k.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return An;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new Rn(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:Ln.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:Ln.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ir.create=(e,t)=>new Ir({valueType:e,minSize:null,maxSize:null,typeName:$r.ZodSet,...Bn(t)});var Lr=class e extends Vn{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.function)return A(t,{code:k.invalid_type,expected:O.function,received:t.parsedType}),An;function n(e,n){return On({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Dn(),Tn].filter(e=>!!e),issueData:{code:k.invalid_arguments,argumentsError:n}})}function r(e,n){return On({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Dn(),Tn].filter(e=>!!e),issueData:{code:k.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ur){let e=this;return Mn(async function(...t){let o=new wn([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return Mn(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new wn([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new wn([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Nr.create(t).rest(Sr.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Nr.create([]).rest(Sr.create()),returns:n||Sr.create(),typeName:$r.ZodFunction,...Bn(r)})}},Rr=class extends Vn{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Rr.create=(e,t)=>new Rr({getter:e,typeName:$r.ZodLazy,...Bn(t)});var zr=class extends Vn{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return A(t,{received:t.data,code:k.invalid_literal,expected:this._def.value}),An}return{status:`valid`,value:e.data}}get value(){return this._def.value}};zr.create=(e,t)=>new zr({value:e,typeName:$r.ZodLiteral,...Bn(t)});function Br(e,t){return new Vr({values:e,typeName:$r.ZodEnum,...Bn(t)})}var Vr=class e extends Vn{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return A(t,{expected:xn.joinValues(n),received:t.parsedType,code:k.invalid_type}),An}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return A(t,{received:t.data,code:k.invalid_enum_value,options:n}),An}return Mn(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};Vr.create=Br;var Hr=class extends Vn{_parse(e){let t=xn.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==O.string&&n.parsedType!==O.number){let e=xn.objectValues(t);return A(n,{expected:xn.joinValues(e),received:n.parsedType,code:k.invalid_type}),An}if(this._cache||=new Set(xn.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=xn.objectValues(t);return A(n,{received:n.data,code:k.invalid_enum_value,options:e}),An}return Mn(e.data)}get enum(){return this._def.values}};Hr.create=(e,t)=>new Hr({values:e,typeName:$r.ZodNativeEnum,...Bn(t)});var Ur=class extends Vn{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==O.promise&&t.common.async===!1?(A(t,{code:k.invalid_type,expected:O.promise,received:t.parsedType}),An):Mn((t.parsedType===O.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Ur.create=(e,t)=>new Ur({type:e,typeName:$r.ZodPromise,...Bn(t)});var Wr=class extends Vn{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$r.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{A(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return An;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?An:r.status===`dirty`||t.value===`dirty`?jn(r.value):r});{if(t.value===`aborted`)return An;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?An:r.status===`dirty`||t.value===`dirty`?jn(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?An:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?An:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Fn(e))return An;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>Fn(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):An);xn.assertNever(r)}};Wr.create=(e,t,n)=>new Wr({schema:e,typeName:$r.ZodEffects,effect:t,...Bn(n)}),Wr.createWithPreprocess=(e,t,n)=>new Wr({schema:t,effect:{type:`preprocess`,transform:e},typeName:$r.ZodEffects,...Bn(n)});var Gr=class extends Vn{_parse(e){return this._getType(e)===O.undefined?Mn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Gr.create=(e,t)=>new Gr({innerType:e,typeName:$r.ZodOptional,...Bn(t)});var Kr=class extends Vn{_parse(e){return this._getType(e)===O.null?Mn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Kr.create=(e,t)=>new Kr({innerType:e,typeName:$r.ZodNullable,...Bn(t)});var qr=class extends Vn{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===O.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};qr.create=(e,t)=>new qr({innerType:e,typeName:$r.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...Bn(t)});var Jr=class extends Vn{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return In(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new wn(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new wn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Jr.create=(e,t)=>new Jr({innerType:e,typeName:$r.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...Bn(t)});var Yr=class extends Vn{_parse(e){if(this._getType(e)!==O.nan){let t=this._getOrReturnCtx(e);return A(t,{code:k.invalid_type,expected:O.nan,received:t.parsedType}),An}return{status:`valid`,value:e.data}}};Yr.create=e=>new Yr({typeName:$r.ZodNaN,...Bn(e)});var Xr=class extends Vn{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Zr=class e extends Vn{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?An:e.status===`dirty`?(t.dirty(),jn(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?An:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:$r.ZodPipeline})}},Qr=class extends Vn{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Fn(e)&&(e.value=Object.freeze(e.value)),e);return In(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Qr.create=(e,t)=>new Qr({innerType:e,typeName:$r.ZodReadonly,...Bn(t)}),Dr.lazycreate;var $r;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})($r||={});var j=fr.create,ei=mr.create;Yr.create,hr.create;var ti=gr.create;_r.create,vr.create,yr.create,br.create;var ni=xr.create,ri=Sr.create;Cr.create,wr.create;var ii=Tr.create,ai=Dr.create;Dr.strictCreate;var oi=Or.create,si=Ar.create;Mr.create,Nr.create;var ci=Pr.create;Fr.create,Ir.create,Lr.create,Rr.create;var li=zr.create,ui=Vr.create,di=Hr.create;Ur.create,Wr.create,Gr.create,Kr.create,Wr.createWithPreprocess,Zr.create;var fi=ai({name:j(),arguments:j()}),pi=ai({id:j(),type:li(`function`),function:fi,encryptedValue:j().optional()}),mi=ai({id:j(),role:j(),content:j().optional(),name:j().optional(),encryptedValue:j().optional()}),hi=ai({type:li(`text`),text:j()}),gi=si(`type`,[ai({type:li(`data`),value:j(),mimeType:j()}),ai({type:li(`url`),value:j(),mimeType:j().optional()})]),_i=ai({type:li(`image`),source:gi,metadata:ri().optional()}),vi=ai({type:li(`audio`),source:gi,metadata:ri().optional()}),yi=ai({type:li(`video`),source:gi,metadata:ri().optional()}),bi=ai({type:li(`document`),source:gi,metadata:ri().optional()}),xi=ai({type:li(`binary`),mimeType:j(),id:j().optional(),url:j().optional(),data:j().optional(),filename:j().optional()}),Si=(e,t)=>{!e.id&&!e.url&&!e.data&&t.addIssue({code:k.custom,message:`BinaryInputContent requires at least one of id, url, or data.`,path:[`id`]})};xi.superRefine((e,t)=>{Si(e,t)});var Ci=si(`type`,[hi,_i,vi,yi,bi,xi]).superRefine((e,t)=>{e.type===`binary`&&Si(e,t)}),wi=si(`role`,[mi.extend({role:li(`developer`),content:j()}),mi.extend({role:li(`system`),content:j()}),mi.extend({role:li(`assistant`),content:j().optional(),toolCalls:ii(pi).optional()}),mi.extend({role:li(`user`),content:oi([j(),ii(Ci)])}),ai({id:j(),content:j(),role:li(`tool`),toolCallId:j(),error:j().optional(),encryptedValue:j().optional()}),ai({id:j(),role:li(`activity`),activityType:j(),content:ci(ni())}),ai({id:j(),role:li(`reasoning`),content:j(),encryptedValue:j().optional()})]);oi([li(`developer`),li(`system`),li(`assistant`),li(`user`),li(`tool`),li(`activity`),li(`reasoning`)]);var Ti=ai({description:j(),value:j()}),Ei=ai({name:j(),description:j(),parameters:ni(),metadata:ci(ni()).optional()}),Di=ai({id:j(),reason:j(),message:j().optional(),toolCallId:j().optional(),responseSchema:ci(ni()).optional(),expiresAt:j().optional(),metadata:ci(ni()).optional()}),Oi=ai({interruptId:j(),status:ui([`resolved`,`cancelled`]),payload:ni().optional()}),ki=ai({threadId:j(),runId:j(),parentRunId:j().optional(),state:ni(),messages:ii(wi),tools:ii(Ei),context:ii(Ti),forwardedProps:ni(),resume:ii(Oi).optional()}),Ai=ni(),ji=class extends Error{constructor(e){super(e)}},Mi=class extends ji{constructor(){super(`Connect not implemented. This method is not supported by the current agent.`)}},Ni=ai({name:j(),description:j().optional()}),Pi=ai({name:j().optional(),type:j().optional(),description:j().optional(),version:j().optional(),provider:j().optional(),documentationUrl:j().optional(),metadata:ci(ri()).optional()}),Fi=ai({streaming:ti().optional(),websocket:ti().optional(),httpBinary:ti().optional(),pushNotifications:ti().optional(),resumable:ti().optional()}),Ii=ai({supported:ti().optional(),items:ii(Ei).optional(),parallelCalls:ti().optional(),clientProvided:ti().optional()}),Li=ai({structuredOutput:ti().optional(),supportedMimeTypes:ii(j()).optional()}),Ri=ai({snapshots:ti().optional(),deltas:ti().optional(),memory:ti().optional(),persistentState:ti().optional()}),zi=ai({supported:ti().optional(),delegation:ti().optional(),handoffs:ti().optional(),subAgents:ii(Ni).optional()}),Bi=ai({supported:ti().optional(),streaming:ti().optional(),encrypted:ti().optional()}),Vi=ai({image:ti().optional(),audio:ti().optional(),video:ti().optional(),pdf:ti().optional(),file:ti().optional()}),Hi=ai({image:ti().optional(),audio:ti().optional()}),Ui=ai({input:Vi.optional(),output:Hi.optional()}),Wi=ai({codeExecution:ti().optional(),sandboxed:ti().optional(),maxIterations:ei().optional(),maxExecutionTime:ei().optional()}),Gi=ai({supported:ti().optional(),approvals:ti().optional(),interventions:ti().optional(),feedback:ti().optional(),interrupts:ti().optional(),approveWithEdits:ti().optional()});ai({identity:Pi.optional(),transport:Fi.optional(),tools:Ii.optional(),output:Li.optional(),state:Ri.optional(),multiAgent:zi.optional(),reasoning:Bi.optional(),multimodal:Ui.optional(),execution:Wi.optional(),humanInTheLoop:Gi.optional(),custom:ci(ri()).optional()});var Ki=oi([li(`developer`),li(`system`),li(`assistant`),li(`user`)]),M=function(e){return e.TEXT_MESSAGE_START=`TEXT_MESSAGE_START`,e.TEXT_MESSAGE_CONTENT=`TEXT_MESSAGE_CONTENT`,e.TEXT_MESSAGE_END=`TEXT_MESSAGE_END`,e.TEXT_MESSAGE_CHUNK=`TEXT_MESSAGE_CHUNK`,e.TOOL_CALL_START=`TOOL_CALL_START`,e.TOOL_CALL_ARGS=`TOOL_CALL_ARGS`,e.TOOL_CALL_END=`TOOL_CALL_END`,e.TOOL_CALL_CHUNK=`TOOL_CALL_CHUNK`,e.TOOL_CALL_RESULT=`TOOL_CALL_RESULT`,e.THINKING_START=`THINKING_START`,e.THINKING_END=`THINKING_END`,e.THINKING_TEXT_MESSAGE_START=`THINKING_TEXT_MESSAGE_START`,e.THINKING_TEXT_MESSAGE_CONTENT=`THINKING_TEXT_MESSAGE_CONTENT`,e.THINKING_TEXT_MESSAGE_END=`THINKING_TEXT_MESSAGE_END`,e.STATE_SNAPSHOT=`STATE_SNAPSHOT`,e.STATE_DELTA=`STATE_DELTA`,e.MESSAGES_SNAPSHOT=`MESSAGES_SNAPSHOT`,e.ACTIVITY_SNAPSHOT=`ACTIVITY_SNAPSHOT`,e.ACTIVITY_DELTA=`ACTIVITY_DELTA`,e.RAW=`RAW`,e.CUSTOM=`CUSTOM`,e.RUN_STARTED=`RUN_STARTED`,e.RUN_FINISHED=`RUN_FINISHED`,e.RUN_ERROR=`RUN_ERROR`,e.STEP_STARTED=`STEP_STARTED`,e.STEP_FINISHED=`STEP_FINISHED`,e.REASONING_START=`REASONING_START`,e.REASONING_MESSAGE_START=`REASONING_MESSAGE_START`,e.REASONING_MESSAGE_CONTENT=`REASONING_MESSAGE_CONTENT`,e.REASONING_MESSAGE_END=`REASONING_MESSAGE_END`,e.REASONING_MESSAGE_CHUNK=`REASONING_MESSAGE_CHUNK`,e.REASONING_END=`REASONING_END`,e.REASONING_ENCRYPTED_VALUE=`REASONING_ENCRYPTED_VALUE`,e}({}),qi=ai({type:di(M),timestamp:ei().optional(),rawEvent:ni().optional()}).passthrough(),Ji=qi.extend({type:li(M.TEXT_MESSAGE_START),messageId:j(),role:Ki.default(`assistant`),name:j().optional()}),Yi=qi.extend({type:li(M.TEXT_MESSAGE_CONTENT),messageId:j(),delta:j()}),Xi=qi.extend({type:li(M.TEXT_MESSAGE_END),messageId:j()}),Zi=qi.extend({type:li(M.TEXT_MESSAGE_CHUNK),messageId:j().optional(),role:Ki.optional(),delta:j().optional(),name:j().optional()}),Qi=qi.extend({type:li(M.THINKING_TEXT_MESSAGE_START)}),$i=Yi.omit({messageId:!0,type:!0}).extend({type:li(M.THINKING_TEXT_MESSAGE_CONTENT)}),ea=qi.extend({type:li(M.THINKING_TEXT_MESSAGE_END)}),ta=qi.extend({type:li(M.TOOL_CALL_START),toolCallId:j(),toolCallName:j(),parentMessageId:j().optional()}),na=qi.extend({type:li(M.TOOL_CALL_ARGS),toolCallId:j(),delta:j()}),ra=qi.extend({type:li(M.TOOL_CALL_END),toolCallId:j()}),ia=qi.extend({messageId:j(),type:li(M.TOOL_CALL_RESULT),toolCallId:j(),content:j(),role:li(`tool`).optional()}),aa=qi.extend({type:li(M.TOOL_CALL_CHUNK),toolCallId:j().optional(),toolCallName:j().optional(),parentMessageId:j().optional(),delta:j().optional()}),oa=qi.extend({type:li(M.THINKING_START),title:j().optional()}),sa=qi.extend({type:li(M.THINKING_END)}),ca=qi.extend({type:li(M.STATE_SNAPSHOT),snapshot:Ai}),la=qi.extend({type:li(M.STATE_DELTA),delta:ii(ni())}),ua=qi.extend({type:li(M.MESSAGES_SNAPSHOT),messages:ii(wi)}),da=qi.extend({type:li(M.ACTIVITY_SNAPSHOT),messageId:j(),activityType:j(),content:ci(ni()),replace:ti().optional().default(!0)}),fa=qi.extend({type:li(M.ACTIVITY_DELTA),messageId:j(),activityType:j(),patch:ii(ni())}),pa=qi.extend({type:li(M.RAW),event:ni(),source:j().optional()}),ma=qi.extend({type:li(M.CUSTOM),name:j(),value:ni()}),ha=qi.extend({type:li(M.RUN_STARTED),threadId:j(),runId:j(),parentRunId:j().optional(),input:ki.optional()}),ga=si(`type`,[ai({type:li(`success`)}).strict(),ai({type:li(`interrupt`),interrupts:ii(Di).min(1)}).strict()]),_a=qi.extend({type:li(M.RUN_FINISHED),threadId:j(),runId:j(),result:ni().optional(),outcome:ga.nullable().optional().transform(e=>e??void 0)}),va=qi.extend({type:li(M.RUN_ERROR),message:j(),code:j().optional()}),ya=qi.extend({type:li(M.STEP_STARTED),stepName:j()}),ba=qi.extend({type:li(M.STEP_FINISHED),stepName:j()}),xa=oi([li(`tool-call`),li(`message`)]),Sa=si(`type`,[Ji,Yi,Xi,Zi,oa,sa,Qi,$i,ea,ta,na,ra,aa,ia,ca,la,ua,da,fa,pa,ma,ha,_a,va,ya,ba,qi.extend({type:li(M.REASONING_START),messageId:j()}),qi.extend({type:li(M.REASONING_MESSAGE_START),messageId:j(),role:li(`reasoning`)}),qi.extend({type:li(M.REASONING_MESSAGE_CONTENT),messageId:j(),delta:j()}),qi.extend({type:li(M.REASONING_MESSAGE_END),messageId:j()}),qi.extend({type:li(M.REASONING_MESSAGE_CHUNK),messageId:j().optional(),delta:j().optional()}),qi.extend({type:li(M.REASONING_END),messageId:j()}),qi.extend({type:li(M.REASONING_ENCRYPTED_VALUE),subtype:xa,entityId:j(),encryptedValue:j()})]),Ca=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),wa=Object.prototype.hasOwnProperty;function Ta(e,t){return wa.call(e,t)}function Ea(e){if(Array.isArray(e)){for(var t=Array(e.length),n=0;n<t.length;n++)t[n]=``+n;return t}if(Object.keys)return Object.keys(e);var r=[];for(var i in e)Ta(e,i)&&r.push(i);return r}function Da(e){switch(typeof e){case`object`:return JSON.parse(JSON.stringify(e));case`undefined`:return null;default:return e}}function Oa(e){for(var t=0,n=e.length,r;t<n;){if(r=e.charCodeAt(t),r>=48&&r<=57){t++;continue}return!1}return!0}function ka(e){return e.indexOf(`/`)===-1&&e.indexOf(`~`)===-1?e:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Aa(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function ja(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t<n;t++)if(ja(e[t]))return!0}else if(typeof e==`object`){for(var r=Ea(e),i=r.length,a=0;a<i;a++)if(ja(e[r[a]]))return!0}}return!1}function Ma(e,t){var n=[e];for(var r in t){var i=typeof t[r]==`object`?JSON.stringify(t[r],null,2):t[r];i!==void 0&&n.push(r+`: `+i)}return n.join(`
|
|
15
|
-
`)}var Na=function(e){Ca(t,e);function t(t,n,r,i,a){var o=this.constructor,s=e.call(this,Ma(t,{name:n,index:r,operation:i,tree:a}))||this;return s.name=n,s.index=r,s.operation=i,s.tree=a,Object.setPrototypeOf(s,o.prototype),s.message=Ma(t,{name:n,index:r,operation:i,tree:a}),s}return t}(Error),Pa=s({JsonPatchError:()=>Fa,_areEquals:()=>Ga,applyOperation:()=>Ba,applyPatch:()=>Va,applyReducer:()=>Ha,deepClone:()=>Ia,getValueByPointer:()=>za,validate:()=>Wa,validator:()=>Ua}),Fa=Na,Ia=Da,La={add:function(e,t,n){return e[t]=this.value,{newDocument:n}},remove:function(e,t,n){var r=e[t];return delete e[t],{newDocument:n,removed:r}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:function(e,t,n){var r=za(n,this.path);r&&=Da(r);var i=Ba(n,{op:`remove`,path:this.from}).removed;return Ba(n,{op:`add`,path:this.path,value:i}),{newDocument:n,removed:r}},copy:function(e,t,n){var r=za(n,this.from);return Ba(n,{op:`add`,path:this.path,value:Da(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:Ga(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},Ra={add:function(e,t,n){return Oa(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){return{newDocument:n,removed:e.splice(t,1)[0]}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:La.move,copy:La.copy,test:La.test,_get:La._get};function za(e,t){if(t==``)return e;var n={op:`_get`,path:t};return Ba(e,n),n.value}function Ba(e,t,n,r,i,a){if(n===void 0&&(n=!1),r===void 0&&(r=!0),i===void 0&&(i=!0),a===void 0&&(a=0),n&&(typeof n==`function`?n(t,0,e,t.path):Ua(t,0)),t.path===``){var o={newDocument:e};if(t.op===`add`)return o.newDocument=t.value,o;if(t.op===`replace`)return o.newDocument=t.value,o.removed=e,o;if(t.op===`move`||t.op===`copy`)return o.newDocument=za(e,t.from),t.op===`move`&&(o.removed=e),o;if(t.op===`test`){if(o.test=Ga(e,t.value),o.test===!1)throw new Fa(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o.newDocument=e,o}else if(t.op===`remove`)return o.removed=e,o.newDocument=null,o;else if(t.op===`_get`)return t.value=e,o;else if(n)throw new Fa("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,a,t,e);else return o}else{r||(e=Da(e));var s=(t.path||``).split(`/`),c=e,l=1,u=s.length,d=void 0,f=void 0,p=void 0;for(p=typeof n==`function`?n:Ua;;){if(f=s[l],f&&f.indexOf(`~`)!=-1&&(f=Aa(f)),i&&(f==`__proto__`||f==`prototype`&&l>0&&s[l-1]==`constructor`))throw TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&d===void 0&&(c[f]===void 0?d=s.slice(0,l).join(`/`):l==u-1&&(d=t.path),d!==void 0&&p(t,0,e,d)),l++,Array.isArray(c)){if(f===`-`)f=c.length;else if(n&&!Oa(f))throw new Fa(`Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index`,`OPERATION_PATH_ILLEGAL_ARRAY_INDEX`,a,t,e);else Oa(f)&&(f=~~f);if(l>=u){if(n&&t.op===`add`&&f>c.length)throw new Fa(`The specified index MUST NOT be greater than the number of elements in the array`,`OPERATION_VALUE_OUT_OF_BOUNDS`,a,t,e);var o=Ra[t.op].call(t,c,f,e);if(o.test===!1)throw new Fa(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}}else if(l>=u){var o=La[t.op].call(t,c,f,e);if(o.test===!1)throw new Fa(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}if(c=c[f],n&&l<u&&(!c||typeof c!=`object`))throw new Fa(`Cannot perform operation at the desired path`,`OPERATION_PATH_UNRESOLVABLE`,a,t,e)}}}function Va(e,t,n,r,i){if(r===void 0&&(r=!0),i===void 0&&(i=!0),n&&!Array.isArray(t))throw new Fa(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);r||(e=Da(e));for(var a=Array(t.length),o=0,s=t.length;o<s;o++)a[o]=Ba(e,t[o],n,!0,i,o),e=a[o].newDocument;return a.newDocument=e,a}function Ha(e,t,n){var r=Ba(e,t);if(r.test===!1)throw new Fa(`Test operation failed`,`TEST_OPERATION_FAILED`,n,t,e);return r.newDocument}function Ua(e,t,n,r){if(typeof e!=`object`||!e||Array.isArray(e))throw new Fa(`Operation is not an object`,`OPERATION_NOT_AN_OBJECT`,t,e,n);if(!La[e.op])throw new Fa("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,t,e,n);if(typeof e.path!=`string`)throw new Fa("Operation `path` property is not a string",`OPERATION_PATH_INVALID`,t,e,n);if(e.path.indexOf(`/`)!==0&&e.path.length>0)throw new Fa('Operation `path` property must start with "/"',`OPERATION_PATH_INVALID`,t,e,n);if((e.op===`move`||e.op===`copy`)&&typeof e.from!=`string`)throw new Fa("Operation `from` property is not present (applicable in `move` and `copy` operations)",`OPERATION_FROM_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&e.value===void 0)throw new Fa("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&ja(e.value))throw new Fa("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED`,t,e,n);if(n){if(e.op==`add`){var i=e.path.split(`/`).length,a=r.split(`/`).length;if(i!==a+1&&i!==a)throw new Fa("Cannot perform an `add` operation at the desired path",`OPERATION_PATH_CANNOT_ADD`,t,e,n)}else if(e.op===`replace`||e.op===`remove`||e.op===`_get`){if(e.path!==r)throw new Fa(`Cannot perform the operation at a path that does not exist`,`OPERATION_PATH_UNRESOLVABLE`,t,e,n)}else if(e.op===`move`||e.op===`copy`){var o=Wa([{op:`_get`,path:e.from,value:void 0}],n);if(o&&o.name===`OPERATION_PATH_UNRESOLVABLE`)throw new Fa(`Cannot perform the operation from a path that does not exist`,`OPERATION_FROM_UNRESOLVABLE`,t,e,n)}}}function Wa(e,t,n){try{if(!Array.isArray(e))throw new Fa(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);if(t)Va(Da(t),Da(e),n||!0);else{n||=Ua;for(var r=0;r<e.length;r++)n(e[r],r,t,void 0)}}catch(e){if(e instanceof Fa)return e;throw e}}function Ga(e,t){if(e===t)return!0;if(e&&t&&typeof e==`object`&&typeof t==`object`){var n=Array.isArray(e),r=Array.isArray(t),i,a,o;if(n&&r){if(a=e.length,a!=t.length)return!1;for(i=a;i--!==0;)if(!Ga(e[i],t[i]))return!1;return!0}if(n!=r)return!1;var s=Object.keys(e);if(a=s.length,a!==Object.keys(t).length)return!1;for(i=a;i--!==0;)if(!t.hasOwnProperty(s[i]))return!1;for(i=a;i--!==0;)if(o=s[i],!Ga(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}var Ka=s({compare:()=>ro,generate:()=>to,observe:()=>eo,unobserve:()=>$a}),qa=new WeakMap,Ja=function(){function e(e){this.observers=new Map,this.obj=e}return e}(),Ya=function(){function e(e,t){this.callback=e,this.observer=t}return e}();function Xa(e){return qa.get(e)}function Za(e,t){return e.observers.get(t)}function Qa(e,t){e.observers.delete(t.callback)}function $a(e,t){t.unobserve()}function eo(e,t){var n=[],r,i=Xa(e);if(!i)i=new Ja(e),qa.set(e,i);else{var a=Za(i,t);r=a&&a.observer}if(r)return r;if(r={},i.value=Da(e),t){r.callback=t,r.next=null;var o=function(){to(r)},s=function(){clearTimeout(r.next),r.next=setTimeout(o)};typeof window<`u`&&(window.addEventListener(`mouseup`,s),window.addEventListener(`keyup`,s),window.addEventListener(`mousedown`,s),window.addEventListener(`keydown`,s),window.addEventListener(`change`,s))}return r.patches=n,r.object=e,r.unobserve=function(){to(r),clearTimeout(r.next),Qa(i,r),typeof window<`u`&&(window.removeEventListener(`mouseup`,s),window.removeEventListener(`keyup`,s),window.removeEventListener(`mousedown`,s),window.removeEventListener(`keydown`,s),window.removeEventListener(`change`,s))},i.observers.set(t,new Ya(t,r)),r}function to(e,t){t===void 0&&(t=!1);var n=qa.get(e.object);no(n.value,e.object,e.patches,``,t),e.patches.length&&Va(n.value,e.patches);var r=e.patches;return r.length>0&&(e.patches=[],e.callback&&e.callback(r)),r}function no(e,t,n,r,i){if(t!==e){typeof t.toJSON==`function`&&(t=t.toJSON());for(var a=Ea(t),o=Ea(e),s=!1,c=o.length-1;c>=0;c--){var l=o[c],u=e[l];if(Ta(t,l)&&!(t[l]===void 0&&u!==void 0&&Array.isArray(t)===!1)){var d=t[l];typeof u==`object`&&u&&typeof d==`object`&&d&&Array.isArray(u)===Array.isArray(d)?no(u,d,n,r+`/`+ka(l),i):u!==d&&(i&&n.push({op:`test`,path:r+`/`+ka(l),value:Da(u)}),n.push({op:`replace`,path:r+`/`+ka(l),value:Da(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&n.push({op:`test`,path:r+`/`+ka(l),value:Da(u)}),n.push({op:`remove`,path:r+`/`+ka(l)}),s=!0):(i&&n.push({op:`test`,path:r,value:e}),n.push({op:`replace`,path:r,value:t}))}if(!(!s&&a.length==o.length))for(var c=0;c<a.length;c++){var l=a[c];!Ta(e,l)&&t[l]!==void 0&&n.push({op:`add`,path:r+`/`+ka(l),value:Da(t[l])})}}}function ro(e,t,n){n===void 0&&(n=!1);var r=[];return no(e,t,r,``,n),r}var io=Object.assign({},Pa,Ka,{JsonPatchError:Na,deepClone:Da,escapePathComponent:ka,unescapePathComponent:Aa}),ao=function(e,t){return ao=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ao(e,t)};function oo(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);ao(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var so=function(){return so=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},so.apply(this,arguments)};function co(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function lo(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function uo(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function fo(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function po(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function mo(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function ho(e){return this instanceof ho?(this.v=e,this):new ho(e)}function go(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof ho?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function _o(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof fo==`function`?fo(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function vo(e){return typeof e==`function`}function yo(e){var t=e(function(e){Error.call(e),e.stack=Error().stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var bo=yo(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
16
|
-
`+t.map(function(e,t){return t+1+`) `+e.toString()}).join(`
|
|
17
|
-
`):``,this.name=`UnsubscriptionError`,this.errors=t}});function xo(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var So=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var o=fo(a),s=o.next();!s.done;s=o.next())s.value.remove(this)}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else a.remove(this);var c=this.initialTeardown;if(vo(c))try{c()}catch(e){i=e instanceof bo?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var u=fo(l),d=u.next();!d.done;d=u.next()){var f=d.value;try{To(f)}catch(e){i??=[],e instanceof bo?i=mo(mo([],po(i)),po(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}if(i)throw new bo(i)}},e.prototype.add=function(t){if(t&&t!==this)if(this.closed)To(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=this._finalizers??[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&xo(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&xo(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e}(),Co=So.EMPTY;function wo(e){return e instanceof So||e&&`closed`in e&&vo(e.remove)&&vo(e.add)&&vo(e.unsubscribe)}function To(e){vo(e)?e():e.unsubscribe()}var Eo={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Do={setTimeout:function(e,t){var n=[...arguments].slice(2),r=Do.delegate;return r?.setTimeout?r.setTimeout.apply(r,mo([e,t],po(n))):setTimeout.apply(void 0,mo([e,t],po(n)))},clearTimeout:function(e){return(Do.delegate?.clearTimeout||clearTimeout)(e)},delegate:void 0};function Oo(e){Do.setTimeout(function(){var t=Eo.onUnhandledError;if(t)t(e);else throw e})}function ko(){}var Ao=(function(){return No(`C`,void 0,void 0)})();function jo(e){return No(`E`,void 0,e)}function Mo(e){return No(`N`,e,void 0)}function No(e,t,n){return{kind:e,value:t,error:n}}var Po=null;function Fo(e){if(Eo.useDeprecatedSynchronousErrorHandling){var t=!Po;if(t&&(Po={errorThrown:!1,error:null}),e(),t){var n=Po,r=n.errorThrown,i=n.error;if(Po=null,r)throw i}}else e()}function Io(e){Eo.useDeprecatedSynchronousErrorHandling&&Po&&(Po.errorThrown=!0,Po.error=e)}var Lo=function(e){oo(t,e);function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,wo(t)&&t.add(n)):n.destination=Go,n}return t.create=function(e,t,n){return new Vo(e,t,n)},t.prototype.next=function(e){this.isStopped?Wo(Mo(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?Wo(jo(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?Wo(Ao,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(So),Ro=Function.prototype.bind;function zo(e,t){return Ro.call(e,t)}var Bo=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){Ho(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Ho(e)}else Ho(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Ho(e)}},e}(),Vo=function(e){oo(t,e);function t(t,n,r){var i=e.call(this)||this,a;if(vo(t)||!t)a={next:t??void 0,error:n??void 0,complete:r??void 0};else{var o;i&&Eo.useDeprecatedNextContext?(o=Object.create(t),o.unsubscribe=function(){return i.unsubscribe()},a={next:t.next&&zo(t.next,o),error:t.error&&zo(t.error,o),complete:t.complete&&zo(t.complete,o)}):a=t}return i.destination=new Bo(a),i}return t}(Lo);function Ho(e){Eo.useDeprecatedSynchronousErrorHandling?Io(e):Oo(e)}function Uo(e){throw e}function Wo(e,t){var n=Eo.onStoppedNotification;n&&Do.setTimeout(function(){return n(e,t)})}var Go={closed:!0,next:ko,error:Uo,complete:ko},Ko=(function(){return typeof Symbol==`function`&&Symbol.observable||`@@observable`})();function qo(e){return e}function Jo(){return Yo([...arguments])}function Yo(e){return e.length===0?qo:e.length===1?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)}}var Xo=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this,i=$o(e)?e:new Vo(e,t,n);return Fo(function(){var e=r,t=e.operator,n=e.source;i.add(t?t.call(i,n):n?r._subscribe(i):r._trySubscribe(i))}),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return t=Zo(t),new t(function(t,r){var i=new Vo({next:function(t){try{e(t)}catch(e){r(e),i.unsubscribe()}},error:r,complete:t});n.subscribe(i)})},e.prototype._subscribe=function(e){return this.source?.subscribe(e)},e.prototype[Ko]=function(){return this},e.prototype.pipe=function(){return Yo([...arguments])(this)},e.prototype.toPromise=function(e){var t=this;return e=Zo(e),new e(function(e,n){var r;t.subscribe(function(e){return r=e},function(e){return n(e)},function(){return e(r)})})},e.create=function(t){return new e(t)},e}();function Zo(e){return e??Eo.Promise??Promise}function Qo(e){return e&&vo(e.next)&&vo(e.error)&&vo(e.complete)}function $o(e){return e&&e instanceof Lo||Qo(e)&&wo(e)}function es(e){return vo(e?.lift)}function ts(e){return function(t){if(es(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw TypeError(`Unable to lift unknown Observable type`)}}function ns(e,t,n,r,i){return new rs(e,t,n,r,i)}var rs=function(e){oo(t,e);function t(t,n,r,i,a,o){var s=e.call(this,t)||this;return s.onFinalize=a,s.shouldUnsubscribe=o,s._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,s._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,s._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,s}return t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)==null||t.call(this))}},t}(Lo),is=yo(function(e){return function(){e(this),this.name=`ObjectUnsubscribedError`,this.message=`object unsubscribed`}}),as=function(e){oo(t,e);function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return t.prototype.lift=function(e){var t=new os(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new is},t.prototype.next=function(e){var t=this;Fo(function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||=Array.from(t.observers);try{for(var i=fo(t.currentObservers),a=i.next();!a.done;a=i.next())a.value.next(e)}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var t=this;Fo(function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;Fo(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){return this.observers?.length>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,i=n.isStopped,a=n.observers;return r||i?Co:(this.currentObservers=null,a.push(e),new So(function(){t.currentObservers=null,xo(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,i=t.isStopped;n?e.error(r):i&&e.complete()},t.prototype.asObservable=function(){var e=new Xo;return e.source=this,e},t.create=function(e,t){return new os(e,t)},t}(Xo),os=function(e){oo(t,e);function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return t.prototype.next=function(e){var t,n;(n=(t=this.destination)?.next)==null||n.call(t,e)},t.prototype.error=function(e){var t,n;(n=(t=this.destination)?.error)==null||n.call(t,e)},t.prototype.complete=function(){var e,t;(t=(e=this.destination)?.complete)==null||t.call(e)},t.prototype._subscribe=function(e){return this.source?.subscribe(e)??Co},t}(as),ss={now:function(){return(ss.delegate||Date).now()},delegate:void 0},cs=function(e){oo(t,e);function t(t,n,r){t===void 0&&(t=1/0),n===void 0&&(n=1/0),r===void 0&&(r=ss);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=n,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,n),i}return t.prototype.next=function(t){var n=this,r=n.isStopped,i=n._buffer,a=n._infiniteTimeWindow,o=n._timestampProvider,s=n._windowTime;r||(i.push(t),!a&&i.push(o.now()+s)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this,r=n._infiniteTimeWindow,i=n._buffer.slice(),a=0;a<i.length&&!e.closed;a+=r?1:2)e.next(i[a]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,n=e._timestampProvider,r=e._buffer,i=e._infiniteTimeWindow,a=(i?1:2)*t;if(t<1/0&&a<r.length&&r.splice(0,r.length-a),!i){for(var o=n.now(),s=0,c=1;c<r.length&&r[c]<=o;c+=2)s=c;s&&r.splice(0,s+1)}},t}(as),ls=new Xo(function(e){return e.complete()});function us(e){return e&&vo(e.schedule)}function ds(e){return e[e.length-1]}function fs(e){return us(ds(e))?e.pop():void 0}var ps=(function(e){return e&&typeof e.length==`number`&&typeof e!=`function`});function ms(e){return vo(e?.then)}function hs(e){return vo(e[Ko])}function gs(e){return Symbol.asyncIterator&&vo(e?.[Symbol.asyncIterator])}function _s(e){return TypeError(`You provided `+(typeof e==`object`&&e?`an invalid object`:`'`+e+`'`)+` where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}function vs(){return typeof Symbol!=`function`||!Symbol.iterator?`@@iterator`:Symbol.iterator}var ys=vs();function bs(e){return vo(e?.[ys])}function xs(e){return go(this,arguments,function(){var t,n,r,i;return uo(this,function(a){switch(a.label){case 0:t=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,ho(t.read())];case 3:return n=a.sent(),r=n.value,i=n.done,i?[4,ho(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,ho(r)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Ss(e){return vo(e?.getReader)}function Cs(e){if(e instanceof Xo)return e;if(e!=null){if(hs(e))return ws(e);if(ps(e))return Ts(e);if(ms(e))return Es(e);if(gs(e))return Os(e);if(bs(e))return Ds(e);if(Ss(e))return ks(e)}throw _s(e)}function ws(e){return new Xo(function(t){var n=e[Ko]();if(vo(n.subscribe))return n.subscribe(t);throw TypeError(`Provided object does not correctly implement Symbol.observable`)})}function Ts(e){return new Xo(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function Es(e){return new Xo(function(t){e.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,Oo)})}function Ds(e){return new Xo(function(t){var n,r;try{for(var i=fo(e),a=i.next();!a.done;a=i.next()){var o=a.value;if(t.next(o),t.closed)return}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function Os(e){return new Xo(function(t){As(e,t).catch(function(e){return t.error(e)})})}function ks(e){return Os(xs(e))}function As(e,t){var n,r,i,a;return lo(this,void 0,void 0,function(){var o,s;return uo(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=_o(e),c.label=1;case 1:return[4,n.next()];case 2:if(r=c.sent(),r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=c.sent(),i={error:s},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(a=n.return)?[4,a.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function js(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var a=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(a),!i)return a}function Ms(e,t){return t===void 0&&(t=0),ts(function(n,r){n.subscribe(ns(r,function(n){return js(r,e,function(){return r.next(n)},t)},function(){return js(r,e,function(){return r.complete()},t)},function(n){return js(r,e,function(){return r.error(n)},t)}))})}function Ns(e,t){return t===void 0&&(t=0),ts(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Ps(e,t){return Cs(e).pipe(Ns(t),Ms(t))}function Fs(e,t){return Cs(e).pipe(Ns(t),Ms(t))}function Is(e,t){return new Xo(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Ls(e,t){return new Xo(function(n){var r;return js(n,t,function(){r=e[ys](),js(n,t,function(){var e,t,i;try{e=r.next(),t=e.value,i=e.done}catch(e){n.error(e);return}i?n.complete():n.next(t)},0,!0)}),function(){return vo(r?.return)&&r.return()}})}function Rs(e,t){if(!e)throw Error(`Iterable cannot be null`);return new Xo(function(n){js(n,t,function(){var r=e[Symbol.asyncIterator]();js(n,t,function(){r.next().then(function(e){e.done?n.complete():n.next(e.value)})},0,!0)})})}function zs(e,t){return Rs(xs(e),t)}function Bs(e,t){if(e!=null){if(hs(e))return Ps(e,t);if(ps(e))return Is(e,t);if(ms(e))return Fs(e,t);if(gs(e))return Rs(e,t);if(bs(e))return Ls(e,t);if(Ss(e))return zs(e,t)}throw _s(e)}function Vs(e,t){return t?Bs(e,t):Cs(e)}function Hs(){var e=[...arguments];return Vs(e,fs(e))}function Us(e,t){var n=vo(e)?e:function(){return e},r=function(e){return e.error(n())};return new Xo(t?function(e){return t.schedule(r,0,e)}:r)}var Ws=yo(function(e){return function(){e(this),this.name=`EmptyError`,this.message=`no elements in sequence`}});function Gs(e,t){var n=typeof t==`object`;return new Promise(function(r,i){var a=!1,o;e.subscribe({next:function(e){o=e,a=!0},error:i,complete:function(){a?r(o):n?r(t.defaultValue):i(new Ws)}})})}function Ks(e,t){return ts(function(n,r){var i=0;n.subscribe(ns(r,function(n){r.next(e.call(t,n,i++))}))})}function qs(e,t,n,r,i,a,o,s){var c=[],l=0,u=0,d=!1,f=function(){d&&!c.length&&!l&&t.complete()},p=function(e){return l<r?m(e):c.push(e)},m=function(e){a&&t.next(e),l++;var s=!1;Cs(n(e,u++)).subscribe(ns(t,function(e){i?.(e),a?p(e):t.next(e)},function(){s=!0},void 0,function(){if(s)try{l--;for(var e=function(){var e=c.shift();o?js(t,o,function(){return m(e)}):m(e)};c.length&&l<r;)e();f()}catch(e){t.error(e)}}))};return e.subscribe(ns(t,p,function(){d=!0,f()})),function(){s?.()}}function Js(e,t,n){return n===void 0&&(n=1/0),vo(t)?Js(function(n,r){return Ks(function(e,i){return t(n,e,r,i)})(Cs(e(n,r)))},n):(typeof t==`number`&&(n=t),ts(function(t,r){return qs(t,r,e,n)}))}function Ys(e){return e===void 0&&(e=1/0),Js(qo,e)}function Xs(e){return new Xo(function(t){Cs(e()).subscribe(t)})}function Zs(e){return ts(function(t,n){var r=null,i=!1,a;r=t.subscribe(ns(n,void 0,void 0,function(o){a=Cs(e(o,Zs(e)(t))),r?(r.unsubscribe(),r=null,a.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,a.subscribe(n))})}function Qs(e,t){return vo(t)?Js(e,t,1):Js(e,1)}function $s(e){return ts(function(t,n){var r=!1;t.subscribe(ns(n,function(e){r=!0,n.next(e)},function(){r||n.next(e),n.complete()}))})}function ec(e){return ts(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function tc(e,t){return ts(function(n,r){var i=null,a=0,o=!1,s=function(){return o&&!i&&r.complete()};n.subscribe(ns(r,function(n){i?.unsubscribe();var o=0,c=a++;Cs(e(n,c)).subscribe(i=ns(r,function(e){return r.next(t?t(n,e,c,o++):e)},function(){i=null,s()}))},function(){o=!0,s()}))})}function nc(e){return ts(function(t,n){Cs(e).subscribe(ns(n,function(){return n.complete()},ko)),!n.closed&&t.subscribe(n)})}function rc(e,t,n){var r=vo(e)||t||n?{next:e,error:t,complete:n}:e;return r?ts(function(e,t){var n;(n=r.subscribe)==null||n.call(r);var i=!0;e.subscribe(ns(t,function(e){var n;(n=r.next)==null||n.call(r,e),t.next(e)},function(){var e;i=!1,(e=r.complete)==null||e.call(r),t.complete()},function(e){var n;i=!1,(n=r.error)==null||n.call(r,e),t.error(e)},function(){var e,t;i&&((e=r.unsubscribe)==null||e.call(r)),(t=r.finalize)==null||t.call(r)}))}):qo}function ic(e){return` \r
|
|
18
|
-
`.indexOf(e)>=0}function ac(e){for(var t=[`topLevel`],n=0,r,i,a,o=function(e){return t.push(e)},s=function(e){return t[t.length-1]=e},c=function(e){r??(r=n,i=t.length,a=e)},l=function(e){e===a&&(r=void 0,i=void 0,a=void 0)},u=function(){return t.pop()},d=function(){return n--},f=function(e){if(`0`<=e&&e<=`9`){o(`number`);return}switch(e){case`"`:o(`string`);return;case`-`:o(`numberNeedsDigit`);return;case`t`:o(`true`);return;case`f`:o(`false`);return;case`n`:o(`null`);return;case`[`:o(`arrayNeedsValue`);return;case`{`:o(`objectNeedsKey`);return}},p=e.length;n<p;n++){var m=e[n];switch(t[t.length-1]){case`topLevel`:f(m);break;case`string`:switch(m){case`"`:u();break;case`\\`:c(`stringEscape`),o(`stringEscaped`);break}break;case`stringEscaped`:m===`u`?o(`stringUnicode`):(l(`stringEscape`),u());break;case`stringUnicode`:n-e.lastIndexOf(`u`,n)===4&&(l(`stringEscape`),u());break;case`number`:m===`.`?s(`numberNeedsDigit`):m===`e`||m===`E`?s(`numberNeedsExponent`):(m<`0`||m>`9`)&&(d(),u());break;case`numberNeedsDigit`:s(`number`);break;case`numberNeedsExponent`:s(m===`+`||m===`-`?`numberNeedsDigit`:`number`);break;case`true`:case`false`:case`null`:(m<`a`||m>`z`)&&(d(),u());break;case`arrayNeedsValue`:m===`]`?u():ic(m)||(l(`collectionItem`),s(`arrayNeedsComma`),f(m));break;case`arrayNeedsComma`:m===`]`?u():m===`,`&&(c(`collectionItem`),s(`arrayNeedsValue`));break;case`objectNeedsKey`:m===`}`?u():m===`"`&&(c(`collectionItem`),s(`objectNeedsColon`),o(`string`));break;case`objectNeedsColon`:m===`:`&&s(`objectNeedsValue`);break;case`objectNeedsValue`:ic(m)||(l(`collectionItem`),s(`objectNeedsComma`),f(m));break;case`objectNeedsComma`:m===`}`?u():m===`,`&&(c(`collectionItem`),s(`objectNeedsKey`));break}}i!=null&&(t.length=i);for(var h=[r==null?e:e.slice(0,r)],g=function(t){return h.push(t.slice(e.length-e.lastIndexOf(t[0])))},_=t.length-1;_>=0;_--)switch(t[_]){case`string`:h.push(`"`);break;case`numberNeedsDigit`:case`numberNeedsExponent`:h.push(`0`);break;case`true`:g(`true`);break;case`false`:g(`false`);break;case`null`:g(`null`);break;case`arrayNeedsValue`:case`arrayNeedsComma`:h.push(`]`);break;case`objectNeedsKey`:case`objectNeedsColon`:case`objectNeedsValue`:case`objectNeedsComma`:h.push(`}`);break}return h.join(``)}function oc(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(n&15)<<28,t=(n&112)>>4,!(n&128))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}throw Error(`invalid varint`)}function sc(e,t,n){for(let r=0;r<28;r+=7){let i=e>>>r,a=!(!(i>>>7)&&t==0),o=(a?i|128:i)&255;if(n.push(o),!a)return}let r=e>>>28&15|(t&7)<<4,i=!!(t>>3);if(n.push((i?r|128:r)&255),i){for(let e=3;e<31;e+=7){let r=t>>>e,i=!!(r>>>7),a=(i?r|128:r)&255;if(n.push(a),!i)return}n.push(t>>>31&1)}}var cc=4294967296;function lc(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=cc&&(i+=r/cc|0,r%=cc)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?mc(r,i):pc(r,i)}function uc(e,t){let n=pc(e,t),r=n.hi&2147483648;r&&(n=mc(n.lo,n.hi));let i=dc(n.lo,n.hi);return r?`-`+i:i}function dc(e,t){if({lo:e,hi:t}=fc(e,t),t<=2097151)return String(cc*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+hc(o)+hc(a)}function fc(e,t){return{lo:e>>>0,hi:t>>>0}}function pc(e,t){return{lo:e|0,hi:t|0}}function mc(e,t){return t=~t,e?e=~e+1:t+=1,pc(e,t)}var hc=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function gc(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function _c(){let e=this.buf[this.pos++],t=e&127;if(!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}var vc=yc();function yc(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(globalThis.Deno||globalThis.Bun||typeof process!=`object`||{}.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`invalid int64: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),bc(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),xc(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),bc(e),lc(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),xc(e),lc(e)},dec(e,t){return uc(e,t)},uDec(e,t){return dc(e,t)}}}function bc(e){if(!/^-?[0-9]+$/.test(e))throw Error(`invalid int64: `+e)}function xc(e){if(!/^[0-9]+$/.test(e))throw Error(`invalid uint64: `+e)}var Sc=Symbol.for(`@bufbuild/protobuf/text-encoding`);function Cc(){if(globalThis[Sc]==null){let e=new globalThis.TextEncoder,t=new globalThis.TextDecoder,n;globalThis[Sc]={encodeUtf8(t){return e.encode(t)},decodeUtf8(e,r){return r?(n===void 0&&(n=new globalThis.TextDecoder(`utf-8`,{fatal:!0})),n.decode(e)):t.decode(e)},checkUtf8(e){try{return!0}catch{return!1}}}}return globalThis[Sc]}var wc;(function(e){e[e.Varint=0]=`Varint`,e[e.Bit64=1]=`Bit64`,e[e.LengthDelimited=2]=`LengthDelimited`,e[e.StartGroup=3]=`StartGroup`,e[e.EndGroup=4]=`EndGroup`,e[e.Bit32=5]=`Bit32`})(wc||={});var Tc=class{constructor(e=Cc().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw Error(`invalid state, fork stack empty`);return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Dc(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return Ec(e),gc(e,this.buf),this}bool(e){return this.buf.push(+!!e),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Oc(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Dc(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Ec(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Ec(e),e=(e<<1^e>>31)>>>0,gc(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=vc.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=vc.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=vc.enc(e);return sc(t.lo,t.hi,this.buf),this}sint64(e){let t=vc.enc(e),n=t.hi>>31;return sc(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=vc.uEnc(e);return sc(t.lo,t.hi,this.buf),this}},N=class{constructor(e,t=Cc().decodeUtf8){this.decodeUtf8=t,this.varint64=oc,this.uint32=_c,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.pos,t=this.uint32(),n=this.pos-e;if(n>5||n==5&&this.buf[this.pos-1]>15)throw Error(`illegal tag: varint overflows uint32`);let r=t>>>3,i=t&7;if(r<=0||i>5)throw Error(`illegal tag: field no `+r+` wire type `+i);return[r,i]}skip(e,t,n=100){let r=this.pos;switch(e){case wc.Varint:for(;this.buf[this.pos++]&128;);break;case wc.Bit64:this.pos+=4;case wc.Bit32:this.pos+=4;break;case wc.LengthDelimited:let r=this.uint32();this.pos+=r;break;case wc.StartGroup:if(n<=0)throw Error(`maximum recursion depth reached`);for(;;){let[e,r]=this.tag();if(r===wc.EndGroup){if(t!==void 0&&e!==t)throw Error(`invalid end group tag`);break}this.skip(r,e,n-1)}break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return vc.dec(...this.varint64())}uint64(){return vc.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,vc.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return vc.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return vc.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(e){return this.decodeUtf8(this.bytes(),e)}};function Ec(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid int32: `+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw Error(`invalid int32: `+e)}function Dc(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid uint32: `+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw Error(`invalid uint32: `+e)}function Oc(e){if(typeof e==`string`){let t=e;if(e=Number(e),Number.isNaN(e)&&t!==`NaN`)throw Error(`invalid float32: `+t)}else if(typeof e!=`number`)throw Error(`invalid float32: `+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw Error(`invalid float32: `+e)}var kc=function(e){return e[e.NULL_VALUE=0]=`NULL_VALUE`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function Ac(){return{fields:{}}}var jc={encode(e,t=new Tc){return Object.entries(e.fields).forEach(([e,n])=>{n!==void 0&&Nc.encode({key:e,value:n},t.uint32(10).fork()).join()}),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Ac();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:{if(e!==10)break;let t=Nc.decode(n,n.uint32());t.value!==void 0&&(i.fields[t.key]=t.value);continue}}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return jc.fromPartial(e??{})},fromPartial(e){let t=Ac();return t.fields=Object.entries(e.fields??{}).reduce((e,[t,n])=>(n!==void 0&&(e[t]=n),e),{}),t},wrap(e){let t=Ac();if(e!==void 0)for(let n of Object.keys(e))t.fields[n]=e[n];return t},unwrap(e){let t={};if(e.fields)for(let n of Object.keys(e.fields))t[n]=e.fields[n];return t}};function Mc(){return{key:``,value:void 0}}var Nc={encode(e,t=new Tc){return e.key!==``&&t.uint32(10).string(e.key),e.value!==void 0&&Fc.encode(Fc.wrap(e.value),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Mc();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.key=n.string();continue;case 2:if(e!==18)break;i.value=Fc.unwrap(Fc.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Nc.fromPartial(e??{})},fromPartial(e){let t=Mc();return t.key=e.key??``,t.value=e.value??void 0,t}};function Pc(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var Fc={encode(e,t=new Tc){return e.nullValue!==void 0&&t.uint32(8).int32(e.nullValue),e.numberValue!==void 0&&t.uint32(17).double(e.numberValue),e.stringValue!==void 0&&t.uint32(26).string(e.stringValue),e.boolValue!==void 0&&t.uint32(32).bool(e.boolValue),e.structValue!==void 0&&jc.encode(jc.wrap(e.structValue),t.uint32(42).fork()).join(),e.listValue!==void 0&&Lc.encode(Lc.wrap(e.listValue),t.uint32(50).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Pc();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==8)break;i.nullValue=n.int32();continue;case 2:if(e!==17)break;i.numberValue=n.double();continue;case 3:if(e!==26)break;i.stringValue=n.string();continue;case 4:if(e!==32)break;i.boolValue=n.bool();continue;case 5:if(e!==42)break;i.structValue=jc.unwrap(jc.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.listValue=Lc.unwrap(Lc.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Fc.fromPartial(e??{})},fromPartial(e){let t=Pc();return t.nullValue=e.nullValue??void 0,t.numberValue=e.numberValue??void 0,t.stringValue=e.stringValue??void 0,t.boolValue=e.boolValue??void 0,t.structValue=e.structValue??void 0,t.listValue=e.listValue??void 0,t},wrap(e){let t=Pc();if(e===null)t.nullValue=kc.NULL_VALUE;else if(typeof e==`boolean`)t.boolValue=e;else if(typeof e==`number`)t.numberValue=e;else if(typeof e==`string`)t.stringValue=e;else if(globalThis.Array.isArray(e))t.listValue=e;else if(typeof e==`object`)t.structValue=e;else if(e!==void 0)throw new globalThis.Error(`Unsupported any value type: `+typeof e);return t},unwrap(e){if(e.stringValue!==void 0)return e.stringValue;if(e?.numberValue!==void 0)return e.numberValue;if(e?.boolValue!==void 0)return e.boolValue;if(e?.structValue!==void 0)return e.structValue;if(e?.listValue!==void 0)return e.listValue;if(e?.nullValue!==void 0)return null}};function Ic(){return{values:[]}}var Lc={encode(e,t=new Tc){for(let n of e.values)Fc.encode(Fc.wrap(n),t.uint32(10).fork()).join();return t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Ic();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.values.push(Fc.unwrap(Fc.decode(n,n.uint32())));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Lc.fromPartial(e??{})},fromPartial(e){let t=Ic();return t.values=e.values?.map(e=>e)||[],t},wrap(e){let t=Ic();return t.values=e??[],t},unwrap(e){return e?.hasOwnProperty(`values`)&&globalThis.Array.isArray(e.values)?e.values:e}},Rc=function(e){return e[e.ADD=0]=`ADD`,e[e.REMOVE=1]=`REMOVE`,e[e.REPLACE=2]=`REPLACE`,e[e.MOVE=3]=`MOVE`,e[e.COPY=4]=`COPY`,e[e.TEST=5]=`TEST`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function zc(){return{op:0,path:``,from:void 0,value:void 0}}var Bc={encode(e,t=new Tc){return e.op!==0&&t.uint32(8).int32(e.op),e.path!==``&&t.uint32(18).string(e.path),e.from!==void 0&&t.uint32(26).string(e.from),e.value!==void 0&&Fc.encode(Fc.wrap(e.value),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=zc();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==8)break;i.op=n.int32();continue;case 2:if(e!==18)break;i.path=n.string();continue;case 3:if(e!==26)break;i.from=n.string();continue;case 4:if(e!==34)break;i.value=Fc.unwrap(Fc.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Bc.fromPartial(e??{})},fromPartial(e){let t=zc();return t.op=e.op??0,t.path=e.path??``,t.from=e.from??void 0,t.value=e.value??void 0,t}};function Vc(){return{id:``,type:``,function:void 0}}var Hc={encode(e,t=new Tc){return e.id!==``&&t.uint32(10).string(e.id),e.type!==``&&t.uint32(18).string(e.type),e.function!==void 0&&Wc.encode(e.function,t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Vc();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.type=n.string();continue;case 3:if(e!==26)break;i.function=Wc.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Hc.fromPartial(e??{})},fromPartial(e){let t=Vc();return t.id=e.id??``,t.type=e.type??``,t.function=e.function!==void 0&&e.function!==null?Wc.fromPartial(e.function):void 0,t}};function Uc(){return{name:``,arguments:``}}var Wc={encode(e,t=new Tc){return e.name!==``&&t.uint32(10).string(e.name),e.arguments!==``&&t.uint32(18).string(e.arguments),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Uc();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.name=n.string();continue;case 2:if(e!==18)break;i.arguments=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Wc.fromPartial(e??{})},fromPartial(e){let t=Uc();return t.name=e.name??``,t.arguments=e.arguments??``,t}};function Gc(){return{value:``,mimeType:``}}var Kc={encode(e,t=new Tc){return e.value!==``&&t.uint32(10).string(e.value),e.mimeType!==``&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Gc();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.value=n.string();continue;case 2:if(e!==18)break;i.mimeType=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Kc.fromPartial(e??{})},fromPartial(e){let t=Gc();return t.value=e.value??``,t.mimeType=e.mimeType??``,t}};function qc(){return{value:``,mimeType:void 0}}var Jc={encode(e,t=new Tc){return e.value!==``&&t.uint32(10).string(e.value),e.mimeType!==void 0&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=qc();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.value=n.string();continue;case 2:if(e!==18)break;i.mimeType=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Jc.fromPartial(e??{})},fromPartial(e){let t=qc();return t.value=e.value??``,t.mimeType=e.mimeType??void 0,t}};function Yc(){return{data:void 0,url:void 0}}var Xc={encode(e,t=new Tc){return e.data!==void 0&&Kc.encode(e.data,t.uint32(10).fork()).join(),e.url!==void 0&&Jc.encode(e.url,t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Yc();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.data=Kc.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.url=Jc.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Xc.fromPartial(e??{})},fromPartial(e){let t=Yc();return t.data=e.data!==void 0&&e.data!==null?Kc.fromPartial(e.data):void 0,t.url=e.url!==void 0&&e.url!==null?Jc.fromPartial(e.url):void 0,t}};function Zc(){return{text:``}}var Qc={encode(e,t=new Tc){return e.text!==``&&t.uint32(10).string(e.text),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Zc();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.text=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Qc.fromPartial(e??{})},fromPartial(e){let t=Zc();return t.text=e.text??``,t}};function $c(){return{source:void 0,metadata:void 0}}var el={encode(e,t=new Tc){return e.source!==void 0&&Xc.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&Fc.encode(Fc.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=$c();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=Xc.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=Fc.unwrap(Fc.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return el.fromPartial(e??{})},fromPartial(e){let t=$c();return t.source=e.source!==void 0&&e.source!==null?Xc.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function tl(){return{source:void 0,metadata:void 0}}var nl={encode(e,t=new Tc){return e.source!==void 0&&Xc.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&Fc.encode(Fc.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=tl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=Xc.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=Fc.unwrap(Fc.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return nl.fromPartial(e??{})},fromPartial(e){let t=tl();return t.source=e.source!==void 0&&e.source!==null?Xc.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function rl(){return{source:void 0,metadata:void 0}}var il={encode(e,t=new Tc){return e.source!==void 0&&Xc.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&Fc.encode(Fc.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=rl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=Xc.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=Fc.unwrap(Fc.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return il.fromPartial(e??{})},fromPartial(e){let t=rl();return t.source=e.source!==void 0&&e.source!==null?Xc.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function al(){return{source:void 0,metadata:void 0}}var ol={encode(e,t=new Tc){return e.source!==void 0&&Xc.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&Fc.encode(Fc.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=al();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=Xc.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=Fc.unwrap(Fc.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ol.fromPartial(e??{})},fromPartial(e){let t=al();return t.source=e.source!==void 0&&e.source!==null?Xc.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function sl(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var cl={encode(e,t=new Tc){return e.text!==void 0&&Qc.encode(e.text,t.uint32(10).fork()).join(),e.image!==void 0&&el.encode(e.image,t.uint32(18).fork()).join(),e.audio!==void 0&&nl.encode(e.audio,t.uint32(26).fork()).join(),e.video!==void 0&&il.encode(e.video,t.uint32(34).fork()).join(),e.document!==void 0&&ol.encode(e.document,t.uint32(42).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=sl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.text=Qc.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.image=el.decode(n,n.uint32());continue;case 3:if(e!==26)break;i.audio=nl.decode(n,n.uint32());continue;case 4:if(e!==34)break;i.video=il.decode(n,n.uint32());continue;case 5:if(e!==42)break;i.document=ol.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return cl.fromPartial(e??{})},fromPartial(e){let t=sl();return t.text=e.text!==void 0&&e.text!==null?Qc.fromPartial(e.text):void 0,t.image=e.image!==void 0&&e.image!==null?el.fromPartial(e.image):void 0,t.audio=e.audio!==void 0&&e.audio!==null?nl.fromPartial(e.audio):void 0,t.video=e.video!==void 0&&e.video!==null?il.fromPartial(e.video):void 0,t.document=e.document!==void 0&&e.document!==null?ol.fromPartial(e.document):void 0,t}};function ll(){return{id:``,role:``,content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var ul={encode(e,t=new Tc){e.id!==``&&t.uint32(10).string(e.id),e.role!==``&&t.uint32(18).string(e.role),e.content!==void 0&&t.uint32(26).string(e.content),e.name!==void 0&&t.uint32(34).string(e.name);for(let n of e.toolCalls)Hc.encode(n,t.uint32(42).fork()).join();e.toolCallId!==void 0&&t.uint32(50).string(e.toolCallId),e.error!==void 0&&t.uint32(58).string(e.error);for(let n of e.contentParts)cl.encode(n,t.uint32(66).fork()).join();return t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=ll();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.role=n.string();continue;case 3:if(e!==26)break;i.content=n.string();continue;case 4:if(e!==34)break;i.name=n.string();continue;case 5:if(e!==42)break;i.toolCalls.push(Hc.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.toolCallId=n.string();continue;case 7:if(e!==58)break;i.error=n.string();continue;case 8:if(e!==66)break;i.contentParts.push(cl.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ul.fromPartial(e??{})},fromPartial(e){let t=ll();return t.id=e.id??``,t.role=e.role??``,t.content=e.content??void 0,t.name=e.name??void 0,t.toolCalls=e.toolCalls?.map(e=>Hc.fromPartial(e))||[],t.toolCallId=e.toolCallId??void 0,t.error=e.error??void 0,t.contentParts=e.contentParts?.map(e=>cl.fromPartial(e))||[],t}};function dl(){return{id:``,reason:``,message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var fl={encode(e,t=new Tc){return e.id!==``&&t.uint32(10).string(e.id),e.reason!==``&&t.uint32(18).string(e.reason),e.message!==void 0&&t.uint32(26).string(e.message),e.toolCallId!==void 0&&t.uint32(34).string(e.toolCallId),e.responseSchema!==void 0&&Fc.encode(Fc.wrap(e.responseSchema),t.uint32(42).fork()).join(),e.expiresAt!==void 0&&t.uint32(50).string(e.expiresAt),e.metadata!==void 0&&Fc.encode(Fc.wrap(e.metadata),t.uint32(58).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=dl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.reason=n.string();continue;case 3:if(e!==26)break;i.message=n.string();continue;case 4:if(e!==34)break;i.toolCallId=n.string();continue;case 5:if(e!==42)break;i.responseSchema=Fc.unwrap(Fc.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.expiresAt=n.string();continue;case 7:if(e!==58)break;i.metadata=Fc.unwrap(Fc.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return fl.fromPartial(e??{})},fromPartial(e){let t=dl();return t.id=e.id??``,t.reason=e.reason??``,t.message=e.message??void 0,t.toolCallId=e.toolCallId??void 0,t.responseSchema=e.responseSchema??void 0,t.expiresAt=e.expiresAt??void 0,t.metadata=e.metadata??void 0,t}},pl=function(e){return e[e.TEXT_MESSAGE_START=0]=`TEXT_MESSAGE_START`,e[e.TEXT_MESSAGE_CONTENT=1]=`TEXT_MESSAGE_CONTENT`,e[e.TEXT_MESSAGE_END=2]=`TEXT_MESSAGE_END`,e[e.TOOL_CALL_START=3]=`TOOL_CALL_START`,e[e.TOOL_CALL_ARGS=4]=`TOOL_CALL_ARGS`,e[e.TOOL_CALL_END=5]=`TOOL_CALL_END`,e[e.STATE_SNAPSHOT=6]=`STATE_SNAPSHOT`,e[e.STATE_DELTA=7]=`STATE_DELTA`,e[e.MESSAGES_SNAPSHOT=8]=`MESSAGES_SNAPSHOT`,e[e.RAW=9]=`RAW`,e[e.CUSTOM=10]=`CUSTOM`,e[e.RUN_STARTED=11]=`RUN_STARTED`,e[e.RUN_FINISHED=12]=`RUN_FINISHED`,e[e.RUN_ERROR=13]=`RUN_ERROR`,e[e.STEP_STARTED=14]=`STEP_STARTED`,e[e.STEP_FINISHED=15]=`STEP_FINISHED`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function ml(){return{type:0,timestamp:void 0,rawEvent:void 0}}var P={encode(e,t=new Tc){return e.type!==0&&t.uint32(8).int32(e.type),e.timestamp!==void 0&&t.uint32(16).int64(e.timestamp),e.rawEvent!==void 0&&Fc.encode(Fc.wrap(e.rawEvent),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=ml();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==8)break;i.type=n.int32();continue;case 2:if(e!==16)break;i.timestamp=$l(n.int64());continue;case 3:if(e!==26)break;i.rawEvent=Fc.unwrap(Fc.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return P.fromPartial(e??{})},fromPartial(e){let t=ml();return t.type=e.type??0,t.timestamp=e.timestamp??void 0,t.rawEvent=e.rawEvent??void 0,t}};function hl(){return{baseEvent:void 0,messageId:``,role:void 0,name:void 0}}var gl={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.name!==void 0&&t.uint32(34).string(e.name),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=hl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.role=n.string();continue;case 4:if(e!==34)break;i.name=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return gl.fromPartial(e??{})},fromPartial(e){let t=hl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.role=e.role??void 0,t.name=e.name??void 0,t}};function _l(){return{baseEvent:void 0,messageId:``,delta:``}}var vl={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),e.delta!==``&&t.uint32(26).string(e.delta),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=_l();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return vl.fromPartial(e??{})},fromPartial(e){let t=_l();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.delta=e.delta??``,t}};function yl(){return{baseEvent:void 0,messageId:``}}var bl={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=yl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return bl.fromPartial(e??{})},fromPartial(e){let t=yl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t}};function xl(){return{baseEvent:void 0,toolCallId:``,toolCallName:``,parentMessageId:void 0}}var Sl={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),e.toolCallName!==``&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=xl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.toolCallName=n.string();continue;case 4:if(e!==34)break;i.parentMessageId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Sl.fromPartial(e??{})},fromPartial(e){let t=xl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.toolCallName=e.toolCallName??``,t.parentMessageId=e.parentMessageId??void 0,t}};function Cl(){return{baseEvent:void 0,toolCallId:``,delta:``}}var wl={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),e.delta!==``&&t.uint32(26).string(e.delta),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Cl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return wl.fromPartial(e??{})},fromPartial(e){let t=Cl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.delta=e.delta??``,t}};function Tl(){return{baseEvent:void 0,toolCallId:``}}var El={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Tl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return El.fromPartial(e??{})},fromPartial(e){let t=Tl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t}};function Dl(){return{baseEvent:void 0,snapshot:void 0}}var Ol={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.snapshot!==void 0&&Fc.encode(Fc.wrap(e.snapshot),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Dl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.snapshot=Fc.unwrap(Fc.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ol.fromPartial(e??{})},fromPartial(e){let t=Dl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.snapshot=e.snapshot??void 0,t}};function kl(){return{baseEvent:void 0,delta:[]}}var Al={encode(e,t=new Tc){e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.delta)Bc.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=kl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.delta.push(Bc.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Al.fromPartial(e??{})},fromPartial(e){let t=kl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.delta=e.delta?.map(e=>Bc.fromPartial(e))||[],t}};function jl(){return{baseEvent:void 0,messages:[]}}var Ml={encode(e,t=new Tc){e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.messages)ul.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=jl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messages.push(ul.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ml.fromPartial(e??{})},fromPartial(e){let t=jl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.messages=e.messages?.map(e=>ul.fromPartial(e))||[],t}};function Nl(){return{baseEvent:void 0,event:void 0,source:void 0}}var Pl={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.event!==void 0&&Fc.encode(Fc.wrap(e.event),t.uint32(18).fork()).join(),e.source!==void 0&&t.uint32(26).string(e.source),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Nl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.event=Fc.unwrap(Fc.decode(n,n.uint32()));continue;case 3:if(e!==26)break;i.source=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Pl.fromPartial(e??{})},fromPartial(e){let t=Nl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.event=e.event??void 0,t.source=e.source??void 0,t}};function Fl(){return{baseEvent:void 0,name:``,value:void 0}}var Il={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.name!==``&&t.uint32(18).string(e.name),e.value!==void 0&&Fc.encode(Fc.wrap(e.value),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Fl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.name=n.string();continue;case 3:if(e!==26)break;i.value=Fc.unwrap(Fc.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Il.fromPartial(e??{})},fromPartial(e){let t=Fl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.name=e.name??``,t.value=e.value??void 0,t}};function Ll(){return{baseEvent:void 0,threadId:``,runId:``}}var Rl={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==``&&t.uint32(18).string(e.threadId),e.runId!==``&&t.uint32(26).string(e.runId),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Ll();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.threadId=n.string();continue;case 3:if(e!==26)break;i.runId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Rl.fromPartial(e??{})},fromPartial(e){let t=Ll();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??``,t.runId=e.runId??``,t}};function zl(){return{baseEvent:void 0,threadId:``,runId:``,result:void 0,outcome:``,interrupts:[]}}var Bl={encode(e,t=new Tc){e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==``&&t.uint32(18).string(e.threadId),e.runId!==``&&t.uint32(26).string(e.runId),e.result!==void 0&&Fc.encode(Fc.wrap(e.result),t.uint32(34).fork()).join(),e.outcome!==``&&t.uint32(42).string(e.outcome);for(let n of e.interrupts)fl.encode(n,t.uint32(50).fork()).join();return t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=zl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.threadId=n.string();continue;case 3:if(e!==26)break;i.runId=n.string();continue;case 4:if(e!==34)break;i.result=Fc.unwrap(Fc.decode(n,n.uint32()));continue;case 5:if(e!==42)break;i.outcome=n.string();continue;case 6:if(e!==50)break;i.interrupts.push(fl.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Bl.fromPartial(e??{})},fromPartial(e){let t=zl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??``,t.runId=e.runId??``,t.result=e.result??void 0,t.outcome=e.outcome??``,t.interrupts=e.interrupts?.map(e=>fl.fromPartial(e))||[],t}};function Vl(){return{baseEvent:void 0,code:void 0,message:``}}var Hl={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.code!==void 0&&t.uint32(18).string(e.code),e.message!==``&&t.uint32(26).string(e.message),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Vl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.code=n.string();continue;case 3:if(e!==26)break;i.message=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Hl.fromPartial(e??{})},fromPartial(e){let t=Vl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.code=e.code??void 0,t.message=e.message??``,t}};function Ul(){return{baseEvent:void 0,stepName:``}}var Wl={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==``&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Ul();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.stepName=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Wl.fromPartial(e??{})},fromPartial(e){let t=Ul();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??``,t}};function Gl(){return{baseEvent:void 0,stepName:``}}var Kl={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==``&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Gl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.stepName=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Kl.fromPartial(e??{})},fromPartial(e){let t=Gl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??``,t}};function ql(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var Jl={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==void 0&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.delta!==void 0&&t.uint32(34).string(e.delta),e.name!==void 0&&t.uint32(42).string(e.name),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=ql();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.role=n.string();continue;case 4:if(e!==34)break;i.delta=n.string();continue;case 5:if(e!==42)break;i.name=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Jl.fromPartial(e??{})},fromPartial(e){let t=ql();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??void 0,t.role=e.role??void 0,t.delta=e.delta??void 0,t.name=e.name??void 0,t}};function Yl(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var Xl={encode(e,t=new Tc){return e.baseEvent!==void 0&&P.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==void 0&&t.uint32(18).string(e.toolCallId),e.toolCallName!==void 0&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.delta!==void 0&&t.uint32(42).string(e.delta),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Yl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=P.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.toolCallName=n.string();continue;case 4:if(e!==34)break;i.parentMessageId=n.string();continue;case 5:if(e!==42)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Xl.fromPartial(e??{})},fromPartial(e){let t=Yl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?P.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??void 0,t.toolCallName=e.toolCallName??void 0,t.parentMessageId=e.parentMessageId??void 0,t.delta=e.delta??void 0,t}};function Zl(){return{textMessageStart:void 0,textMessageContent:void 0,textMessageEnd:void 0,toolCallStart:void 0,toolCallArgs:void 0,toolCallEnd:void 0,stateSnapshot:void 0,stateDelta:void 0,messagesSnapshot:void 0,raw:void 0,custom:void 0,runStarted:void 0,runFinished:void 0,runError:void 0,stepStarted:void 0,stepFinished:void 0,textMessageChunk:void 0,toolCallChunk:void 0}}var Ql={encode(e,t=new Tc){return e.textMessageStart!==void 0&&gl.encode(e.textMessageStart,t.uint32(10).fork()).join(),e.textMessageContent!==void 0&&vl.encode(e.textMessageContent,t.uint32(18).fork()).join(),e.textMessageEnd!==void 0&&bl.encode(e.textMessageEnd,t.uint32(26).fork()).join(),e.toolCallStart!==void 0&&Sl.encode(e.toolCallStart,t.uint32(34).fork()).join(),e.toolCallArgs!==void 0&&wl.encode(e.toolCallArgs,t.uint32(42).fork()).join(),e.toolCallEnd!==void 0&&El.encode(e.toolCallEnd,t.uint32(50).fork()).join(),e.stateSnapshot!==void 0&&Ol.encode(e.stateSnapshot,t.uint32(58).fork()).join(),e.stateDelta!==void 0&&Al.encode(e.stateDelta,t.uint32(66).fork()).join(),e.messagesSnapshot!==void 0&&Ml.encode(e.messagesSnapshot,t.uint32(74).fork()).join(),e.raw!==void 0&&Pl.encode(e.raw,t.uint32(82).fork()).join(),e.custom!==void 0&&Il.encode(e.custom,t.uint32(90).fork()).join(),e.runStarted!==void 0&&Rl.encode(e.runStarted,t.uint32(98).fork()).join(),e.runFinished!==void 0&&Bl.encode(e.runFinished,t.uint32(106).fork()).join(),e.runError!==void 0&&Hl.encode(e.runError,t.uint32(114).fork()).join(),e.stepStarted!==void 0&&Wl.encode(e.stepStarted,t.uint32(122).fork()).join(),e.stepFinished!==void 0&&Kl.encode(e.stepFinished,t.uint32(130).fork()).join(),e.textMessageChunk!==void 0&&Jl.encode(e.textMessageChunk,t.uint32(138).fork()).join(),e.toolCallChunk!==void 0&&Xl.encode(e.toolCallChunk,t.uint32(146).fork()).join(),t},decode(e,t){let n=e instanceof N?e:new N(e),r=t===void 0?n.len:n.pos+t,i=Zl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.textMessageStart=gl.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.textMessageContent=vl.decode(n,n.uint32());continue;case 3:if(e!==26)break;i.textMessageEnd=bl.decode(n,n.uint32());continue;case 4:if(e!==34)break;i.toolCallStart=Sl.decode(n,n.uint32());continue;case 5:if(e!==42)break;i.toolCallArgs=wl.decode(n,n.uint32());continue;case 6:if(e!==50)break;i.toolCallEnd=El.decode(n,n.uint32());continue;case 7:if(e!==58)break;i.stateSnapshot=Ol.decode(n,n.uint32());continue;case 8:if(e!==66)break;i.stateDelta=Al.decode(n,n.uint32());continue;case 9:if(e!==74)break;i.messagesSnapshot=Ml.decode(n,n.uint32());continue;case 10:if(e!==82)break;i.raw=Pl.decode(n,n.uint32());continue;case 11:if(e!==90)break;i.custom=Il.decode(n,n.uint32());continue;case 12:if(e!==98)break;i.runStarted=Rl.decode(n,n.uint32());continue;case 13:if(e!==106)break;i.runFinished=Bl.decode(n,n.uint32());continue;case 14:if(e!==114)break;i.runError=Hl.decode(n,n.uint32());continue;case 15:if(e!==122)break;i.stepStarted=Wl.decode(n,n.uint32());continue;case 16:if(e!==130)break;i.stepFinished=Kl.decode(n,n.uint32());continue;case 17:if(e!==138)break;i.textMessageChunk=Jl.decode(n,n.uint32());continue;case 18:if(e!==146)break;i.toolCallChunk=Xl.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ql.fromPartial(e??{})},fromPartial(e){let t=Zl();return t.textMessageStart=e.textMessageStart!==void 0&&e.textMessageStart!==null?gl.fromPartial(e.textMessageStart):void 0,t.textMessageContent=e.textMessageContent!==void 0&&e.textMessageContent!==null?vl.fromPartial(e.textMessageContent):void 0,t.textMessageEnd=e.textMessageEnd!==void 0&&e.textMessageEnd!==null?bl.fromPartial(e.textMessageEnd):void 0,t.toolCallStart=e.toolCallStart!==void 0&&e.toolCallStart!==null?Sl.fromPartial(e.toolCallStart):void 0,t.toolCallArgs=e.toolCallArgs!==void 0&&e.toolCallArgs!==null?wl.fromPartial(e.toolCallArgs):void 0,t.toolCallEnd=e.toolCallEnd!==void 0&&e.toolCallEnd!==null?El.fromPartial(e.toolCallEnd):void 0,t.stateSnapshot=e.stateSnapshot!==void 0&&e.stateSnapshot!==null?Ol.fromPartial(e.stateSnapshot):void 0,t.stateDelta=e.stateDelta!==void 0&&e.stateDelta!==null?Al.fromPartial(e.stateDelta):void 0,t.messagesSnapshot=e.messagesSnapshot!==void 0&&e.messagesSnapshot!==null?Ml.fromPartial(e.messagesSnapshot):void 0,t.raw=e.raw!==void 0&&e.raw!==null?Pl.fromPartial(e.raw):void 0,t.custom=e.custom!==void 0&&e.custom!==null?Il.fromPartial(e.custom):void 0,t.runStarted=e.runStarted!==void 0&&e.runStarted!==null?Rl.fromPartial(e.runStarted):void 0,t.runFinished=e.runFinished!==void 0&&e.runFinished!==null?Bl.fromPartial(e.runFinished):void 0,t.runError=e.runError!==void 0&&e.runError!==null?Hl.fromPartial(e.runError):void 0,t.stepStarted=e.stepStarted!==void 0&&e.stepStarted!==null?Wl.fromPartial(e.stepStarted):void 0,t.stepFinished=e.stepFinished!==void 0&&e.stepFinished!==null?Kl.fromPartial(e.stepFinished):void 0,t.textMessageChunk=e.textMessageChunk!==void 0&&e.textMessageChunk!==null?Jl.fromPartial(e.textMessageChunk):void 0,t.toolCallChunk=e.toolCallChunk!==void 0&&e.toolCallChunk!==null?Xl.fromPartial(e.toolCallChunk):void 0,t}};function $l(e){let t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error(`Value is larger than Number.MAX_SAFE_INTEGER`);if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error(`Value is smaller than Number.MIN_SAFE_INTEGER`);return t}var eu=e=>{if(!(!e||typeof e!=`object`)){if(e.data)return{type:`data`,value:e.data.value,mimeType:e.data.mimeType};if(e.url)return{type:`url`,value:e.url.value,mimeType:e.url.mimeType}}},tu=e=>{if(!(!e||typeof e!=`object`)){if(e.text)return{type:`text`,text:e.text.text};if(e.image)return{type:`image`,source:eu(e.image.source),metadata:e.image.metadata};if(e.audio)return{type:`audio`,source:eu(e.audio.source),metadata:e.audio.metadata};if(e.video)return{type:`video`,source:eu(e.video.source),metadata:e.video.metadata};if(e.document)return{type:`document`,source:eu(e.document.source),metadata:e.document.metadata}}};function nu(e){let t=Ql.decode(e),n=Object.values(t).find(e=>e!==void 0);if(!n)throw Error(`Invalid event`);if(n.type=pl[n.baseEvent.type],n.timestamp=n.baseEvent.timestamp,n.rawEvent=n.baseEvent.rawEvent,delete n.baseEvent,n.type===M.MESSAGES_SNAPSHOT)for(let e of n.messages){let t=e;if(t.role===`user`&&Array.isArray(t.contentParts)){let e=t.contentParts.map(e=>tu(e)).filter(e=>e!==void 0);e.length>0&&(t.content=e)}Array.isArray(t.contentParts)&&t.contentParts.length===0&&(t.contentParts=void 0),t.toolCalls?.length===0&&(t.toolCalls=void 0)}if(n.type===M.RUN_FINISHED){let e=n,t=typeof e.outcome==`string`&&e.outcome!==``?e.outcome:void 0,r=Array.isArray(e.interrupts)?e.interrupts:[];delete e.interrupts,t===`interrupt`?e.outcome={type:`interrupt`,interrupts:r}:t===`success`?e.outcome={type:`success`}:delete e.outcome}if(n.type===M.STATE_DELTA)for(let e of n.delta)e.op=Rc[e.op].toLowerCase(),Object.keys(e).forEach(t=>{e[t]===void 0&&delete e[t]});return Object.keys(n).forEach(e=>{n[e]===void 0&&delete n[e]}),Sa.parse(n)}var ru;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(ru||={});var iu;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(iu||={});var F=ru.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),au=e=>{switch(typeof e){case`undefined`:return F.undefined;case`string`:return F.string;case`number`:return Number.isNaN(e)?F.nan:F.number;case`boolean`:return F.boolean;case`function`:return F.function;case`bigint`:return F.bigint;case`symbol`:return F.symbol;case`object`:return Array.isArray(e)?F.array:e===null?F.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?F.promise:typeof Map<`u`&&e instanceof Map?F.map:typeof Set<`u`&&e instanceof Set?F.set:typeof Date<`u`&&e instanceof Date?F.date:F.object;default:return F.unknown}},I=ru.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),ou=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ru.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};ou.create=e=>new ou(e);var su=(e,t)=>{let n;switch(e.code){case I.invalid_type:n=e.received===F.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case I.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,ru.jsonStringifyReplacer)}`;break;case I.unrecognized_keys:n=`Unrecognized key(s) in object: ${ru.joinValues(e.keys,`, `)}`;break;case I.invalid_union:n=`Invalid input`;break;case I.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ru.joinValues(e.options)}`;break;case I.invalid_enum_value:n=`Invalid enum value. Expected ${ru.joinValues(e.options)}, received '${e.received}'`;break;case I.invalid_arguments:n=`Invalid function arguments`;break;case I.invalid_return_type:n=`Invalid function return type`;break;case I.invalid_date:n=`Invalid date`;break;case I.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:ru.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case I.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case I.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case I.custom:n=`Invalid input`;break;case I.invalid_intersection_types:n=`Intersection results could not be merged`;break;case I.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case I.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,ru.assertNever(e)}return{message:n}},cu=su;function lu(){return cu}var uu=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function L(e,t){let n=lu(),r=uu({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===su?void 0:su].filter(e=>!!e)});e.common.issues.push(r)}var du=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return fu;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return fu;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},fu=Object.freeze({status:`aborted`}),pu=e=>({status:`dirty`,value:e}),mu=e=>({status:`valid`,value:e}),hu=e=>e.status===`aborted`,gu=e=>e.status===`dirty`,_u=e=>e.status===`valid`,vu=e=>typeof Promise<`u`&&e instanceof Promise,yu;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(yu||={});var bu=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},xu=(e,t)=>{if(_u(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new ou(e.common.issues);return this._error=t,this._error}}};function Su(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var Cu=class{get description(){return this._def.description}_getType(e){return au(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:au(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new du,ctx:{common:e.parent.common,data:e.data,parsedType:au(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(vu(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:au(e)};return xu(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:au(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return _u(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>_u(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:au(e)},r=this._parse({data:e,path:n.path,parent:n});return xu(n,await(vu(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:I.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Ed({schema:this,typeName:Fd.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return Dd.create(this,this._def)}nullable(){return Od.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return sd.create(this)}promise(){return Td.create(this,this._def)}or(e){return ud.create([this,e],this._def)}and(e){return md.create(this,e,this._def)}transform(e){return new Ed({...Su(this._def),schema:this,typeName:Fd.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new kd({...Su(this._def),innerType:this,defaultValue:t,typeName:Fd.ZodDefault})}brand(){return new Md({typeName:Fd.ZodBranded,type:this,...Su(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Ad({...Su(this._def),innerType:this,catchValue:t,typeName:Fd.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Nd.create(this,e)}readonly(){return Pd.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},wu=/^c[^\s-]{8,}$/i,Tu=/^[0-9a-z]+$/,Eu=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Du=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ou=/^[a-z0-9_-]{21}$/i,ku=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Au=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ju=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Mu=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,Nu,Pu=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Fu=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Iu=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Lu=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ru=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,zu=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Bu=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,Vu=RegExp(`^${Bu}$`);function Hu(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Uu(e){return RegExp(`^${Hu(e)}$`)}function Wu(e){let t=`${Bu}T${Hu(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Gu(e,t){return!!((t===`v4`||!t)&&Pu.test(e)||(t===`v6`||!t)&&Iu.test(e))}function Ku(e,t){if(!ku.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function qu(e,t){return!!((t===`v4`||!t)&&Fu.test(e)||(t===`v6`||!t)&&Lu.test(e))}var Ju=class e extends Cu{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==F.string){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:F.string,received:t.parsedType}),fu}let t=new du,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),L(n,{code:I.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),L(n,{code:I.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?L(n,{code:I.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&L(n,{code:I.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)ju.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`email`,code:I.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)Nu||=new RegExp(Mu,`u`),Nu.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`emoji`,code:I.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Du.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`uuid`,code:I.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Ou.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`nanoid`,code:I.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)wu.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`cuid`,code:I.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Tu.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`cuid2`,code:I.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Eu.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`ulid`,code:I.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),L(n,{validation:`url`,code:I.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`regex`,code:I.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Wu(r).test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Vu.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Uu(r).test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Au.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`duration`,code:I.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Gu(e.data,r.version)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`ip`,code:I.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Ku(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`jwt`,code:I.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?qu(e.data,r.version)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`cidr`,code:I.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Ru.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`base64`,code:I.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?zu.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`base64url`,code:I.invalid_string,message:r.message}),t.dirty()):ru.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:I.invalid_string,...yu.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...yu.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...yu.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...yu.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...yu.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...yu.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...yu.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...yu.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...yu.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...yu.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...yu.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...yu.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...yu.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...yu.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...yu.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...yu.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...yu.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...yu.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...yu.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...yu.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...yu.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...yu.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...yu.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...yu.errToObj(t)})}nonempty(e){return this.min(1,yu.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Ju.create=e=>new Ju({checks:[],typeName:Fd.ZodString,coerce:e?.coerce??!1,...Su(e)});function Yu(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Xu=class e extends Cu{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==F.number){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:F.number,received:t.parsedType}),fu}let t,n=new du;for(let r of this._def.checks)r.kind===`int`?ru.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),L(t,{code:I.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),L(t,{code:I.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),L(t,{code:I.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Yu(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),L(t,{code:I.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),L(t,{code:I.not_finite,message:r.message}),n.dirty()):ru.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,yu.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,yu.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,yu.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,yu.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:yu.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:yu.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:yu.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:yu.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:yu.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:yu.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:yu.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:yu.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:yu.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:yu.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&ru.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Xu.create=e=>new Xu({checks:[],typeName:Fd.ZodNumber,coerce:e?.coerce||!1,...Su(e)});var Zu=class e extends Cu{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==F.bigint)return this._getInvalidInput(e);let t,n=new du;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),L(t,{code:I.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),L(t,{code:I.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),L(t,{code:I.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):ru.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:F.bigint,received:t.parsedType}),fu}gte(e,t){return this.setLimit(`min`,e,!0,yu.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,yu.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,yu.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,yu.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:yu.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:yu.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:yu.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:yu.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:yu.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:yu.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Zu.create=e=>new Zu({checks:[],typeName:Fd.ZodBigInt,coerce:e?.coerce??!1,...Su(e)});var Qu=class extends Cu{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==F.boolean){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:F.boolean,received:t.parsedType}),fu}return mu(e.data)}};Qu.create=e=>new Qu({typeName:Fd.ZodBoolean,coerce:e?.coerce||!1,...Su(e)});var $u=class e extends Cu{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==F.date){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:F.date,received:t.parsedType}),fu}if(Number.isNaN(e.data.getTime()))return L(this._getOrReturnCtx(e),{code:I.invalid_date}),fu;let t=new du,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),L(n,{code:I.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),L(n,{code:I.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):ru.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:yu.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:yu.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};$u.create=e=>new $u({checks:[],coerce:e?.coerce||!1,typeName:Fd.ZodDate,...Su(e)});var ed=class extends Cu{_parse(e){if(this._getType(e)!==F.symbol){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:F.symbol,received:t.parsedType}),fu}return mu(e.data)}};ed.create=e=>new ed({typeName:Fd.ZodSymbol,...Su(e)});var td=class extends Cu{_parse(e){if(this._getType(e)!==F.undefined){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:F.undefined,received:t.parsedType}),fu}return mu(e.data)}};td.create=e=>new td({typeName:Fd.ZodUndefined,...Su(e)});var nd=class extends Cu{_parse(e){if(this._getType(e)!==F.null){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:F.null,received:t.parsedType}),fu}return mu(e.data)}};nd.create=e=>new nd({typeName:Fd.ZodNull,...Su(e)});var rd=class extends Cu{constructor(){super(...arguments),this._any=!0}_parse(e){return mu(e.data)}};rd.create=e=>new rd({typeName:Fd.ZodAny,...Su(e)});var id=class extends Cu{constructor(){super(...arguments),this._unknown=!0}_parse(e){return mu(e.data)}};id.create=e=>new id({typeName:Fd.ZodUnknown,...Su(e)});var ad=class extends Cu{_parse(e){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:F.never,received:t.parsedType}),fu}};ad.create=e=>new ad({typeName:Fd.ZodNever,...Su(e)});var od=class extends Cu{_parse(e){if(this._getType(e)!==F.undefined){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:F.void,received:t.parsedType}),fu}return mu(e.data)}};od.create=e=>new od({typeName:Fd.ZodVoid,...Su(e)});var sd=class e extends Cu{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==F.array)return L(t,{code:I.invalid_type,expected:F.array,received:t.parsedType}),fu;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(L(t,{code:e?I.too_big:I.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(L(t,{code:I.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(L(t,{code:I.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new bu(t,e,t.path,n)))).then(e=>du.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new bu(t,e,t.path,n)));return du.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:yu.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:yu.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:yu.toString(n)}})}nonempty(e){return this.min(1,e)}};sd.create=(e,t)=>new sd({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Fd.ZodArray,...Su(t)});function cd(e){if(e instanceof ld){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Dd.create(cd(r))}return new ld({...e._def,shape:()=>t})}else if(e instanceof sd)return new sd({...e._def,type:cd(e.element)});else if(e instanceof Dd)return Dd.create(cd(e.unwrap()));else if(e instanceof Od)return Od.create(cd(e.unwrap()));else if(e instanceof hd)return hd.create(e.items.map(e=>cd(e)));else return e}var ld=class e extends Cu{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=ru.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==F.object){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:F.object,received:t.parsedType}),fu}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ad&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new bu(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof ad){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(L(n,{code:I.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new bu(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>du.mergeObjectSync(t,e)):du.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return yu.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:yu.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Fd.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of ru.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of ru.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return cd(this)}partial(t){let n={};for(let e of ru.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of ru.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Dd;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Sd(ru.objectKeys(this.shape))}};ld.create=(e,t)=>new ld({shape:()=>e,unknownKeys:`strip`,catchall:ad.create(),typeName:Fd.ZodObject,...Su(t)}),ld.strictCreate=(e,t)=>new ld({shape:()=>e,unknownKeys:`strict`,catchall:ad.create(),typeName:Fd.ZodObject,...Su(t)}),ld.lazycreate=(e,t)=>new ld({shape:e,unknownKeys:`strip`,catchall:ad.create(),typeName:Fd.ZodObject,...Su(t)});var ud=class extends Cu{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new ou(e.ctx.common.issues));return L(t,{code:I.invalid_union,unionErrors:n}),fu}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new ou(e));return L(t,{code:I.invalid_union,unionErrors:i}),fu}}get options(){return this._def.options}};ud.create=(e,t)=>new ud({options:e,typeName:Fd.ZodUnion,...Su(t)});var dd=e=>e instanceof bd?dd(e.schema):e instanceof Ed?dd(e.innerType()):e instanceof xd?[e.value]:e instanceof Cd?e.options:e instanceof wd?ru.objectValues(e.enum):e instanceof kd?dd(e._def.innerType):e instanceof td?[void 0]:e instanceof nd?[null]:e instanceof Dd?[void 0,...dd(e.unwrap())]:e instanceof Od?[null,...dd(e.unwrap())]:e instanceof Md||e instanceof Pd?dd(e.unwrap()):e instanceof Ad?dd(e._def.innerType):[],fd=class e extends Cu{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==F.object)return L(t,{code:I.invalid_type,expected:F.object,received:t.parsedType}),fu;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(L(t,{code:I.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),fu)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=dd(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:Fd.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Su(r)})}};function pd(e,t){let n=au(e),r=au(t);if(e===t)return{valid:!0,data:e};if(n===F.object&&r===F.object){let n=ru.objectKeys(t),r=ru.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=pd(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===F.array&&r===F.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=pd(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===F.date&&r===F.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var md=class extends Cu{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(hu(e)||hu(r))return fu;let i=pd(e.value,r.value);return i.valid?((gu(e)||gu(r))&&t.dirty(),{status:t.value,value:i.data}):(L(n,{code:I.invalid_intersection_types}),fu)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};md.create=(e,t,n)=>new md({left:e,right:t,typeName:Fd.ZodIntersection,...Su(n)});var hd=class e extends Cu{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==F.array)return L(n,{code:I.invalid_type,expected:F.array,received:n.parsedType}),fu;if(n.data.length<this._def.items.length)return L(n,{code:I.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),fu;!this._def.rest&&n.data.length>this._def.items.length&&(L(n,{code:I.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new bu(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>du.mergeArray(t,e)):du.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};hd.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new hd({items:e,typeName:Fd.ZodTuple,rest:null,...Su(t)})};var gd=class e extends Cu{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==F.object)return L(n,{code:I.invalid_type,expected:F.object,received:n.parsedType}),fu;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new bu(n,e,n.path,e)),value:a._parse(new bu(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?du.mergeObjectAsync(t,r):du.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Cu?new e({keyType:t,valueType:n,typeName:Fd.ZodRecord,...Su(r)}):new e({keyType:Ju.create(),valueType:t,typeName:Fd.ZodRecord,...Su(n)})}},_d=class extends Cu{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==F.map)return L(n,{code:I.invalid_type,expected:F.map,received:n.parsedType}),fu;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new bu(n,e,n.path,[a,`key`])),value:i._parse(new bu(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return fu;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return fu;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};_d.create=(e,t,n)=>new _d({valueType:t,keyType:e,typeName:Fd.ZodMap,...Su(n)});var vd=class e extends Cu{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==F.set)return L(n,{code:I.invalid_type,expected:F.set,received:n.parsedType}),fu;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(L(n,{code:I.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(L(n,{code:I.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return fu;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new bu(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:yu.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:yu.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};vd.create=(e,t)=>new vd({valueType:e,minSize:null,maxSize:null,typeName:Fd.ZodSet,...Su(t)});var yd=class e extends Cu{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==F.function)return L(t,{code:I.invalid_type,expected:F.function,received:t.parsedType}),fu;function n(e,n){return uu({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,lu(),su].filter(e=>!!e),issueData:{code:I.invalid_arguments,argumentsError:n}})}function r(e,n){return uu({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,lu(),su].filter(e=>!!e),issueData:{code:I.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Td){let e=this;return mu(async function(...t){let o=new ou([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return mu(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new ou([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new ou([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:hd.create(t).rest(id.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||hd.create([]).rest(id.create()),returns:n||id.create(),typeName:Fd.ZodFunction,...Su(r)})}},bd=class extends Cu{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};bd.create=(e,t)=>new bd({getter:e,typeName:Fd.ZodLazy,...Su(t)});var xd=class extends Cu{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return L(t,{received:t.data,code:I.invalid_literal,expected:this._def.value}),fu}return{status:`valid`,value:e.data}}get value(){return this._def.value}};xd.create=(e,t)=>new xd({value:e,typeName:Fd.ZodLiteral,...Su(t)});function Sd(e,t){return new Cd({values:e,typeName:Fd.ZodEnum,...Su(t)})}var Cd=class e extends Cu{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return L(t,{expected:ru.joinValues(n),received:t.parsedType,code:I.invalid_type}),fu}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return L(t,{received:t.data,code:I.invalid_enum_value,options:n}),fu}return mu(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};Cd.create=Sd;var wd=class extends Cu{_parse(e){let t=ru.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==F.string&&n.parsedType!==F.number){let e=ru.objectValues(t);return L(n,{expected:ru.joinValues(e),received:n.parsedType,code:I.invalid_type}),fu}if(this._cache||=new Set(ru.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=ru.objectValues(t);return L(n,{received:n.data,code:I.invalid_enum_value,options:e}),fu}return mu(e.data)}get enum(){return this._def.values}};wd.create=(e,t)=>new wd({values:e,typeName:Fd.ZodNativeEnum,...Su(t)});var Td=class extends Cu{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==F.promise&&t.common.async===!1?(L(t,{code:I.invalid_type,expected:F.promise,received:t.parsedType}),fu):mu((t.parsedType===F.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Td.create=(e,t)=>new Td({type:e,typeName:Fd.ZodPromise,...Su(t)});var Ed=class extends Cu{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Fd.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{L(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return fu;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?fu:r.status===`dirty`||t.value===`dirty`?pu(r.value):r});{if(t.value===`aborted`)return fu;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?fu:r.status===`dirty`||t.value===`dirty`?pu(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?fu:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?fu:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!_u(e))return fu;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>_u(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):fu);ru.assertNever(r)}};Ed.create=(e,t,n)=>new Ed({schema:e,typeName:Fd.ZodEffects,effect:t,...Su(n)}),Ed.createWithPreprocess=(e,t,n)=>new Ed({schema:t,effect:{type:`preprocess`,transform:e},typeName:Fd.ZodEffects,...Su(n)});var Dd=class extends Cu{_parse(e){return this._getType(e)===F.undefined?mu(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Dd.create=(e,t)=>new Dd({innerType:e,typeName:Fd.ZodOptional,...Su(t)});var Od=class extends Cu{_parse(e){return this._getType(e)===F.null?mu(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Od.create=(e,t)=>new Od({innerType:e,typeName:Fd.ZodNullable,...Su(t)});var kd=class extends Cu{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===F.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};kd.create=(e,t)=>new kd({innerType:e,typeName:Fd.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...Su(t)});var Ad=class extends Cu{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return vu(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new ou(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new ou(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Ad.create=(e,t)=>new Ad({innerType:e,typeName:Fd.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...Su(t)});var jd=class extends Cu{_parse(e){if(this._getType(e)!==F.nan){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:F.nan,received:t.parsedType}),fu}return{status:`valid`,value:e.data}}};jd.create=e=>new jd({typeName:Fd.ZodNaN,...Su(e)});var Md=class extends Cu{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Nd=class e extends Cu{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?fu:e.status===`dirty`?(t.dirty(),pu(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?fu:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:Fd.ZodPipeline})}},Pd=class extends Cu{_parse(e){let t=this._def.innerType._parse(e),n=e=>(_u(e)&&(e.value=Object.freeze(e.value)),e);return vu(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Pd.create=(e,t)=>new Pd({innerType:e,typeName:Fd.ZodReadonly,...Su(t)}),ld.lazycreate;var Fd;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(Fd||={});var Id=Ju.create;Xu.create,jd.create,Zu.create;var Ld=Qu.create;$u.create,ed.create,td.create,nd.create;var Rd=rd.create;id.create,ad.create,od.create,sd.create;var zd=ld.create;ld.strictCreate,ud.create;var Bd=fd.create;md.create,hd.create,gd.create,_d.create,vd.create,yd.create,bd.create;var Vd=xd.create,Hd=Cd.create;wd.create,Td.create,Ed.create,Dd.create,Od.create,Ed.createWithPreprocess,Nd.create;var Ud=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Wd=e=>{if(typeof e!=`string`)throw TypeError(`Invalid argument expected string`);let t=e.match(Ud);if(!t)throw Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},Gd=e=>e===`*`||e===`x`||e===`X`,Kd=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},qd=(e,t)=>typeof e==typeof t?[e,t]:[String(e),String(t)],Jd=(e,t)=>{if(Gd(e)||Gd(t))return 0;let[n,r]=qd(Kd(e),Kd(t));return n>r?1:n<r?-1:0},Yd=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let r=Jd(e[n]||`0`,t[n]||`0`);if(r!==0)return r}return 0},Xd=(e,t)=>{let n=Wd(e),r=Wd(t),i=n.pop(),a=r.pop(),o=Yd(n,r);return o===0?i&&a?Yd(i.split(`.`),a.split(`.`)):i||a?i?-1:1:0:o},Zd=e=>{if(typeof structuredClone==`function`)return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return Array.isArray(e)?[...e]:{...e}}};function Qd(){return bn()}function $d(e){if(Object.freeze(e),typeof e==`object`&&e)for(let t of Object.values(e))typeof t==`object`&&t&&!Object.isFrozen(t)&&$d(t);return e}var ef=512*1024;function tf(e,t,n){let r=0,i=[e,t],a=new WeakSet;for(;i.length>0;){let e=i.pop();if(typeof e==`string`){if(r+=e.length,r>n)return!0}else if(typeof e==`object`&&e){if(a.has(e))continue;if(a.add(e),Array.isArray(e))for(let t=0;t<e.length;t++)i.push(e[t]);else{let t=Object.keys(e);for(let a=0;a<t.length;a++){let o=t[a];if(r+=o.length,r>n)return!0;i.push(e[o])}}}}return!1}async function nf(e,t,n,r){let i=typeof process<`u`&&!0,a=i&&!!{}.VITEST_WORKER_ID,o=i&&!!{}.VITEST_WORKER_ID,s=o&&!tf(t,n,ef),c=s?Zd(t):t,l=s?Zd(n):n,u=!1,d=!1,f;for(let t of e)try{s&&($d(c),$d(l));let e=await r(t,c,l);if(e===void 0)continue;let n=!1;if(e.messages!==void 0&&e.messages!==c&&(c=Zd(e.messages),u=!0,n=!0),e.state!==void 0&&e.state!==l&&(l=Zd(e.state),d=!0,n=!0),s&&n&&tf(c,l,ef)&&(s=!1),f=e.stopPropagation,f===!0)break}catch(e){if(o&&e instanceof TypeError){if(a)throw e;console.error(`AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.`,e)}else a||console.error(`Subscriber error:`,e);continue}return{...u?{messages:Object.isFrozen(c)?Zd(c):c}:{},...d?{state:Object.isFrozen(l)?Zd(l):l}:{},...f===void 0?{}:{stopPropagation:f}}}function rf(e){if(!e)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(e===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let t=e.events??!0,n=e.lifecycle??!0,r=e.verbose??!1;return{enabled:t||n,events:t,lifecycle:n,verbose:r}}function af(e){if(e instanceof of)return e;if(e===!0)return new of(rf(!0))}var of=class{constructor(e){this.config=e}event(e,t,n,r){this.config.events&&(this.config.verbose?console.debug(`[${e}] ${t}`,typeof n==`string`?n:JSON.stringify(n)):console.debug(`[${e}] ${t}`,r??n))}lifecycle(e,t,n){this.config.lifecycle&&(n?console.debug(`[${e}] ${t}`,n):console.debug(`[${e}] ${t}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function sf(e){return e.enabled?new of(e):void 0}function cf(e,t,n){if(t){let r=e.find(e=>e.id===t);if(r?.role===`assistant`)return r;r&&console.warn(`TOOL_CALL_START: parentMessageId '${t}' matches a '${r.role}' message, not assistant — falling back to toolCallId`);let i={id:r?n:t,role:`assistant`,toolCalls:[]};return e.push(i),i}let r={id:n,role:`assistant`,toolCalls:[]};return e.push(r),r}var lf=(e,t,n,r,i)=>{let a=af(i),o=Zd(n.messages),s=Zd(e.state),c={},l=e=>{e.messages!==void 0&&(o=e.messages,c.messages=e.messages),e.state!==void 0&&(s=e.state,c.state=e.state)},u=()=>{let e=Zd(c);return c={},e.messages!==void 0||e.state!==void 0?Hs(e):ls};return t.pipe(Qs(async t=>{let i=await nf(r,o,s,(r,i,a)=>r.onEvent?.({event:t,agent:n,input:e,messages:i,state:a}));if(l(i),i.stopPropagation===!0?a?.event(`APPLY`,`Event dropped:`,t,{type:t.type,reason:`stopPropagation by subscriber`}):a?.event(`APPLY`,`Event applied:`,t,{type:t.type,subscribers:r.length}),i.stopPropagation===!0)return u();switch(t.type){case M.TEXT_MESSAGE_START:{let i=await nf(r,o,s,(r,i,a)=>r.onTextMessageStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{messageId:e,role:n=`assistant`,name:r}=t;if(!o.find(t=>t.id===e)){let t={id:e,role:n,content:``,...r!==void 0&&{name:r}};o.push(t),l({messages:o})}}return u()}case M.TEXT_MESSAGE_CONTENT:{let{messageId:i,delta:a}=t,c=o.find(e=>e.id===i);if(!c)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${i}'`),u();let d=await nf(r,o,s,(r,i,a)=>r.onTextMessageContentEvent?.({event:t,messages:i,state:a,agent:n,input:e,textMessageBuffer:typeof c.content==`string`?c.content:``}));return l(d),d.stopPropagation!==!0&&(c.content=`${typeof c.content==`string`?c.content:``}${a}`,l({messages:o})),u()}case M.TEXT_MESSAGE_END:{let{messageId:i}=t,a=o.find(e=>e.id===i);return a?(l(await nf(r,o,s,(r,i,o)=>r.onTextMessageEndEvent?.({event:t,messages:i,state:o,agent:n,input:e,textMessageBuffer:typeof a.content==`string`?a.content:``}))),await Promise.all(r.map(t=>{t.onNewMessage?.({message:a,messages:o,state:s,agent:n,input:e})})),u()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${i}'`),u())}case M.TOOL_CALL_START:{let i=await nf(r,o,s,(r,i,a)=>r.onToolCallStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{toolCallId:e,toolCallName:n,parentMessageId:r}=t,i=cf(o,r,e);i.toolCalls??=[],i.toolCalls.push({id:e,type:`function`,function:{name:n,arguments:``}}),l({messages:o})}return u()}case M.TOOL_CALL_ARGS:{let{toolCallId:i,delta:a}=t,c=o.find(e=>e.toolCalls?.some(e=>e.id===i));if(!c)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${i}'`),u();let d=c.toolCalls?.find(e=>e.id===i);if(!d)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${i}'`),u();let f=await nf(r,o,s,(r,i,a)=>{let o=d.function.arguments,s=d.function.name,c={};try{c=ac(o)}catch{}return r.onToolCallArgsEvent?.({event:t,messages:i,state:a,agent:n,input:e,toolCallBuffer:o,toolCallName:s,partialToolCallArgs:c})});return l(f),f.stopPropagation!==!0&&(d.function.arguments+=a,l({messages:o})),u()}case M.TOOL_CALL_END:{let{toolCallId:i}=t,a=o.find(e=>e.toolCalls?.some(e=>e.id===i));if(!a)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${i}'`),u();let c=a.toolCalls?.find(e=>e.id===i);return c?(l(await nf(r,o,s,(r,i,a)=>{let o=c.function.arguments,s=c.function.name,l={};try{l=JSON.parse(o)}catch{}return r.onToolCallEndEvent?.({event:t,messages:i,state:a,agent:n,input:e,toolCallName:s,toolCallArgs:l})})),await Promise.all(r.map(t=>{t.onNewToolCall?.({toolCall:c,messages:o,state:s,agent:n,input:e})})),u()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${i}'`),u())}case M.TOOL_CALL_RESULT:{let i=await nf(r,o,s,(r,i,a)=>r.onToolCallResultEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{messageId:i,toolCallId:a,content:c,role:u}=t,d={id:i,toolCallId:a,role:u||`tool`,content:c},f=o.findIndex(e=>e.role===`assistant`&&e.toolCalls?.some(e=>e.id===a));if(f===-1)o.push(d);else{let e=f+1;for(;e<o.length&&o[e].role===`tool`;)e++;o.splice(e,0,d)}await Promise.all(r.map(t=>{t.onNewMessage?.({message:d,messages:o,state:s,agent:n,input:e})})),l({messages:o})}return u()}case M.STATE_SNAPSHOT:{let i=await nf(r,o,s,(r,i,a)=>r.onStateSnapshotEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{snapshot:e}=t;s=e,l({state:s})}return u()}case M.STATE_DELTA:{let i=await nf(r,o,s,(r,i,a)=>r.onStateDeltaEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{delta:e}=t;try{s=io.applyPatch(s,e,!0,!1).newDocument,l({state:s})}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Failed to apply state patch:\nCurrent state: ${JSON.stringify(s,null,2)}\nPatch operations: ${JSON.stringify(e,null,2)}\nError: ${n}`)}}return u()}case M.MESSAGES_SNAPSHOT:{let i=await nf(r,o,s,(r,i,a)=>r.onMessagesSnapshotEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{messages:e}=t,n=new Map(e.map(e=>[e.id,e])),r=e.some(e=>e.role===`reasoning`),i=e=>e.role===`activity`||e.role===`reasoning`&&!r;o=o.filter(e=>i(e)||n.has(e.id)).map(e=>i(e)?e:n.get(e.id));let a=new Set(o.map(e=>e.id));for(let t of e)a.has(t.id)||o.push(t);l({messages:o})}return u()}case M.ACTIVITY_SNAPSHOT:{let i=t,a=o.findIndex(e=>e.id===i.messageId),c=a>=0?o[a]:void 0,d=c?.role===`activity`?c:void 0,f=i.replace??!0,p=await nf(r,o,s,(t,r,a)=>t.onActivitySnapshotEvent?.({event:i,messages:r,state:a,agent:n,input:e,activityMessage:d,existingMessage:c}));if(l(p),p.stopPropagation!==!0){let t={id:i.messageId,role:`activity`,activityType:i.activityType,content:Zd(i.content)},c;a===-1?(o.push(t),c=t):d?f&&(o[a]={...d,activityType:i.activityType,content:Zd(i.content)}):f&&(o[a]=t,c=t),l({messages:o}),c&&await Promise.all(r.map(t=>t.onNewMessage?.({message:c,messages:o,state:s,agent:n,input:e})))}return u()}case M.ACTIVITY_DELTA:{let i=t,a=o.findIndex(e=>e.id===i.messageId);if(a===-1)return u();let c=o[a];if(c.role!==`activity`)return console.warn(`ACTIVITY_DELTA: Message '${i.messageId}' is not an activity message`),u();let d=c,f=await nf(r,o,s,(t,r,a)=>t.onActivityDeltaEvent?.({event:i,messages:r,state:a,agent:n,input:e,activityMessage:d}));if(l(f),f.stopPropagation!==!0)try{let e=Zd(d.content??{}),t=io.applyPatch(e,i.patch??[],!0,!1).newDocument;o[a]={...d,content:Zd(t),activityType:i.activityType},l({messages:o})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`Failed to apply activity patch for '${i.messageId}': ${t}`)}return u()}case M.RAW:return l(await nf(r,o,s,(r,i,a)=>r.onRawEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case M.CUSTOM:return l(await nf(r,o,s,(r,i,a)=>r.onCustomEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case M.RUN_STARTED:{let i=await nf(r,o,s,(r,i,a)=>r.onRunStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let e=t;if(e.input?.messages){for(let t of e.input.messages)o.find(e=>e.id===t.id)||o.push(t);l({messages:o})}}return u()}case M.RUN_FINISHED:{let i=t,a=i.outcome?.type===`interrupt`?{event:i,outcome:`interrupt`,interrupts:i.outcome.interrupts}:{event:i,outcome:`success`,result:i.result},c=await nf(r,o,s,(t,r,i)=>t.onRunFinishedEvent?.({...a,messages:r,state:i,agent:n,input:e}));return l(c),c.stopPropagation!==!0&&(n.pendingInterrupts=a.outcome===`interrupt`?[...a.interrupts]:[]),u()}case M.RUN_ERROR:return l(await nf(r,o,s,(r,i,a)=>r.onRunErrorEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case M.STEP_STARTED:return l(await nf(r,o,s,(r,i,a)=>r.onStepStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case M.STEP_FINISHED:return l(await nf(r,o,s,(r,i,a)=>r.onStepFinishedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case M.TEXT_MESSAGE_CHUNK:throw Error(`TEXT_MESSAGE_CHUNK must be tranformed before being applied`);case M.TOOL_CALL_CHUNK:throw Error(`TOOL_CALL_CHUNK must be tranformed before being applied`);case M.THINKING_START:return u();case M.THINKING_END:return u();case M.THINKING_TEXT_MESSAGE_START:return u();case M.THINKING_TEXT_MESSAGE_CONTENT:return u();case M.THINKING_TEXT_MESSAGE_END:return u();case M.REASONING_START:return l(await nf(r,o,s,(r,i,a)=>r.onReasoningStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case M.REASONING_MESSAGE_START:{let i=await nf(r,o,s,(r,i,a)=>r.onReasoningMessageStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{messageId:e}=t;if(!o.find(t=>t.id===e)){let t={id:e,role:`reasoning`,content:``};o.push(t),l({messages:o})}}return u()}case M.REASONING_MESSAGE_CONTENT:{let{messageId:i,delta:a}=t,c=o.find(e=>e.id===i);if(!c)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${i}'`),u();let d=await nf(r,o,s,(r,i,a)=>r.onReasoningMessageContentEvent?.({event:t,messages:i,state:a,agent:n,input:e,reasoningMessageBuffer:typeof c.content==`string`?c.content:``}));return l(d),d.stopPropagation!==!0&&(c.content=`${typeof c.content==`string`?c.content:``}${a}`,l({messages:o})),u()}case M.REASONING_MESSAGE_END:{let{messageId:i}=t,a=o.find(e=>e.id===i);return a?(l(await nf(r,o,s,(r,i,o)=>r.onReasoningMessageEndEvent?.({event:t,messages:i,state:o,agent:n,input:e,reasoningMessageBuffer:typeof a.content==`string`?a.content:``}))),await Promise.all(r.map(t=>{t.onNewMessage?.({message:a,messages:o,state:s,agent:n,input:e})})),u()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${i}'`),u())}case M.REASONING_MESSAGE_CHUNK:throw Error(`REASONING_MESSAGE_CHUNK must be transformed before being applied`);case M.REASONING_END:return l(await nf(r,o,s,(r,i,a)=>r.onReasoningEndEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case M.REASONING_ENCRYPTED_VALUE:{let{subtype:i,entityId:a,encryptedValue:d}=t,f=await nf(r,o,s,(r,i,a)=>r.onReasoningEncryptedValueEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(f),f.stopPropagation!==!0){let e=!1;if(i===`tool-call`){for(let t of o)if(t.role===`assistant`&&t.toolCalls){let n=t.toolCalls.find(e=>e.id===a);if(n){n.encryptedValue=d,e=!0;break}}}else{let t=o.find(e=>e.id===a);t?.role!==`activity`&&t&&(t.encryptedValue=d,e=!0)}e&&(c.messages=o)}return u()}}return t.type,u()}),Ys(),r.length>0?$s({}):e=>e)},uf=e=>t=>{let n=af(e),r=new Map,i=new Map,a=!1,o=!1,s=!1,c=new Map,l=!1,u=!1,d=!1,f=()=>{r.clear(),i.clear(),c.clear(),l=!1,u=!1,a=!1,o=!1,d=!0};return t.pipe(Js(e=>{let t=e.type;if(n?.event(`VERIFY`,`Event:`,e,{type:e.type}),o)return Us(()=>new ji(`Cannot send event type '${t}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(a&&t!==M.RUN_ERROR&&t!==M.RUN_STARTED)return Us(()=>new ji(`Cannot send event type '${t}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(!s){if(s=!0,t!==M.RUN_STARTED&&t!==M.RUN_ERROR)return Us(()=>new ji(`First event must be 'RUN_STARTED'`))}else if(t===M.RUN_STARTED){if(d&&!a)return Us(()=>new ji(`Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run.`));a&&f()}switch(t){case M.TEXT_MESSAGE_START:{let t=e.messageId;return r.has(t)?Us(()=>new ji(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${t}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`)):(r.set(t,!0),Hs(e))}case M.TEXT_MESSAGE_CONTENT:{let t=e.messageId;return r.has(t)?Hs(e):Us(()=>new ji(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${t}'. Start a text message with 'TEXT_MESSAGE_START' first.`))}case M.TEXT_MESSAGE_END:{let t=e.messageId;return r.has(t)?(r.delete(t),Hs(e)):Us(()=>new ji(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${t}'. A 'TEXT_MESSAGE_START' event must be sent first.`))}case M.TOOL_CALL_START:{let t=e.toolCallId;return i.has(t)?Us(()=>new ji(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${t}' is already in progress. Complete it with 'TOOL_CALL_END' first.`)):(i.set(t,!0),Hs(e))}case M.TOOL_CALL_ARGS:{let t=e.toolCallId;return i.has(t)?Hs(e):Us(()=>new ji(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${t}'. Start a tool call with 'TOOL_CALL_START' first.`))}case M.TOOL_CALL_END:{let t=e.toolCallId;return i.has(t)?(i.delete(t),Hs(e)):Us(()=>new ji(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${t}'. A 'TOOL_CALL_START' event must be sent first.`))}case M.STEP_STARTED:{let t=e.stepName;return c.has(t)?Us(()=>new ji(`Step "${t}" is already active for 'STEP_STARTED'`)):(c.set(t,!0),Hs(e))}case M.STEP_FINISHED:{let t=e.stepName;return c.has(t)?(c.delete(t),Hs(e)):Us(()=>new ji(`Cannot send 'STEP_FINISHED' for step "${t}" that was not started`))}case M.RUN_STARTED:return d=!0,Hs(e);case M.RUN_FINISHED:if(c.size>0){let e=Array.from(c.keys()).join(`, `);return Us(()=>new ji(`Cannot send 'RUN_FINISHED' while steps are still active: ${e}`))}if(r.size>0){let e=Array.from(r.keys()).join(`, `);return Us(()=>new ji(`Cannot send 'RUN_FINISHED' while text messages are still active: ${e}`))}if(i.size>0){let e=Array.from(i.keys()).join(`, `);return Us(()=>new ji(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${e}`))}return a=!0,Hs(e);case M.RUN_ERROR:return o=!0,Hs(e);case M.CUSTOM:return Hs(e);case M.THINKING_TEXT_MESSAGE_START:return l?u?Us(()=>new ji(`Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.`)):(u=!0,Hs(e)):Us(()=>new ji(`Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first.`));case M.THINKING_TEXT_MESSAGE_CONTENT:return u?Hs(e):Us(()=>new ji(`Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first.`));case M.THINKING_TEXT_MESSAGE_END:return u?(u=!1,Hs(e)):Us(()=>new ji(`Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first.`));case M.THINKING_START:return l?Us(()=>new ji(`Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.`)):(l=!0,Hs(e));case M.THINKING_END:return l?(l=!1,Hs(e)):Us(()=>new ji(`Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first.`));default:return Hs(e)}}))},df=function(e){return e.HEADERS=`headers`,e.DATA=`data`,e}({}),ff=e=>Xs(()=>Vs(e())).pipe(tc(e=>{if(!e.ok){let t=e.headers.get(`content-type`)||``;return Vs(e.text()).pipe(Js(n=>{let r=n;if(t.includes(`application/json`))try{r=JSON.parse(n)}catch{}let i=Error(`HTTP ${e.status}: ${typeof r==`string`?r:JSON.stringify(r)}`);return i.status=e.status,i.payload=r,Us(()=>i)}))}let t={type:df.HEADERS,status:e.status,headers:e.headers},n=e.body?.getReader();return n?new Xo(e=>(e.next(t),(async()=>{try{for(;;){let{done:t,value:r}=await n.read();if(t)break;let i={type:df.DATA,data:r};e.next(i)}e.complete()}catch(t){e.error(t)}})(),()=>{n.cancel().catch(e=>{if(e?.name!==`AbortError`)throw e})})):Us(()=>Error(`Failed to getReader() from response`))})),pf=(e,t)=>{let n=af(t),r=new as,i=new TextDecoder(`utf-8`,{fatal:!1}),a=``;e.subscribe({next:e=>{if(e.type!==df.HEADERS&&e.type===df.DATA&&e.data){let t=i.decode(e.data,{stream:!0});a+=t;let n=a.split(/\n\n/);a=n.pop()||``;for(let e of n)o(e)}},error:e=>r.error(e),complete:()=>{a&&(a+=i.decode(),o(a)),r.complete()}});function o(e){let t=e.split(`
|
|
19
|
-
`),i=[];for(let e of t)e.startsWith(`data:`)&&i.push(e.slice(5).replace(/^ /,``));if(i.length>0)try{let e=i.join(`
|
|
20
|
-
`),t=JSON.parse(e);n?.event(`SSE`,`Event received:`,t,{type:t.type}),r.next(t)}catch(e){r.error(e)}}return r.asObservable()},mf=e=>{let t=new as,n=new Uint8Array;e.subscribe({next:e=>{if(e.type!==df.HEADERS&&e.type===df.DATA&&e.data){let t=new Uint8Array(n.length+e.data.length);t.set(n,0),t.set(e.data,n.length),n=t,r()}},error:e=>t.error(e),complete:()=>{if(n.length>0)try{r()}catch{console.warn(`Incomplete or invalid protocol buffer data at stream end`)}t.complete()}});function r(){for(;n.length>=4;){let e=4+new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(n.length<e)break;try{let r=nu(n.slice(4,e));t.next(r),n=n.slice(e)}catch(e){let n=e instanceof Error?e.message:String(e);t.error(Error(`Failed to decode protocol buffer message: ${n}`));return}}}return t.asObservable()},hf=(e,t)=>{let n=af(t),r=new as,i=new cs,a=!1;return e.subscribe({next:e=>{if(i.next(e),e.type===df.HEADERS&&!a){a=!0;let t=e.headers.get(`content-type`);n?.lifecycle(`HTTP`,`Stream format detected:`,{contentType:t,parser:t===`application/vnd.ag-ui.event+proto`?`protobuf`:`sse`}),t===`application/vnd.ag-ui.event+proto`?mf(i).subscribe({next:e=>r.next(e),error:e=>r.error(e),complete:()=>r.complete()}):pf(i,n).subscribe({next:e=>{try{let t=Sa.parse(e);n?.event(`HTTP`,`Event validated:`,t,{type:t.type,valid:!0}),r.next(t)}catch(t){n?.event(`HTTP`,`Event invalid:`,{json:e,error:String(t)}),r.error(t)}},error:e=>{if(e?.name===`AbortError`){r.next({type:M.RUN_ERROR,message:e.message||`Request aborted`,code:`abort`,rawEvent:e}),r.complete();return}return r.error(e)},complete:()=>r.complete()})}else a||r.error(Error(`No headers event received before data events`))},error:e=>{i.error(e),r.error(e)},complete:()=>{i.complete()}}),r.asObservable()},gf=Hd([`TextMessageStart`,`TextMessageContent`,`TextMessageEnd`,`ActionExecutionStart`,`ActionExecutionArgs`,`ActionExecutionEnd`,`ActionExecutionResult`,`AgentStateMessage`,`MetaEvent`,`RunStarted`,`RunFinished`,`RunError`,`NodeStarted`,`NodeFinished`]),_f=Hd([`LangGraphInterruptEvent`,`PredictState`,`Exit`]);Bd(`type`,[zd({type:Vd(gf.enum.TextMessageStart),messageId:Id(),parentMessageId:Id().optional(),role:Id().optional()}),zd({type:Vd(gf.enum.TextMessageContent),messageId:Id(),content:Id()}),zd({type:Vd(gf.enum.TextMessageEnd),messageId:Id()}),zd({type:Vd(gf.enum.ActionExecutionStart),actionExecutionId:Id(),actionName:Id(),parentMessageId:Id().optional()}),zd({type:Vd(gf.enum.ActionExecutionArgs),actionExecutionId:Id(),args:Id()}),zd({type:Vd(gf.enum.ActionExecutionEnd),actionExecutionId:Id()}),zd({type:Vd(gf.enum.ActionExecutionResult),actionName:Id(),actionExecutionId:Id(),result:Id()}),zd({type:Vd(gf.enum.AgentStateMessage),threadId:Id(),agentName:Id(),nodeName:Id(),runId:Id(),active:Ld(),role:Id(),state:Id(),running:Ld()}),zd({type:Vd(gf.enum.MetaEvent),name:_f,value:Rd()}),zd({type:Vd(gf.enum.RunError),message:Id(),code:Id().optional()})]),zd({id:Id(),role:Id(),content:Id(),parentMessageId:Id().optional()}),zd({id:Id(),name:Id(),arguments:Rd(),parentMessageId:Id().optional()}),zd({id:Id(),result:Rd(),actionExecutionId:Id(),actionName:Id()});var vf=e=>{if(typeof e==`string`)return e;if(!Array.isArray(e))return;let t=e.filter(e=>e.type===`text`).map(e=>e.text).filter(e=>e.length>0);if(t.length!==0)return t.join(`
|
|
21
|
-
`)},yf=(e,t,n)=>r=>{let i={},a=!0,o=!0,s=``,c=null,l=null,u=[],d={},f=e=>{typeof e==`object`&&e&&(`messages`in e&&delete e.messages,i=e)};return r.pipe(Js(r=>{switch(r.type){case M.TEXT_MESSAGE_START:{let e=r;return[{type:gf.enum.TextMessageStart,messageId:e.messageId,role:e.role}]}case M.TEXT_MESSAGE_CONTENT:{let e=r;return[{type:gf.enum.TextMessageContent,messageId:e.messageId,content:e.delta}]}case M.TEXT_MESSAGE_END:{let e=r;return[{type:gf.enum.TextMessageEnd,messageId:e.messageId}]}case M.TOOL_CALL_START:{let e=r;return u.push({id:e.toolCallId,type:`function`,function:{name:e.toolCallName,arguments:``}}),o=!0,d[e.toolCallId]=e.toolCallName,[{type:gf.enum.ActionExecutionStart,actionExecutionId:e.toolCallId,actionName:e.toolCallName,parentMessageId:e.parentMessageId}]}case M.TOOL_CALL_ARGS:{let c=r,d=u.find(e=>e.id===c.toolCallId);if(!d)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${c.toolCallId}'`),[];d.function.arguments+=c.delta;let p=!1;if(l){let e=l.find(e=>e.tool==d.function.name);if(e)try{let t=JSON.parse(ac(d.function.arguments));e.tool_argument&&e.tool_argument in t?(f({...i,[e.state_key]:t[e.tool_argument]}),p=!0):e.tool_argument||(f({...i,[e.state_key]:t}),p=!0)}catch{}}return[{type:gf.enum.ActionExecutionArgs,actionExecutionId:c.toolCallId,args:c.delta},...p?[{type:gf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]:[]]}case M.TOOL_CALL_END:{let e=r;return[{type:gf.enum.ActionExecutionEnd,actionExecutionId:e.toolCallId}]}case M.TOOL_CALL_RESULT:{let e=r;return[{type:gf.enum.ActionExecutionResult,actionExecutionId:e.toolCallId,result:e.content,actionName:d[e.toolCallId]||`unknown`}]}case M.RAW:return[];case M.CUSTOM:{let e=r;switch(e.name){case`Exit`:a=!1;break;case`PredictState`:l=e.value;break}return[{type:gf.enum.MetaEvent,name:e.name,value:e.value}]}case M.STATE_SNAPSHOT:return f(r.snapshot),[{type:gf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}];case M.STATE_DELTA:{let c=r,l=io.applyPatch(i,c.delta,!0,!1);return l?(f(l.newDocument),[{type:gf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]):[]}case M.MESSAGES_SNAPSHOT:return c=r.messages,[{type:gf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...c?{messages:c}:{}}),active:!0}];case M.RUN_STARTED:return[];case M.RUN_FINISHED:return c&&(i.messages=c),Object.keys(i).length===0?[]:[{type:gf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...c?{messages:bf(c)}:{}}),active:!1}];case M.RUN_ERROR:{let e=r;return[{type:gf.enum.RunError,message:e.message,code:e.code}]}case M.STEP_STARTED:return s=r.stepName,u=[],l=null,[{type:gf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!0}];case M.STEP_FINISHED:return u=[],l=null,[{type:gf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!1}];default:return[]}}))};function bf(e){let t=[];for(let n of e)if(n.role===`assistant`||n.role===`user`||n.role===`system`){let e=vf(n.content);if(e){let r={id:n.id,role:n.role,content:e};t.push(r)}if(n.role===`assistant`&&n.toolCalls&&n.toolCalls.length>0)for(let e of n.toolCalls){let r={id:e.id,name:e.function.name,arguments:JSON.parse(e.function.arguments),parentMessageId:n.id};t.push(r)}}else if(n.role===`tool`){let r=`unknown`;for(let t of e)if(t.role===`assistant`&&t.toolCalls?.length){for(let e of t.toolCalls)if(e.id===n.toolCallId){r=e.function.name;break}}let i={id:n.id,result:n.content,actionExecutionId:n.toolCallId,actionName:r};t.push(i)}return t}var xf=e=>t=>{let n=af(e),r,i,a,o,s=()=>{if(!r||o!==`text`)throw Error(`No text message to close`);let e={type:M.TEXT_MESSAGE_END,messageId:r.messageId};return o=void 0,r=void 0,n?.event(`TRANSFORM`,`TEXT_MESSAGE_END`,e,{messageId:e.messageId}),e},c=()=>{if(!i||o!==`tool`)throw Error(`No tool call to close`);let e={type:M.TOOL_CALL_END,toolCallId:i.toolCallId};return o=void 0,i=void 0,n?.event(`TRANSFORM`,`TOOL_CALL_END`,e,{toolCallId:e.toolCallId}),e},l=()=>{if(!a||o!==`reasoning`)throw Error(`No reasoning message to close`);let e={type:M.REASONING_MESSAGE_END,messageId:a.messageId};return o=void 0,a=void 0,n?.event(`TRANSFORM`,`REASONING_MESSAGE_END`,e,{messageId:e.messageId}),e},u=()=>o===`text`?[s()]:o===`tool`?[c()]:o===`reasoning`?[l()]:[];return t.pipe(Js(e=>{switch(e.type){case M.TEXT_MESSAGE_START:case M.TEXT_MESSAGE_CONTENT:case M.TEXT_MESSAGE_END:case M.TOOL_CALL_START:case M.TOOL_CALL_ARGS:case M.TOOL_CALL_END:case M.TOOL_CALL_RESULT:case M.STATE_SNAPSHOT:case M.STATE_DELTA:case M.MESSAGES_SNAPSHOT:case M.CUSTOM:case M.RUN_STARTED:case M.RUN_FINISHED:case M.RUN_ERROR:case M.STEP_STARTED:case M.STEP_FINISHED:case M.THINKING_START:case M.THINKING_END:case M.THINKING_TEXT_MESSAGE_START:case M.THINKING_TEXT_MESSAGE_CONTENT:case M.THINKING_TEXT_MESSAGE_END:case M.REASONING_START:case M.REASONING_MESSAGE_START:case M.REASONING_MESSAGE_CONTENT:case M.REASONING_MESSAGE_END:case M.REASONING_END:return[...u(),e];case M.RAW:case M.ACTIVITY_SNAPSHOT:case M.ACTIVITY_DELTA:case M.REASONING_ENCRYPTED_VALUE:return[e];case M.TEXT_MESSAGE_CHUNK:let t=e,s=[];if((o!==`text`||t.messageId!==void 0&&t.messageId!==r?.messageId)&&s.push(...u()),o!==`text`){if(t.messageId===void 0)throw Error(`First TEXT_MESSAGE_CHUNK must have a messageId`);r={messageId:t.messageId,name:t.name},o=`text`;let e={type:M.TEXT_MESSAGE_START,messageId:t.messageId,role:t.role||`assistant`,...t.name!==void 0&&{name:t.name}};s.push(e),n?.event(`TRANSFORM`,`TEXT_MESSAGE_START`,e,{messageId:t.messageId})}if(t.delta!==void 0){let e={type:M.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:t.delta};s.push(e),n?.event(`TRANSFORM`,`TEXT_MESSAGE_CONTENT`,e,{messageId:r.messageId})}return s;case M.TOOL_CALL_CHUNK:let c=e,l=[];if((o!==`tool`||c.toolCallId!==void 0&&c.toolCallId!==i?.toolCallId)&&l.push(...u()),o!==`tool`){if(c.toolCallId===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallId`);if(c.toolCallName===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallName`);i={toolCallId:c.toolCallId,toolCallName:c.toolCallName,parentMessageId:c.parentMessageId},o=`tool`;let e={type:M.TOOL_CALL_START,toolCallId:c.toolCallId,toolCallName:c.toolCallName,parentMessageId:c.parentMessageId};l.push(e),n?.event(`TRANSFORM`,`TOOL_CALL_START`,e,{toolCallId:c.toolCallId,toolCallName:c.toolCallName})}if(c.delta!==void 0){let e={type:M.TOOL_CALL_ARGS,toolCallId:i.toolCallId,delta:c.delta};l.push(e),n?.event(`TRANSFORM`,`TOOL_CALL_ARGS`,e,{toolCallId:i.toolCallId})}return l;case M.REASONING_MESSAGE_CHUNK:let d=e,f=[];if((o!==`reasoning`||d.messageId&&d.messageId!==a?.messageId)&&f.push(...u()),o!==`reasoning`){if(d.messageId===void 0)throw Error(`First REASONING_MESSAGE_CHUNK must have a messageId`);a={messageId:d.messageId},o=`reasoning`;let e={type:M.REASONING_MESSAGE_START,messageId:d.messageId};f.push(e),n?.event(`TRANSFORM`,`REASONING_MESSAGE_START`,e,{messageId:d.messageId})}if(d.delta!==void 0){let e={type:M.REASONING_MESSAGE_CONTENT,messageId:a.messageId,delta:d.delta};f.push(e),n?.event(`TRANSFORM`,`REASONING_MESSAGE_CONTENT`,e,{messageId:a.messageId})}return f}return e.type,[]}),ec(()=>{u()}))};function Sf(e,t=new Date){return e.expiresAt===void 0?!1:new Date(e.expiresAt)<=t}function Cf(e,t){let n=new Set(e.map(e=>e.id)),r=new Set(Object.keys(t)),i=[...n].filter(e=>!r.has(e));if(i.length>0)throw Error(`buildResumeArray: missing responses for open interrupts: ${i.join(`, `)}`);let a=[...r].filter(e=>!n.has(e));if(a.length>0)throw Error(`buildResumeArray: responses reference unknown interrupt ids: ${a.join(`, `)}`);return e.map(e=>{let n=t[e.id];if(n.status===`resolved`){let t={interruptId:e.id,status:`resolved`};return n.payload!==void 0&&(t.payload=n.payload),t}return{interruptId:e.id,status:`cancelled`}})}var wf=class{runNext(e,t){return t.run(e).pipe(xf(!1))}runNextWithState(e,t){let n=Zd(e.messages||[]),r=Zd(e.state||{}),i=new cs;return lf(e,i,t,[]).subscribe(e=>{e.messages!==void 0&&(n=e.messages),e.state!==void 0&&(r=e.state)}),this.runNext(e,t).pipe(Qs(async e=>(i.next(e),await new Promise(e=>setTimeout(e,0)),{event:e,messages:Zd(n),state:Zd(r)})))}},Tf=class extends wf{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function Ef(e){let t=e.content;if(Array.isArray(t)){let n=t.filter(e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``);return{...e,content:n}}return typeof t==`string`?e:{...e,content:``}}var Df=class extends wf{run(e,t){let{parentRunId:n,...r}=e,i={...r,messages:r.messages.map(Ef)};return this.runNext(i,t)}},Of=`THINKING_START`,kf=`THINKING_END`,Af=`THINKING_TEXT_MESSAGE_START`,jf=`THINKING_TEXT_MESSAGE_CONTENT`,Mf=`THINKING_TEXT_MESSAGE_END`,Nf=class extends wf{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(e,t){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(e,t).pipe(Ks(e=>this.transformEvent(e)))}transformEvent(e){switch(e.type){case Of:{this.currentReasoningId=Qd();let{title:t,...n}=e;return this.warnAboutTransformation(Of,M.REASONING_START),{...n,type:M.REASONING_START,messageId:this.currentReasoningId}}case Af:return this.currentMessageId=Qd(),this.warnAboutTransformation(Af,M.REASONING_MESSAGE_START),{...e,type:M.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:`assistant`};case jf:{let{delta:t,...n}=e;return this.warnAboutTransformation(jf,M.REASONING_MESSAGE_CONTENT),{...n,type:M.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??Qd(),delta:t}}case Mf:{let t=this.currentMessageId??Qd();return this.warnAboutTransformation(Mf,M.REASONING_MESSAGE_END),{...e,type:M.REASONING_MESSAGE_END,messageId:t}}case kf:{let t=this.currentReasoningId??Qd();return this.warnAboutTransformation(kf,M.REASONING_END),{...e,type:M.REASONING_END,messageId:t}}default:return e}}};function Pf(e){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:`document`}function Ff(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`binary`&&`mimeType`in e&&typeof e.mimeType==`string`}function If(e){let t=Pf(e.mimeType);return e.data?{type:t,source:{type:`data`,value:e.data,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e.url?{type:t,source:{type:`url`,value:e.url,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e}function Lf(e){let t=e.content;if(!Array.isArray(t))return e;let n=t.map(e=>Ff(e)?If(e):e);return{...e,content:n}}var Rf=class extends wf{run(e,t){let n={...e,messages:e.messages.map(Lf)};return this.runNext(n,t)}},zf=`0.0.57`,Bf=class{get maxVersion(){return zf}get debug(){return this._debug}set debug(e){this._debug=rf(e),this._debugLogger=sf(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(e){typeof e==`boolean`?this._debugLogger=e?sf(rf(!0)):void 0:this._debugLogger=e}constructor({agentId:e,description:t,threadId:n,initialMessages:r,initialState:i,debug:a}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.agentId=e,this.description=t??``,this.threadId=n??bn(),this.messages=Zd(r??[]),this.state=Zd(i??{}),this._debug=rf(a),this._debugLogger=sf(this._debug),Xd(this.maxVersion,`0.0.39`)<=0&&this.middlewares.unshift(new Df),Xd(this.maxVersion,`0.0.45`)<=0&&this.middlewares.unshift(new Nf),Xd(this.maxVersion,`0.0.47`)<=0&&this.middlewares.unshift(new Rf)}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}}use(...e){let t=e.map(e=>typeof e==`function`?new Tf(e):e);return this.middlewares.push(...t),this}async runAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??bn();let n=this.prepareRunAgentInput(e);this.debugLogger?.lifecycle(`LIFECYCLE`,`Run started:`,{agentId:this.agentId,threadId:this.threadId});let r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];await this.onInitialize(n,a),this.activeRunDetach$=new as;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await Gs(Jo(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(n),xf(this.debugLogger),uf(this.debugLogger),e=>e.pipe(nc(this.activeRunDetach$)),e=>this.apply(n,e,a),e=>this.processApplyEvents(n,e,a),Zs(e=>(this.debugLogger?.lifecycle(`LIFECYCLE`,`Run errored:`,{agentId:this.agentId,error:e instanceof Error?e.message:String(e)}),this.isRunning=!1,this.onError(n,e,a))),ec(()=>{this.debugLogger?.lifecycle(`LIFECYCLE`,`Run finished:`,{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(Hs(null)));let s=Zd(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}connect(e){throw new Mi}async connectAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??bn();let n=this.prepareRunAgentInput(e),r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];await this.onInitialize(n,a),this.activeRunDetach$=new as;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await Gs(Jo(()=>Xs(()=>this.connect(n)),xf(this.debugLogger),uf(this.debugLogger),e=>e.pipe(nc(this.activeRunDetach$)),e=>this.apply(n,e,a),e=>this.processApplyEvents(n,e,a),Zs(e=>(this.isRunning=!1,e instanceof Mi?ls:this.onError(n,e,a))),ec(()=>{this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(Hs(null)),{defaultValue:void 0});let s=Zd(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let e=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await e}apply(e,t,n){return lf(e,t,this,n,this.debugLogger)}processApplyEvents(e,t,n){return t.pipe(rc(t=>{t.messages&&(this.messages=t.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),t.state&&(this.state=t.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}))}prepareRunAgentInput(e){let t=Zd(this.messages).filter(e=>e.role!==`activity`);return{threadId:this.threadId,runId:e?.runId||bn(),tools:Zd(e?.tools??[]),context:Zd(e?.context??[]),forwardedProps:Zd(e?.forwardedProps??{}),state:Zd(this.state),messages:t,...e?.resume===void 0?{}:{resume:Zd(e.resume)}}}async onInitialize(e,t){if(this.pendingInterrupts.length>0){let t=new Set((e.resume??[]).map(e=>e.interruptId)),n=this.pendingInterrupts.map(e=>e.id).filter(e=>!t.has(e));if(n.length>0)throw new ji(`Thread has ${n.length} pending interrupt(s) not addressed by resume: ${n.join(`, `)}`);for(let e of this.pendingInterrupts)if(Sf(e))throw new ji(`Interrupt ${e.id} expired at ${e.expiresAt}`)}let n=await nf(t,this.messages,this.state,(t,n,r)=>t.onRunInitialized?.({messages:n,state:r,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages&&(this.messages=n.messages,e.messages=n.messages,t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state&&(this.state=n.state,e.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}onError(e,t,n){return Vs(nf(n,this.messages,this.state,(n,r,i)=>n.onRunFailed?.({error:t,messages:r,state:i,agent:this,input:e}))).pipe(Ks(r=>{let i=r;if((i.messages!==void 0||i.state!==void 0)&&(i.messages!==void 0&&(this.messages=i.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),i.state!==void 0&&(this.state=i.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))),i.stopPropagation!==!0){let e=String(t);if(!(t.name===`AbortError`||t.message===`Fetch is aborted`||t.message===`signal is aborted without reason`||t.message===`component unmounted`||e===`component unmounted`))throw console.error(`Agent execution failed:`,t),t}return{}}))}async onFinalize(e,t){let n=await nf(t,this.messages,this.state,(t,n,r)=>t.onRunFinalized?.({messages:n,state:r,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state!==void 0&&(this.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}clone(){let e=Object.create(Object.getPrototypeOf(this));return e.agentId=this.agentId,e.description=this.description,e.threadId=this.threadId,e.messages=Zd(this.messages),e.state=Zd(this.state),e._debug=this._debug,e._debugLogger=this._debugLogger,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e.pendingInterrupts=Zd(this.pendingInterrupts),e}addMessage(e){this.messages.push(e),(async()=>{for(let t of this.subscribers)await t.onNewMessage?.({message:e,messages:this.messages,state:this.state,agent:this});if(e.role===`assistant`&&e.toolCalls)for(let t of e.toolCalls)for(let e of this.subscribers)await e.onNewToolCall?.({toolCall:t,messages:this.messages,state:this.state,agent:this});for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(e){this.messages.push(...e),(async()=>{for(let t of e){for(let e of this.subscribers)await e.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role===`assistant`&&t.toolCalls)for(let e of t.toolCalls)for(let t of this.subscribers)await t.onNewToolCall?.({toolCall:e,messages:this.messages,state:this.state,agent:this})}for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(e){this.messages=Zd(e),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(e){this.state=Zd(e),(async()=>{for(let e of this.subscribers)await e.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(e){this.agentId=this.agentId??bn();let t=this.prepareRunAgentInput(e);return(this.middlewares.length===0?this.run(t):this.middlewares.reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(t)).pipe(xf(this.debugLogger),uf(this.debugLogger),yf(this.threadId,t.runId,this.agentId),e=>e.pipe(Ks(e=>(this.debugLogger?.event(`LEGACY`,`Event:`,e,{type:e.type}),e))))}},Vf=class extends Bf{requestInit(e){return{method:`POST`,headers:{...this.headers,"Content-Type":`application/json`,Accept:`text/event-stream`},body:JSON.stringify(e),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(e){super(e),this.abortController=new AbortController,this.url=e.url,this.headers=Zd(e.headers??{}),this.fetch=e.fetch??((e,t)=>fetch(e,t))}run(e){return hf(ff(()=>this.fetch(this.url,this.requestInit(e))),this.debugLogger)}clone(){let e=super.clone();e.url=this.url,e.headers=Zd(this.headers??{}),e.fetch=this.fetch;let t=new AbortController,n=this.abortController.signal;return n.aborted&&t.abort(n.reason),e.abortController=t,e}},Hf;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(Hf||={});var Uf;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Uf||={});var Wf=Hf.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Gf=e=>{switch(typeof e){case`undefined`:return Wf.undefined;case`string`:return Wf.string;case`number`:return Number.isNaN(e)?Wf.nan:Wf.number;case`boolean`:return Wf.boolean;case`function`:return Wf.function;case`bigint`:return Wf.bigint;case`symbol`:return Wf.symbol;case`object`:return Array.isArray(e)?Wf.array:e===null?Wf.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?Wf.promise:typeof Map<`u`&&e instanceof Map?Wf.map:typeof Set<`u`&&e instanceof Set?Wf.set:typeof Date<`u`&&e instanceof Date?Wf.date:Wf.object;default:return Wf.unknown}},R=Hf.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),Kf=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Hf.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Kf.create=e=>new Kf(e);var qf=(e,t)=>{let n;switch(e.code){case R.invalid_type:n=e.received===Wf.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case R.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Hf.jsonStringifyReplacer)}`;break;case R.unrecognized_keys:n=`Unrecognized key(s) in object: ${Hf.joinValues(e.keys,`, `)}`;break;case R.invalid_union:n=`Invalid input`;break;case R.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Hf.joinValues(e.options)}`;break;case R.invalid_enum_value:n=`Invalid enum value. Expected ${Hf.joinValues(e.options)}, received '${e.received}'`;break;case R.invalid_arguments:n=`Invalid function arguments`;break;case R.invalid_return_type:n=`Invalid function return type`;break;case R.invalid_date:n=`Invalid date`;break;case R.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Hf.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case R.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case R.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case R.custom:n=`Invalid input`;break;case R.invalid_intersection_types:n=`Intersection results could not be merged`;break;case R.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case R.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,Hf.assertNever(e)}return{message:n}},Jf=qf;function Yf(){return Jf}var Xf=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function z(e,t){let n=Yf(),r=Xf({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===qf?void 0:qf].filter(e=>!!e)});e.common.issues.push(r)}var Zf=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return Qf;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return Qf;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},Qf=Object.freeze({status:`aborted`}),$f=e=>({status:`dirty`,value:e}),ep=e=>({status:`valid`,value:e}),tp=e=>e.status===`aborted`,np=e=>e.status===`dirty`,rp=e=>e.status===`valid`,ip=e=>typeof Promise<`u`&&e instanceof Promise,ap;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(ap||={});var op=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},sp=(e,t)=>{if(rp(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new Kf(e.common.issues);return this._error=t,this._error}}};function cp(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var lp=class{get description(){return this._def.description}_getType(e){return Gf(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Gf(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Zf,ctx:{common:e.parent.common,data:e.data,parsedType:Gf(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ip(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Gf(e)};return sp(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Gf(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return rp(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>rp(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Gf(e)},r=this._parse({data:e,path:n.path,parent:n});return sp(n,await(ip(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:R.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new fm({schema:this,typeName:xm.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return pm.create(this,this._def)}nullable(){return mm.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qp.create(this)}promise(){return dm.create(this,this._def)}or(e){return Xp.create([this,e],this._def)}and(e){return em.create(this,e,this._def)}transform(e){return new fm({...cp(this._def),schema:this,typeName:xm.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new hm({...cp(this._def),innerType:this,defaultValue:t,typeName:xm.ZodDefault})}brand(){return new vm({typeName:xm.ZodBranded,type:this,...cp(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new gm({...cp(this._def),innerType:this,catchValue:t,typeName:xm.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ym.create(this,e)}readonly(){return bm.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},up=/^c[^\s-]{8,}$/i,dp=/^[0-9a-z]+$/,fp=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pp=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,mp=/^[a-z0-9_-]{21}$/i,hp=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,gp=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,_p=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,vp=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,yp,bp=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,xp=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Sp=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Cp=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wp=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Tp=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ep=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,Dp=RegExp(`^${Ep}$`);function Op(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function kp(e){return RegExp(`^${Op(e)}$`)}function Ap(e){let t=`${Ep}T${Op(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function jp(e,t){return!!((t===`v4`||!t)&&bp.test(e)||(t===`v6`||!t)&&Sp.test(e))}function Mp(e,t){if(!hp.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Np(e,t){return!!((t===`v4`||!t)&&xp.test(e)||(t===`v6`||!t)&&Cp.test(e))}var Pp=class e extends lp{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Wf.string){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:Wf.string,received:t.parsedType}),Qf}let t=new Zf,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),z(n,{code:R.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),z(n,{code:R.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?z(n,{code:R.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&z(n,{code:R.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)_p.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`email`,code:R.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)yp||=new RegExp(vp,`u`),yp.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`emoji`,code:R.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)pp.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`uuid`,code:R.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)mp.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`nanoid`,code:R.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)up.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`cuid`,code:R.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)dp.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`cuid2`,code:R.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)fp.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`ulid`,code:R.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),z(n,{validation:`url`,code:R.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`regex`,code:R.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),z(n,{code:R.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),z(n,{code:R.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),z(n,{code:R.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Ap(r).test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:R.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Dp.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:R.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?kp(r).test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:R.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?gp.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`duration`,code:R.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?jp(e.data,r.version)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`ip`,code:R.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Mp(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`jwt`,code:R.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?Np(e.data,r.version)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`cidr`,code:R.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?wp.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`base64`,code:R.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Tp.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`base64url`,code:R.invalid_string,message:r.message}),t.dirty()):Hf.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:R.invalid_string,...ap.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...ap.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...ap.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...ap.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...ap.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...ap.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...ap.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...ap.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...ap.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...ap.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...ap.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...ap.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...ap.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...ap.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...ap.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...ap.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...ap.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...ap.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...ap.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...ap.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...ap.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...ap.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...ap.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...ap.errToObj(t)})}nonempty(e){return this.min(1,ap.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Pp.create=e=>new Pp({checks:[],typeName:xm.ZodString,coerce:e?.coerce??!1,...cp(e)});function Fp(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Ip=class e extends lp{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Wf.number){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:Wf.number,received:t.parsedType}),Qf}let t,n=new Zf;for(let r of this._def.checks)r.kind===`int`?Hf.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),z(t,{code:R.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),z(t,{code:R.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),z(t,{code:R.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Fp(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),z(t,{code:R.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),z(t,{code:R.not_finite,message:r.message}),n.dirty()):Hf.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,ap.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,ap.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,ap.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,ap.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ap.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:ap.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:ap.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:ap.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:ap.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:ap.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:ap.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:ap.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:ap.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:ap.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&Hf.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Ip.create=e=>new Ip({checks:[],typeName:xm.ZodNumber,coerce:e?.coerce||!1,...cp(e)});var Lp=class e extends lp{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Wf.bigint)return this._getInvalidInput(e);let t,n=new Zf;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),z(t,{code:R.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),z(t,{code:R.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),z(t,{code:R.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Hf.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:Wf.bigint,received:t.parsedType}),Qf}gte(e,t){return this.setLimit(`min`,e,!0,ap.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,ap.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,ap.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,ap.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ap.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:ap.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:ap.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:ap.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:ap.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:ap.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Lp.create=e=>new Lp({checks:[],typeName:xm.ZodBigInt,coerce:e?.coerce??!1,...cp(e)});var Rp=class extends lp{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Wf.boolean){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:Wf.boolean,received:t.parsedType}),Qf}return ep(e.data)}};Rp.create=e=>new Rp({typeName:xm.ZodBoolean,coerce:e?.coerce||!1,...cp(e)});var zp=class e extends lp{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Wf.date){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:Wf.date,received:t.parsedType}),Qf}if(Number.isNaN(e.data.getTime()))return z(this._getOrReturnCtx(e),{code:R.invalid_date}),Qf;let t=new Zf,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),z(n,{code:R.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),z(n,{code:R.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):Hf.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:ap.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:ap.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};zp.create=e=>new zp({checks:[],coerce:e?.coerce||!1,typeName:xm.ZodDate,...cp(e)});var Bp=class extends lp{_parse(e){if(this._getType(e)!==Wf.symbol){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:Wf.symbol,received:t.parsedType}),Qf}return ep(e.data)}};Bp.create=e=>new Bp({typeName:xm.ZodSymbol,...cp(e)});var Vp=class extends lp{_parse(e){if(this._getType(e)!==Wf.undefined){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:Wf.undefined,received:t.parsedType}),Qf}return ep(e.data)}};Vp.create=e=>new Vp({typeName:xm.ZodUndefined,...cp(e)});var Hp=class extends lp{_parse(e){if(this._getType(e)!==Wf.null){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:Wf.null,received:t.parsedType}),Qf}return ep(e.data)}};Hp.create=e=>new Hp({typeName:xm.ZodNull,...cp(e)});var Up=class extends lp{constructor(){super(...arguments),this._any=!0}_parse(e){return ep(e.data)}};Up.create=e=>new Up({typeName:xm.ZodAny,...cp(e)});var Wp=class extends lp{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ep(e.data)}};Wp.create=e=>new Wp({typeName:xm.ZodUnknown,...cp(e)});var Gp=class extends lp{_parse(e){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:Wf.never,received:t.parsedType}),Qf}};Gp.create=e=>new Gp({typeName:xm.ZodNever,...cp(e)});var Kp=class extends lp{_parse(e){if(this._getType(e)!==Wf.undefined){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:Wf.void,received:t.parsedType}),Qf}return ep(e.data)}};Kp.create=e=>new Kp({typeName:xm.ZodVoid,...cp(e)});var qp=class e extends lp{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==Wf.array)return z(t,{code:R.invalid_type,expected:Wf.array,received:t.parsedType}),Qf;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(z(t,{code:e?R.too_big:R.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(z(t,{code:R.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(z(t,{code:R.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new op(t,e,t.path,n)))).then(e=>Zf.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new op(t,e,t.path,n)));return Zf.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:ap.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:ap.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:ap.toString(n)}})}nonempty(e){return this.min(1,e)}};qp.create=(e,t)=>new qp({type:e,minLength:null,maxLength:null,exactLength:null,typeName:xm.ZodArray,...cp(t)});function Jp(e){if(e instanceof Yp){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=pm.create(Jp(r))}return new Yp({...e._def,shape:()=>t})}else if(e instanceof qp)return new qp({...e._def,type:Jp(e.element)});else if(e instanceof pm)return pm.create(Jp(e.unwrap()));else if(e instanceof mm)return mm.create(Jp(e.unwrap()));else if(e instanceof tm)return tm.create(e.items.map(e=>Jp(e)));else return e}var Yp=class e extends lp{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=Hf.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==Wf.object){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:Wf.object,received:t.parsedType}),Qf}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Gp&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new op(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Gp){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(z(n,{code:R.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new op(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>Zf.mergeObjectSync(t,e)):Zf.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return ap.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:ap.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:xm.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of Hf.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of Hf.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Jp(this)}partial(t){let n={};for(let e of Hf.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of Hf.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof pm;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return cm(Hf.objectKeys(this.shape))}};Yp.create=(e,t)=>new Yp({shape:()=>e,unknownKeys:`strip`,catchall:Gp.create(),typeName:xm.ZodObject,...cp(t)}),Yp.strictCreate=(e,t)=>new Yp({shape:()=>e,unknownKeys:`strict`,catchall:Gp.create(),typeName:xm.ZodObject,...cp(t)}),Yp.lazycreate=(e,t)=>new Yp({shape:e,unknownKeys:`strip`,catchall:Gp.create(),typeName:xm.ZodObject,...cp(t)});var Xp=class extends lp{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Kf(e.ctx.common.issues));return z(t,{code:R.invalid_union,unionErrors:n}),Qf}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Kf(e));return z(t,{code:R.invalid_union,unionErrors:i}),Qf}}get options(){return this._def.options}};Xp.create=(e,t)=>new Xp({options:e,typeName:xm.ZodUnion,...cp(t)});var Zp=e=>e instanceof om?Zp(e.schema):e instanceof fm?Zp(e.innerType()):e instanceof sm?[e.value]:e instanceof lm?e.options:e instanceof um?Hf.objectValues(e.enum):e instanceof hm?Zp(e._def.innerType):e instanceof Vp?[void 0]:e instanceof Hp?[null]:e instanceof pm?[void 0,...Zp(e.unwrap())]:e instanceof mm?[null,...Zp(e.unwrap())]:e instanceof vm||e instanceof bm?Zp(e.unwrap()):e instanceof gm?Zp(e._def.innerType):[],Qp=class e extends lp{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==Wf.object)return z(t,{code:R.invalid_type,expected:Wf.object,received:t.parsedType}),Qf;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(z(t,{code:R.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Qf)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Zp(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:xm.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...cp(r)})}};function $p(e,t){let n=Gf(e),r=Gf(t);if(e===t)return{valid:!0,data:e};if(n===Wf.object&&r===Wf.object){let n=Hf.objectKeys(t),r=Hf.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=$p(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===Wf.array&&r===Wf.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=$p(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===Wf.date&&r===Wf.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var em=class extends lp{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(tp(e)||tp(r))return Qf;let i=$p(e.value,r.value);return i.valid?((np(e)||np(r))&&t.dirty(),{status:t.value,value:i.data}):(z(n,{code:R.invalid_intersection_types}),Qf)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};em.create=(e,t,n)=>new em({left:e,right:t,typeName:xm.ZodIntersection,...cp(n)});var tm=class e extends lp{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Wf.array)return z(n,{code:R.invalid_type,expected:Wf.array,received:n.parsedType}),Qf;if(n.data.length<this._def.items.length)return z(n,{code:R.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),Qf;!this._def.rest&&n.data.length>this._def.items.length&&(z(n,{code:R.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new op(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>Zf.mergeArray(t,e)):Zf.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};tm.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new tm({items:e,typeName:xm.ZodTuple,rest:null,...cp(t)})};var nm=class e extends lp{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Wf.object)return z(n,{code:R.invalid_type,expected:Wf.object,received:n.parsedType}),Qf;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new op(n,e,n.path,e)),value:a._parse(new op(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?Zf.mergeObjectAsync(t,r):Zf.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof lp?new e({keyType:t,valueType:n,typeName:xm.ZodRecord,...cp(r)}):new e({keyType:Pp.create(),valueType:t,typeName:xm.ZodRecord,...cp(n)})}},rm=class extends lp{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Wf.map)return z(n,{code:R.invalid_type,expected:Wf.map,received:n.parsedType}),Qf;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new op(n,e,n.path,[a,`key`])),value:i._parse(new op(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return Qf;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return Qf;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};rm.create=(e,t,n)=>new rm({valueType:t,keyType:e,typeName:xm.ZodMap,...cp(n)});var im=class e extends lp{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Wf.set)return z(n,{code:R.invalid_type,expected:Wf.set,received:n.parsedType}),Qf;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(z(n,{code:R.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(z(n,{code:R.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return Qf;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new op(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:ap.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:ap.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};im.create=(e,t)=>new im({valueType:e,minSize:null,maxSize:null,typeName:xm.ZodSet,...cp(t)});var am=class e extends lp{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==Wf.function)return z(t,{code:R.invalid_type,expected:Wf.function,received:t.parsedType}),Qf;function n(e,n){return Xf({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Yf(),qf].filter(e=>!!e),issueData:{code:R.invalid_arguments,argumentsError:n}})}function r(e,n){return Xf({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Yf(),qf].filter(e=>!!e),issueData:{code:R.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof dm){let e=this;return ep(async function(...t){let o=new Kf([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return ep(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Kf([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Kf([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:tm.create(t).rest(Wp.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||tm.create([]).rest(Wp.create()),returns:n||Wp.create(),typeName:xm.ZodFunction,...cp(r)})}},om=class extends lp{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};om.create=(e,t)=>new om({getter:e,typeName:xm.ZodLazy,...cp(t)});var sm=class extends lp{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return z(t,{received:t.data,code:R.invalid_literal,expected:this._def.value}),Qf}return{status:`valid`,value:e.data}}get value(){return this._def.value}};sm.create=(e,t)=>new sm({value:e,typeName:xm.ZodLiteral,...cp(t)});function cm(e,t){return new lm({values:e,typeName:xm.ZodEnum,...cp(t)})}var lm=class e extends lp{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return z(t,{expected:Hf.joinValues(n),received:t.parsedType,code:R.invalid_type}),Qf}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return z(t,{received:t.data,code:R.invalid_enum_value,options:n}),Qf}return ep(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};lm.create=cm;var um=class extends lp{_parse(e){let t=Hf.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Wf.string&&n.parsedType!==Wf.number){let e=Hf.objectValues(t);return z(n,{expected:Hf.joinValues(e),received:n.parsedType,code:R.invalid_type}),Qf}if(this._cache||=new Set(Hf.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=Hf.objectValues(t);return z(n,{received:n.data,code:R.invalid_enum_value,options:e}),Qf}return ep(e.data)}get enum(){return this._def.values}};um.create=(e,t)=>new um({values:e,typeName:xm.ZodNativeEnum,...cp(t)});var dm=class extends lp{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==Wf.promise&&t.common.async===!1?(z(t,{code:R.invalid_type,expected:Wf.promise,received:t.parsedType}),Qf):ep((t.parsedType===Wf.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};dm.create=(e,t)=>new dm({type:e,typeName:xm.ZodPromise,...cp(t)});var fm=class extends lp{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===xm.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{z(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return Qf;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?Qf:r.status===`dirty`||t.value===`dirty`?$f(r.value):r});{if(t.value===`aborted`)return Qf;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?Qf:r.status===`dirty`||t.value===`dirty`?$f(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?Qf:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?Qf:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!rp(e))return Qf;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>rp(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):Qf);Hf.assertNever(r)}};fm.create=(e,t,n)=>new fm({schema:e,typeName:xm.ZodEffects,effect:t,...cp(n)}),fm.createWithPreprocess=(e,t,n)=>new fm({schema:t,effect:{type:`preprocess`,transform:e},typeName:xm.ZodEffects,...cp(n)});var pm=class extends lp{_parse(e){return this._getType(e)===Wf.undefined?ep(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};pm.create=(e,t)=>new pm({innerType:e,typeName:xm.ZodOptional,...cp(t)});var mm=class extends lp{_parse(e){return this._getType(e)===Wf.null?ep(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};mm.create=(e,t)=>new mm({innerType:e,typeName:xm.ZodNullable,...cp(t)});var hm=class extends lp{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===Wf.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};hm.create=(e,t)=>new hm({innerType:e,typeName:xm.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...cp(t)});var gm=class extends lp{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ip(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Kf(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Kf(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};gm.create=(e,t)=>new gm({innerType:e,typeName:xm.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...cp(t)});var _m=class extends lp{_parse(e){if(this._getType(e)!==Wf.nan){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:Wf.nan,received:t.parsedType}),Qf}return{status:`valid`,value:e.data}}};_m.create=e=>new _m({typeName:xm.ZodNaN,...cp(e)});var vm=class extends lp{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},ym=class e extends lp{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?Qf:e.status===`dirty`?(t.dirty(),$f(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?Qf:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:xm.ZodPipeline})}},bm=class extends lp{_parse(e){let t=this._def.innerType._parse(e),n=e=>(rp(e)&&(e.value=Object.freeze(e.value)),e);return ip(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};bm.create=(e,t)=>new bm({innerType:e,typeName:xm.ZodReadonly,...cp(t)}),Yp.lazycreate;var xm;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(xm||={});var Sm=Pp.create,Cm=Ip.create;_m.create,Lp.create;var wm=Rp.create;zp.create,Bp.create,Vp.create,Hp.create;var Tm=Up.create;Wp.create,Gp.create,Kp.create;var Em=qp.create,Dm=Yp.create;Yp.strictCreate;var Om=Xp.create;Qp.create,em.create,tm.create;var km=nm.create;rm.create,im.create,am.create,om.create;var Am=sm.create,jm=lm.create;um.create,dm.create,fm.create,pm.create,mm.create;var Mm=fm.createWithPreprocess;ym.create;var Nm={string:(e=>Pp.create({...e,coerce:!0})),number:(e=>Ip.create({...e,coerce:!0})),boolean:(e=>Rp.create({...e,coerce:!0})),bigint:(e=>Lp.create({...e,coerce:!0})),date:(e=>zp.create({...e,coerce:!0}))},Pm=class extends Error{constructor(e,t=`UNKNOWN_ERROR`){super(e),this.name=this.constructor.name,this.code=t,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Fm=class extends Pm{constructor(e,t){super(e,`VALIDATION_ERROR`),this.details=t}},Im=class extends Pm{constructor(e,t){super(e,`DATA_ERROR`),this.path=t}},Lm=class extends Pm{constructor(e,t,n){super(e,`EXPRESSION_ERROR`),this.expression=t,this.details=n}},Rm=class extends Pm{constructor(e){super(e,`STATE_ERROR`)}};function zm(e){return e&&typeof e==`object`&&`value`in e&&`peek`in e}function Bm(e,t){return{name:e.name,returnType:e.returnType,schema:e.schema,execute:t}}var Vm=class{constructor(e,t,n=[],r){this.id=e;let i=new Map;for(let e of t)i.set(e.name,e);this.components=i;let a=new Map;for(let e of n)a.set(e.name,e);this.functions=a,this.themeSchema=r,this.invoker=(e,t,n,r)=>{let i=this.functions.get(e);if(!i)throw new Lm(`Function not found in catalog '${this.id}': ${e}`,e);try{let e=i.schema.parse(t);return i.execute(e,n,r)}catch(t){throw t?.name===`ZodError`||t instanceof Kf?new Lm(`Validation failed for function '${e}': ${t.message}`,e,t.errors??t.issues):t}}}},Hm=class{constructor(){this.listeners=new Set}subscribe(e){return this.listeners.add(e),{unsubscribe:()=>this.listeners.delete(e)}}async emit(e){for(let t of this.listeners)try{await t(e)}catch(e){console.error(`EventEmitter error:`,e)}}dispose(){this.listeners.clear()}},Um=Symbol.for(`preact-signals`);function Wm(){if(Xm>1)Xm--;else{var e,t=!1;for((function(){var e=eh;for(eh=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();Ym!==void 0;){var n=Ym;for(Ym=void 0,Zm++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ah(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(Zm=0,Xm--,t)throw e}}function Gm(e){if(Xm>0)return e();$m=++Qm,Xm++;try{return e()}finally{Wm()}}var Km,qm=void 0;function Jm(e){var t=qm,n=Km;qm=void 0,Km=void 0;try{return e()}finally{qm=t,Km=n}}var Ym=void 0,Xm=0,Zm=0,Qm=0,$m=0,eh=void 0,th=0;function nh(e){if(qm!==void 0){var t=e.n;if(t===void 0||t.t!==qm)return t={i:0,S:e,p:qm.s,n:void 0,t:qm,e:void 0,x:void 0,r:t},qm.s!==void 0&&(qm.s.n=t),qm.s=t,e.n=t,32&qm.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=qm.s,t.n=void 0,qm.s.n=t,qm.s=t),t}}function rh(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}rh.prototype.brand=Um,rh.prototype.h=function(){return!0},rh.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?Jm(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},rh.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&Jm(function(){var e;(e=t.Z)==null||e.call(t)}))}},rh.prototype.subscribe=function(e){var t=this;return mh(function(){var n=t.value;Jm(function(){return e(n)})},{name:`sub`})},rh.prototype.valueOf=function(){return this.value},rh.prototype.toString=function(){return this.value+``},rh.prototype.toJSON=function(){return this.value},rh.prototype.peek=function(){var e=this;return Jm(function(){return e.value})},Object.defineProperty(rh.prototype,"value",{get:function(){var e=nh(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Zm>100)throw Error(`Cycle detected`);(function(e){Xm!==0&&Zm===0&&e.l!==$m&&(e.l=$m,eh={S:e,v:e.v,i:e.i,o:eh})})(this),this.v=e,this.i++,th++,Xm++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Wm()}}}});function ih(e,t){return new rh(e,t)}function ah(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function oh(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function sh(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function ch(e,t){rh.call(this,void 0,t),this.x=e,this.s=void 0,this.g=th-1,this.f=4}ch.prototype=new rh,ch.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===th))return!0;if(this.g=th,this.f|=1,this.i>0&&!ah(this))return this.f&=-2,!0;var e=qm;try{oh(this),qm=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return qm=e,sh(this),this.f&=-2,!0},ch.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}rh.prototype.S.call(this,e)},ch.prototype.U=function(e){if(this.t!==void 0&&(rh.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},ch.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(ch.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=nh(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function lh(e,t){return new ch(e,t)}function uh(e){var t=e.m;if(e.m=void 0,typeof t==`function`){Xm++;var n=qm;qm=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,dh(e),t}finally{qm=n,Wm()}}}function dh(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,uh(e)}function fh(e){if(qm!==this)throw Error(`Out-of-order effect`);sh(this),qm=e,this.f&=-2,8&this.f&&dh(this),Wm()}function ph(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Km&&Km.push(this)}ph.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.m=t)}finally{e()}},ph.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,uh(this),oh(this),Xm++;var e=qm;return qm=this,fh.bind(this,e)},ph.prototype.N=function(){2&this.f||(this.f|=2,this.u=Ym,Ym=this)},ph.prototype.d=function(){this.f|=8,1&this.f||dh(this)},ph.prototype.dispose=function(){this.d()};function mh(e,t){var n=new ph(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}function hh(e){return/^\d+$/.test(e)}var gh=class{constructor(e={}){this.data={},this.signals=new Map,this.subscriptions=new Set,this.data=e}getSignal(e){let t=this.normalizePath(e);return this.signals.has(t)||this.signals.set(t,ih(this.get(t))),this.signals.get(t)}set(e,t){if(e==null)throw new Im(`Path cannot be null or undefined.`);if(e===`/`||e===``)return this.data=t,this.notifyAllSignals(),this;let n=this.parsePath(e),r=n.pop();this.data||={};let i=this.data;for(let t=0;t<n.length;t++){let a=n[t];if(Array.isArray(i)&&!hh(a))throw new Im(`Cannot use non-numeric segment '${a}' on an array in path '${e}'.`,e);if(i[a]!==void 0&&i[a]!==null&&typeof i[a]!=`object`)throw new Im(`Cannot set path '${e}': segment '${a}' is a primitive value.`,e);if(i[a]===void 0||i[a]===null){let e=t<n.length-1?n[t+1]:r;i[a]=hh(e)?[]:{}}i=i[a]}if(Array.isArray(i)&&!hh(r))throw new Im(`Cannot use non-numeric segment '${r}' on an array in path '${e}'.`,e);return t===void 0?Array.isArray(i)?i[parseInt(r,10)]=void 0:delete i[r]:i[r]=t,this.notifySignals(e),this}get(e){if(e==null)throw new Im(`Path cannot be null or undefined.`);if(e===`/`||e===``)return this.data;let t=this.parsePath(e),n=this.data;for(let e of t){if(n==null)return;n=n[e]}return n}subscribe(e,t){let n=this.getSignal(e),r=!0,i=n.peek(),a=mh(()=>{let e=n.value;i=e,r||t(e)});return r=!1,this.subscriptions.add(a),{get value(){return i},unsubscribe:()=>{a(),this.subscriptions.delete(a)}}}dispose(){for(let e of this.subscriptions)e();this.subscriptions.clear(),this.signals.clear()}normalizePath(e){return e.length>1&&e.endsWith(`/`)?e.slice(0,-1):e||`/`}parsePath(e){return e.split(`/`).filter(e=>e.length>0)}notifySignals(e){let t=this.normalizePath(e);Gm(()=>{this.updateSignal(t);let e=t;for(;e!==`/`&&e!==``;)e=e.substring(0,e.lastIndexOf(`/`))||`/`,this.updateSignal(e);for(let e of this.signals.keys())this.isDescendant(e,t)&&this.updateSignal(e)})}updateSignal(e){let t=this.signals.get(e);if(t){let n=this.get(e);Array.isArray(n)?t.value=[...n]:typeof n==`object`&&n?t.value={...n}:t.value=n}}notifyAllSignals(){Gm(()=>{for(let e of this.signals.keys())this.updateSignal(e)})}isDescendant(e,t){return t===`/`||t===``?e!==`/`:e.startsWith(t+`/`)}},_h=class{constructor(){this.components=new Map,this._onCreated=new Hm,this._onDeleted=new Hm,this.onCreated=this._onCreated,this.onDeleted=this._onDeleted}get(e){return this.components.get(e)}get entries(){return this.components.entries()}addComponent(e){if(this.components.has(e.id))throw new Rm(`Component with id '${e.id}' already exists.`);this.components.set(e.id,e),this._onCreated.emit(e)}removeComponent(e){let t=this.components.get(e);t&&(this.components.delete(e),t.dispose(),this._onDeleted.emit(e))}dispose(){for(let e of this.components.values())e.dispose();this.components.clear(),this._onCreated.dispose(),this._onDeleted.dispose()}},vh=Dm({name:Sm().describe(`The name of the action, taken from the component's action.event.name property.`),surfaceId:Sm().describe(`The id of the surface where the event originated.`),sourceComponentId:Sm().describe(`The id of the component that triggered the event.`),timestamp:Sm().datetime().describe(`An ISO 8601 timestamp of when the event occurred.`),context:km(Tm()).describe(`A JSON object containing the key-value pairs from the component's action.event.context, after resolving all data bindings.`)}).strict(),yh=Om([Dm({code:Am(`VALIDATION_FAILED`),surfaceId:Sm().describe(`The id of the surface where the error occurred.`),path:Sm().describe(`The JSON pointer to the field that failed validation (e.g. '/components/0/text').`),message:Sm().describe(`A short one or two sentence description of why validation failed.`)}).strict(),Dm({code:Sm().refine(e=>e!==`VALIDATION_FAILED`),message:Sm().describe(`A short one or two sentence description of why the error occurred.`),surfaceId:Sm().describe(`The id of the surface where the error occurred.`)}).passthrough()]);Dm({version:Am(`v0.9`)}).and(Om([Dm({action:vh}),Dm({error:yh})])),Dm({version:Am(`v0.9`),surfaces:km(Dm({}).passthrough()).describe(`A map of surface IDs to their current data models.`)}).strict();var bh=class{constructor(e,t,n={},r=!1){this.id=e,this.catalog=t,this.theme=n,this.sendDataModel=r,this._onAction=new Hm,this._onError=new Hm,this.onAction=this._onAction,this.onError=this._onError,this.dataModel=new gh({}),this.componentsModel=new _h}async dispatchAction(e,t){if(e&&typeof e==`object`&&`event`in e&&e.event){let n={name:e.event.name,surfaceId:this.id,sourceComponentId:t,timestamp:new Date().toISOString(),context:e.event.context||{}},r=vh.safeParse(n);r.success?await this._onAction.emit(r.data):console.error(`A2UI: Invalid action payload dispatched.`,r.error.format())}}async dispatchError(e){await this._onError.emit({...e,surfaceId:this.id})}dispose(){this.dataModel.dispose(),this.componentsModel.dispose(),this._onAction.dispose(),this._onError.dispose()}},xh=class{constructor(){this.surfaces=new Map,this.surfaceUnsubscribers=new Map,this._onSurfaceCreated=new Hm,this._onSurfaceDeleted=new Hm,this._onAction=new Hm,this.onSurfaceCreated=this._onSurfaceCreated,this.onSurfaceDeleted=this._onSurfaceDeleted,this.onAction=this._onAction}addSurface(e){if(this.surfaces.has(e.id)){console.warn(`Surface ${e.id} already exists. Ignoring.`);return}this.surfaces.set(e.id,e);let t=e.onAction.subscribe(e=>this._onAction.emit(e));this.surfaceUnsubscribers.set(e.id,t),this._onSurfaceCreated.emit(e)}deleteSurface(e){let t=this.surfaces.get(e);if(t){let n=this.surfaceUnsubscribers.get(e);n&&(n.unsubscribe(),this.surfaceUnsubscribers.delete(e)),this.surfaces.delete(e),t.dispose(),this._onSurfaceDeleted.emit(e)}}getSurface(e){return this.surfaces.get(e)}get surfacesMap(){return this.surfaces}dispose(){for(let e of Array.from(this.surfaces.keys()))this.deleteSurface(e);this._onSurfaceCreated.dispose(),this._onSurfaceDeleted.dispose(),this._onAction.dispose()}},Sh=class{constructor(e,t,n){this.id=e,this.type=t,this._onUpdated=new Hm,this.onUpdated=this._onUpdated,this._properties=n}get properties(){return this._properties}set properties(e){this._properties=e,this._onUpdated.emit(this)}dispose(){this._onUpdated.dispose()}get componentTree(){return{id:this.id,type:this.type,...this._properties}}},Ch=Symbol(`Let zodToJsonSchema decide on which parser to use`),wh={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,target:`jsonSchema7`,strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`,openAiAnyTypeName:`OpenAiAnyType`},Th=e=>typeof e==`string`?{...wh,name:e}:{...wh,...e},Eh=e=>{let t=Th(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}};function Dh(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function Oh(e,t,n,r,i){e[t]=n,Dh(e,t,r,i)}var kh=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)},Ah;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(Ah||={});var jh;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(jh||={});var Mh=Ah.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Nh=e=>{switch(typeof e){case`undefined`:return Mh.undefined;case`string`:return Mh.string;case`number`:return Number.isNaN(e)?Mh.nan:Mh.number;case`boolean`:return Mh.boolean;case`function`:return Mh.function;case`bigint`:return Mh.bigint;case`symbol`:return Mh.symbol;case`object`:return Array.isArray(e)?Mh.array:e===null?Mh.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?Mh.promise:typeof Map<`u`&&e instanceof Map?Mh.map:typeof Set<`u`&&e instanceof Set?Mh.set:typeof Date<`u`&&e instanceof Date?Mh.date:Mh.object;default:return Mh.unknown}},B=Ah.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),Ph=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ah.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t=Object.create(null),n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Ph.create=e=>new Ph(e);var Fh=(e,t)=>{let n;switch(e.code){case B.invalid_type:n=e.received===Mh.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case B.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ah.jsonStringifyReplacer)}`;break;case B.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ah.joinValues(e.keys,`, `)}`;break;case B.invalid_union:n=`Invalid input`;break;case B.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ah.joinValues(e.options)}`;break;case B.invalid_enum_value:n=`Invalid enum value. Expected ${Ah.joinValues(e.options)}, received '${e.received}'`;break;case B.invalid_arguments:n=`Invalid function arguments`;break;case B.invalid_return_type:n=`Invalid function return type`;break;case B.invalid_date:n=`Invalid date`;break;case B.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Ah.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case B.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case B.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case B.custom:n=`Invalid input`;break;case B.invalid_intersection_types:n=`Intersection results could not be merged`;break;case B.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case B.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,Ah.assertNever(e)}return{message:n}},Ih=Fh;function Lh(){return Ih}var Rh=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function V(e,t){let n=Lh(),r=Rh({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Fh?void 0:Fh].filter(e=>!!e)});e.common.issues.push(r)}var zh=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return Bh;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return Bh;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},Bh=Object.freeze({status:`aborted`}),Vh=e=>({status:`dirty`,value:e}),Hh=e=>({status:`valid`,value:e}),Uh=e=>e.status===`aborted`,Wh=e=>e.status===`dirty`,Gh=e=>e.status===`valid`,Kh=e=>typeof Promise<`u`&&e instanceof Promise,qh;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(qh||={});var Jh=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Yh=(e,t)=>{if(Gh(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new Ph(e.common.issues);return this._error=t,this._error}}};function Xh(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var Zh=class{get description(){return this._def.description}_getType(e){return Nh(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Nh(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new zh,ctx:{common:e.parent.common,data:e.data,parsedType:Nh(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Kh(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nh(e)};return Yh(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nh(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Gh(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Gh(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nh(e)},r=this._parse({data:e,path:n.path,parent:n});return Yh(n,await(Kh(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:B.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new e_({schema:this,typeName:H.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return t_.create(this,this._def)}nullable(){return n_.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Fg.create(this)}promise(){return $g.create(this,this._def)}or(e){return Rg.create([this,e],this._def)}and(e){return Hg.create(this,e,this._def)}transform(e){return new e_({...Xh(this._def),schema:this,typeName:H.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new r_({...Xh(this._def),innerType:this,defaultValue:t,typeName:H.ZodDefault})}brand(){return new o_({typeName:H.ZodBranded,type:this,...Xh(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new i_({...Xh(this._def),innerType:this,catchValue:t,typeName:H.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return s_.create(this,e)}readonly(){return c_.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Qh=/^c[^\s-]{8,}$/i,$h=/^[0-9a-z]+$/,eg=/^[0-9A-HJKMNP-TV-Z]{26}$/i,tg=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ng=/^[a-z0-9_-]{21}$/i,rg=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ig=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ag=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,og=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,sg,cg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,lg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ug=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,dg=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fg=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,pg=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mg=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,hg=RegExp(`^${mg}$`);function gg(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function _g(e){return RegExp(`^${gg(e)}$`)}function vg(e){let t=`${mg}T${gg(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function yg(e,t){return!!((t===`v4`||!t)&&cg.test(e)||(t===`v6`||!t)&&ug.test(e))}function bg(e,t){if(!rg.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function xg(e,t){return!!((t===`v4`||!t)&&lg.test(e)||(t===`v6`||!t)&&dg.test(e))}var Sg=class e extends Zh{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Mh.string){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:Mh.string,received:t.parsedType}),Bh}let t=new zh,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:B.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:B.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?V(n,{code:B.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&V(n,{code:B.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)ag.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`email`,code:B.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)sg||=new RegExp(og,`u`),sg.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`emoji`,code:B.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)tg.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`uuid`,code:B.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)ng.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`nanoid`,code:B.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Qh.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`cuid`,code:B.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)$h.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`cuid2`,code:B.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)eg.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`ulid`,code:B.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),V(n,{validation:`url`,code:B.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`regex`,code:B.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),V(n,{code:B.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),V(n,{code:B.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),V(n,{code:B.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?vg(r).test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{code:B.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?hg.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{code:B.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?_g(r).test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{code:B.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?ig.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`duration`,code:B.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?yg(e.data,r.version)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`ip`,code:B.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?bg(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`jwt`,code:B.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?xg(e.data,r.version)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`cidr`,code:B.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?fg.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`base64`,code:B.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?pg.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`base64url`,code:B.invalid_string,message:r.message}),t.dirty()):Ah.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:B.invalid_string,...qh.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...qh.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...qh.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...qh.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...qh.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...qh.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...qh.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...qh.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...qh.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...qh.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...qh.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...qh.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...qh.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...qh.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...qh.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...qh.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...qh.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...qh.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...qh.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...qh.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...qh.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...qh.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...qh.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...qh.errToObj(t)})}nonempty(e){return this.min(1,qh.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Sg.create=e=>new Sg({checks:[],typeName:H.ZodString,coerce:e?.coerce??!1,...Xh(e)});function Cg(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var wg=class e extends Zh{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Mh.number){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:Mh.number,received:t.parsedType}),Bh}let t,n=new zh;for(let r of this._def.checks)r.kind===`int`?Ah.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),V(t,{code:B.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),V(t,{code:B.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),V(t,{code:B.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Cg(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),V(t,{code:B.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),V(t,{code:B.not_finite,message:r.message}),n.dirty()):Ah.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,qh.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,qh.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,qh.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,qh.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:qh.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:qh.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:qh.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:qh.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:qh.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:qh.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:qh.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:qh.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:qh.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:qh.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&Ah.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};wg.create=e=>new wg({checks:[],typeName:H.ZodNumber,coerce:e?.coerce||!1,...Xh(e)});var Tg=class e extends Zh{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Mh.bigint)return this._getInvalidInput(e);let t,n=new zh;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),V(t,{code:B.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),V(t,{code:B.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),V(t,{code:B.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Ah.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:Mh.bigint,received:t.parsedType}),Bh}gte(e,t){return this.setLimit(`min`,e,!0,qh.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,qh.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,qh.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,qh.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:qh.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:qh.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:qh.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:qh.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:qh.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:qh.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Tg.create=e=>new Tg({checks:[],typeName:H.ZodBigInt,coerce:e?.coerce??!1,...Xh(e)});var Eg=class extends Zh{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Mh.boolean){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:Mh.boolean,received:t.parsedType}),Bh}return Hh(e.data)}};Eg.create=e=>new Eg({typeName:H.ZodBoolean,coerce:e?.coerce||!1,...Xh(e)});var Dg=class e extends Zh{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Mh.date){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:Mh.date,received:t.parsedType}),Bh}if(Number.isNaN(e.data.getTime()))return V(this._getOrReturnCtx(e),{code:B.invalid_date}),Bh;let t=new zh,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:B.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:B.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):Ah.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:qh.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:qh.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Dg.create=e=>new Dg({checks:[],coerce:e?.coerce||!1,typeName:H.ZodDate,...Xh(e)});var Og=class extends Zh{_parse(e){if(this._getType(e)!==Mh.symbol){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:Mh.symbol,received:t.parsedType}),Bh}return Hh(e.data)}};Og.create=e=>new Og({typeName:H.ZodSymbol,...Xh(e)});var kg=class extends Zh{_parse(e){if(this._getType(e)!==Mh.undefined){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:Mh.undefined,received:t.parsedType}),Bh}return Hh(e.data)}};kg.create=e=>new kg({typeName:H.ZodUndefined,...Xh(e)});var Ag=class extends Zh{_parse(e){if(this._getType(e)!==Mh.null){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:Mh.null,received:t.parsedType}),Bh}return Hh(e.data)}};Ag.create=e=>new Ag({typeName:H.ZodNull,...Xh(e)});var jg=class extends Zh{constructor(){super(...arguments),this._any=!0}_parse(e){return Hh(e.data)}};jg.create=e=>new jg({typeName:H.ZodAny,...Xh(e)});var Mg=class extends Zh{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Hh(e.data)}};Mg.create=e=>new Mg({typeName:H.ZodUnknown,...Xh(e)});var Ng=class extends Zh{_parse(e){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:Mh.never,received:t.parsedType}),Bh}};Ng.create=e=>new Ng({typeName:H.ZodNever,...Xh(e)});var Pg=class extends Zh{_parse(e){if(this._getType(e)!==Mh.undefined){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:Mh.void,received:t.parsedType}),Bh}return Hh(e.data)}};Pg.create=e=>new Pg({typeName:H.ZodVoid,...Xh(e)});var Fg=class e extends Zh{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==Mh.array)return V(t,{code:B.invalid_type,expected:Mh.array,received:t.parsedType}),Bh;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(V(t,{code:e?B.too_big:B.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(V(t,{code:B.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(V(t,{code:B.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new Jh(t,e,t.path,n)))).then(e=>zh.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Jh(t,e,t.path,n)));return zh.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:qh.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:qh.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:qh.toString(n)}})}nonempty(e){return this.min(1,e)}};Fg.create=(e,t)=>new Fg({type:e,minLength:null,maxLength:null,exactLength:null,typeName:H.ZodArray,...Xh(t)});function Ig(e){if(e instanceof Lg){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=t_.create(Ig(r))}return new Lg({...e._def,shape:()=>t})}else if(e instanceof Fg)return new Fg({...e._def,type:Ig(e.element)});else if(e instanceof t_)return t_.create(Ig(e.unwrap()));else if(e instanceof n_)return n_.create(Ig(e.unwrap()));else if(e instanceof Ug)return Ug.create(e.items.map(e=>Ig(e)));else return e}var Lg=class e extends Zh{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=Ah.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==Mh.object){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:Mh.object,received:t.parsedType}),Bh}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ng&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new Jh(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Ng){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(V(n,{code:B.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new Jh(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>zh.mergeObjectSync(t,e)):zh.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return qh.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:qh.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:H.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of Ah.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of Ah.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Ig(this)}partial(t){let n={};for(let e of Ah.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of Ah.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof t_;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Xg(Ah.objectKeys(this.shape))}};Lg.create=(e,t)=>new Lg({shape:()=>e,unknownKeys:`strip`,catchall:Ng.create(),typeName:H.ZodObject,...Xh(t)}),Lg.strictCreate=(e,t)=>new Lg({shape:()=>e,unknownKeys:`strict`,catchall:Ng.create(),typeName:H.ZodObject,...Xh(t)}),Lg.lazycreate=(e,t)=>new Lg({shape:e,unknownKeys:`strip`,catchall:Ng.create(),typeName:H.ZodObject,...Xh(t)});var Rg=class extends Zh{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Ph(e.ctx.common.issues));return V(t,{code:B.invalid_union,unionErrors:n}),Bh}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Ph(e));return V(t,{code:B.invalid_union,unionErrors:i}),Bh}}get options(){return this._def.options}};Rg.create=(e,t)=>new Rg({options:e,typeName:H.ZodUnion,...Xh(t)});var zg=e=>e instanceof Jg?zg(e.schema):e instanceof e_?zg(e.innerType()):e instanceof Yg?[e.value]:e instanceof Zg?e.options:e instanceof Qg?Ah.objectValues(e.enum):e instanceof r_?zg(e._def.innerType):e instanceof kg?[void 0]:e instanceof Ag?[null]:e instanceof t_?[void 0,...zg(e.unwrap())]:e instanceof n_?[null,...zg(e.unwrap())]:e instanceof o_||e instanceof c_?zg(e.unwrap()):e instanceof i_?zg(e._def.innerType):[],Bg=class e extends Zh{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==Mh.object)return V(t,{code:B.invalid_type,expected:Mh.object,received:t.parsedType}),Bh;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(V(t,{code:B.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Bh)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=zg(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:H.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Xh(r)})}};function Vg(e,t){let n=Nh(e),r=Nh(t);if(e===t)return{valid:!0,data:e};if(n===Mh.object&&r===Mh.object){let n=Ah.objectKeys(t),r=Ah.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Vg(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===Mh.array&&r===Mh.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Vg(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===Mh.date&&r===Mh.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Hg=class extends Zh{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Uh(e)||Uh(r))return Bh;let i=Vg(e.value,r.value);return i.valid?((Wh(e)||Wh(r))&&t.dirty(),{status:t.value,value:i.data}):(V(n,{code:B.invalid_intersection_types}),Bh)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Hg.create=(e,t,n)=>new Hg({left:e,right:t,typeName:H.ZodIntersection,...Xh(n)});var Ug=class e extends Zh{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Mh.array)return V(n,{code:B.invalid_type,expected:Mh.array,received:n.parsedType}),Bh;if(n.data.length<this._def.items.length)return V(n,{code:B.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),Bh;!this._def.rest&&n.data.length>this._def.items.length&&(V(n,{code:B.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new Jh(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>zh.mergeArray(t,e)):zh.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Ug.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Ug({items:e,typeName:H.ZodTuple,rest:null,...Xh(t)})};var Wg=class e extends Zh{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Mh.object)return V(n,{code:B.invalid_type,expected:Mh.object,received:n.parsedType}),Bh;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Jh(n,e,n.path,e)),value:a._parse(new Jh(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?zh.mergeObjectAsync(t,r):zh.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Zh?new e({keyType:t,valueType:n,typeName:H.ZodRecord,...Xh(r)}):new e({keyType:Sg.create(),valueType:t,typeName:H.ZodRecord,...Xh(n)})}},Gg=class extends Zh{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Mh.map)return V(n,{code:B.invalid_type,expected:Mh.map,received:n.parsedType}),Bh;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Jh(n,e,n.path,[a,`key`])),value:i._parse(new Jh(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return Bh;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return Bh;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Gg.create=(e,t,n)=>new Gg({valueType:t,keyType:e,typeName:H.ZodMap,...Xh(n)});var Kg=class e extends Zh{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Mh.set)return V(n,{code:B.invalid_type,expected:Mh.set,received:n.parsedType}),Bh;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(V(n,{code:B.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(V(n,{code:B.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return Bh;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new Jh(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:qh.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:qh.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Kg.create=(e,t)=>new Kg({valueType:e,minSize:null,maxSize:null,typeName:H.ZodSet,...Xh(t)});var qg=class e extends Zh{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==Mh.function)return V(t,{code:B.invalid_type,expected:Mh.function,received:t.parsedType}),Bh;function n(e,n){return Rh({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Lh(),Fh].filter(e=>!!e),issueData:{code:B.invalid_arguments,argumentsError:n}})}function r(e,n){return Rh({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Lh(),Fh].filter(e=>!!e),issueData:{code:B.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof $g){let e=this;return Hh(async function(...t){let o=new Ph([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return Hh(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Ph([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Ph([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Ug.create(t).rest(Mg.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Ug.create([]).rest(Mg.create()),returns:n||Mg.create(),typeName:H.ZodFunction,...Xh(r)})}},Jg=class extends Zh{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Jg.create=(e,t)=>new Jg({getter:e,typeName:H.ZodLazy,...Xh(t)});var Yg=class extends Zh{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return V(t,{received:t.data,code:B.invalid_literal,expected:this._def.value}),Bh}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Yg.create=(e,t)=>new Yg({value:e,typeName:H.ZodLiteral,...Xh(t)});function Xg(e,t){return new Zg({values:e,typeName:H.ZodEnum,...Xh(t)})}var Zg=class e extends Zh{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return V(t,{expected:Ah.joinValues(n),received:t.parsedType,code:B.invalid_type}),Bh}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return V(t,{received:t.data,code:B.invalid_enum_value,options:n}),Bh}return Hh(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};Zg.create=Xg;var Qg=class extends Zh{_parse(e){let t=Ah.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Mh.string&&n.parsedType!==Mh.number){let e=Ah.objectValues(t);return V(n,{expected:Ah.joinValues(e),received:n.parsedType,code:B.invalid_type}),Bh}if(this._cache||=new Set(Ah.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=Ah.objectValues(t);return V(n,{received:n.data,code:B.invalid_enum_value,options:e}),Bh}return Hh(e.data)}get enum(){return this._def.values}};Qg.create=(e,t)=>new Qg({values:e,typeName:H.ZodNativeEnum,...Xh(t)});var $g=class extends Zh{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==Mh.promise&&t.common.async===!1?(V(t,{code:B.invalid_type,expected:Mh.promise,received:t.parsedType}),Bh):Hh((t.parsedType===Mh.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};$g.create=(e,t)=>new $g({type:e,typeName:H.ZodPromise,...Xh(t)});var e_=class extends Zh{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===H.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{V(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return Bh;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?Bh:r.status===`dirty`||t.value===`dirty`?Vh(r.value):r});{if(t.value===`aborted`)return Bh;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?Bh:r.status===`dirty`||t.value===`dirty`?Vh(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?Bh:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?Bh:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Gh(e))return Bh;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>Gh(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):Bh);Ah.assertNever(r)}};e_.create=(e,t,n)=>new e_({schema:e,typeName:H.ZodEffects,effect:t,...Xh(n)}),e_.createWithPreprocess=(e,t,n)=>new e_({schema:t,effect:{type:`preprocess`,transform:e},typeName:H.ZodEffects,...Xh(n)});var t_=class extends Zh{_parse(e){return this._getType(e)===Mh.undefined?Hh(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};t_.create=(e,t)=>new t_({innerType:e,typeName:H.ZodOptional,...Xh(t)});var n_=class extends Zh{_parse(e){return this._getType(e)===Mh.null?Hh(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};n_.create=(e,t)=>new n_({innerType:e,typeName:H.ZodNullable,...Xh(t)});var r_=class extends Zh{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===Mh.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};r_.create=(e,t)=>new r_({innerType:e,typeName:H.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...Xh(t)});var i_=class extends Zh{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Kh(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Ph(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Ph(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};i_.create=(e,t)=>new i_({innerType:e,typeName:H.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...Xh(t)});var a_=class extends Zh{_parse(e){if(this._getType(e)!==Mh.nan){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:Mh.nan,received:t.parsedType}),Bh}return{status:`valid`,value:e.data}}};a_.create=e=>new a_({typeName:H.ZodNaN,...Xh(e)});var o_=class extends Zh{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},s_=class e extends Zh{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?Bh:e.status===`dirty`?(t.dirty(),Vh(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?Bh:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:H.ZodPipeline})}},c_=class extends Zh{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Gh(e)&&(e.value=Object.freeze(e.value)),e);return Kh(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};c_.create=(e,t)=>new c_({innerType:e,typeName:H.ZodReadonly,...Xh(t)}),Lg.lazycreate;var H;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(H||={}),Sg.create,wg.create,a_.create,Tg.create,Eg.create,Dg.create,Og.create,kg.create,Ag.create,jg.create,Mg.create,Ng.create,Pg.create,Fg.create,Lg.create,Lg.strictCreate,Rg.create,Bg.create,Hg.create,Ug.create,Wg.create,Gg.create,Kg.create,qg.create,Jg.create,Yg.create,Zg.create,Qg.create,$g.create,e_.create,t_.create,n_.create,e_.createWithPreprocess,s_.create;function l_(e){if(e.target!==`openAi`)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy===`relative`?kh(t,e.currentPath):t.join(`/`)}}function u_(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==H.ZodAny&&(n.items=ev(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&Oh(n,`minItems`,e.minLength.value,e.minLength.message,t),e.maxLength&&Oh(n,`maxItems`,e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Oh(n,`minItems`,e.exactLength.value,e.exactLength.message,t),Oh(n,`maxItems`,e.exactLength.value,e.exactLength.message,t)),n}function d_(e,t){let n={type:`integer`,format:`int64`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`min`:t.target===`jsonSchema7`?r.inclusive?Oh(n,`minimum`,r.value,r.message,t):Oh(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),Oh(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?Oh(n,`maximum`,r.value,r.message,t):Oh(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),Oh(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:Oh(n,`multipleOf`,r.value,r.message,t);break}return n}function f_(){return{type:`boolean`}}function p_(e,t){return ev(e.type._def,t)}var m_=(e,t)=>ev(e.innerType._def,t);function h_(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>h_(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return g_(e,t)}}var g_=(e,t)=>{let n={type:`integer`,format:`unix-time`};if(t.target===`openApi3`)return n;for(let r of e.checks)switch(r.kind){case`min`:Oh(n,`minimum`,r.value,r.message,t);break;case`max`:Oh(n,`maximum`,r.value,r.message,t);break}return n};function __(e,t){return{...ev(e.innerType._def,t),default:e.defaultValue()}}function v_(e,t){return t.effectStrategy===`input`?ev(e.schema._def,t):l_(t)}function y_(e){return{type:`string`,enum:Array.from(e.values)}}var b_=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function x_(e,t){let n=[ev(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),ev(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=t.target===`jsonSchema2019-09`?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(e=>{if(b_(e))i.push(...e.allOf),e.unevaluatedProperties===void 0&&(r=void 0);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}else r=void 0;i.push(t)}}),i.length?{allOf:i,...r}:void 0}function S_(e,t){let n=typeof e.value;return n!==`bigint`&&n!==`number`&&n!==`boolean`&&n!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:t.target===`openApi3`?{type:n===`bigint`?`integer`:n,enum:[e.value]}:{type:n===`bigint`?`integer`:n,const:e.value}}var C_=void 0,w_={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(C_===void 0&&(C_=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),C_),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function T_(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:Oh(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t);break;case`max`:Oh(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`email`:switch(t.emailStrategy){case`format:email`:k_(n,`email`,r.message,t);break;case`format:idn-email`:k_(n,`idn-email`,r.message,t);break;case`pattern:zod`:A_(n,w_.email,r.message,t);break}break;case`url`:k_(n,`uri`,r.message,t);break;case`uuid`:k_(n,`uuid`,r.message,t);break;case`regex`:A_(n,r.regex,r.message,t);break;case`cuid`:A_(n,w_.cuid,r.message,t);break;case`cuid2`:A_(n,w_.cuid2,r.message,t);break;case`startsWith`:A_(n,RegExp(`^${E_(r.value,t)}`),r.message,t);break;case`endsWith`:A_(n,RegExp(`${E_(r.value,t)}$`),r.message,t);break;case`datetime`:k_(n,`date-time`,r.message,t);break;case`date`:k_(n,`date`,r.message,t);break;case`time`:k_(n,`time`,r.message,t);break;case`duration`:k_(n,`duration`,r.message,t);break;case`length`:Oh(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t),Oh(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`includes`:A_(n,RegExp(E_(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&k_(n,`ipv4`,r.message,t),r.version!==`v4`&&k_(n,`ipv6`,r.message,t);break;case`base64url`:A_(n,w_.base64url,r.message,t);break;case`jwt`:A_(n,w_.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&A_(n,w_.ipv4Cidr,r.message,t),r.version!==`v4`&&A_(n,w_.ipv6Cidr,r.message,t);break;case`emoji`:A_(n,w_.emoji(),r.message,t);break;case`ulid`:A_(n,w_.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:k_(n,`binary`,r.message,t);break;case`contentEncoding:base64`:Oh(n,`contentEncoding`,`base64`,r.message,t);break;case`pattern:zod`:A_(n,w_.base64,r.message,t);break}break;case`nanoid`:A_(n,w_.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:(e=>{})(r)}return n}function E_(e,t){return t.patternStrategy===`escape`?O_(e):e}var D_=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function O_(e){let t=``;for(let n=0;n<e.length;n++)D_.has(e[n])||(t+=`\\`),t+=e[n];return t}function k_(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):Oh(e,`format`,t,n,r)}function A_(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:j_(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):Oh(e,`pattern`,j_(t,r),n,r)}function j_(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
|
|
22
|
-
]))`;continue}else if(r[e]===`$`){i+=`($|(?=[\r
|
|
23
|
-
]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function M_(e,t){if(t.target===`openAi`&&console.warn(`Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.`),t.target===`openApi3`&&e.keyType?._def.typeName===H.ZodEnum)return{type:`object`,required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,r)=>({...n,[r]:ev(e.valueType._def,{...t,currentPath:[...t.currentPath,`properties`,r]})??l_(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:`object`,additionalProperties:ev(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(t.target===`openApi3`)return n;if(e.keyType?._def.typeName===H.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=T_(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===H.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===H.ZodBranded&&e.keyType._def.type._def.typeName===H.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=p_(e.keyType._def,t);return{...n,propertyNames:i}}return n}function N_(e,t){return t.mapStrategy===`record`?M_(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[ev(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||l_(t),ev(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||l_(t)],minItems:2,maxItems:2}}}function P_(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function F_(e){return e.target===`openAi`?void 0:{not:l_({...e,currentPath:[...e.currentPath,`not`]})}}function I_(e){return e.target===`openApi3`?{enum:[`null`],nullable:!0}:{type:`null`}}var L_={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function R_(e,t){if(t.target===`openApi3`)return z_(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in L_&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=L_[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return z_(e,t)}var z_=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>ev(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function B_(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target===`openApi3`?{type:L_[e.innerType._def.typeName],nullable:!0}:{type:[L_[e.innerType._def.typeName],`null`]};if(t.target===`openApi3`){let n=ev(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&`$ref`in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let n=ev(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function V_(e,t){let n={type:`number`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`int`:n.type=`integer`,Dh(n,`type`,r.message,t);break;case`min`:t.target===`jsonSchema7`?r.inclusive?Oh(n,`minimum`,r.value,r.message,t):Oh(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),Oh(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?Oh(n,`maximum`,r.value,r.message,t):Oh(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),Oh(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:Oh(n,`multipleOf`,r.value,r.message,t);break}return n}function H_(e,t){let n=t.target===`openAi`,r={type:`object`,properties:{}},i=[],a=e.shape();for(let e in a){let o=a[e];if(o===void 0||o._def===void 0)continue;let s=W_(o);s&&n&&(o._def.typeName===`ZodOptional`&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let c=ev(o._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});c!==void 0&&(r.properties[e]=c,s||i.push(e))}i.length&&(r.required=i);let o=U_(e,t);return o!==void 0&&(r.additionalProperties=o),r}function U_(e,t){if(e.catchall._def.typeName!==`ZodNever`)return ev(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function W_(e){try{return e.isOptional()}catch{return!0}}var G_=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return ev(e.innerType._def,t);let n=ev(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:l_(t)},n]}:l_(t)},K_=(e,t)=>{if(t.pipeStrategy===`input`)return ev(e.in._def,t);if(t.pipeStrategy===`output`)return ev(e.out._def,t);let n=ev(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,ev(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function q_(e,t){return ev(e.type._def,t)}function J_(e,t){let n={type:`array`,uniqueItems:!0,items:ev(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&Oh(n,`minItems`,e.minSize.value,e.minSize.message,t),e.maxSize&&Oh(n,`maxItems`,e.maxSize.value,e.maxSize.message,t),n}function Y_(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>ev(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:ev(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>ev(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function X_(e){return{not:l_(e)}}function Z_(e){return l_(e)}var Q_=(e,t)=>ev(e.innerType._def,t),$_=(e,t,n)=>{switch(t){case H.ZodString:return T_(e,n);case H.ZodNumber:return V_(e,n);case H.ZodObject:return H_(e,n);case H.ZodBigInt:return d_(e,n);case H.ZodBoolean:return f_();case H.ZodDate:return h_(e,n);case H.ZodUndefined:return X_(n);case H.ZodNull:return I_(n);case H.ZodArray:return u_(e,n);case H.ZodUnion:case H.ZodDiscriminatedUnion:return R_(e,n);case H.ZodIntersection:return x_(e,n);case H.ZodTuple:return Y_(e,n);case H.ZodRecord:return M_(e,n);case H.ZodLiteral:return S_(e,n);case H.ZodEnum:return y_(e);case H.ZodNativeEnum:return P_(e);case H.ZodNullable:return B_(e,n);case H.ZodOptional:return G_(e,n);case H.ZodMap:return N_(e,n);case H.ZodSet:return J_(e,n);case H.ZodLazy:return()=>e.getter()._def;case H.ZodPromise:return q_(e,n);case H.ZodNaN:case H.ZodNever:return F_(n);case H.ZodEffects:return v_(e,n);case H.ZodAny:return l_(n);case H.ZodUnknown:return Z_(n);case H.ZodDefault:return __(e,n);case H.ZodBranded:return p_(e,n);case H.ZodReadonly:return Q_(e,n);case H.ZodCatch:return m_(e,n);case H.ZodPipeline:return K_(e,n);case H.ZodFunction:case H.ZodVoid:case H.ZodSymbol:return;default:return(e=>void 0)(t)}};function ev(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==Ch)return i}if(r&&!n){let e=tv(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=$_(e,e.typeName,t),o=typeof a==`function`?ev(a(),t):a;if(o&&nv(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var tv=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:kh(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),l_(t)):t.$refStrategy===`seen`?l_(t):void 0}},nv=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),rv=(e,t)=>{let n=Eh(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:ev(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??l_(n)}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=ev(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??l_(n),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o),n.flags.hasReferencedOpenAiAnyType&&(r||={},r[n.openAiAnyTypeName]||(r[n.openAiAnyTypeName]={type:[`string`,`number`,`integer`,`boolean`,`array`,`null`],items:{$ref:n.$refStrategy===`relative`?`1`:[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join(`/`)}}));let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return n.target===`jsonSchema7`?s.$schema=`http://json-schema.org/draft-07/schema#`:(n.target===`jsonSchema2019-09`||n.target===`openAi`)&&(s.$schema=`https://json-schema.org/draft/2019-09/schema#`),n.target===`openAi`&&(`anyOf`in s||`oneOf`in s||`allOf`in s||`type`in s&&Array.isArray(s.type))&&console.warn(`Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.`),s},iv=class{constructor(e,t){this.catalogs=e,this.actionHandler=t,this.model=new xh,this.actionHandler&&this.model.onAction.subscribe(this.actionHandler)}getClientCapabilities(e){let t={"v0.9":{supportedCatalogIds:this.catalogs.map(e=>e.id)}};return e?.includeInlineCatalogs&&(t[`v0.9`].inlineCatalogs=this.catalogs.map(e=>this.generateInlineCatalog(e))),t}generateInlineCatalog(e){let t={};for(let[n,r]of e.components.entries()){let e=rv(r.schema,{target:`jsonSchema2019-09`});this.processRefs(e),t[n]={allOf:[{$ref:`common_types.json#/$defs/ComponentCommon`},{properties:{component:{const:n},...e.properties},required:[`component`,...e.required||[]]}]}}let n=[];for(let t of e.functions.values()){let e=rv(t.schema,{target:`jsonSchema2019-09`});this.processRefs(e),n.push({name:t.name,description:t.schema.description,returnType:t.returnType,parameters:e})}let r;if(e.themeSchema){let t=rv(e.themeSchema,{target:`jsonSchema2019-09`});this.processRefs(t),r=t.properties}return{catalogId:e.id,components:t,functions:n.length>0?n:void 0,theme:r}}processRefs(e){if(!(typeof e!=`object`||!e)){if(typeof e.description==`string`&&e.description.startsWith(`REF:`)){let t=e.description.substring(4).split(`|`),n=t[0],r=t[1]||``;for(let t of Object.keys(e))delete e[t];e.$ref=n,r&&(e.description=r);return}if(Array.isArray(e))for(let t of e)this.processRefs(t);else for(let t of Object.keys(e))this.processRefs(e[t])}}getClientDataModel(){let e={};for(let t of this.model.surfacesMap.values())t.sendDataModel&&(e[t.id]=t.dataModel.get(`/`));if(Object.keys(e).length!==0)return{version:`v0.9`,surfaces:e}}onSurfaceCreated(e){return this.model.onSurfaceCreated.subscribe(e)}onSurfaceDeleted(e){return this.model.onSurfaceDeleted.subscribe(e)}processMessages(e){for(let t of e)this.processMessage(t)}processMessage(e){let t=[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`].filter(t=>t in e);if(t.length>1)throw new Fm(`Message contains multiple update types: ${t.join(`, `)}.`);if(`createSurface`in e){this.processCreateSurfaceMessage(e);return}if(`deleteSurface`in e){this.processDeleteSurfaceMessage(e);return}if(`updateComponents`in e){this.processUpdateComponentsMessage(e);return}if(`updateDataModel`in e){this.processUpdateDataModelMessage(e);return}}processCreateSurfaceMessage(e){let{surfaceId:t,catalogId:n,theme:r,sendDataModel:i}=e.createSurface,a=this.catalogs.find(e=>e.id===n);if(!a)throw new Rm(`Catalog not found: ${n}`);if(this.model.getSurface(t))throw new Rm(`Surface ${t} already exists.`);let o=new bh(t,a,r,i??!1);this.model.addSurface(o)}processDeleteSurfaceMessage(e){let t=e.deleteSurface;t.surfaceId&&this.model.deleteSurface(t.surfaceId)}processUpdateComponentsMessage(e){let t=e.updateComponents;if(!t.surfaceId)return;let n=this.model.getSurface(t.surfaceId);if(!n)throw new Rm(`Surface not found for message: ${t.surfaceId}`);for(let e of t.components){let{id:t,component:r,...i}=e;if(!t)throw new Fm(`Component '${r}' is missing an 'id'.`);let a=n.componentsModel.get(t);if(a)if(r&&r!==a.type){n.componentsModel.removeComponent(t);let e=new Sh(t,r,i);n.componentsModel.addComponent(e)}else a.properties=i;else{if(!r)throw new Fm(`Cannot create component ${t} without a type.`);let e=new Sh(t,r,i);n.componentsModel.addComponent(e)}}}processUpdateDataModelMessage(e){let t=e.updateDataModel;if(!t.surfaceId)return;let n=this.model.getSurface(t.surfaceId);if(!n)throw new Rm(`Surface not found for message: ${t.surfaceId}`);let r=t.path||`/`,i=t.value;n.dataModel.set(r,i)}resolvePath(e,t){return e.startsWith(`/`)?e:t?`${t.endsWith(`/`)?t:`${t}/`}${e}`:`/${e}`}},av=class e{constructor(e,t){this.surface=e,this.path=t,this.dataModel=e.dataModel,this.functionInvoker=e.catalog.invoker}set(e,t){let n=this.resolvePath(e);this.dataModel.set(n,t)}resolveDynamicValue(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;if(`path`in e){let t=this.resolvePath(e.path);return this.dataModel.get(t)}if(`call`in e){let t=e,n={};for(let[e,r]of Object.entries(t.args))n[e]=this.resolveDynamicValue(r);let r=new AbortController,i=this.evaluateFunctionReactive(t.call,n,r.signal);return i===void 0?void 0:zm(i)?i.peek():i}return e}subscribeDynamicValue(e,t){let n=this.resolveSignal(e),r=!0,i=n.peek(),a=mh(()=>{let e=n.value;i=e,r||t(e)});return r=!1,{get value(){return i},unsubscribe:()=>{a(),n.unsubscribe&&n.unsubscribe()}}}resolveSignal(e){if(typeof e!=`object`||!e||Array.isArray(e))return ih(e);if(`path`in e){let t=this.resolvePath(e.path);return this.dataModel.getSignal(t)}if(`call`in e){let t=e,n={};for(let[e,r]of Object.entries(t.args))n[e]=this.resolveSignal(r);if(Object.keys(n).length===0){let e=new AbortController,n=this.evaluateFunctionReactive(t.call,{},e.signal),r=n instanceof rh?n:ih(n);return r.unsubscribe=()=>e.abort(),r}let r=Object.keys(n),i=ih(void 0),a,o,s=lh(()=>{let e={};for(let t=0;t<r.length;t++)e[r[t]]=n[r[t]].value;return e}),c=mh(()=>{try{let e=s.value;a&&a.abort(),o&&=(o(),void 0),a=new AbortController;let n=this.evaluateFunctionReactive(t.call,e,a.signal);zm(n)?o=mh(()=>{i.value=n.value}):i.value=n}catch(e){this.dispatchExpressionError(e,t.call),i.value=void 0}});return i.unsubscribe=()=>{c(),o&&o(),a&&a.abort();for(let e=0;e<r.length;e++){let t=n[r[e]];t.unsubscribe&&t.unsubscribe()}},i}return ih(e)}resolveAction(e){if(`event`in e){let t={};if(e.event.context)for(let[n,r]of Object.entries(e.event.context))t[n]=this.resolveDynamicValue(r);return{event:{...e.event,context:t}}}return`functionCall`in e?this.resolveDynamicValue(e.functionCall):e}evaluateFunctionReactive(e,t,n){try{return this.functionInvoker(e,t,this,n)}catch(t){this.dispatchExpressionError(t,e);return}}dispatchExpressionError(e,t){if(e?.name===`ZodError`||e instanceof Kf){let n=new Lm(`Validation failed for function '${t}': ${e.message}`,t,e.errors??e.issues);this.surface.dispatchError({code:`EXPRESSION_ERROR`,message:n.message,expression:t,details:n.details})}else e instanceof Lm?this.surface.dispatchError({code:`EXPRESSION_ERROR`,message:e.message,expression:e.expression,details:e.details}):this.surface.dispatchError({code:`EXPRESSION_ERROR`,message:e.message??`An unexpected error occurred in function ${t}.`,expression:t,details:{stack:e.stack}})}nested(t){let n=this.resolvePath(t);return new e(this.surface,n)}resolvePath(e){if(e.startsWith(`/`))return e;if(e===``||e===`.`)return this.path;let t=this.path;return t.endsWith(`/`)&&t.length>1&&(t=t.slice(0,-1)),t===`/`&&(t=``),`${t}/${e}`}},ov=class{constructor(e,t,n=`/`){let r=e.componentsModel.get(t);if(!r)throw new Rm(`Component not found: ${t}`);this.componentModel=r,this.surfaceComponents=e.componentsModel,this.dataContext=new av(e,n),this._actionDispatcher=t=>e.dispatchAction(t,this.componentModel.id)}dispatchAction(e){return this._actionDispatcher(e)}};function sv(e){return cv(e)}function cv(e,t){let n=e;for(;n._def.typeName===`ZodOptional`||n._def.typeName===`ZodNullable`||n._def.typeName===`ZodDefault`;)n=n._def.innerType;if(t===`checks`)return{type:`CHECKABLE`};if(n._def.typeName===`ZodUnion`){let e=n._def.options;if(e.some(e=>e._def.typeName===`ZodObject`&&e._def.shape().event))return{type:`ACTION`};if(e.some(e=>e._def.typeName===`ZodObject`&&e._def.shape().path&&!e._def.shape().componentId))return{type:`DYNAMIC`};if(e.some(e=>e._def.typeName===`ZodObject`&&e._def.shape().componentId&&e._def.shape().path))return{type:`STRUCTURAL`}}else n._def.typeName;if(n._def.typeName===`ZodArray`)return{type:`ARRAY`,element:cv(n._def.type)};if(n._def.typeName===`ZodObject`){let e={},t=n._def.shape();for(let[n,r]of Object.entries(t))e[n]=cv(r,n);return{type:`OBJECT`,shape:e}}return{type:`STATIC`}}var lv=class{constructor(e,t){this.dataListeners=[],this.propsListeners=[],this.currentProps={},this.isConnected=!1,this.context=e,this.behaviorTree=sv(t),this.behaviorTree.type!==`OBJECT`&&(this.behaviorTree={type:`OBJECT`,shape:{}}),this.resolveInitialProps()}resolveInitialProps(){let e=this.context.componentModel.properties,t=this.resolveAndBind(e,this.behaviorTree,[],!0);this.currentProps={...this.currentProps,...t}}connect(){if(this.isConnected)return;this.isConnected=!0;let e=this.context.componentModel.onUpdated.subscribe(()=>{this.rebuildAllBindings()});this.compUnsub=()=>e.unsubscribe(),this.rebuildAllBindings()}rebuildAllBindings(){this.dataListeners.forEach(e=>e()),this.dataListeners=[];let e=this.context.componentModel.properties,t=this.resolveAndBind(e,this.behaviorTree,[],!1);this.currentProps={...this.currentProps,...t},this.notify()}resolveAndBind(e,t,n,r){if(e==null)return e;switch(t.type){case`DYNAMIC`:{let t=this.context.dataContext.subscribeDynamicValue(e,e=>{this.updateDeepValue(n,e),this.notify()});return r?t.unsubscribe():this.dataListeners.push(()=>t.unsubscribe()),t.value}case`ACTION`:return()=>{let t=e=>{if(typeof e!=`object`||!e)return e;if(`path`in e||`call`in e)return this.context.dataContext.resolveDynamicValue(e);if(Array.isArray(e))return e.map(t);let n={};for(let[r,i]of Object.entries(e))n[r]=t(i);return n};this.context.dispatchAction(t(e))};case`STRUCTURAL`:if(e&&typeof e==`object`&&e.path&&e.componentId){let t=this.context.dataContext.subscribeDynamicValue({path:e.path},t=>{let r=Array.isArray(t)?t:[],i=this.context.dataContext.nested(e.path),a=r.map((t,n)=>({id:e.componentId,basePath:i.nested(String(n)).path}));this.updateDeepValue(n,a),this.notify()});r?t.unsubscribe():this.dataListeners.push(()=>t.unsubscribe());let i=Array.isArray(t.value)?t.value:[],a=this.context.dataContext.nested(e.path);return i.map((t,n)=>({id:e.componentId,basePath:a.nested(String(n)).path}))}return e;case`CHECKABLE`:{let t=Array.isArray(e)?e:[],i=t.map(()=>({valid:!0,message:``})),a=n.slice(0,-1),o=()=>{let e=i.filter(e=>!e.valid).map(e=>e.message);this.updateDeepValue([...a,`isValid`],e.length===0),this.updateDeepValue([...a,`validationErrors`],e),this.notify()};t.forEach((e,t)=>{let n=e.condition||e,a=e.message||`Validation failed`;i[t].message=a;let s=this.context.dataContext.subscribeDynamicValue(n,e=>{i[t].valid=!!e,o()});r?s.unsubscribe():this.dataListeners.push(()=>s.unsubscribe()),i[t].valid=!!s.value});let s=i.filter(e=>!e.valid).map(e=>e.message);return this.updateDeepValue([...a,`isValid`],s.length===0),this.updateDeepValue([...a,`validationErrors`],s),e}case`STATIC`:return e;case`ARRAY`:return Array.isArray(e)?e.map((e,i)=>this.resolveAndBind(e,t.element,[...n,i.toString()],r)):e;case`OBJECT`:{if(typeof e!=`object`)return e;let i={};for(let[a,o]of Object.entries(e)){let e=t.shape[a]||{type:`STATIC`};i[a]=this.resolveAndBind(o,e,[...n,a],r)}for(let[n,r]of Object.entries(t.shape))if(r.type===`DYNAMIC`){let t=`set${n.charAt(0).toUpperCase()+n.slice(1)}`,r=e[n];i[t]=e=>{r&&typeof r==`object`&&`path`in r&&this.context.dataContext.set(r.path,e)}}return i}}}updateDeepValue(e,t){this.currentProps=this.cloneAndUpdate(this.currentProps,e,t)}cloneAndUpdate(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(Array.isArray(e)){let t=[...e];return t[Number(r)]=this.cloneAndUpdate(t[Number(r)],i,n),t}else return{...e||{},[r]:this.cloneAndUpdate((e||{})[r],i,n)}}dispose(){this.isConnected&&(this.isConnected=!1,this.dataListeners.forEach(e=>e()),this.dataListeners=[],this.compUnsub&&=(this.compUnsub(),void 0))}notify(){this.propsListeners.forEach(e=>e(this.currentProps))}subscribe(e){return this.propsListeners.length===0&&this.connect(),this.propsListeners.push(e),{unsubscribe:()=>{this.propsListeners=this.propsListeners.filter(t=>t!==e),this.propsListeners.length===0&&this.dispose()}}}get snapshot(){return this.currentProps}},uv=Dm({path:Sm().describe(`A JSON Pointer path to a value in the data model.`)}).describe(`REF:common_types.json#/$defs/DataBinding|A JSON Pointer path to a value in the data model.`),dv=Dm({call:Sm().describe(`The name of the function to call.`),args:km(Tm()).describe(`Arguments passed to the function.`),returnType:jm([`string`,`number`,`boolean`,`array`,`object`,`any`,`void`]).default(`boolean`)}).describe(`REF:common_types.json#/$defs/FunctionCall|Invokes a named function on the client.`),fv=Om([wm(),uv,dv]).describe(`REF:common_types.json#/$defs/DynamicBoolean|A boolean value that can be a literal, a path, or a function call returning a boolean.`),pv=Om([Sm(),uv,dv]).describe(`REF:common_types.json#/$defs/DynamicString|Represents a string`),mv=Om([Cm(),uv,dv]).describe(`REF:common_types.json#/$defs/DynamicNumber|Represents a value that can be either a literal number, a path to a number in the data model, or a function call returning a number.`),hv=Om([Em(Sm()),uv,dv]).describe(`REF:common_types.json#/$defs/DynamicStringList|Represents a value that can be either a literal array of strings, a path to a string array in the data model, or a function call returning a string array.`),gv=Om([Sm(),Cm(),wm(),Em(Tm()),uv,dv]).describe(`REF:common_types.json#/$defs/DynamicValue|A value that can be a literal, a path, or a function call returning any type.`),_v=Sm().describe(`REF:common_types.json#/$defs/ComponentId|The unique identifier for a component.`),vv=Om([Em(_v).describe(`A static list of child component IDs.`),Dm({componentId:_v,path:Sm().describe(`The path to the list of component property objects in the data model.`)}).describe(`A template for generating a dynamic list of children.`)]).describe(`REF:common_types.json#/$defs/ChildList`),yv=Om([Dm({event:Dm({name:Sm(),context:km(gv).optional()})}).describe(`Triggers a server-side event.`),Dm({functionCall:dv}).describe(`Executes a local client-side function.`)]).describe(`REF:common_types.json#/$defs/Action`),bv=Dm({condition:fv,message:Sm().describe(`The error message to display if the check fails.`)}).describe(`REF:common_types.json#/$defs/CheckRule|A check rule consisting of a condition and an error message.`),xv=Dm({checks:Em(bv).optional().describe(`A list of checks to perform.`)}).describe(`REF:common_types.json#/$defs/Checkable|Properties for components that support client-side checks.`),Sv=Dm({label:pv.optional().describe(`REF:common_types.json#/$defs/DynamicString|A short string used by assistive technologies to convey the purpose of an element.`),description:pv.optional().describe(`REF:common_types.json#/$defs/DynamicString|Additional information provided by assistive technologies about an element.`)}).describe(`REF:common_types.json#/$defs/AccessibilityAttributes|Attributes to enhance accessibility.`),Cv={ComponentId:_v,ChildList:vv,DataBinding:uv,DynamicValue:gv,DynamicString:pv,DynamicNumber:mv,DynamicBoolean:fv,DynamicStringList:hv,FunctionCall:dv,CheckRule:bv,Checkable:xv,Action:yv,AccessibilityAttributes:Sv,AnyComponent:Dm({component:Sm().describe(`The type name of the component.`),id:_v.optional(),weight:Cm().optional()}).passthrough().describe(`A generic A2UI component definition.`)},wv=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Tv=o(((e,t)=>{t.exports=wv()})),U=Tv();function Ev(e,t){let n=(0,b.memo)(t,(e,t)=>!(e.props!==t.props||e.context.componentModel.id!==t.context.componentModel.id||e.context.dataContext.path!==t.context.dataContext.path));return{name:e.name,schema:e.schema,render:({context:t,buildChild:r})=>{let i=(0,b.useRef)(null);i.current?i.current.context!==t&&(i.current.dispose(),i.current=new lv(t,e.schema)):i.current=new lv(t,e.schema);let a=i.current,o=(0,b.useSyncExternalStore)((0,b.useCallback)(e=>{let t=a.subscribe(e);return()=>t.unsubscribe()},[a]),(0,b.useCallback)(()=>a.snapshot,[a]));return(0,b.useEffect)(()=>()=>a.dispose(),[a]),(0,U.jsx)(n,{props:o||{},buildChild:r,context:t})}}}var Dv=`16px`,Ov=`1px solid #ccc`,kv=e=>{switch(e){case`center`:return`center`;case`end`:return`flex-end`;case`spaceAround`:return`space-around`;case`spaceBetween`:return`space-between`;case`spaceEvenly`:return`space-evenly`;case`start`:return`flex-start`;case`stretch`:return`stretch`;default:return`flex-start`}},Av=e=>{switch(e){case`start`:return`flex-start`;case`center`:return`center`;case`end`:return`flex-end`;case`stretch`:return`stretch`;default:return`stretch`}},jv=()=>({margin:`8px`,boxSizing:`border-box`}),Mv=()=>({margin:`8px`,padding:Dv,border:Ov,borderRadius:`8px`,boxSizing:`border-box`}),Nv=class e{static{this.MAX_DEPTH=10}parse(t,n=0){if(n>e.MAX_DEPTH)throw new Lm(`Max recursion depth reached in parse`);if(!t||!t.includes("${"))return[t];let r=[],i=new Pv(t);for(;!i.isAtEnd();)if(i.matches("${")){i.advance(2);let e=this.extractInterpolationContent(i),t=this.parseExpression(e,n+1);t!==null&&r.push(t)}else if(i.peek()===`\\`&&i.peek(1)===`$`&&i.peek(2)===`{`)i.advance(),r.push("${"),i.advance(2);else{let e=i.pos;for(;!i.isAtEnd()&&!(i.matches("${")||i.peek()===`\\`&&i.peek(1)===`$`&&i.peek(2)===`{`);)i.advance();r.push(i.input.substring(e,i.pos))}return r.filter(e=>e!==null&&e!==``)}extractInterpolationContent(e){let t=e.pos,n=1;for(;!e.isAtEnd()&&n>0;){let t=e.advance();if(t===`{`)n++;else if(t===`}`)n--;else if(t===`'`||t===`"`){let n=t;for(;!e.isAtEnd();){let t=e.advance();if(t===`\\`)e.advance();else if(t===n)break}}}if(n>0)throw new Lm(`Unclosed interpolation: missing '}'`);return e.input.substring(t,e.pos-1)}parseExpression(e,t=0){if(e=e.trim(),!e)return``;let n=new Pv(e),r=this.parseExpressionInternal(n,t);if(!n.isAtEnd())throw new Lm(`Unexpected characters at end of expression: '${n.input.substring(n.pos)}'`);return r}parseExpressionInternal(e,t){if(e.skipWhitespace(),e.isAtEnd())return``;if(e.matches("${")){e.advance(2);let n=this.extractInterpolationContent(e);return this.parseExpression(n,t+1)}if(e.matchesString(`'`)||e.matchesString(`"`))return this.parseStringLiteral(e);if(this.isDigit(e.peek()))return this.parseNumberLiteral(e);if(e.matchesKeyword(`true`))return!0;if(e.matchesKeyword(`false`))return!1;if(e.matchesKeyword(`null`))return``;let n=this.scanPathOrIdentifier(e);return e.skipWhitespace(),e.peek()===`(`?this.parseFunctionCall(n,e,t):n?{path:n}:``}scanPathOrIdentifier(e){let t=e.pos;for(;!e.isAtEnd();){let t=e.peek();if(this.isAlnum(t)||t===`/`||t===`.`||t===`_`||t===`-`)e.advance();else break}return e.input.substring(t,e.pos)}parseFunctionCall(e,t,n){t.match(`(`),t.skipWhitespace();let r={};for(;!t.isAtEnd()&&t.peek()!==`)`;){let i=this.scanIdentifier(t);if(t.skipWhitespace(),!t.match(`:`))throw new Lm(`Expected ':' after argument name '${i}' in function '${e}'`);t.skipWhitespace(),r[i]=this.parseExpressionInternal(t,n),t.skipWhitespace(),t.peek()===`,`&&(t.advance(),t.skipWhitespace())}if(!t.match(`)`))throw new Lm(`Expected ')' after function arguments for '${e}'`);return{call:e,args:r,returnType:`any`}}scanIdentifier(e){let t=e.pos;for(;!e.isAtEnd()&&(this.isAlnum(e.peek())||e.peek()===`_`);)e.advance();return e.input.substring(t,e.pos)}parseStringLiteral(e){let t=e.advance(),n=``;for(;!e.isAtEnd();){let r=e.advance();if(r===`\\`){let t=e.advance();t===`n`?n+=`
|
|
24
|
-
`:t===`t`?n+=` `:t===`r`?n+=`\r`:n+=t}else if(r===t)break;else n+=r}return n}parseNumberLiteral(e){let t=e.pos;for(;!e.isAtEnd()&&(this.isDigit(e.peek())||e.peek()===`.`);)e.advance();return Number(e.input.substring(t,e.pos))}isAlnum(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`}isDigit(e){return e>=`0`&&e<=`9`}},Pv=class{constructor(e){this.input=e,this.pos=0}isAtEnd(){return this.pos>=this.input.length}peek(e=0){return this.pos+e>=this.input.length?`\0`:this.input[this.pos+e]}advance(e=1){let t=this.input.substring(this.pos,this.pos+e);return this.pos+=e,t}match(e){return this.peek()===e?(this.advance(),!0):!1}matches(e){return!!this.input.startsWith(e,this.pos)}matchesString(e){return this.peek()===e}matchesKeyword(e){if(this.input.startsWith(e,this.pos)){let t=this.peek(e.length);if(!/[a-zA-Z0-9_]/.test(t))return this.advance(e.length),!0}return!1}skipWhitespace(){for(;!this.isAtEnd()&&/\s/.test(this.peek());)this.advance()}},Fv=365.2425,Iv=6048e5,Lv=864e5,Rv=3600*24;Rv*7,Rv*Fv/12*3;var zv=Symbol.for(`constructDateFrom`);function Bv(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&zv in e?e[zv](t):e instanceof Date?new e.constructor(t):new Date(t)}function Vv(e,t){return Bv(t||e,e)}var Hv={};function Uv(){return Hv}function Wv(e,t){let n=Uv(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Vv(e,t?.in),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function Gv(e,t){return Wv(e,{...t,weekStartsOn:1})}function Kv(e,t){let n=Vv(e,t?.in),r=n.getFullYear(),i=Bv(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=Gv(i),o=Bv(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=Gv(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function qv(e){let t=Vv(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function Jv(e,...t){let n=Bv.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function Yv(e,t){let n=Vv(e,t?.in);return n.setHours(0,0,0,0),n}function Xv(e,t,n){let[r,i]=Jv(n?.in,e,t),a=Yv(r),o=Yv(i),s=+a-qv(a),c=+o-qv(o);return Math.round((s-c)/Lv)}function Zv(e,t){let n=Kv(e,t),r=Bv(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),Gv(r)}function Qv(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function $v(e){return!(!Qv(e)&&typeof e!=`number`||isNaN(+Vv(e)))}function ey(e,t){let n=Vv(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}var ty={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},ny=(e,t,n)=>{let r,i=ty[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function ry(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var iy={date:ry({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:ry({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:ry({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},ay={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},oy=(e,t,n,r)=>ay[e];function sy(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var cy={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:sy({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:sy({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:sy({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:sy({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:sy({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function ly(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?dy(s,e=>e.test(o)):uy(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function uy(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function dy(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function fy(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var py={code:`en-US`,formatDistance:ny,formatLong:iy,formatRelative:oy,localize:cy,match:{ordinalNumber:fy({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:ly({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:ly({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:ly({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:ly({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:ly({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function my(e,t){let n=Vv(e,t?.in);return Xv(n,ey(n))+1}function hy(e,t){let n=Vv(e,t?.in),r=Gv(n)-+Zv(n);return Math.round(r/Iv)+1}function gy(e,t){let n=Vv(e,t?.in),r=n.getFullYear(),i=Uv(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=Bv(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=Wv(o,t),c=Bv(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=Wv(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function _y(e,t){let n=Uv(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=gy(e,t),a=Bv(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),Wv(a,t)}function vy(e,t){let n=Vv(e,t?.in),r=Wv(n,t)-+_y(n,t);return Math.round(r/Iv)+1}function yy(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var by={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return yy(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):yy(n+1,2)},d(e,t){return yy(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return yy(e.getHours()%12||12,t.length)},H(e,t){return yy(e.getHours(),t.length)},m(e,t){return yy(e.getMinutes(),t.length)},s(e,t){return yy(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return yy(Math.trunc(r*10**(n-3)),t.length)}},xy={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},Sy={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return by.y(e,t)},Y:function(e,t,n,r){let i=gy(e,r),a=i>0?i:1-i;return t===`YY`?yy(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):yy(a,t.length)},R:function(e,t){return yy(Kv(e),t.length)},u:function(e,t){return yy(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return yy(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return yy(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return by.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return yy(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=vy(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):yy(i,t.length)},I:function(e,t,n){let r=hy(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):yy(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):by.d(e,t)},D:function(e,t,n){let r=my(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):yy(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return yy(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return yy(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return yy(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?xy.noon:r===0?xy.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?xy.evening:r>=12?xy.afternoon:r>=4?xy.morning:xy.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return by.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):by.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):yy(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):yy(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):by.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):by.s(e,t)},S:function(e,t){return by.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return wy(r);case`XXXX`:case`XX`:return Ty(r);default:return Ty(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return wy(r);case`xxxx`:case`xx`:return Ty(r);default:return Ty(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+Cy(r,`:`);default:return`GMT`+Ty(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+Cy(r,`:`);default:return`GMT`+Ty(r,`:`)}},t:function(e,t,n){return yy(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return yy(+e,t.length)}};function Cy(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+yy(a,2)}function wy(e,t){return e%60==0?(e>0?`-`:`+`)+yy(Math.abs(e)/60,2):Ty(e,t)}function Ty(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=yy(Math.trunc(r/60),2),a=yy(r%60,2);return n+i+t+a}var Ey=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},Dy=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},Oy={p:Dy,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return Ey(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,Ey(r,t)).replace(`{{time}}`,Dy(i,t))}},ky=/^D+$/,Ay=/^Y+$/,jy=[`D`,`DD`,`YY`,`YYYY`];function My(e){return ky.test(e)}function Ny(e){return Ay.test(e)}function Py(e,t,n){let r=Fy(e,t,n);if(console.warn(r),jy.includes(e))throw RangeError(r)}function Fy(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var Iy=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ly=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Ry=/^'([^]*?)'?$/,zy=/''/g,By=/[a-zA-Z]/;function Vy(e,t,n){let r=Uv(),i=n?.locale??r.locale??py,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=Vv(e,n?.in);if(!$v(s))throw RangeError(`Invalid time value`);let c=t.match(Ly).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=Oy[t];return n(e,i.formatLong)}return e}).join(``).match(Iy).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:Hy(e)};if(Sy[t])return{isToken:!0,value:e};if(t.match(By))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&Ny(a)||!n?.useAdditionalDayOfYearTokens&&My(a))&&Py(a,t,String(e));let o=Sy[a[0]];return o(s,a,i.localize,l)}).join(``)}function Hy(e){let t=e.match(Ry);return t?t[1].replace(zy,`'`):e}var Uy={name:`add`,returnType:`number`,schema:Dm({a:Mm(e=>e===null?void 0:e,Nm.number()),b:Mm(e=>e===null?void 0:e,Nm.number())})},Wy={name:`subtract`,returnType:`number`,schema:Dm({a:Mm(e=>e===null?void 0:e,Nm.number()),b:Mm(e=>e===null?void 0:e,Nm.number())})},Gy={name:`multiply`,returnType:`number`,schema:Dm({a:Mm(e=>e===null?void 0:e,Nm.number()),b:Mm(e=>e===null?void 0:e,Nm.number())})},Ky={name:`divide`,returnType:`number`,schema:Dm({a:Mm(e=>e===null?void 0:e,Nm.number()),b:Mm(e=>e===null?void 0:e,Nm.number())})},qy={name:`equals`,returnType:`boolean`,schema:Dm({a:Tm().refine(e=>e!==void 0,`Required`),b:Tm().refine(e=>e!==void 0,`Required`)})},Jy={name:`not_equals`,returnType:`boolean`,schema:Dm({a:Tm().refine(e=>e!==void 0,`Required`),b:Tm().refine(e=>e!==void 0,`Required`)})},Yy={name:`greater_than`,returnType:`boolean`,schema:Dm({a:Mm(e=>e===null?void 0:e,Nm.number()),b:Mm(e=>e===null?void 0:e,Nm.number())})},Xy={name:`less_than`,returnType:`boolean`,schema:Dm({a:Mm(e=>e===null?void 0:e,Nm.number()),b:Mm(e=>e===null?void 0:e,Nm.number())})},Zy={name:`and`,returnType:`boolean`,schema:Dm({values:Em(Tm()).min(2)})},Qy={name:`or`,returnType:`boolean`,schema:Dm({values:Em(Tm()).min(2)})},$y={name:`not`,returnType:`boolean`,schema:Dm({value:Tm().refine(e=>e!==void 0,`Required`)})},eb={name:`contains`,returnType:`boolean`,schema:Dm({string:Mm(e=>e===void 0?void 0:String(e),Sm()),substring:Mm(e=>e===void 0?void 0:String(e),Sm())})},tb={name:`starts_with`,returnType:`boolean`,schema:Dm({string:Mm(e=>e===void 0?void 0:String(e),Sm()),prefix:Mm(e=>e===void 0?void 0:String(e),Sm())})},nb={name:`ends_with`,returnType:`boolean`,schema:Dm({string:Mm(e=>e===void 0?void 0:String(e),Sm()),suffix:Mm(e=>e===void 0?void 0:String(e),Sm())})},rb={name:`required`,returnType:`boolean`,schema:Dm({value:Tm().refine(e=>e!==void 0,`Required`)})},ib={name:`regex`,returnType:`boolean`,schema:Dm({value:Mm(e=>e===void 0?void 0:String(e),Sm()),pattern:Mm(e=>e===void 0?void 0:String(e),Sm())})},ab={name:`length`,returnType:`boolean`,schema:Dm({value:Tm().refine(e=>e!==void 0,`Required`),min:Nm.number().optional(),max:Nm.number().optional()}).refine(e=>e.min!==void 0||e.max!==void 0,{message:`Must provide either 'min' or 'max'`})},ob={name:`numeric`,returnType:`boolean`,schema:Dm({value:Nm.number(),min:Nm.number().optional(),max:Nm.number().optional()}).refine(e=>e.min!==void 0||e.max!==void 0,{message:`Must provide either 'min' or 'max'`})},sb={name:`email`,returnType:`boolean`,schema:Dm({value:Mm(e=>e===void 0?void 0:String(e),Sm())})},cb={name:`formatString`,returnType:`any`,schema:Dm({value:Nm.string()})},lb={name:`formatNumber`,returnType:`string`,schema:Dm({value:Nm.number(),decimals:Nm.number().optional(),grouping:wm().default(!0)})},ub={name:`formatCurrency`,returnType:`string`,schema:Dm({value:Nm.number(),currency:Nm.string(),decimals:Nm.number().optional(),grouping:wm().default(!0)})},db={name:`formatDate`,returnType:`string`,schema:Dm({value:Tm().refine(e=>e!==void 0,`Required`),format:Nm.string()})},fb={name:`pluralize`,returnType:`string`,schema:Dm({value:Nm.number(),zero:Nm.string().optional(),one:Nm.string().optional(),two:Nm.string().optional(),few:Nm.string().optional(),many:Nm.string().optional(),other:Nm.string()}).passthrough()},pb={name:`openUrl`,returnType:`void`,schema:Dm({url:Mm(e=>e===void 0?void 0:String(e),Sm())})},mb=[Bm(Uy,e=>e.a+e.b),Bm(Wy,e=>e.a-e.b),Bm(Gy,e=>e.a*e.b),Bm(Ky,e=>{let t=e.a,n=e.b;if(t==null||n==null)return NaN;let r=Number(t),i=Number(n);return Number.isNaN(r)||Number.isNaN(i)?NaN:i===0?1/0:r/i}),Bm(qy,e=>e.a===e.b),Bm(Jy,e=>e.a!==e.b),Bm(Yy,e=>e.a>e.b),Bm(Xy,e=>e.a<e.b),Bm(Zy,e=>e.values.every(e=>!!e)),Bm(Qy,e=>e.values.some(e=>!!e)),Bm($y,e=>!e.value),Bm(eb,e=>e.string.includes(e.substring)),Bm(tb,e=>e.string.startsWith(e.prefix)),Bm(nb,e=>e.string.endsWith(e.suffix)),Bm(rb,e=>{let t=e.value;return!(t==null||typeof t==`string`&&t===``||Array.isArray(t)&&t.length===0)}),Bm(ib,e=>{try{return new RegExp(e.pattern).test(e.value)}catch(t){throw new Lm(`Invalid regex pattern: ${e.pattern}`,`regex`,t)}}),Bm(ab,e=>{let t=e.value,n=0;return(typeof t==`string`||Array.isArray(t))&&(n=t.length),!(e.min!==void 0&&!isNaN(e.min)&&n<e.min||e.max!==void 0&&!isNaN(e.max)&&n>e.max)}),Bm(ob,e=>!(isNaN(e.value)||e.min!==void 0&&!isNaN(e.min)&&e.value<e.min||e.max!==void 0&&!isNaN(e.max)&&e.value>e.max)),Bm(sb,e=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(e.value)),Bm(cb,(e,t)=>{let n=e.value,r=new Nv().parse(n);if(r.length===0)return``;let i=r.map(e=>typeof e!=`object`||!e||Array.isArray(e)?e:t.resolveSignal(e));return lh(()=>i.map(e=>zm(e)?e.value:e).join(``))}),Bm(lb,e=>isNaN(e.value)?``:new Intl.NumberFormat(`en-US`,{minimumFractionDigits:e.decimals,maximumFractionDigits:e.decimals,useGrouping:e.grouping}).format(e.value)),Bm(ub,e=>{if(isNaN(e.value))return``;try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:e.currency,minimumFractionDigits:e.decimals,maximumFractionDigits:e.decimals,useGrouping:e.grouping}).format(e.value)}catch{return e.value.toFixed(e.decimals||2)}}),Bm(db,e=>{if(!e.value)return``;let t=new Date(e.value);if(isNaN(t.getTime()))return``;try{return e.format===`ISO`?t.toISOString():Vy(t,e.format)}catch(e){return console.warn(`Error formatting date:`,e),t.toISOString()}}),Bm(fb,e=>{let t=new Intl.PluralRules(`en-US`).select(e.value);return String(e[t]||e.other||``)}),Bm(pb,e=>{e.url&&typeof window<`u`&&window.open&&window.open(e.url,`_blank`)})],hb={accessibility:Sv.optional(),weight:Cm().describe(`The relative weight of this component within a Row or Column. This is similar to the CSS 'flex-grow' property. Note: this may ONLY be set when the component is a direct descendant of a Row or Column.`).optional()},gb={name:`Text`,schema:Dm({...hb,text:pv.describe(`The text content to display. While simple Markdown formatting is supported (i.e. without HTML, images, or links), utilizing dedicated UI components is generally preferred for a richer and more structured presentation.`),variant:jm([`h1`,`h2`,`h3`,`h4`,`h5`,`caption`,`body`]).default(`body`).describe(`A hint for the base text style.`).optional()}).strict()},_b={name:`Image`,schema:Dm({...hb,url:pv.describe(`The URL of the image to display.`),description:pv.describe(`The accessibility description of the image.`).optional(),fit:jm([`contain`,`cover`,`fill`,`none`,`scaleDown`]).default(`fill`).describe(`Specifies how the image should be resized to fit its container. This corresponds to the CSS 'object-fit' property.`).optional(),variant:jm([`icon`,`avatar`,`smallFeature`,`mediumFeature`,`largeFeature`,`header`]).default(`mediumFeature`).describe(`A hint for the image size and style.`).optional()}).strict()},vb=`accountCircle.add.arrowBack.arrowForward.attachFile.calendarToday.call.camera.check.close.delete.download.edit.event.error.fastForward.favorite.favoriteOff.folder.help.home.info.locationOn.lock.lockOpen.mail.menu.moreVert.moreHoriz.notificationsOff.notifications.pause.payment.person.phone.photo.play.print.refresh.rewind.search.send.settings.share.shoppingCart.skipNext.skipPrevious.star.starHalf.starOff.stop.upload.visibility.visibilityOff.volumeDown.volumeMute.volumeOff.volumeUp.warning`.split(`.`),yb={name:`Icon`,schema:Dm({...hb,name:Om([jm(vb),Dm({path:Sm()}).strict()]).describe(`The name of the icon to display.`)}).strict()},bb={name:`Video`,schema:Dm({...hb,url:pv.describe(`The URL of the video to display.`)}).strict()},xb={name:`AudioPlayer`,schema:Dm({...hb,url:pv.describe(`The URL of the audio to be played.`),description:pv.describe(`A description of the audio, such as a title or summary.`).optional()}).strict()},Sb={name:`Row`,schema:Dm({...hb,children:vv.describe(`Defines the children. Use an array of strings for a fixed set of children, or a template object to generate children from a data list. Children cannot be defined inline, they must be referred to by ID.`),justify:jm([`center`,`end`,`spaceAround`,`spaceBetween`,`spaceEvenly`,`start`,`stretch`]).default(`start`).describe(`Defines the arrangement of children along the main axis (horizontally). Use 'spaceBetween' to push items to the edges, or 'start'/'end'/'center' to pack them together.`).optional(),align:jm([`start`,`center`,`end`,`stretch`]).default(`stretch`).describe(`Defines the alignment of children along the cross axis (vertically). This is similar to the CSS 'align-items' property, but uses camelCase values (e.g., 'start').`).optional()}).strict().describe(`A layout component that arranges its children horizontally. To create a grid layout, nest Columns within this Row.`)},Cb={name:`Column`,schema:Dm({...hb,children:vv.describe(`Defines the children. Use an array of strings for a fixed set of children, or a template object to generate children from a data list. Children cannot be defined inline, they must be referred to by ID.`),justify:jm([`start`,`center`,`end`,`spaceBetween`,`spaceAround`,`spaceEvenly`,`stretch`]).default(`start`).describe(`Defines the arrangement of children along the main axis (vertically). Use 'spaceBetween' to push items to the edges (e.g. header at top, footer at bottom), or 'start'/'end'/'center' to pack them together.`).optional(),align:jm([`center`,`end`,`start`,`stretch`]).default(`stretch`).describe(`Defines the alignment of children along the cross axis (horizontally). This is similar to the CSS 'align-items' property.`).optional()}).strict().describe(`A layout component that arranges its children vertically. To create a grid layout, nest Rows within this Column.`)},wb={name:`List`,schema:Dm({...hb,children:vv.describe(`Defines the children. Use an array of strings for a fixed set of children, or a template object to generate children from a data list.`),direction:jm([`vertical`,`horizontal`]).default(`vertical`).describe(`The direction in which the list items are laid out.`).optional(),align:jm([`start`,`center`,`end`,`stretch`]).default(`stretch`).describe(`Defines the alignment of children along the cross axis.`).optional()}).strict()},Tb={name:`Card`,schema:Dm({...hb,child:_v.describe(`The ID of the single child component to be rendered inside the card. To display multiple elements, you MUST wrap them in a layout component (like Column or Row) and pass that container's ID here. Do NOT pass multiple IDs or a non-existent ID. Do NOT define the child component inline.`)}).strict()},Eb={name:`Tabs`,schema:Dm({...hb,tabs:Em(Dm({title:pv.describe(`The tab title.`),child:_v.describe(`The ID of the child component. Do NOT define the component inline.`)}).strict()).min(1).describe(`An array of objects, where each object defines a tab with a title and a child component.`)}).strict()},Db={name:`Modal`,schema:Dm({...hb,trigger:_v.describe(`The ID of the component that opens the modal when interacted with (e.g., a button). Do NOT define the component inline.`),content:_v.describe(`The ID of the component to be displayed inside the modal. Do NOT define the component inline.`)}).strict()},Ob={name:`Divider`,schema:Dm({...hb,axis:jm([`horizontal`,`vertical`]).default(`horizontal`).describe(`The orientation of the divider.`).optional()}).strict()},kb={name:`Button`,schema:Dm({...hb,child:_v.describe(`The ID of the child component. Use a 'Text' component for a labeled button. Only use an 'Icon' if the requirements explicitly ask for an icon-only button. Do NOT define the child component inline.`),variant:jm([`default`,`primary`,`borderless`]).default(`default`).describe(`A hint for the button style. If omitted, a default button style is used. 'primary' indicates this is the main call-to-action button. 'borderless' means the button has no visual border or background, making its child content appear like a clickable link.`).optional(),action:yv,checks:xv.shape.checks}).strict()},Ab={name:`TextField`,schema:Dm({...hb,label:pv.describe(`The text label for the input field.`),value:pv.describe(`The value of the text field.`).optional(),variant:jm([`longText`,`number`,`shortText`,`obscured`]).default(`shortText`).describe(`The type of input field to display.`).optional(),validationRegexp:Sm().describe(`A regular expression used for client-side validation of the input.`).optional(),checks:xv.shape.checks}).strict()},jb={name:`CheckBox`,schema:Dm({...hb,label:pv.describe(`The text to display next to the checkbox.`),value:fv.describe(`The current state of the checkbox (true for checked, false for unchecked).`),checks:xv.shape.checks}).strict()},Mb={name:`ChoicePicker`,schema:Dm({...hb,label:pv.describe(`The label for the group of options.`).optional(),variant:jm([`multipleSelection`,`mutuallyExclusive`]).default(`mutuallyExclusive`).describe(`A hint for how the choice picker should be displayed and behave.`).optional(),options:Em(Dm({label:pv.describe(`The text to display for this option.`),value:Sm().describe(`The stable value associated with this option.`)}).strict()).describe(`The list of available options to choose from.`),value:hv.describe(`The list of currently selected values. This should be bound to a string array in the data model.`),displayStyle:jm([`checkbox`,`chips`]).default(`checkbox`).describe(`The display style of the component.`).optional(),filterable:wm().default(!1).describe(`If true, displays a search input to filter the options.`).optional(),checks:xv.shape.checks}).strict().describe(`A component that allows selecting one or more options from a list.`)},Nb={name:`Slider`,schema:Dm({...hb,label:pv.describe(`The label for the slider.`).optional(),min:Cm().default(0).describe(`The minimum value of the slider.`).optional(),max:Cm().describe(`The maximum value of the slider.`),value:mv.describe(`The current value of the slider.`),checks:xv.shape.checks}).strict()},Pb={name:`DateTimeInput`,schema:Dm({...hb,value:pv.describe(`The selected date and/or time value in ISO 8601 format. If not yet set, initialize with an empty string.`),enableDate:wm().default(!1).describe(`If true, allows the user to select a date.`).optional(),enableTime:wm().default(!1).describe(`If true, allows the user to select a time.`).optional(),min:Om([pv,Sm().date(),Sm().time(),Sm().datetime()]).describe(`The minimum allowed date/time in ISO 8601 format.`).optional(),max:Om([pv,Sm().date(),Sm().time(),Sm().datetime()]).describe(`The maximum allowed date/time in ISO 8601 format.`).optional(),label:pv.describe(`The text label for the input field.`).optional(),checks:xv.shape.checks}).strict()},Fb=Ev(gb,({props:e})=>{let t=e.text??``,n={...jv(),display:`inline-block`};switch(e.variant){case`h1`:return(0,U.jsx)(`h1`,{style:n,children:t});case`h2`:return(0,U.jsx)(`h2`,{style:n,children:t});case`h3`:return(0,U.jsx)(`h3`,{style:n,children:t});case`h4`:return(0,U.jsx)(`h4`,{style:n,children:t});case`h5`:return(0,U.jsx)(`h5`,{style:n,children:t});case`caption`:return(0,U.jsx)(`small`,{style:{...n,color:`#666`,textAlign:`left`},children:t});default:return(0,U.jsx)(`span`,{style:n,children:t})}}),Ib=Ev(_b,({props:e})=>{let t=e=>e===`scaleDown`?`scale-down`:e||`fill`,n={...jv(),objectFit:t(e.fit),width:`100%`,height:`auto`,display:`block`};return e.variant===`icon`?(n.width=`24px`,n.height=`24px`):e.variant===`avatar`?(n.width=`40px`,n.height=`40px`,n.borderRadius=`50%`):e.variant===`smallFeature`?n.maxWidth=`100px`:e.variant===`largeFeature`?n.maxHeight=`400px`:e.variant===`header`&&(n.height=`200px`,n.objectFit=`cover`),(0,U.jsx)(`img`,{src:e.url,alt:e.description||``,style:n})}),Lb=Ev(yb,({props:e})=>{let t=typeof e.name==`string`?e.name:e.name?.path;return(0,U.jsx)(`span`,{className:`material-symbols-outlined`,style:{...jv(),fontSize:`24px`,width:`24px`,height:`24px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`},children:t})}),Rb=Ev(bb,({props:e})=>{let t={...jv(),width:`100%`,aspectRatio:`16/9`};return(0,U.jsx)(`video`,{src:e.url,controls:!0,style:t})}),zb=Ev(xb,({props:e})=>{let t={...jv(),width:`100%`};return(0,U.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,width:`100%`},children:[e.description&&(0,U.jsx)(`span`,{style:{fontSize:`12px`,color:`#666`},children:e.description}),(0,U.jsx)(`audio`,{src:e.url,controls:!0,style:t})]})}),Bb=({childList:e,buildChild:t})=>Array.isArray(e)?(0,U.jsx)(U.Fragment,{children:e.map((e,n)=>{if(e&&typeof e==`object`&&`id`in e){let r=e;return(0,U.jsx)(b.Fragment,{children:t(r.id,r.basePath)},`${r.id}-${n}`)}return typeof e==`string`?(0,U.jsx)(b.Fragment,{children:t(e)},`${e}-${n}`):null})}):null,Vb=new Vm(`https://a2ui.org/specification/v0_9/basic_catalog.json`,[Fb,Ib,Lb,Rb,zb,Ev(Sb,({props:e,buildChild:t,context:n})=>(0,U.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:kv(e.justify),alignItems:Av(e.align),width:`100%`,margin:0,padding:0},children:(0,U.jsx)(Bb,{childList:e.children,buildChild:t,context:n})})),Ev(Cb,({props:e,buildChild:t,context:n})=>(0,U.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:kv(e.justify),alignItems:Av(e.align),width:`100%`,margin:0,padding:0},children:(0,U.jsx)(Bb,{childList:e.children,buildChild:t,context:n})})),Ev(wb,({props:e,buildChild:t,context:n})=>{let r=e.direction===`horizontal`;return(0,U.jsx)(`div`,{style:{display:`flex`,flexDirection:r?`row`:`column`,alignItems:Av(e.align),overflowX:r?`auto`:`hidden`,overflowY:r?`hidden`:`auto`,width:`100%`,margin:0,padding:0},children:(0,U.jsx)(Bb,{childList:e.children,buildChild:t,context:n})})}),Ev(Tb,({props:e,buildChild:t})=>(0,U.jsx)(`div`,{style:{...Mv(),backgroundColor:`#fff`,boxShadow:`0 2px 4px rgba(0,0,0,0.1)`,width:`100%`},children:e.child?t(e.child):null})),Ev(Eb,({props:e,buildChild:t})=>{let[n,r]=(0,b.useState)(0),i=e.tabs||[],a=i[n];return(0,U.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,margin:`8px`},children:[(0,U.jsx)(`div`,{style:{display:`flex`,borderBottom:`1px solid #ccc`,marginBottom:`8px`},children:i.map((e,t)=>(0,U.jsx)(`button`,{onClick:()=>r(t),style:{padding:`8px 16px`,border:`none`,background:`none`,borderBottom:n===t?`2px solid var(--a2ui-primary-color, #007bff)`:`none`,fontWeight:n===t?`bold`:`normal`,cursor:`pointer`,color:n===t?`var(--a2ui-primary-color, #007bff)`:`inherit`},children:e.title},t))}),(0,U.jsx)(`div`,{style:{flex:1},children:a?t(a.child):null})]})}),Ev(Ob,({props:e})=>{let t=e.axis===`vertical`,n={margin:`8px`,border:`none`,backgroundColor:`#ccc`};return t?(n.width=`1px`,n.height=`100%`):(n.width=`100%`,n.height=`1px`),(0,U.jsx)(`div`,{style:n})}),Ev(Db,({props:e,buildChild:t})=>{let[n,r]=(0,b.useState)(!1);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{onClick:()=>r(!0),style:{display:`inline-block`},children:e.trigger?t(e.trigger):null}),n&&(0,U.jsx)(`div`,{style:{position:`fixed`,top:0,left:0,right:0,bottom:0,backgroundColor:`rgba(0,0,0,0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:1e3},onClick:()=>r(!1),children:(0,U.jsxs)(`div`,{style:{backgroundColor:`#fff`,padding:`24px`,borderRadius:`8px`,maxWidth:`90%`,maxHeight:`90%`,overflow:`auto`,display:`flex`,flexDirection:`column`},onClick:e=>e.stopPropagation(),children:[(0,U.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`},children:(0,U.jsx)(`button`,{onClick:()=>r(!1),style:{border:`none`,background:`none`,fontSize:`20px`,cursor:`pointer`,padding:`4px`},children:`×`})}),(0,U.jsx)(`div`,{style:{flex:1},children:e.content?t(e.content):null})]})})]})}),Ev(kb,({props:e,buildChild:t})=>(0,U.jsx)(`button`,{style:{margin:`8px`,padding:`8px 16px`,cursor:`pointer`,border:e.variant===`borderless`?`none`:`1px solid #ccc`,backgroundColor:e.variant===`primary`?`var(--a2ui-primary-color, #007bff)`:e.variant===`borderless`?`transparent`:`#fff`,color:e.variant===`primary`?`#fff`:`inherit`,borderRadius:`4px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,boxSizing:`border-box`},onClick:e.action,disabled:e.isValid===!1,children:e.child?t(e.child):null})),Ev(Ab,({props:e})=>{let t=t=>{e.setValue(t.target.value)},n=e.variant===`longText`,r=e.variant===`number`?`number`:e.variant===`obscured`?`password`:`text`,i={padding:`8px`,width:`100%`,border:Ov,borderRadius:`8px`,boxSizing:`border-box`},a=b.useId(),o=e.validationErrors&&e.validationErrors.length>0;return(0,U.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,width:`100%`,margin:`8px`},children:[e.label&&(0,U.jsx)(`label`,{htmlFor:a,style:{fontSize:`14px`,fontWeight:`bold`},children:e.label}),n?(0,U.jsx)(`textarea`,{id:a,style:{...i,border:o?`1px solid red`:Ov},value:e.value||``,onChange:t}):(0,U.jsx)(`input`,{id:a,type:r,style:{...i,border:o?`1px solid red`:Ov},value:e.value||``,onChange:t}),o&&(0,U.jsx)(`span`,{style:{fontSize:`12px`,color:`red`},children:e.validationErrors[0]})]})}),Ev(jb,({props:e})=>{let t=t=>{e.setValue(t.target.checked)},n=b.useId(),r=e.validationErrors&&e.validationErrors.length>0;return(0,U.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,margin:`8px`},children:[(0,U.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,U.jsx)(`input`,{id:n,type:`checkbox`,checked:!!e.value,onChange:t,style:{cursor:`pointer`,outline:r?`1px solid red`:`none`}}),e.label&&(0,U.jsx)(`label`,{htmlFor:n,style:{cursor:`pointer`,color:r?`red`:`inherit`},children:e.label})]}),r&&(0,U.jsx)(`span`,{style:{fontSize:`12px`,color:`red`,marginTop:`4px`},children:e.validationErrors?.[0]})]})}),Ev(Mb,({props:e,context:t})=>{let[n,r]=(0,b.useState)(``),i=Array.isArray(e.value)?e.value:[],a=e.variant===`mutuallyExclusive`,o=t=>{if(a)e.setValue([t]);else{let n=i.includes(t)?i.filter(e=>e!==t):[...i,t];e.setValue(n)}},s=(e.options||[]).filter(t=>!e.filterable||n===``||String(t.label).toLowerCase().includes(n.toLowerCase())),c={display:`flex`,flexDirection:`column`,gap:`8px`,margin:`8px`,width:`100%`},l={display:`flex`,flexDirection:e.displayStyle===`chips`?`row`:`column`,flexWrap:e.displayStyle===`chips`?`wrap`:`nowrap`,gap:`8px`};return(0,U.jsxs)(`div`,{style:c,children:[e.label&&(0,U.jsx)(`strong`,{style:{fontSize:`14px`},children:e.label}),e.filterable&&(0,U.jsx)(`input`,{type:`text`,placeholder:`Filter options...`,value:n,onChange:e=>r(e.target.value),style:{padding:`4px 8px`,border:`1px solid #ccc`,borderRadius:`8px`}}),(0,U.jsx)(`div`,{style:l,children:s.map((n,r)=>{let s=i.includes(n.value);return e.displayStyle===`chips`?(0,U.jsx)(`button`,{onClick:()=>o(n.value),style:{padding:`4px 12px`,borderRadius:`16px`,border:s?`1px solid var(--a2ui-primary-color, #007bff)`:Ov,backgroundColor:s?`var(--a2ui-primary-color, #007bff)`:`#fff`,color:s?`#fff`:`inherit`,cursor:`pointer`,fontSize:`12px`},children:n.label},r):(0,U.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`},children:[(0,U.jsx)(`input`,{type:a?`radio`:`checkbox`,checked:s,onChange:()=>o(n.value),name:a?`choice-${t.componentModel.id}`:void 0}),(0,U.jsx)(`span`,{style:{fontSize:`14px`},children:n.label})]},r)})})]})}),Ev(Nb,({props:e})=>{let t=t=>{e.setValue(Number(t.target.value))},n=b.useId();return(0,U.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,margin:`8px`,width:`100%`},children:[(0,U.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[e.label&&(0,U.jsx)(`label`,{htmlFor:n,style:{fontSize:`14px`,fontWeight:`bold`},children:e.label}),(0,U.jsx)(`span`,{style:{fontSize:`12px`,color:`#666`},children:e.value})]}),(0,U.jsx)(`input`,{id:n,type:`range`,min:e.min??0,max:e.max,value:e.value??0,onChange:t,style:{width:`100%`,cursor:`pointer`}})]})}),Ev(Pb,({props:e})=>{let t=t=>{e.setValue(t.target.value)},n=b.useId(),r=`datetime-local`;e.enableDate&&!e.enableTime&&(r=`date`),!e.enableDate&&e.enableTime&&(r=`time`);let i={padding:`8px`,width:`100%`,border:Ov,borderRadius:`8px`,boxSizing:`border-box`};return(0,U.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,width:`100%`,margin:`8px`},children:[e.label&&(0,U.jsx)(`label`,{htmlFor:n,style:{fontSize:`14px`,fontWeight:`bold`},children:e.label}),(0,U.jsx)(`input`,{id:n,type:r,style:i,value:e.value||``,onChange:t,min:typeof e.min==`string`?e.min:void 0,max:typeof e.max==`string`?e.max:void 0})]})})],mb),Hb=(0,b.createContext)(void 0);function Ub({theme:e,children:t}){return(0,U.jsx)(Hb.Provider,{value:e??{},children:t})}var Wb=(0,b.memo)(({surface:e,id:t,basePath:n,compImpl:r,componentModel:i})=>{let a=r.render,o=(0,b.useMemo)(()=>new ov(e,t,n),[e,t,n,i]);return(0,U.jsx)(a,{context:o,buildChild:(0,b.useCallback)((t,n)=>{let r=n||o.dataContext.path;return(0,U.jsx)(Gb,{surface:e,id:t,basePath:r},`${t}-${r}`)},[e,o.dataContext.path])})});Wb.displayName=`ResolvedChild`;var Gb=(0,b.memo)(({surface:e,id:t,basePath:n})=>{let r=(0,b.useMemo)(()=>{let n=0;return{subscribe:r=>{let i=e.componentsModel.onCreated.subscribe(e=>{e.id===t&&(n++,r())}),a=e.componentsModel.onDeleted.subscribe(e=>{e===t&&(n++,r())});return()=>{i.unsubscribe(),a.unsubscribe()}},getSnapshot:()=>{let r=e.componentsModel.get(t);return r?`${r.type}-${n}`:`missing-${n}`}}},[e,t]);(0,b.useSyncExternalStore)(r.subscribe,r.getSnapshot);let i=e.componentsModel.get(t);if(!i)return(0,U.jsx)(`div`,{style:{padding:`12px 16px`,borderRadius:`8px`,background:`linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%)`,backgroundSize:`200% 100%`,animation:`a2ui-shimmer 1.5s ease-in-out infinite`,minHeight:`2rem`},children:(0,U.jsx)(`style`,{children:`@keyframes a2ui-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }`})});let a=e.catalog.components.get(i.type);return a?(0,U.jsx)(Wb,{surface:e,id:t,basePath:n,componentModel:i,compImpl:a}):(0,U.jsxs)(`div`,{style:{color:`red`},children:[`Unknown component: `,i.type]})});Gb.displayName=`DeferredChild`;var Kb=({surface:e})=>(0,U.jsx)(Gb,{surface:e,id:`root`,basePath:`/`}),qb;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(qb||={});var Jb;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Jb||={});var Yb=qb.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Xb=e=>{switch(typeof e){case`undefined`:return Yb.undefined;case`string`:return Yb.string;case`number`:return Number.isNaN(e)?Yb.nan:Yb.number;case`boolean`:return Yb.boolean;case`function`:return Yb.function;case`bigint`:return Yb.bigint;case`symbol`:return Yb.symbol;case`object`:return Array.isArray(e)?Yb.array:e===null?Yb.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?Yb.promise:typeof Map<`u`&&e instanceof Map?Yb.map:typeof Set<`u`&&e instanceof Set?Yb.set:typeof Date<`u`&&e instanceof Date?Yb.date:Yb.object;default:return Yb.unknown}},W=qb.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),Zb=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,qb.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Zb.create=e=>new Zb(e);var Qb=(e,t)=>{let n;switch(e.code){case W.invalid_type:n=e.received===Yb.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case W.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,qb.jsonStringifyReplacer)}`;break;case W.unrecognized_keys:n=`Unrecognized key(s) in object: ${qb.joinValues(e.keys,`, `)}`;break;case W.invalid_union:n=`Invalid input`;break;case W.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${qb.joinValues(e.options)}`;break;case W.invalid_enum_value:n=`Invalid enum value. Expected ${qb.joinValues(e.options)}, received '${e.received}'`;break;case W.invalid_arguments:n=`Invalid function arguments`;break;case W.invalid_return_type:n=`Invalid function return type`;break;case W.invalid_date:n=`Invalid date`;break;case W.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:qb.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case W.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case W.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case W.custom:n=`Invalid input`;break;case W.invalid_intersection_types:n=`Intersection results could not be merged`;break;case W.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case W.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,qb.assertNever(e)}return{message:n}},$b=Qb;function ex(){return $b}var tx=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function G(e,t){let n=ex(),r=tx({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Qb?void 0:Qb].filter(e=>!!e)});e.common.issues.push(r)}var nx=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return rx;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return rx;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},rx=Object.freeze({status:`aborted`}),ix=e=>({status:`dirty`,value:e}),ax=e=>({status:`valid`,value:e}),ox=e=>e.status===`aborted`,sx=e=>e.status===`dirty`,cx=e=>e.status===`valid`,lx=e=>typeof Promise<`u`&&e instanceof Promise,ux;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(ux||={});var dx=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},fx=(e,t)=>{if(cx(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new Zb(e.common.issues);return this._error=t,this._error}}};function px(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var mx=class{get description(){return this._def.description}_getType(e){return Xb(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Xb(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new nx,ctx:{common:e.parent.common,data:e.data,parsedType:Xb(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(lx(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xb(e)};return fx(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xb(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return cx(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>cx(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xb(e)},r=this._parse({data:e,path:n.path,parent:n});return fx(n,await(lx(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:W.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new _S({schema:this,typeName:ES.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return vS.create(this,this._def)}nullable(){return yS.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qx.create(this)}promise(){return gS.create(this,this._def)}or(e){return tS.create([this,e],this._def)}and(e){return aS.create(this,e,this._def)}transform(e){return new _S({...px(this._def),schema:this,typeName:ES.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new bS({...px(this._def),innerType:this,defaultValue:t,typeName:ES.ZodDefault})}brand(){return new CS({typeName:ES.ZodBranded,type:this,...px(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new xS({...px(this._def),innerType:this,catchValue:t,typeName:ES.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return wS.create(this,e)}readonly(){return TS.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},hx=/^c[^\s-]{8,}$/i,gx=/^[0-9a-z]+$/,_x=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vx=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,yx=/^[a-z0-9_-]{21}$/i,bx=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xx=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Sx=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Cx=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,wx,Tx=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ex=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Dx=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ox=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kx=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ax=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,jx=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,Mx=RegExp(`^${jx}$`);function Nx(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Px(e){return RegExp(`^${Nx(e)}$`)}function Fx(e){let t=`${jx}T${Nx(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Ix(e,t){return!!((t===`v4`||!t)&&Tx.test(e)||(t===`v6`||!t)&&Dx.test(e))}function Lx(e,t){if(!bx.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Rx(e,t){return!!((t===`v4`||!t)&&Ex.test(e)||(t===`v6`||!t)&&Ox.test(e))}var zx=class e extends mx{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Yb.string){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:Yb.string,received:t.parsedType}),rx}let t=new nx,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),G(n,{code:W.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),G(n,{code:W.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?G(n,{code:W.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&G(n,{code:W.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Sx.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`email`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)wx||=new RegExp(Cx,`u`),wx.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`emoji`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)vx.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`uuid`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)yx.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`nanoid`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)hx.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`cuid`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)gx.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`cuid2`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)_x.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`ulid`,code:W.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),G(n,{validation:`url`,code:W.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`regex`,code:W.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Fx(r).test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Mx.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Px(r).test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?xx.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`duration`,code:W.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Ix(e.data,r.version)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`ip`,code:W.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Lx(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`jwt`,code:W.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?Rx(e.data,r.version)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`cidr`,code:W.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?kx.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`base64`,code:W.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Ax.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`base64url`,code:W.invalid_string,message:r.message}),t.dirty()):qb.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:W.invalid_string,...ux.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...ux.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...ux.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...ux.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...ux.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...ux.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...ux.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...ux.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...ux.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...ux.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...ux.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...ux.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...ux.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...ux.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...ux.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...ux.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...ux.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...ux.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...ux.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...ux.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...ux.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...ux.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...ux.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...ux.errToObj(t)})}nonempty(e){return this.min(1,ux.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};zx.create=e=>new zx({checks:[],typeName:ES.ZodString,coerce:e?.coerce??!1,...px(e)});function Bx(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Vx=class e extends mx{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Yb.number){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:Yb.number,received:t.parsedType}),rx}let t,n=new nx;for(let r of this._def.checks)r.kind===`int`?qb.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),G(t,{code:W.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:W.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:W.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Bx(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),G(t,{code:W.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),G(t,{code:W.not_finite,message:r.message}),n.dirty()):qb.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,ux.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,ux.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,ux.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,ux.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ux.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:ux.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:ux.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:ux.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:ux.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:ux.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:ux.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:ux.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:ux.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:ux.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&qb.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Vx.create=e=>new Vx({checks:[],typeName:ES.ZodNumber,coerce:e?.coerce||!1,...px(e)});var Hx=class e extends mx{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Yb.bigint)return this._getInvalidInput(e);let t,n=new nx;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:W.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:W.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),G(t,{code:W.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):qb.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:Yb.bigint,received:t.parsedType}),rx}gte(e,t){return this.setLimit(`min`,e,!0,ux.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,ux.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,ux.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,ux.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ux.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:ux.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:ux.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:ux.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:ux.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:ux.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Hx.create=e=>new Hx({checks:[],typeName:ES.ZodBigInt,coerce:e?.coerce??!1,...px(e)});var Ux=class extends mx{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Yb.boolean){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:Yb.boolean,received:t.parsedType}),rx}return ax(e.data)}};Ux.create=e=>new Ux({typeName:ES.ZodBoolean,coerce:e?.coerce||!1,...px(e)});var Wx=class e extends mx{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Yb.date){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:Yb.date,received:t.parsedType}),rx}if(Number.isNaN(e.data.getTime()))return G(this._getOrReturnCtx(e),{code:W.invalid_date}),rx;let t=new nx,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),G(n,{code:W.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),G(n,{code:W.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):qb.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:ux.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:ux.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Wx.create=e=>new Wx({checks:[],coerce:e?.coerce||!1,typeName:ES.ZodDate,...px(e)});var Gx=class extends mx{_parse(e){if(this._getType(e)!==Yb.symbol){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:Yb.symbol,received:t.parsedType}),rx}return ax(e.data)}};Gx.create=e=>new Gx({typeName:ES.ZodSymbol,...px(e)});var Kx=class extends mx{_parse(e){if(this._getType(e)!==Yb.undefined){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:Yb.undefined,received:t.parsedType}),rx}return ax(e.data)}};Kx.create=e=>new Kx({typeName:ES.ZodUndefined,...px(e)});var qx=class extends mx{_parse(e){if(this._getType(e)!==Yb.null){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:Yb.null,received:t.parsedType}),rx}return ax(e.data)}};qx.create=e=>new qx({typeName:ES.ZodNull,...px(e)});var Jx=class extends mx{constructor(){super(...arguments),this._any=!0}_parse(e){return ax(e.data)}};Jx.create=e=>new Jx({typeName:ES.ZodAny,...px(e)});var Yx=class extends mx{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ax(e.data)}};Yx.create=e=>new Yx({typeName:ES.ZodUnknown,...px(e)});var Xx=class extends mx{_parse(e){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:Yb.never,received:t.parsedType}),rx}};Xx.create=e=>new Xx({typeName:ES.ZodNever,...px(e)});var Zx=class extends mx{_parse(e){if(this._getType(e)!==Yb.undefined){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:Yb.void,received:t.parsedType}),rx}return ax(e.data)}};Zx.create=e=>new Zx({typeName:ES.ZodVoid,...px(e)});var Qx=class e extends mx{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==Yb.array)return G(t,{code:W.invalid_type,expected:Yb.array,received:t.parsedType}),rx;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(G(t,{code:e?W.too_big:W.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(G(t,{code:W.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(G(t,{code:W.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new dx(t,e,t.path,n)))).then(e=>nx.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new dx(t,e,t.path,n)));return nx.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:ux.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:ux.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:ux.toString(n)}})}nonempty(e){return this.min(1,e)}};Qx.create=(e,t)=>new Qx({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ES.ZodArray,...px(t)});function $x(e){if(e instanceof eS){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=vS.create($x(r))}return new eS({...e._def,shape:()=>t})}else if(e instanceof Qx)return new Qx({...e._def,type:$x(e.element)});else if(e instanceof vS)return vS.create($x(e.unwrap()));else if(e instanceof yS)return yS.create($x(e.unwrap()));else if(e instanceof oS)return oS.create(e.items.map(e=>$x(e)));else return e}var eS=class e extends mx{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=qb.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==Yb.object){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:Yb.object,received:t.parsedType}),rx}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Xx&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new dx(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Xx){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(G(n,{code:W.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new dx(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>nx.mergeObjectSync(t,e)):nx.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return ux.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:ux.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:ES.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of qb.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of qb.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return $x(this)}partial(t){let n={};for(let e of qb.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of qb.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof vS;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return pS(qb.objectKeys(this.shape))}};eS.create=(e,t)=>new eS({shape:()=>e,unknownKeys:`strip`,catchall:Xx.create(),typeName:ES.ZodObject,...px(t)}),eS.strictCreate=(e,t)=>new eS({shape:()=>e,unknownKeys:`strict`,catchall:Xx.create(),typeName:ES.ZodObject,...px(t)}),eS.lazycreate=(e,t)=>new eS({shape:e,unknownKeys:`strip`,catchall:Xx.create(),typeName:ES.ZodObject,...px(t)});var tS=class extends mx{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Zb(e.ctx.common.issues));return G(t,{code:W.invalid_union,unionErrors:n}),rx}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Zb(e));return G(t,{code:W.invalid_union,unionErrors:i}),rx}}get options(){return this._def.options}};tS.create=(e,t)=>new tS({options:e,typeName:ES.ZodUnion,...px(t)});var nS=e=>e instanceof dS?nS(e.schema):e instanceof _S?nS(e.innerType()):e instanceof fS?[e.value]:e instanceof mS?e.options:e instanceof hS?qb.objectValues(e.enum):e instanceof bS?nS(e._def.innerType):e instanceof Kx?[void 0]:e instanceof qx?[null]:e instanceof vS?[void 0,...nS(e.unwrap())]:e instanceof yS?[null,...nS(e.unwrap())]:e instanceof CS||e instanceof TS?nS(e.unwrap()):e instanceof xS?nS(e._def.innerType):[],rS=class e extends mx{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==Yb.object)return G(t,{code:W.invalid_type,expected:Yb.object,received:t.parsedType}),rx;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(G(t,{code:W.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),rx)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=nS(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:ES.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...px(r)})}};function iS(e,t){let n=Xb(e),r=Xb(t);if(e===t)return{valid:!0,data:e};if(n===Yb.object&&r===Yb.object){let n=qb.objectKeys(t),r=qb.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=iS(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===Yb.array&&r===Yb.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=iS(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===Yb.date&&r===Yb.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var aS=class extends mx{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(ox(e)||ox(r))return rx;let i=iS(e.value,r.value);return i.valid?((sx(e)||sx(r))&&t.dirty(),{status:t.value,value:i.data}):(G(n,{code:W.invalid_intersection_types}),rx)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};aS.create=(e,t,n)=>new aS({left:e,right:t,typeName:ES.ZodIntersection,...px(n)});var oS=class e extends mx{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Yb.array)return G(n,{code:W.invalid_type,expected:Yb.array,received:n.parsedType}),rx;if(n.data.length<this._def.items.length)return G(n,{code:W.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),rx;!this._def.rest&&n.data.length>this._def.items.length&&(G(n,{code:W.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new dx(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>nx.mergeArray(t,e)):nx.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};oS.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new oS({items:e,typeName:ES.ZodTuple,rest:null,...px(t)})};var sS=class e extends mx{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Yb.object)return G(n,{code:W.invalid_type,expected:Yb.object,received:n.parsedType}),rx;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new dx(n,e,n.path,e)),value:a._parse(new dx(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?nx.mergeObjectAsync(t,r):nx.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof mx?new e({keyType:t,valueType:n,typeName:ES.ZodRecord,...px(r)}):new e({keyType:zx.create(),valueType:t,typeName:ES.ZodRecord,...px(n)})}},cS=class extends mx{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Yb.map)return G(n,{code:W.invalid_type,expected:Yb.map,received:n.parsedType}),rx;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new dx(n,e,n.path,[a,`key`])),value:i._parse(new dx(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return rx;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return rx;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};cS.create=(e,t,n)=>new cS({valueType:t,keyType:e,typeName:ES.ZodMap,...px(n)});var lS=class e extends mx{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Yb.set)return G(n,{code:W.invalid_type,expected:Yb.set,received:n.parsedType}),rx;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(G(n,{code:W.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(G(n,{code:W.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return rx;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new dx(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:ux.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:ux.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};lS.create=(e,t)=>new lS({valueType:e,minSize:null,maxSize:null,typeName:ES.ZodSet,...px(t)});var uS=class e extends mx{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==Yb.function)return G(t,{code:W.invalid_type,expected:Yb.function,received:t.parsedType}),rx;function n(e,n){return tx({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ex(),Qb].filter(e=>!!e),issueData:{code:W.invalid_arguments,argumentsError:n}})}function r(e,n){return tx({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ex(),Qb].filter(e=>!!e),issueData:{code:W.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof gS){let e=this;return ax(async function(...t){let o=new Zb([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return ax(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Zb([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Zb([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:oS.create(t).rest(Yx.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||oS.create([]).rest(Yx.create()),returns:n||Yx.create(),typeName:ES.ZodFunction,...px(r)})}},dS=class extends mx{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};dS.create=(e,t)=>new dS({getter:e,typeName:ES.ZodLazy,...px(t)});var fS=class extends mx{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return G(t,{received:t.data,code:W.invalid_literal,expected:this._def.value}),rx}return{status:`valid`,value:e.data}}get value(){return this._def.value}};fS.create=(e,t)=>new fS({value:e,typeName:ES.ZodLiteral,...px(t)});function pS(e,t){return new mS({values:e,typeName:ES.ZodEnum,...px(t)})}var mS=class e extends mx{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return G(t,{expected:qb.joinValues(n),received:t.parsedType,code:W.invalid_type}),rx}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return G(t,{received:t.data,code:W.invalid_enum_value,options:n}),rx}return ax(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};mS.create=pS;var hS=class extends mx{_parse(e){let t=qb.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Yb.string&&n.parsedType!==Yb.number){let e=qb.objectValues(t);return G(n,{expected:qb.joinValues(e),received:n.parsedType,code:W.invalid_type}),rx}if(this._cache||=new Set(qb.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=qb.objectValues(t);return G(n,{received:n.data,code:W.invalid_enum_value,options:e}),rx}return ax(e.data)}get enum(){return this._def.values}};hS.create=(e,t)=>new hS({values:e,typeName:ES.ZodNativeEnum,...px(t)});var gS=class extends mx{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==Yb.promise&&t.common.async===!1?(G(t,{code:W.invalid_type,expected:Yb.promise,received:t.parsedType}),rx):ax((t.parsedType===Yb.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};gS.create=(e,t)=>new gS({type:e,typeName:ES.ZodPromise,...px(t)});var _S=class extends mx{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ES.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{G(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return rx;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?rx:r.status===`dirty`||t.value===`dirty`?ix(r.value):r});{if(t.value===`aborted`)return rx;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?rx:r.status===`dirty`||t.value===`dirty`?ix(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?rx:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?rx:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!cx(e))return rx;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>cx(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):rx);qb.assertNever(r)}};_S.create=(e,t,n)=>new _S({schema:e,typeName:ES.ZodEffects,effect:t,...px(n)}),_S.createWithPreprocess=(e,t,n)=>new _S({schema:t,effect:{type:`preprocess`,transform:e},typeName:ES.ZodEffects,...px(n)});var vS=class extends mx{_parse(e){return this._getType(e)===Yb.undefined?ax(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vS.create=(e,t)=>new vS({innerType:e,typeName:ES.ZodOptional,...px(t)});var yS=class extends mx{_parse(e){return this._getType(e)===Yb.null?ax(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};yS.create=(e,t)=>new yS({innerType:e,typeName:ES.ZodNullable,...px(t)});var bS=class extends mx{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===Yb.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};bS.create=(e,t)=>new bS({innerType:e,typeName:ES.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...px(t)});var xS=class extends mx{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return lx(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Zb(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Zb(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};xS.create=(e,t)=>new xS({innerType:e,typeName:ES.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...px(t)});var SS=class extends mx{_parse(e){if(this._getType(e)!==Yb.nan){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:Yb.nan,received:t.parsedType}),rx}return{status:`valid`,value:e.data}}};SS.create=e=>new SS({typeName:ES.ZodNaN,...px(e)});var CS=class extends mx{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},wS=class e extends mx{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?rx:e.status===`dirty`?(t.dirty(),ix(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?rx:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:ES.ZodPipeline})}},TS=class extends mx{_parse(e){let t=this._def.innerType._parse(e),n=e=>(cx(e)&&(e.value=Object.freeze(e.value)),e);return lx(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};TS.create=(e,t)=>new TS({innerType:e,typeName:ES.ZodReadonly,...px(t)}),eS.lazycreate;var ES;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(ES||={});var DS=zx.create;Vx.create,SS.create,Hx.create,Ux.create,Wx.create,Gx.create,Kx.create,qx.create,Jx.create;var OS=Yx.create;Xx.create,Zx.create,Qx.create;var kS=eS.create;eS.strictCreate,tS.create,rS.create,aS.create,oS.create,sS.create,cS.create,lS.create,uS.create,dS.create,fS.create;var AS=mS.create;hS.create,gS.create,_S.create,vS.create,yS.create,_S.createWithPreprocess,wS.create;var jS=Ev({name:`Text`,schema:kS({text:Cv.DynamicString,variant:AS([`h1`,`h2`,`h3`,`h4`,`h5`,`caption`,`body`]).optional()})},({props:e})=>{let t=e.text??``;switch(e.variant){case`h1`:return(0,U.jsx)(`h1`,{children:t});case`h2`:return(0,U.jsx)(`h2`,{children:t});case`h3`:return(0,U.jsx)(`h3`,{children:t});case`h4`:return(0,U.jsx)(`h4`,{children:t});case`h5`:return(0,U.jsx)(`h5`,{children:t});case`caption`:return(0,U.jsx)(`small`,{children:t});default:return(0,U.jsx)(`span`,{children:t})}}),MS=Ev({name:`Button`,schema:kS({child:Cv.ComponentId,action:Cv.Action,variant:AS([`primary`,`borderless`]).optional()})},({props:e,buildChild:t})=>(0,U.jsx)(`button`,{style:{padding:`8px 16px`,cursor:`pointer`,border:e.variant===`borderless`?`none`:`1px solid #ccc`,backgroundColor:e.variant===`primary`?`#007bff`:`transparent`,color:e.variant===`primary`?`#fff`:`inherit`,borderRadius:`4px`},onClick:e.action,children:e.child?t(e.child):null})),NS=({childList:e,buildChild:t})=>Array.isArray(e)?(0,U.jsx)(U.Fragment,{children:e.map((e,n)=>{if(e&&typeof e==`object`&&`id`in e){let r=e;return(0,U.jsx)(b.Fragment,{children:t(r.id,r.basePath)},`${r.id}-${n}`)}return typeof e==`string`?(0,U.jsx)(b.Fragment,{children:t(e)},`${e}-${n}`):null})}):null,PS=kS({children:Cv.ChildList,justify:AS([`center`,`end`,`spaceAround`,`spaceBetween`,`spaceEvenly`,`start`,`stretch`]).optional(),align:AS([`start`,`center`,`end`,`stretch`]).optional()}),FS=e=>{switch(e){case`center`:return`center`;case`end`:return`flex-end`;case`spaceAround`:return`space-around`;case`spaceBetween`:return`space-between`;case`spaceEvenly`:return`space-evenly`;case`start`:return`flex-start`;case`stretch`:return`stretch`;default:return`flex-start`}},IS=e=>{switch(e){case`start`:return`flex-start`;case`center`:return`center`;case`end`:return`flex-end`;case`stretch`:return`stretch`;default:return`stretch`}},LS=Ev({name:`Row`,schema:PS},({props:e,buildChild:t})=>(0,U.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:FS(e.justify),alignItems:IS(e.align)},children:(0,U.jsx)(NS,{childList:e.children,buildChild:t})})),RS=kS({children:Cv.ChildList,justify:AS([`start`,`center`,`end`,`spaceBetween`,`spaceAround`,`spaceEvenly`,`stretch`]).optional(),align:AS([`center`,`end`,`start`,`stretch`]).optional()}),zS=e=>{switch(e){case`center`:return`center`;case`end`:return`flex-end`;case`spaceAround`:return`space-around`;case`spaceBetween`:return`space-between`;case`spaceEvenly`:return`space-evenly`;case`start`:return`flex-start`;case`stretch`:return`stretch`;default:return`flex-start`}},BS=e=>{switch(e){case`start`:return`flex-start`;case`center`:return`center`;case`end`:return`flex-end`;case`stretch`:return`stretch`;default:return`stretch`}};new Vm(`https://a2ui.org/specification/v0_9/catalogs/minimal/minimal_catalog.json`,[jS,MS,LS,Ev({name:`Column`,schema:RS},({props:e,buildChild:t})=>(0,U.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:zS(e.justify),alignItems:BS(e.align),gap:`8px`},children:(0,U.jsx)(NS,{childList:e.children,buildChild:t})})),Ev({name:`TextField`,schema:kS({label:Cv.DynamicString,value:Cv.DynamicString,variant:AS([`longText`,`number`,`shortText`,`obscured`]).optional(),validationRegexp:DS().optional()})},({props:e,context:t})=>{let n=t=>{e.setValue&&e.setValue(t.target.value)},r=e.variant===`longText`,i=e.variant===`number`?`number`:e.variant===`obscured`?`password`:`text`,a={padding:`8px`,width:`100%`,border:`1px solid #ccc`,borderRadius:`4px`,boxSizing:`border-box`},o=`textfield-${t.componentModel.id}`;return(0,U.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,width:`100%`},children:[e.label&&(0,U.jsx)(`label`,{htmlFor:o,style:{fontSize:`14px`,fontWeight:`bold`},children:e.label}),r?(0,U.jsx)(`textarea`,{id:o,style:a,value:e.value||``,onChange:n}):(0,U.jsx)(`input`,{id:o,type:i,style:a,value:e.value||``,onChange:n})]})})],[Bm({name:`capitalize`,returnType:`string`,schema:kS({value:OS()})},e=>{let t=e.value;return typeof t==`string`?t.toUpperCase():t})]);var VS=(0,b.createContext)(null),HS=(0,b.createContext)(null);function US({onAction:e,theme:t,catalog:n,children:r}){let i=(0,b.useRef)(e??null);i.current=e??null;let a=(0,b.useRef)(null);a.current||=new iv([n??Vb],e=>{if(i.current){let t={userAction:{name:e?.name??`unknown`,surfaceId:e?.surfaceId??`default`,sourceComponentId:e?.sourceComponentId,context:e?.context,timestamp:e?.timestamp??new Date().toISOString()}};i.current(t)}});let o=a.current,[s,c]=(0,b.useState)(0),[l,u]=(0,b.useState)(null),d=(0,b.useRef)(null);d.current||={processMessages:e=>{try{o.processMessages(e)}catch(e){console.warn(`[A2UI] processMessages error:`,e),u(e instanceof Error?e.message:String(e));return}u(null),c(e=>e+1)},dispatch:e=>{i.current&&i.current(e)},getSurface:e=>o.model.getSurface(e),clearSurfaces:()=>{let e=o.model.surfacesMap;for(let[t]of e)o.processMessages([{version:`v0.9`,deleteSurface:{surfaceId:t}}]);c(e=>e+1)}};let f=d.current,p=(0,b.useMemo)(()=>({version:s,error:l}),[s,l]);return(0,U.jsx)(VS.Provider,{value:f,children:(0,U.jsx)(HS.Provider,{value:p,children:(0,U.jsx)(Ub,{theme:t,children:r})})})}function WS(){let e=(0,b.useContext)(VS);if(!e)throw Error(`useA2UIActions must be used within an A2UIProvider`);return e}function GS(){let e=(0,b.useContext)(HS);if(!e)throw Error(`useA2UIState must be used within an A2UIProvider`);return e}function KS(){let e=WS(),t=GS();return{processMessages:e.processMessages,getSurface:e.getSurface,clearSurfaces:e.clearSurfaces,version:t.version}}function qS(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=qS(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function JS(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=qS(e))&&(r&&(r+=` `),r+=t);return r}function YS(...e){return JS(e)}var XS=(0,b.memo)(function(){return(0,U.jsx)(`div`,{className:`a2ui-loading`,style:{padding:`16px`,opacity:.5},children:`Loading...`})}),ZS=(0,b.memo)(function({surfaceId:e,className:t,fallback:n=null,loadingFallback:r}){let{getSurface:i,version:a}=KS(),o=i(e);if(!o)return(0,U.jsx)(U.Fragment,{children:n});let s=r??(0,U.jsx)(XS,{});return(0,U.jsx)(`div`,{className:YS(`a2ui-surface`,t),"data-surface-id":e,"data-version":a,children:(0,U.jsx)(b.Suspense,{fallback:s,children:(0,U.jsx)(Kb,{surface:o})})})}),QS=`https://a2ui.org/specification/v0_9/basic_catalog.json`,$S=`A2UI Component Schema — available components for generating UI surfaces. Use these component names and properties when creating A2UI operations.`;function eC(e){for(let t of Vb.components.keys())if(!e.components.has(t))return!1;return!0}function tC(e){let t=[];for(let n of e.components.keys())Vb.components.has(n)||t.push(n);return t}function nC(e){let t=e??Vb,n=[];if(n.push(`Available A2UI catalog:`),t.id===QS)return n.push(`- ${t.id} (basic catalog)`),n.join(`
|
|
25
|
-
`);let r=eC(t),i=tC(t);n.push(`- ${t.id}`),r?n.push(` Extends the basic catalog with all standard components plus:`):(n.push(` Custom catalog (does NOT include all basic components).`),n.push(` Custom components:`));for(let e of i){let r=t.components.get(e);if(!r)continue;let i=rv(r.schema);n.push(` - ${e}:`),n.push(` ${JSON.stringify(i,null,2).split(`
|
|
26
|
-
`).join(`
|
|
27
|
-
`)}`)}return n.join(`
|
|
28
|
-
`)}var rC=Vb,iC={description:$S,value:nC(rC)};function aC(e){return e.map(e=>{let t=e.updateComponents;if(!t||typeof t!=`object`||Array.isArray(t))return e;let n=t.components;if(!Array.isArray(n))return e;let r=n.filter(e=>!!(e&&typeof e==`object`&&!Array.isArray(e)));if(r.some(e=>e.id===`root`))return e;let i=r.filter(e=>typeof e.id==`string`&&e.id.endsWith(`-root`));if(i.length!==1)return e;let a=i[0];return{...e,updateComponents:{...t,components:n.map(e=>e===a?{...a,id:`root`}:e)}}})}function oC(e){return String(e.type||``).toUpperCase()}function sC(e,t){return String(e.messageId||t)}function cC(e,t){return String(e.runId||t)}function lC(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function uC(e){if(Array.isArray(e))return aC(e.filter(e=>!!(e&&typeof e==`object`)));if(e&&typeof e==`object`){let t=e.a2ui_operations;return Array.isArray(t)?aC(t.filter(e=>!!(e&&typeof e==`object`))):[e]}return[]}function dC(e){return e==null||e===``?``:typeof e==`string`?e:JSON.stringify(e,null,2)}var fC=class{agent;onEvent;tools=new Map;runMessageIds=new Map;pendingByRun=new Map;activeRunId=``;constructor(e){this.agent=new Vf({url:e.url,agentId:e.agentId,threadId:e.threadId,fetch:e.fetch}),this.onEvent=e.onEvent}async run(e,t,n){return this.activeRunId=t,this.agent.addMessage({id:`${t}:user`,role:`user`,content:e}),this.execute({runId:t,abortController:this.controllerFor(n)})}async resume(e,t){let n=this.agent.pendingInterrupts.length>0?this.agent.pendingInterrupts:this.pendingByRun.get(this.activeRunId)||[],r=Cf(n.length>0?n:[{id:t.interruptId,reason:`approval`}],{[t.interruptId]:t.status===`resolved`?{status:`resolved`,payload:t.payload}:{status:`cancelled`}});if(!r.some(e=>e.interruptId===t.interruptId))throw Error(`AG-UI interrupt ${t.interruptId} is not pending`);return this.activeRunId=e,this.execute({runId:e,resume:r})}abort(){this.agent.abortRun()}controllerFor(e){if(!e)return;let t=new AbortController;return e.aborted&&t.abort(e.reason),e.addEventListener(`abort`,()=>t.abort(e.reason),{once:!0}),t}async execute(e){let t=`completed`,n=await this.agent.runAgent({runId:e.runId,context:[iC],forwardedProps:{injectA2UITool:!0},resume:e.resume,abortController:e.abortController},{onEvent:({event:n})=>{let r=this.project(n,e.runId);r.status&&(t=r.status),r.events.forEach(e=>this.onEvent(e))},onRunFinishedEvent:({outcome:e})=>{t=e===`interrupt`?`interrupted`:`completed`},onRunErrorEvent:()=>{t=`failed`}}),r=this.agent.pendingInterrupts.slice();return r.length>0&&(this.pendingByRun.set(e.runId,r),t=`interrupted`),{status:t,result:n}}project(e,t){let n=oC(e),r=cC(e,t),i=sC(e,`${r}:assistant`),a=e,o=[];if(n===`RUN_STARTED`)o.push({type:`activity`,phase:`AG-UI 运行已创建`,status:`running`,countEvent:!1});else if(n===`TEXT_MESSAGE_START`)this.runMessageIds.set(r,i),o.push({type:`assistant_message_created`,messageId:i});else if(n===`TEXT_MESSAGE_CONTENT`)o.push({type:`text_delta`,messageId:this.runMessageIds.get(r)||i,delta:String(a.delta||``)});else if(n===`TEXT_MESSAGE_END`)o.push({type:`activity`,phase:`生成回复内容`,status:`running`});else if(n===`REASONING_MESSAGE_CONTENT`)o.push({type:`reasoning_delta`,messageId:this.runMessageIds.get(r)||i,delta:String(a.delta||``)});else if(n===`TOOL_CALL_START`){let e=String(a.toolCallId||`tool`);this.tools.set(e,{name:String(a.toolCallName||`tool`),args:``}),o.push({type:`tool_upsert`,messageId:this.runMessageIds.get(r)||`${r}:assistant`,name:String(a.toolCallName||`tool`),args:``,status:`running`})}else if(n===`TOOL_CALL_ARGS`){let e=String(a.toolCallId||`tool`),t=this.tools.get(e)||{name:`tool`,args:``};t.args+=String(a.delta||``),this.tools.set(e,t),o.push({type:`tool_upsert`,messageId:this.runMessageIds.get(r)||`${r}:assistant`,name:t.name,args:t.args,status:`running`})}else if(n===`TOOL_CALL_RESULT`){let e=String(a.toolCallId||`tool`),t=this.tools.get(e)||{name:`tool`,args:``};o.push({type:`tool_result`,messageId:this.runMessageIds.get(r)||`${r}:assistant`,name:t.name,output:String(a.content||``)})}else if(n===`ACTIVITY_SNAPSHOT`){let e=a.content,t=lC(e),n=String(t.surfaceId||t.surface_id||a.messageId||`default`);o.push({type:`agui_activity`,messageId:this.runMessageIds.get(r)||i,surfaceId:n,messages:uC(t.content??e)})}else if(n===`RUN_FINISHED`){let e=lC(a.outcome);if(String(e.type||``).toLowerCase()===`interrupt`){let t=Array.isArray(e.interrupts)?e.interrupts:[];this.pendingByRun.set(r,t);for(let e of t){let t=lC(e.metadata),n=e.toolCallId?this.tools.get(e.toolCallId):void 0,i=String(t.tool_name||t.toolName||n?.name||e.reason||`人工确认`),a=dC(t.arguments??t.tool_args??t.args??n?.args);o.push({type:`approval_requested`,messageId:this.runMessageIds.get(r)||`${r}:assistant`,approvalRequestId:e.id,protocol:`ag-ui`,name:i,args:a,...e.message?{message:e.message}:{},...t.approval_level?{approvalLevel:String(t.approval_level)}:{}})}return o.push({type:`activity`,phase:`等待人工确认`,status:`waiting`}),{events:o,status:`interrupted`}}o.push({type:`terminal`,status:`completed`})}else if(n===`RUN_ERROR`)return o.push({type:`error`,error:Error(`AG-UI 运行失败`)}),{events:o,status:`failed`};return{events:o}}},pC=new Set([`completed`,`failed`,`error`,`cancelled`,`canceled`,`aborted`,`interrupted`,`resume_failed`]);function mC(e){if(e.EventType!==`run_status`)return null;let t=String(e.Content?.status||``).trim().toLowerCase();return pC.has(t)?t:null}function hC(e,t){let n=String(t?.type||e||``).trim();if(n===`response.created`)return{phase:`运行已创建`,status:`running`};if(n===`response.in_progress`)return{phase:`等待运行时输出`,status:`waiting`};if(n===`response.output_item.added`){let e=t?.item;return e?.type===`function_call`?{phase:`调用工具 ${e.name||`tool`}`,status:`running`}:String(e?.type||``).includes(`reasoning`)?{phase:`生成思考过程`,status:`running`}:{phase:`生成回复内容`,status:`running`}}return n.includes(`reasoning`)?{phase:`生成思考过程`,status:`running`}:n.includes(`function_call`)||n===`response.tool_call`?{phase:`调用工具`,status:`running`}:n.includes(`tool_result`)?{phase:`收到工具结果`,status:`running`}:n.includes(`output_text`)||n.includes(`content_part`)?{phase:`生成回复内容`,status:`running`}:n===`response.completed`?{phase:`运行完成`,status:`completed`}:n===`response.failed`?{phase:`运行失败`,status:`failed`}:n===`response.incomplete`?{phase:`运行中断`,status:`failed`}:null}function gC(){let e=globalThis.crypto;return e&&typeof e.randomUUID==`function`?`run_${e.randomUUID()}`:`run_${Date.now()}_${Math.random().toString(16).slice(2)}`}var _C={idle:[`creating-session`,`uploading-files`,`connecting`,`error`],"creating-session":[`uploading-files`,`connecting`,`error`,`idle`],"uploading-files":[`connecting`,`error`,`idle`],connecting:[`streaming`,`error`,`idle`],streaming:[`completing`,`stopping`,`recovering`,`error`],stopping:[`cancelled`,`idle`],completing:[`idle`],recovering:[`streaming`,`error`,`idle`],error:[`connecting`,`idle`],cancelled:[`idle`]},vC=class{_stage=`idle`;listeners=new Set;abortController=null;activeCompactionId=null;activeSessionId=null;aguiClient=null;aguiThreadSessionId=null;api;config={agentId:`default-agent`,apiFormats:[`responses`],agentFramework:``,selectedModel:``,thinkingMode:`auto`};constructor(e){this.api=e}get stage(){return this._stage}updateConfig(e){this.config={...e,apiFormats:[...e.apiFormats]}}emit(e){let t=`sessionId`in e?e:{...e,sessionId:this.activeSessionId};for(let e of this.listeners)e(t)}getAguiClient(e){let t=this.config.hostedChatTransport;return t?.Protocol!==`ag-ui`||!t.Endpoint?null:((!this.aguiClient||this.aguiThreadSessionId!==e)&&(this.aguiClient=new fC({url:t.Endpoint,agentId:this.config.agentId,threadId:e,onEvent:e=>this.emit(e)}),this.aguiThreadSessionId=e),this.aguiClient)}setStage(e){let t=_C[this._stage];t&&!t.includes(e)&&console.warn(`[RunEngine] Invalid transition: ${this._stage} → ${e}`),this._stage=e,this.emit({type:`stage_changed`,stage:e})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}start(e){if(this._stage!==`idle`)return!1;this.abortController=new AbortController;let t=e.responsesInput!==void 0;return(async()=>{let n=e.sessionId||null;try{let r=!1;n||=await this.createSession(e),n||=`default-session-${Date.now()}`,this.activeSessionId=n;let i=await this.uploadFiles(e,t);this.setStage(`connecting`),this.emit({type:`activity`,phase:`连接运行时`,status:`connecting`,countEvent:!1});let a=t?`responses`:fn({agentFramework:this.config.agentFramework,apiFormats:this.config.apiFormats}),o=an(a),s=o.createState(),c=gC();D.getState().setCurrentRunId(c),D.getState().setActiveInvocationId(c),D.getState().setLastSeqId(0);let l=this.config.hostedChatTransport,u=!t&&e.attachments.length===0&&l?.Protocol===`ag-ui`?this.getAguiClient(n):null;if(u&&l){this.setStage(`streaming`),this.emit({type:`activity`,phase:`等待 AG-UI 输出`,status:`waiting`,countEvent:!1});let t=await u.run(e.text,c,this.abortController?.signal);if(t.status===`interrupted`){this.setStage(`completing`),this.emit({type:`stream_ended`});return}if(t.status!==`completed`){this.setStage(`error`),this.emit({type:`activity`,phase:`AG-UI 运行失败`,status:`failed`,countEvent:!1});return}this.setStage(`completing`),this.emit({type:`activity`,phase:`运行完成`,status:`completed`,countEvent:!1}),this.emit({type:`stream_ended`});return}let d=this.buildRequestBody(n,a,t,e,i,c),f=await this.api.runAgent(d,{signal:this.abortController?.signal});this.setStage(`streaming`),this.emit({type:`activity`,phase:`等待首个输出`,status:`waiting`,countEvent:!1});let p=`msg-${Date.now()}`,m=await this.consumeStream(f,o,s,p,c);if(!m.receivedData&&!e.sessionId&&!r&&(r=!0,n=await this.createSession(e),n)){this.activeSessionId=n,d.SessionId=n,this.setStage(`connecting`),this.emit({type:`activity`,phase:`重建会话后重新连接`,status:`connecting`,countEvent:!1});let e=await this.api.runAgent(d,{signal:this.abortController?.signal});this.setStage(`streaming`),this.emit({type:`activity`,phase:`等待首个输出`,status:`waiting`,countEvent:!1});let t=`msg-${Date.now()}`;m.terminalStatus=(await this.consumeStream(e,o,s,t,c)).terminalStatus}if(m.terminalStatus===`cancelled`){this.setStage(`stopping`),D.getState().stopActivity(`运行时已取消本次执行。`),this.emit({type:`activity`,phase:`运行已取消`,status:`stopped`,countEvent:!1}),this.setStage(`cancelled`);return}if(m.terminalStatus&&m.terminalStatus!==`completed`){this.setStage(`error`),this.emit({type:`activity`,phase:m.terminalStatus===`incomplete`?`运行中断`:`运行失败`,status:`failed`,countEvent:!1});return}this.setStage(`completing`),this.emit({type:`activity`,phase:`运行完成`,status:`completed`,countEvent:!1}),this.emit({type:`stream_ended`})}catch(e){if(this.failCompaction(),!(e instanceof DOMException&&e.name===`AbortError`))if(console.error(`[RunEngine] start() error:`,e),e instanceof TypeError&&e.message.includes(`fetch`)){this.setStage(`recovering`),this.emit({type:`activity`,phase:`网络异常,尝试重连`,status:`waiting`,countEvent:!1});let e=D.getState().lastSeqId,t=D.getState().activeInvocationId;if(e>0&&t&&this.activeSessionId)try{this.resumeRun({sessionId:this.activeSessionId,invocationId:t,afterSeqId:e});return}catch(e){console.warn(`[RunEngine] afterSeqId resume failed, fall back to error:`,e)}}else e instanceof Ct&&e.code===429?(this.setStage(`error`),this.emit({type:`rate_limited`,message:e.message||`请求过于频繁,请稍后重试`,sessionId:n})):(this.setStage(`error`),this.emit({type:`error`,error:e instanceof Error?e:Error(String(e))}))}finally{D.getState().setSessionStreaming(n,!1),this.setStage(`idle`),this.activeCompactionId=null,this.activeSessionId=null,e.onSettled?.(n)}})(),!0}stop(){if(this._stage===`idle`)return;this.setStage(`stopping`);let e=D.getState().currentRunId;e&&this.activeSessionId&&this.api.cancelRun(this.config.agentId,this.activeSessionId,e).catch(e=>{console.warn(`[RunEngine] cancelRun on stop failed:`,e)}),this.abortController?.abort(),this.aguiClient?.abort(),D.getState().stopActivity(e?`已向运行时发送取消请求;如果当前框架只支持协作式取消,后台可能会在下一个安全点停止。`:void 0),D.getState().setCurrentRunId(``),this.setStage(`cancelled`),this.emit({type:`system_message`,content:e?`已请求取消本次运行。`:`已停止接收本次输出;如果运行时不支持取消,后台执行可能仍会继续。`})}disconnect(){this._stage!==`idle`&&(this.abortController?.abort(),this.aguiClient?.abort(),D.getState().setSessionStreaming(this.activeSessionId,!1),D.getState().clearActivity(),this._stage=`idle`,this.activeCompactionId=null,this.activeSessionId=null)}async cancelRemote(e){try{this.activeSessionId&&await this.api.cancelRun(this.config.agentId,this.activeSessionId,e)}catch(e){console.warn(`[RunEngine] cancelRemote failed:`,e)}this.stop()}resumeRun(e){this.abortController?.abort(),this.abortController=new AbortController,this.activeSessionId=e.sessionId,D.getState().setCurrentRunId(e.invocationId),this.setStage(`connecting`),this.emit({type:`activity`,phase:`恢复运行事件订阅`,status:`connecting`,countEvent:!1}),(async()=>{let t=null;try{let n=await this.api.subscribeRunEvents({sessionId:e.sessionId,invocationId:e.invocationId,afterSeqId:e.afterSeqId},{signal:this.abortController?.signal});this.setStage(`streaming`),this.emit({type:`activity`,phase:`等待恢复事件`,status:`waiting`,countEvent:!1});let r=n.getReader(),i=new TextDecoder,a=``;for(;;){let{value:e,done:n}=await r.read();if(n)break;a+=i.decode(e,{stream:!0});let{chunks:o,remainder:s}=cn(a);a=s;for(let e of o){if(!e.trim())continue;let n=sn(e);for(let e of n)e.eventName===`__done__`||e.eventName===`__ping__`||(this.emit({type:`activity`,phase:`收到恢复事件`,status:`running`}),this.emit({type:`stream_event`,event:e.data}),t=mC(e.data)||t)}}this.setStage(`completing`),t===`cancelled`||t===`canceled`||t===`aborted`?this.emit({type:`activity`,phase:`后台长任务已取消`,status:`stopped`,countEvent:!1}):t===`interrupted`?this.emit({type:`activity`,phase:`后台长任务已中断`,status:`stopped`,countEvent:!1}):t===`failed`||t===`error`?this.emit({type:`activity`,phase:`后台长任务失败`,status:`failed`,countEvent:!1}):t===`resume_failed`?this.emit({type:`activity`,phase:`后台长任务恢复失败`,status:`failed`,countEvent:!1}):this.emit({type:`activity`,phase:`后台长任务已完成`,status:`completed`,countEvent:!1}),this.emit({type:`stream_ended`}),e.onSessionReloadNeeded?.()}catch(e){e instanceof DOMException&&e.name===`AbortError`||console.error(`Failed to subscribe to run events:`,e)}finally{D.getState().setSessionStreaming(e.sessionId,!1),D.getState().setCurrentRunId(``),this.setStage(`idle`),this.activeSessionId=null}})()}resumeCheckpoint(e){if(this._stage!==`idle`)return!1;this.abortController=new AbortController,this.activeSessionId=e.sessionId;let t=gC();return D.getState().setCurrentRunId(t),(async()=>{try{if(this.setStage(`connecting`),this.emit({type:`activity`,source:`restore`,phase:`从 checkpoint 恢复运行`,status:`connecting`,countEvent:!1}),this.config.checkpointResumePreviewEnabled)try{let t=(await this.api.previewCheckpointResume({agentId:this.config.agentId,sessionId:e.sessionId,runId:e.runId,checkpointId:e.checkpointId},{signal:this.abortController?.signal})).Preview?.Risk?.Level||`unknown`;this.emit({type:`activity`,source:`restore`,phase:`恢复预览完成:${String(t)} 风险`,status:`waiting`,countEvent:!1})}catch(e){console.warn(`[RunEngine] checkpoint resume preview failed:`,e)}let n=await this.api.resumeRun({agentId:this.config.agentId,sessionId:e.sessionId,runId:e.runId,checkpointId:e.checkpointId,resumeAttemptId:e.resumeAttemptId,invocationId:t},{signal:this.abortController?.signal}),r=an(`responses`),i=r.createState();this.setStage(`streaming`),this.emit({type:`activity`,source:`restore`,phase:`等待恢复输出`,status:`waiting`,countEvent:!1});let a=`msg-${Date.now()}`,o=await this.consumeStream(n,r,i,a,t);if(o.terminalStatus&&o.terminalStatus!==`completed`){if(o.terminalStatus===`cancelled`){this.setStage(`stopping`),D.getState().stopActivity(`运行时已取消本次恢复。`),this.emit({type:`activity`,source:`restore`,phase:`恢复已取消`,status:`stopped`,countEvent:!1}),this.setStage(`cancelled`);return}this.setStage(`error`),this.emit({type:`activity`,source:`restore`,phase:o.terminalStatus===`incomplete`?`恢复中断`:`恢复失败`,status:`failed`,countEvent:!1});return}this.setStage(`completing`),this.emit({type:`activity`,source:`restore`,phase:`恢复完成`,status:`completed`,countEvent:!1}),this.emit({type:`stream_ended`})}catch(e){e instanceof DOMException&&e.name===`AbortError`||(console.error(`[RunEngine] resumeCheckpoint() error:`,e),this.setStage(`error`),this.emit({type:`error`,error:e instanceof Error?e:Error(String(e))}))}finally{D.getState().setSessionStreaming(e.sessionId,!1),D.getState().setCurrentRunId(``),this.setStage(`idle`),this.activeSessionId=null,e.onSettled?.(e.sessionId)}})(),!0}resumeAguiInterrupt(e){if(this._stage!==`idle`)return!1;let t=e.sessionId||this.aguiThreadSessionId;if(!t)return!1;let n=this.getAguiClient(t);if(!n)return!1;this.activeSessionId=t;let r=gC();return D.getState().setCurrentRunId(r),this.setStage(`connecting`),this.emit({type:`activity`,phase:`提交人工确认`,status:`connecting`,countEvent:!1}),(async()=>{try{this.setStage(`streaming`);let t=await n.resume(r,{interruptId:e.interruptId,status:e.status,payload:e.payload}),i=e.payload&&typeof e.payload==`object`?e.payload:{},a=String(i.decision||i.type||``).toLowerCase();if(this.emit({type:`approval_resolved`,approvalRequestId:e.interruptId,decision:e.status===`cancelled`||a===`reject`||a===`rejected`?`rejected`:`approved`}),t.status===`interrupted`){this.setStage(`completing`),this.emit({type:`stream_ended`});return}if(t.status!==`completed`){this.setStage(`error`),this.emit({type:`activity`,phase:`人工确认恢复失败`,status:`failed`,countEvent:!1});return}this.setStage(`completing`),this.emit({type:`activity`,phase:`运行完成`,status:`completed`,countEvent:!1}),this.emit({type:`stream_ended`})}catch(e){this.setStage(`error`),this.emit({type:`error`,error:e instanceof Error?e:Error(String(e))})}finally{D.getState().setCurrentRunId(``),this.setStage(`idle`),this.activeSessionId=null,e.onSettled?.(t)}})(),!0}async createSession(e){this.setStage(`creating-session`);try{let t=(await this.api.createSession(this.config.agentId,{signal:this.abortController?.signal})).SessionId||null;return t&&(e.onSessionCreated?.(t),e.onSessionUpsert?.(t)),t}catch(e){return e instanceof DOMException&&e.name===`AbortError`||console.error(`Failed to create session:`,e),null}}async uploadFiles(e,t){let n=[];if(t||e.attachments.length===0)return n;this.setStage(`uploading-files`);for(let t of e.attachments){if(t.size>100*1024*1024){this.emit({type:`system_message`,content:`【系统提示】文件 ${t.name} 超过 100MB 限制,未发送。`});continue}if(t.type.startsWith(`image/`)){try{n.push({type:`input_image`,image_url:await this.imageFileToDataUrl(t)})}catch(e){this.emit({type:`system_message`,content:`【系统提示】图片 ${t.name} 读取失败,原因: ${ln(e)}`})}continue}let e=new FormData;e.append(`file`,t),e.append(`AgentId`,this.config.agentId);try{let r=await this.api.uploadFile(e,{signal:this.abortController?.signal});r?.FileData?.fileUri&&n.push({type:`input_file`,filename:r.FileData.displayName||t.name,file_url:r.FileData.fileUri})}catch(e){this.emit({type:`system_message`,content:`【系统提示】文件 ${t.name} 上传失败,原因: ${ln(e)}`})}}return n}async imageFileToDataUrl(e){let t=new Uint8Array(await e.arrayBuffer()),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return`data:${e.type||`application/octet-stream`};base64,${btoa(n)}`}buildRequestBody(e,t,n,r,i,a){let o={AgentId:this.config.agentId,SessionId:e,InvocationId:a,Stream:!0,ApiFormat:t,Model:this.config.selectedModel||void 0,ModelMetadata:this.config.selectedModelMetadata||void 0,ModelOptions:yt(vt(this.config.thinkingMode)),Metadata:{agentengine:{tool_approval_mode:this.config.permissionMode||`risk`}}};if(n)o.ResponsesInput=r.responsesInput,o.PreviousResponseId=r.previousResponseId;else{let e=[{type:`input_text`,text:r.text.trim()}];e.push(...i),t===`responses`&&(o.ResponsesInput=[{role:`user`,content:e}]),o.Messages=[{role:`user`,content:e}]}return o}async consumeStream(e,t,n,r,i){let a=e.getReader(),o=new TextDecoder,s=``,c=!1,l=!1;try{for(;;){let{value:e,done:u}=await a.read();if(u)break;c=!0,l||(l=!0,this.emit({type:`assistant_message_created`,messageId:r,invocationId:i})),s+=o.decode(e,{stream:!0});let{chunks:d,remainder:f}=cn(s);s=f;for(let e of d){if(!e.trim())continue;if(this.isCompactionChunk(e)){let t=sn(e);for(let e of t)e.eventName.startsWith(`response.compaction`)&&this.upsertCompactionMessage({...e.data,phase:e.eventName.split(`.`).pop()});continue}let i=sn(e),o=!1,s;for(let e of i){if(e.eventName===`__done__`){o=!0;continue}let i=hC(e.eventName,e.data);i&&this.emit({type:`activity`,...i});let a=t.parse(e,n);for(let e of a)this.dispatchAction(e,r);if(on(a)){o=!0;let e=a.find(e=>e.type===`terminal`);s=e&&`status`in e?String(e.status||``):void 0}}if(o)return a.cancel().catch(()=>{}),{receivedData:c,terminalStatus:s}}}}catch(e){if(!(e instanceof DOMException&&e.name===`AbortError`))throw e}return{receivedData:c}}isCompactionChunk(e){return e.includes(`response.compaction.start`)||e.includes(`response.compaction.done`)||e.includes(`response.compaction.failed`)}dispatchAction(e,t){switch(e.type){case`text_delta`:this.emit({type:`text_delta`,messageId:t,delta:e.text});break;case`text_final`:this.emit({type:`text_final`,messageId:t,text:e.text});break;case`reasoning_delta`:this.emit({type:`reasoning_delta`,messageId:t,delta:e.text});break;case`tool_upsert`:this.emit({type:`tool_upsert`,messageId:t,name:e.name,args:e.args,status:e.status,extra:e.extra});break;case`tool_result`:this.emit({type:`tool_result`,messageId:t,name:e.name,output:e.output});break;case`approval_request`:this.emit({type:`approval_requested`,messageId:t,approvalRequestId:e.approvalRequestId,protocol:`responses`,name:`人工确认`,args:``,message:`本次运行需要人工审批后才能继续。`});break;case`incomplete`:break;case`failed`:this.emit({type:`text_final`,messageId:t,text:`生成失败:${e.message}`});break;case`terminal`:this.emit({type:`terminal`,status:e.status});break;case`compaction`:this.emit({type:`compaction`,phase:e.phase,trigger:e.trigger,compactedUntilSeqId:e.compactedUntilSeqId});break;case`a2ui_surface_begin`:this.emit({type:`a2ui_surface_begin`,surfaceId:e.surfaceId,surface:e.surface});break;case`a2ui_surface_update`:this.emit({type:`a2ui_surface_update`,surfaceId:e.surfaceId,surface:e.surface});break;case`a2ui_surface_end`:this.emit({type:`a2ui_surface_end`,surfaceId:e.surfaceId});break;case`a2ui_interaction`:this.emit({type:`a2ui_interaction`,surfaceId:e.surfaceId,interactionId:e.interactionId,kind:e.kind,inputSchema:e.inputSchema});break}}upsertCompactionMessage(e){let t=typeof e.eventName==`string`?e.eventName.split(`.`).pop():void 0,n=String(e.phase||t||`start`);this.emit({type:`compaction`,phase:n,trigger:e.trigger?String(e.trigger):void 0,compactedUntilSeqId:e.compacted_until_seq_id?Number(e.compacted_until_seq_id):void 0}),n!==`start`&&(this.activeCompactionId=null)}failCompaction(){this.activeCompactionId&&=(this.emit({type:`compaction`,phase:`failed`}),null)}},yC=0;function bC(e){return yC+=1,`${e}-${yC}`}function xC(e){return e.map(e=>e.type===`thinking`&&e.status===`streaming`?{...e,status:`done`}:e)}function SC(e,t){let n=[...e??[]],r=n[n.length-1];return r?.type===`thinking`&&r.status===`streaming`?(n[n.length-1]={...r,content:r.content+t},n):[...n,{id:bC(`thinking`),type:`thinking`,content:t,status:`streaming`}]}function CC(e,t){let n=[...xC(e??[])],r=n[n.length-1];return r?.type===`text`&&r.status===`streaming`?(n[n.length-1]={...r,content:r.content+t},n):[...n,{id:bC(`text`),type:`text`,content:t,status:`streaming`}]}function wC(e,t){let n=xC(e??[]);if(n.filter(e=>e.type===`text`).map(e=>e.content).join(``)===t)return n.map(e=>e.type===`text`&&e.status===`streaming`?{...e,status:`done`}:e);let r=[...n],i=r.map(e=>e.type).lastIndexOf(`text`);return i>=0&&r[i].type===`text`?(r[i]={...r[i],content:t,status:`done`},r):[...r,{id:bC(`text`),type:`text`,content:t,status:`done`}]}function TC(e,t,n){let r=[...xC(e??[])],i=r.findIndex(e=>e.type===`tool`&&e.toolName===t);if(i>=0&&r[i].type===`tool`){let e=r[i],t=e.status===`error`||e.status===`completed`,a=n.output!==void 0,o=n.extra&&(n.extra.approvalRequestId||n.extra.approvalStatus);if(t&&!a&&!o)return r;let s=n.extra??e.extra;return r[i]={...e,...n,extra:s},r}return[...r,{id:bC(`tool`),type:`tool`,toolName:t,args:n.args??``,output:n.output,status:n.status??`running`,extra:n.extra}]}function EC(e){return xC(e??[])}function DC(e){let t=[];if(e.reasoning&&e.reasoning.trim()&&t.push({id:bC(`thinking`),type:`thinking`,content:e.reasoning,status:`done`}),e.tools)for(let n of Object.values(e.tools))t.push({id:bC(`tool`),type:`tool`,toolName:n.name,args:n.args??``,output:n.output,status:n.status??`completed`});return e.content&&e.content.trim()&&t.push({id:bC(`text`),type:`text`,content:e.content,status:`done`}),t}var OC=[],kC=[];function AC(e){return typeof e==`string`?e.trim():``}function jC(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:void 0}function MC(e){return typeof e==`string`||typeof e==`number`?e:void 0}function NC(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function PC(e){return e!==null}function FC(e){return e!==null}function IC(e){return[...e].sort((e,t)=>{let n=t.seqId??-1,r=e.seqId??-1;return n===r?(Date.parse(String(t.timestamp||``))||0)-(Date.parse(String(e.timestamp||``))||0):n-r})}function LC(e){return[...e].sort((e,t)=>{let n=t.seqId??-1,r=e.seqId??-1;return n===r?(Date.parse(String(t.timestamp||``))||0)-(Date.parse(String(e.timestamp||``))||0):n-r})}function RC(e){return IC(e)[0]?.runId||``}function zC(e){let t=RC(e);return t?e.filter(e=>e.runId===t):[]}function BC(e){let t=NC(e);if(!t)return null;let n=NC(t.Metadata??t.metadata),r=NC(t.Content??t.content),i=AC(t.CheckpointId??t.checkpointId??t.checkpoint_id??n?.checkpoint_id??n?.checkpointId??r?.checkpoint_id??r?.checkpointId),a=AC(t.RunId??t.runId??t.run_id??n?.run_id??n?.runId??r?.run_id??r?.runId);return!i||!a?null:{checkpointId:i,runId:a,sessionId:AC(t.SessionId??t.sessionId??t.session_id)||void 0,invocationId:AC(t.InvocationId??t.invocationId??t.invocation_id)||void 0,seqId:jC(t.SeqId??t.seqId??t.seq_id),timestamp:MC(t.Timestamp??t.timestamp??t.CreatedAt??t.createdAt),framework:AC(t.Framework??t.framework??n?.framework??r?.framework)||void 0,frameworkRef:NC(t.FrameworkRef??t.frameworkRef??t.framework_ref??n?.framework_ref??n?.frameworkRef),phase:AC(t.Phase??t.phase??n?.phase??r?.phase)||void 0,stage:AC(t.Stage??t.stage??n?.stage??n?.title)||void 0,summary:AC(t.Summary??t.summary??n?.summary??n?.description)||void 0,nextAction:AC(t.NextAction??t.nextAction??t.next_action??n?.nextAction??n?.next_action)||void 0,status:AC(t.Status??t.status??n?.status??r?.status)||void 0,metadata:n}}function VC(e){let t=NC(e);if(!t)return null;let n=AC(t.ReceiptId??t.receiptId??t.receipt_id),r=AC(t.IdempotencyKey??t.idempotencyKey??t.idempotency_key),i=AC(t.ToolName??t.toolName??t.tool_name);return!n||!r||!i?null:{receiptId:n,idempotencyKey:r,toolName:i,toolCallId:AC(t.ToolCallId??t.toolCallId??t.tool_call_id)||void 0,runId:AC(t.RunId??t.runId??t.run_id)||void 0,checkpointId:AC(t.CheckpointId??t.checkpointId??t.checkpoint_id)||void 0,sessionId:AC(t.SessionId??t.sessionId??t.session_id)||void 0,invocationId:AC(t.InvocationId??t.invocationId??t.invocation_id)||void 0,seqId:jC(t.SeqId??t.seqId??t.seq_id),timestamp:MC(t.Timestamp??t.timestamp??t.CreatedAt??t.createdAt),status:AC(t.Status??t.status)||void 0,replayed:!!(t.Replayed??t.replayed),metadata:NC(t.Metadata??t.metadata)}}var HC=S()((e,t)=>({checkpointsBySessionId:{},toolReceiptsBySessionId:{},setSessionCheckpoints:(t,n)=>e(e=>({checkpointsBySessionId:{...e.checkpointsBySessionId,[t]:IC(zC(n.map(BC).filter(PC).map(e=>({...e,sessionId:e.sessionId||t}))))}})),upsertSessionCheckpoint:(t,n)=>{let r=BC(n);r&&e(e=>{let n=e.checkpointsBySessionId[t]||[];r.sessionId=r.sessionId||t;let i=new Map(n.map(e=>[e.checkpointId,e]));i.set(r.checkpointId,{...i.get(r.checkpointId),...r});let a=zC([...i.values()]);return{checkpointsBySessionId:{...e.checkpointsBySessionId,[t]:IC(a)}}})},getSessionCheckpoints:e=>{let n=String(e||``);return n&&t().checkpointsBySessionId[n]||OC},setSessionToolReceipts:(t,n)=>e(e=>({toolReceiptsBySessionId:{...e.toolReceiptsBySessionId,[t]:LC(n.map(VC).filter(FC).map(e=>({...e,sessionId:e.sessionId||t})))}})),getSessionToolReceipts:e=>{let n=String(e||``);return n&&t().toolReceiptsBySessionId[n]||kC},clearSessionCheckpoints:t=>e(e=>{let n=String(t||``);if(!n)return{checkpointsBySessionId:{},toolReceiptsBySessionId:{}};let r={...e.checkpointsBySessionId},i={...e.toolReceiptsBySessionId};return delete r[n],delete i[n],{checkpointsBySessionId:r,toolReceiptsBySessionId:i}})}));function UC(e){return String(e||``).replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}function WC(e){let t=String(e||``).trim();for(let e=0;e<3;e+=1){if(!t)return t;let e=t[0],n=t[t.length-1];if(!(e===`{`&&n===`}`||e===`[`&&n===`]`||e===`"`&&n===`"`))return t.replace(/\\n/g,`
|
|
29
|
-
`).replace(/\\"/g,`"`);try{let e=JSON.parse(t);if(typeof e!=`string`)return GC(e);t=e.trim()}catch{return UC(t).replace(/\\n/g,`
|
|
30
|
-
`).replace(/\\"/g,`"`)}}return t}function GC(e){return typeof e==`string`?WC(e):Array.isArray(e)?e.map(e=>GC(e)):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,GC(t)]))}function KC(e){return typeof e==`string`?WC(e):GC(e)}function qC(e){return e===!1?!0:typeof e==`string`?e.trim().toLowerCase()===`false`:!1}function JC(e){return e===!0?!0:typeof e==`string`?e.trim().toLowerCase()===`true`:!1}function YC(e){return e==null||e===!1?!1:typeof e==`string`?e.trim().length>0:typeof e==`object`?Object.keys(e).length>0:!0}function XC(e){return String(e?.status||``).trim().toLowerCase()===`accepted_not_extracted`}function ZC(e,t=0){if(!e||t>4)return!1;if(typeof e==`string`){let n=WC(e);return n!==e&&ZC(n,t+1)}if(Array.isArray(e))return e.some(e=>ZC(e,t+1));if(typeof e!=`object`||XC(e))return!1;if(qC(e.ok)||qC(e.success))return!0;let n=JC(e.ok)||JC(e.success),r=String(e.status||``).trim().toLowerCase();return!n&&[`error`,`failed`,`failure`].includes(r)||!n&&(YC(e.error_type)||YC(e.error_message)||YC(e.error))?!0:Object.values(e).some(e=>ZC(e,t+1))}function QC(e){return e==null||e===``?!1:ZC(KC(e))}function $C(e){if(e==null||e===``)return``;let t=KC(e);return typeof t==`string`?t:JSON.stringify(t,null,2)}var ew=new Set([`completed`,`failed`,`error`,`cancelled`,`canceled`,`aborted`,`interrupted`,`resume_failed`]),tw=new Set([`tool_call`,`tool_result`,`stage_tool_call`,`stage_tool_result`]),nw={"run.started":`in_progress`,"run.progress":`in_progress`,"run.interrupted":`interrupted`,"run.completed":`completed`,"run.failed":`failed`,"run.canceled":`cancelled`};function rw(e){let t=e?.Content?.payload;return t&&typeof t==`object`?t:{}}function iw(e,t){let n=String(e||``),r=String(t||``);return n?!r||n.endsWith(r)?n:r.startsWith(n)?r:`${n}${r}`:r}function aw(e){let t=String(e?.EventType||``),n=rw(e);return nw[t]?{...e,EventType:`run_status`,Content:{status:String(n.status||nw[t]),...n.detail?{detail:String(n.detail)}:{}}}:t===`reasoning.delta`||t===`reasoning.completed`?{...e,EventType:`reasoning`,Content:{role:`model`,parts:[{text:String(n.text||``)}]}}:t===`tool.call.begin`?{...e,EventType:`tool_call`,Metadata:{...e.Metadata||{},tool_name:n.name,tool_args:n.args,tool_call_id:n.call_id},Content:{role:`model`,parts:[]}}:t===`tool.call.end`?{...e,EventType:`tool_result`,Metadata:{...e.Metadata||{},tool_name:n.name,tool_output:n.error||n.result,tool_call_id:n.call_id},Content:{role:`model`,parts:[]}}:e}function ow(e){let t=[],n=new Map;for(let r of Array.isArray(e)?e:[]){let e=String(r?.EventType||``);if(e===`text.delta`||e===`text.completed`){let e=String(r?.InvocationId||``).trim();if(!e)continue;let t=n.get(e);n.set(e,{event:r,text:iw(t?.text,rw(r).text)});continue}t.push(aw(r))}for(let{event:e,text:r}of n.values())t.push({...e,EventType:`assistant_stream_snapshot`,Content:{role:`model`,parts:[{text:r}]},Metadata:{...e.Metadata||{},stream_snapshot:!0}});return t.sort((e,t)=>yw(e)-yw(t))}function sw(e){let t=String(e?.EventType||``).trim(),n=rw(e);return String(e?.Content?.status||n.status||nw[t]||``).trim().toLowerCase()}function cw(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(``):``}function lw(e){let t=String(e||``).trim();return t?`/agentengine/api/v1/AttachmentContent?FileUri=${encodeURIComponent(t)}`:``}function uw(e){return String(e||``).match(/^data:([^;,]+)/)?.[1]||``}function dw(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return!n||!r||n===r?!0:n.endsWith(`/*`)?r.startsWith(n.slice(0,-1)):r.endsWith(`/*`)?n.startsWith(r.slice(0,-1)):!1}function fw(e){let t=e?.Content?.parts||[],n=[],r=new Map,i=e=>{let t=`${e.fileUri||e.url||e.name}|${e.type}`;r.has(t)||r.set(t,e)};for(let e of t){if(e?.type===`input_text`||e?.text){n.push(e.text||``);continue}if(e?.type===`input_file`&&e.inlineData){i({name:e.inlineData.displayName||`attachment`,url:`data:${e.inlineData.mimeType||`application/octet-stream`};base64,${e.inlineData.data}`,type:e.inlineData.mimeType||`application/octet-stream`});continue}if(e?.type===`input_file`&&typeof e.file_data==`string`&&e.file_data){i({name:e.filename||e.displayName||e.display_name||`attachment`,url:`data:${e.mime_type||e.mimeType||`application/octet-stream`};base64,${e.file_data}`,type:e.mime_type||e.mimeType||`application/octet-stream`});continue}if(e?.type===`input_file`&&typeof e.file_url==`string`&&e.file_url.trim()){let t=e.file_url.trim();i({name:e.filename||e.displayName||e.display_name||`attachment`,url:lw(t),type:e.mime_type||e.mimeType||`application/octet-stream`,fileUri:t});continue}if(e?.type===`input_image`||e?.type===`image_url`){let t=typeof e.image_url==`string`?e.image_url:e.image_url?.url;t&&i({name:e.filename||e.displayName||e.display_name||`uploaded_image`,url:t,type:e.mime_type||e.mimeType||uw(t)||`image/*`});continue}if(e?.type===`input_file`&&e.fileData){let t=String(e.fileData.fileUri||``).trim();i({name:e.fileData.displayName||`attachment`,url:lw(t),type:e.fileData.mimeType||`application/octet-stream`,fileUri:t})}}let a=Array.isArray(e?.Metadata?.attachments)?e.Metadata.attachments:[];for(let e of a){let t=String(e.file_uri||``).trim(),n={name:e.display_name||`attachment`,url:lw(t),type:e.mime_type||`application/octet-stream`,fileUri:t};!n.url&&!n.fileUri&&Array.from(r.values()).some(e=>e.name===n.name&&dw(e.type,n.type)&&(e.url||e.fileUri))||i(n)}let o=Array.from(r.values());return{text:n.join(``),attachments:o.length>0?o:void 0}}function pw(e){let t=e?.Metadata?.responses_output;if(!Array.isArray(t))return{};let n=zt(),r=Zt({eventName:`response.completed`,data:{response:{id:String(e.Metadata?.response_id||``),output:t}},state:n}),i=``,a={};for(let e of r){if(e.type===`reasoning_delta`){i+=e.text;continue}if(e.type===`tool_upsert`){a[e.name]={...a[e.name]||{name:e.name,args:``},name:e.name,args:e.args,status:e.status,...e.approvalRequestId?{approvalRequestId:e.approvalRequestId}:{},...e.previousResponseId?{previousResponseId:e.previousResponseId}:{},...e.serverLabel?{serverLabel:e.serverLabel}:{},...e.approvalRequestId?{approvalStatus:`pending`}:{}};continue}e.type===`tool_result`&&(a[e.name]={...a[e.name]||{name:e.name,args:``},name:e.name,output:e.output,status:QC(e.output)?`error`:`completed`})}return{...i?{reasoning:i}:{},...Object.keys(a).length>0?{tools:a}:{}}}function mw(e,t,n){return t===`running`?e===`prompt_too_long`?`检测到上下文过长,正在自动压缩历史后重试`:`正在自动压缩上下文`:n?e===`prompt_too_long`?`上下文过长,系统已自动压缩历史并重试`:`系统已自动压缩较早的对话上下文`:t===`failed`?`自动压缩上下文未完成`:e===`prompt_too_long`?`已完成上下文压缩,并继续当前回复`:`已完成上下文压缩`}function hw(e,t){return[e,t.content||``,t.reasoning||``].join(`\0`)}function gw(e){return e?.Metadata?.responses_mirror===!0||String(e?.Metadata?.responses_mirror||``).trim().toLowerCase()===`true`}function _w(e){if(e?.EventType!==`user_message`)return``;let t=fw(e),n=(t.attachments||[]).map(e=>[e.name||``,e.fileUri||``,e.url||``,e.type||``].join(``)).sort().join(``);return[String(t.text||``).trim(),n].join(`\0`)}function vw(e){return e?.EventType===`assistant_stream_snapshot`}function yw(e){let t=Number(e?.SeqId||0);if(Number.isFinite(t)&&t>0)return t;let n=Number(e?.Timestamp||0);return Number.isFinite(n)?n:0}function bw(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function xw(e){let t=String(e?.EventType||``);if(!tw.has(t))return null;let n=String(e.Metadata?.tool_name||e.Metadata?.name||e.Metadata?.function_name||cw(e.Content?.parts)||`tool`).trim()||`tool`,r={name:n,args:``,status:`running`},i=t===`tool_result`||t===`stage_tool_result`?(()=>{let t=bw(e.Metadata?.tool_output??e.Metadata?.output??e.Metadata?.result??cw(e.Content?.parts));return{...r,output:t,status:QC(t)?`error`:`completed`}})():{...r,args:bw(e.Metadata?.tool_args??e.Metadata?.arguments??e.Metadata?.args??{})};return{id:e.EventId||String(Date.now()+Math.random()),role:`model`,content:``,timestamp:e.Timestamp||Date.now(),eventType:t,tools:{[n]:i}}}function Sw(e={},t={}){let n={...e||{}};for(let[e,r]of Object.entries(t||{}))n[e]={...n[e]||{},...r||{},name:e,args:r?.args||n[e]?.args||``};return n}function Cw(e={},t=``){let n=String(t||``).trim().toLowerCase(),r=n===`completed`?`completed`:ew.has(n)?`error`:``;if(!r)return e;let i=!1,a={};for(let[t,n]of Object.entries(e||{}))n?.status===`running`?(i=!0,a[t]={...n,status:r}):a[t]=n;return i?a:e}function ww(e,t){return{...e,reasoning:Tw(e.reasoning,t.reasoning),tools:{...e.tools||{},...t.tools||{}},eventId:t.eventId||e.eventId,responseId:t.responseId||e.responseId,traceId:t.traceId||e.traceId,rootSpanId:t.rootSpanId||e.rootSpanId,timestamp:Math.max(Number(e.timestamp||0),Number(t.timestamp||0))||t.timestamp||e.timestamp,id:t.responseId||t.reasoning||t.tools?t.id:e.id}}function Tw(e=``,t=``){let n=String(e||``),r=String(t||``);return n?!r||n.endsWith(r)?n:r.startsWith(n)?r:`${n}${r}`:r}function Ew(e){return{id:e.id,role:`system`,eventType:`context_checkpoint`,status:e.status,trigger:e.trigger,compactedUntilSeqId:e.compactedUntilSeqId,summary:e.summary,historical:e.historical,timestamp:e.timestamp,content:mw(e.trigger,e.status,e.historical)}}function Dw(e){let t=e?.EventType||``;if(t===`run_status`)return e.Content?.status===`failed`?{id:e.EventId||String(Date.now()+Math.random()),role:`system`,content:e.Content?.detail||`本轮运行失败。`,eventType:t,status:`failed`,timestamp:e.Timestamp||Date.now()}:e.Content?.status===`cancelled`?{id:e.EventId||String(Date.now()+Math.random()),role:`system`,content:e.Content?.detail||`本轮输出已停止。`,eventType:t,status:`cancelled`,timestamp:e.Timestamp||Date.now()}:null;if(t===`context_checkpoint`){let t=fw(e);return Ew({id:e.EventId||String(Date.now()+Math.random()),timestamp:e.Timestamp||Date.now(),status:`completed`,trigger:String(e.Metadata?.trigger||`auto`),compactedUntilSeqId:Number(e.Metadata?.compacted_until_seq_id||0)||void 0,summary:t.text||void 0,historical:!0})}if(t===`reasoning`){let n=fw(e).text||cw(e.Metadata?.reasoning);return n?{id:e.EventId||String(Date.now()+Math.random()),role:`model`,content:``,reasoning:n,timestamp:e.Timestamp||Date.now(),eventType:t}:null}if(tw.has(t))return xw(e);if(t!==`user_message`&&t!==`assistant_message`&&t!==`assistant_stream_snapshot`)return null;let n=fw(e),r=t===`assistant_message`?pw(e):{};if(!n.text&&!n.attachments?.length&&!r.reasoning&&!r.tools)return null;let i=String(e.Metadata?.response_id||e.Metadata?.ResponseId||``).trim(),a=String(e.Metadata?.trace_id||e.Metadata?.TraceId||``).trim(),o=String(e.Metadata?.root_span_id||e.Metadata?.rootSpanId||e.Metadata?.RootSpanId||``).trim();return{id:e.EventId||String(Date.now()+Math.random()),role:t===`user_message`?`user`:`model`,content:n.text,timestamp:e.Timestamp||Date.now(),eventType:t,eventId:e.EventId||void 0,responseId:i||void 0,traceId:a||void 0,rootSpanId:o||void 0,attachments:n.attachments,...r}}function Ow(e=[]){let t=new Map,n=new Map,r=new Set,i=new Set,a=new Set,o=new Set,s=ow(e),c=[];for(let e of s){let t=String(e?.EventId||``).trim();if(t){if(o.has(t))continue;o.add(t)}c.push(e)}let l=new Set,u=new Set,d=new Map;for(let e of c){if(e?.EventType!==`user_message`||gw(e)){if(e?.EventType===`assistant_message`){let t=String(e.InvocationId||``).trim();t&&u.add(t)}if(vw(e)){let t=String(e.InvocationId||``).trim();if(t){let n=d.get(t);(!n||yw(e)>=yw(n))&&d.set(t,e)}}continue}let t=_w(e);t&&l.add(t)}let f=c.filter(e=>{if(vw(e)){let t=String(e.InvocationId||``).trim();return t?u.has(t)?!1:d.get(t)===e:!0}if(e?.EventType!==`user_message`||!gw(e))return!0;let t=_w(e);return!t||!l.has(t)});for(let e of f){let a=String(e.InvocationId||``).trim();a&&e.EventType===`user_message`&&i.add(a),a&&[`assistant_message`,`assistant_stream_snapshot`,`reasoning`,`tool_call`,`tool_result`,`stage_tool_call`,`stage_tool_result`].includes(String(e.EventType||``))&&r.add(a),e.EventType===`run_status`&&a&&(t.set(a,String(e.Content?.status||``).trim()),n.set(a,e))}let p=[],m=new Map,h=null,g=new Map,_=e=>{let t=String(e?.responseId||``).trim(),n=t?m.get(t):void 0;if(n!==void 0){p[n]=ww(p[n],e);return}t&&m.set(t,p.length),p.push(e)},v=()=>{h&&=(_(h),null)},y=e=>{let n=String(e||``).trim();if(!n)return{};let r=g.get(n);return r?(g.delete(n),{tools:Cw(r.tools,t.get(n))}):{}};for(let e of f){if(e.EventType===`run_status`)continue;let t=Dw(e);if(!t)continue;let n=String(e.InvocationId||``).trim();if(n&&(t.invocationId=n),tw.has(t.eventType)){let n=String(e.InvocationId||``).trim();if(!n){v(),_(t);continue}let r=g.get(n);g.set(n,{...r||{id:t.id,role:`model`,content:``,timestamp:t.timestamp,invocationId:n},timestamp:Math.max(Number(r?.timestamp||0),Number(t.timestamp||0)),tools:Sw(r?.tools,t.tools)});continue}if(t.eventType===`reasoning`){let n=String(e.InvocationId||``).trim();if(h&&n&&h.invocationId===n){h.reasoning=`${h.reasoning||``}${t.reasoning||``}`,h.timestamp=t.timestamp;continue}v(),h={...t,...n?{invocationId:n}:{}};continue}let r=t.eventType===`assistant_message`||t.eventType===`assistant_stream_snapshot`;if(r&&h){let n=String(e.InvocationId||``).trim(),r=hw(n,t);if(t.eventType===`assistant_message`&&n&&a.has(r)){h=null;continue}t.eventType===`assistant_message`&&n&&a.add(r),_({...t,...y(n),reasoning:Tw(h.reasoning,t.reasoning)}),h=null;continue}if(v(),r){let n=String(e.InvocationId||``).trim(),r=hw(n,t);if(t.eventType===`assistant_message`&&n&&a.has(r))continue;t.eventType===`assistant_message`&&n&&a.add(r),_({...t,...y(n)});continue}_(t)}v();for(let[e,n]of g.entries())_({...n,tools:Cw(n.tools,t.get(e))});for(let[e,a]of t.entries()){if(a!==`in_progress`||r.has(e)||!i.has(e))continue;let t=n.get(e)||{};_({id:`run-placeholder-${e}`,role:`model`,content:``,status:`running`,eventType:`run_status`,timestamp:t.Timestamp||Date.now()})}return p}function kw(e=[],t=[]){let n=[],r=new Set;for(let i of[...Array.isArray(e)?e:[],...Array.isArray(t)?t:[]]){let e=String(i?.EventId||``).trim();if(e){if(r.has(e))continue;r.add(e)}n.push(i)}return n.sort((e,t)=>{let n=Number(e?.SeqId||0),r=Number(t?.SeqId||0);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:Number(e?.Timestamp||0)-Number(t?.Timestamp||0)})}function Aw(e){return ew.has(sw(e))}function jw(e,t){let n=String(e||``),r=String(t||``);return!n||!r||n.endsWith(r)?n||r:r.startsWith(n)?r:`${n}${r}`}function Mw(e,t){return e?t?Object.fromEntries([...new Set([...Object.keys(e),...Object.keys(t)])].map(n=>[n,{...e[n]||{},...t[n]||{}}])):e:t}function Nw(e,t,n){let r=Ow(t).filter(e=>e.role===`model`).at(-1);if(!r)return e;let i=e.findIndex(e=>e.role===`model`&&e.invocationId===n),a=i>=0?e[i]:void 0,o=jw(a?.content,r.content),s=jw(a?.reasoning,r.reasoning),c=Mw(a?.tools,r.tools),l={...a,...r,id:a?.id||r.id||`${n}:assistant`,invocationId:n,content:o,reasoning:s,tools:c,blocks:DC({content:o,reasoning:s,tools:c})};return i<0?[...e,l]:e.map((e,t)=>t===i?l:e)}var Pw=new Set([`completed`]),Fw=new Set([`failed`,`error`,`cancelled`,`canceled`,`aborted`,`incomplete`]),Iw=new Map;function Lw(e,t){Rt.getState().patchMessages(n=>n.some(t=>t.id===e)?t?n.map(n=>n.id===e?{...n,invocationId:t}:n):n:[...n,{id:e,role:`model`,content:``,timestamp:Date.now(),reasoning:``,invocationId:t}])}function Rw(e){let t=String(e||``).trim().toLowerCase(),n=Pw.has(t)?`completed`:Fw.has(t)?`error`:null;n&&Rt.getState().patchMessages(e=>e.map(e=>{if(!e.tools)return e;let t=!1,r=Object.fromEntries(Object.entries(e.tools).map(([e,r])=>r.status===`running`?(t=!0,[e,{...r,status:n}]):[e,r]));return t?{...e,tools:r}:e}))}function zw(e){let t=!!(e.sessionId&&Me.getState().currentSessionId!==e.sessionId);if(t&&![`activity`,`stage_changed`,`stream_ended`,`error`,`rate_limited`,`terminal`].includes(e.type))return;let n=Rt.getState(),r=e=>{e&&D.getState().updateActivity({sessionId:e})};switch(e.type){case`activity`:D.getState().updateActivity({sessionId:e.sessionId,source:e.source,status:e.status,phase:e.phase,detail:e.detail,countEvent:e.countEvent});break;case`user_message_added`:D.getState().setBanner(null),n.patchMessages(t=>[...t,{id:e.messageId,role:`user`,content:``,timestamp:Date.now()}]);break;case`assistant_message_created`:Lw(e.messageId,e.invocationId);break;case`text_delta`:Lw(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>t.id===e.messageId?{...t,content:t.content+e.delta,blocks:CC(t.blocks,e.delta)}:t));break;case`text_final`:Lw(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>t.id===e.messageId?{...t,content:e.text,blocks:wC(t.blocks,e.text)}:t));break;case`reasoning_delta`:Lw(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>t.id===e.messageId?{...t,reasoning:(t.reasoning||``)+e.delta,blocks:SC(t.blocks,e.delta)}:t));break;case`tool_upsert`:Lw(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>{if(t.id!==e.messageId)return t;let n=t.tools?.[e.name],r=n?.approvalStatus===`approved`||n?.approvalStatus===`rejected`,i=e.status,a=n?.approvalStatus===`rejected`?`completed`:n?.status===`error`&&i!==`error`?`error`:i;return{...t,blocks:TC(t.blocks,e.name,{args:e.args,status:a,extra:e.extra}),tools:{...t.tools||{},[e.name]:{...n||{name:e.name,args:``},name:e.name,args:e.args,status:a,...e.extra||{},...e.extra?.approvalRequestId&&!r?{approvalStatus:`pending`}:{}}}}}));break;case`tool_result`:Lw(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>{if(t.id!==e.messageId)return t;let n=QC(e.output)?`error`:`completed`;return{...t,blocks:TC(t.blocks,e.name,{output:e.output,status:n}),tools:{...t.tools||{},[e.name]:{...t.tools?.[e.name]||{name:e.name,args:``},output:e.output,status:n}}}}));break;case`approval_requested`:Lw(e.messageId),n.patchMessages(t=>t.map(t=>{if(t.id!==e.messageId)return t;let n=t.tools?.[e.approvalRequestId],r=n?.approvalStatus===`approved`||n?.approvalStatus===`rejected`,i={approvalRequestId:e.approvalRequestId,approvalProtocol:e.protocol,approvalStatus:r?n.approvalStatus:`pending`,...e.message?{approvalMessage:e.message}:{},...e.approvalLevel?{approvalLevel:e.approvalLevel}:{}},a=r?n.status:`paused`;return{...t,blocks:TC(t.blocks,e.name,{args:e.args,status:a,extra:i}),tools:{...t.tools||{},[e.approvalRequestId]:{...n||{},name:e.name,args:e.args,status:a,...i}}}}));break;case`approval_resolved`:n.patchMessages(t=>t.map(t=>{if(!t.tools)return t;let n=!1,r=Object.fromEntries(Object.entries(t.tools).map(([t,r])=>{if(r.approvalRequestId!==e.approvalRequestId)return[t,r];n=!0;let i=e.decision===`rejected`?`completed`:r.status===`paused`?`running`:r.status;return[t,{...r,status:i,approvalStatus:e.decision}]}));return n?{...t,tools:r,blocks:t.blocks?.map(t=>{if(t.type!==`tool`||t.extra?.approvalRequestId!==e.approvalRequestId)return t;let n=e.decision===`rejected`?`completed`:t.status===`paused`?`running`:t.status;return{...t,status:n,extra:{...t.extra,approvalStatus:e.decision}}})}:t}));break;case`system_message`:n.patchMessages(t=>[...t,{id:String(Date.now()+Math.random()),role:`system`,content:e.content,timestamp:Date.now()}]);break;case`compaction`:{let t=`compaction-${Date.now()}`,r=e.phase===`start`?`running`:e.phase===`failed`?`failed`:`completed`,i=Ew({id:t,timestamp:Date.now(),status:r,trigger:e.trigger,compactedUntilSeqId:e.compactedUntilSeqId});n.patchMessages(e=>e.findIndex(e=>e.id===t)<0?[...e,i]:e.map(e=>e.id===t?{...e,...i}:e));break}case`stage_changed`:e.stage===`streaming`||e.stage===`connecting`?D.getState().setSessionStreaming(e.sessionId,!0):(e.stage===`completing`||e.stage===`error`||e.stage===`cancelled`)&&D.getState().setSessionStreaming(e.sessionId,!1);break;case`stream_ended`:D.getState().setSessionStreaming(e.sessionId,!1),t||Rt.getState().patchMessages(e=>e.map(e=>e.role!==`model`||!e.blocks?.some(e=>e.status===`streaming`)?e:{...e,blocks:EC(e.blocks.map(e=>e.type===`text`&&e.status===`streaming`?{...e,status:`done`}:e))})),globalThis.setTimeout(()=>{let t=D.getState();t.getSessionActivity(e.sessionId)?.status===`completed`&&t.clearSessionActivity(e.sessionId)},2400);break;case`error`:D.getState().setSessionStreaming(e.sessionId,!1),D.getState().updateActivity({sessionId:e.sessionId,status:`failed`,phase:`连接断开或生成出错`,countEvent:!1}),t||(D.getState().setBanner({kind:`error`,message:`连接断开或生成出错,请重试`,sessionId:e.sessionId}),n.patchMessages(e=>[...e,{id:String(Date.now()),role:`model`,content:`连接断开或生成出错。`,timestamp:Date.now()}]));break;case`rate_limited`:D.getState().setSessionStreaming(e.sessionId,!1),D.getState().updateActivity({sessionId:e.sessionId,status:`failed`,phase:`请求被限流`,countEvent:!1}),t||D.getState().setBanner({kind:`rate_limited`,message:e.message||`请求过于频繁,请稍后重试`,retryAfterSec:e.retryAfterSec,sessionId:e.sessionId});break;case`terminal`:t||Rw(e.status);break;case`stream_event`:{let t=e.sessionId||e.event.SessionId,n=e.event.SeqId;typeof n==`number`&&n>0&&D.getState().setLastSeqId(n),t&&D.getState().updateActivity({sessionId:t});let r=String(e.event.InvocationId||``).trim();if(t&&r){let n=`${t}:${r}`,i=kw(Iw.get(n)||[],[e.event]);Iw.set(n,i),Rt.getState().patchMessages(e=>Nw(e,i,r)),Aw(e.event)&&Iw.delete(n)}e.event.EventType===`run_checkpoint`&&t&&HC.getState().upsertSessionCheckpoint(t,e.event);{let n=sw(e.event);n===`completed`?D.getState().updateActivity({sessionId:t,status:`completed`,phase:`后台长任务已完成`,countEvent:!1}):n===`cancelled`||n===`canceled`||n===`aborted`?D.getState().updateActivity({sessionId:t,status:`stopped`,phase:`后台长任务已取消`,countEvent:!1}):(n===`failed`||n===`error`)&&D.getState().updateActivity({sessionId:t,status:`failed`,phase:`后台长任务失败`,countEvent:!1})}break}case`a2ui_surface_begin`:{let t=`a2ui-${e.surfaceId}`;Rt.getState().patchMessages(n=>[...n.filter(e=>e.id!==t),{id:t,role:`a2ui`,content:``,timestamp:Date.now(),a2ui:{surfaceId:e.surfaceId,surface:e.surface}}]);break}case`a2ui_surface_update`:{let t=`a2ui-${e.surfaceId}`;Rt.getState().patchMessages(n=>n.map(n=>n.id===t&&n.a2ui?{...n,a2ui:{...n.a2ui,surface:e.surface}}:n));break}case`a2ui_surface_end`:{let t=`a2ui-${e.surfaceId}`;Rt.getState().patchMessages(e=>e.map(e=>e.id===t&&e.a2ui?{...e,a2ui:{...e.a2ui,ended:!0}}:e));break}case`a2ui_interaction`:{let t=`a2ui-${e.surfaceId}`;Rt.getState().patchMessages(n=>n.map(n=>n.id===t&&n.a2ui?{...n,a2ui:{...n.a2ui,pendingInteraction:{interactionId:e.interactionId,kind:e.kind,inputSchema:e.inputSchema}}}:n));break}case`agui_activity`:{let t=`agui-a2ui-${e.surfaceId}`;Rt.getState().patchMessages(n=>{let r={surfaceId:e.surfaceId,messages:e.messages},i=!1,a=n.map(t=>{if(t.id!==e.messageId)return t;i=!0;let n=[...(t.aguiActivities||[]).filter(t=>t.surfaceId!==e.surfaceId),r];return{...t,aguiActivities:n}});if(i)return a;let o=n.find(e=>e.id===t),s={id:t,role:`a2ui`,content:``,timestamp:o?.timestamp||Date.now(),aguiActivity:r};return o?n.map(e=>e.id===t?s:e):[...n,s]});break}}}function Bw(){Iw.clear()}function Vw(e){let t=(0,b.useRef)(new Map),n=(0,b.useRef)(()=>{}),{agentId:r,apiFormats:i,agentFramework:a,selectedModel:o,selectedModelMetadata:s,thinkingMode:c,permissionMode:l,currentSessionIdRef:u,queuedDraftRef:d,onRunSettled:f,uiCapabilities:p}=e,m=(0,b.useCallback)(e=>{e.updateConfig({agentId:r,apiFormats:i,agentFramework:a,selectedModel:o,selectedModelMetadata:s,thinkingMode:c,permissionMode:l,hostedChatTransport:pe(p,{requireResumableRun:!!(p.RunLifecycle?.Enabled&&p.RunLifecycle.Resume)}),checkpointResumePreviewEnabled:!!p.RunLifecycle?.CheckpointResumePreview})},[r,i,a,o,s,c,l,p]),h=(0,b.useCallback)(n=>{let r=String(n||`new-session`),i=t.current.get(r);return i?m(i):(i=new vC(e.api),m(i),i.subscribe(zw),t.current.set(r,i)),i},[e.api,m]);(0,b.useEffect)(()=>{for(let e of t.current.values())m(e)},[m]);let g=(0,b.useCallback)(e=>{d.current.push(e),w.getState().setQueuedDrafts(t=>[...t,e])},[d]),_=(0,b.useCallback)(e=>{let i=u.current,a=h(i);if(a.stage!==`idle`)return!1;Bw(),w.getState().setMobileActionsOpen(!1),D.getState().setSessionStreaming(i,!0);let o=e.text.trim(),s=String(Date.now()),c=e.attachments.map(e=>({name:e.name,url:URL.createObjectURL(e),type:e.type||`application/octet-stream`}));(o||c.length>0)&&Rt.getState().patchMessages(e=>[...e,{id:s,role:`user`,content:o,timestamp:Date.now(),attachments:c.length?c:void 0}]);let l=a.start({text:e.text,attachments:e.attachments,responsesInput:e.responsesInput,previousResponseId:e.previousResponseId,sessionId:i,onSessionCreated:e=>{Me.getState().upsertSessions([{SessionId:e,UpdatedAt:new Date().toISOString()}]),u.current=e,ut(r,e),Me.getState().setCurrentSessionId(e),i!==e&&t.current.set(e,a)},onSessionUpsert:()=>{},onSettled:e=>{f?.(e),n.current()}});return l||D.getState().setSessionStreaming(i,!1),l},[r,u,h,f]);(0,b.useEffect)(()=>{n.current=()=>{let e=d.current.shift();if(!e){w.getState().setQueuedDrafts([]);return}w.getState().setQueuedDrafts(e=>e.slice(1)),queueMicrotask(()=>{_(e)||(d.current.unshift(e),w.getState().setQueuedDrafts(t=>[e,...t]))})}},[d,_]);let v=(0,b.useCallback)(async(e,t,n,r)=>{let i={text:e,attachments:t,responsesInput:n,previousResponseId:r};if(h(u.current).stage!==`idle`&&D.getState().isSessionStreaming(u.current)){n===void 0&&g({text:e,attachments:t});return}!_(i)&&n===void 0&&g({text:e,attachments:t})},[u,g,h,_]),y=(0,b.useCallback)(()=>{h(u.current).stop()},[u,h]),x=(0,b.useCallback)(()=>{h(u.current).disconnect()},[u,h]),ee=(0,b.useCallback)(e=>{let t=h(e.sessionId);if(t.stage!==`idle`)return!1;Bw(),w.getState().setMobileActionsOpen(!1),D.getState().setSessionStreaming(e.sessionId,!0);let r=t.resumeCheckpoint({...e,onSettled:e=>{f?.(e),n.current()}});return r||D.getState().setSessionStreaming(e.sessionId,!1),r},[h,f]),te=(0,b.useCallback)(()=>{Bw()},[]);return{submitDraft:v,stopGeneration:y,disconnectRun:x,resumeCheckpoint:ee,submitAguiAction:(0,b.useCallback)(e=>{let t=e.userAction;if(!t)return!1;let n=t.context||{},r=String(n.interruptId||n.interrupt_id||``);if(!r)return!1;let i=u.current;if(!i)return!1;let a=h(i),o=n.status===`cancelled`?`cancelled`:`resolved`,s=Object.prototype.hasOwnProperty.call(n,`payload`)?n.payload:{action:t.name,sourceComponentId:t.sourceComponentId,context:n};return a.resumeAguiInterrupt({sessionId:i,interruptId:r,status:o,payload:s,onSettled:f})},[u,h,f]),respondToAguiApproval:(0,b.useCallback)(e=>{if(!e.interruptId)return!1;let t=u.current;if(!t)return!1;let n=h(t);if(n.stage!==`idle`)return!1;D.getState().setSessionStreaming(t,!0);let r=n.resumeAguiInterrupt({sessionId:t,interruptId:e.interruptId,status:`resolved`,payload:{decision:e.approve?`approve`:`reject`},onSettled:f});return r||D.getState().setSessionStreaming(t,!1),r},[u,h,f]),resetCompaction:te}}function Hw(e){return String(e||``).trim()}function Uw(e){let t=Hw(e).toLowerCase();return t===`up`||t===`down`?t:``}function Ww(e){if(!e||typeof e!=`object`)return null;let t=Uw(e.Rating||e.rating);return t?{agentId:Hw(e.AgentId||e.agentId),sessionId:Hw(e.SessionId||e.sessionId),responseId:Hw(e.ResponseId||e.responseId),eventId:Hw(e.EventId||e.eventId),rating:t,comment:String(e.Comment??e.comment??``),traceId:Hw(e.TraceId||e.traceId),rootSpanId:Hw(e.RootSpanId||e.rootSpanId),updatedAt:Hw(e.UpdatedAt||e.updatedAt)}:null}function Gw(e,t,n){return!!(e?.role===`model`&&Hw(e.responseId)&&Hw(e.eventId)&&!(t&&n))}function Kw({agentId:e,sessionId:t,message:n}){let r=Hw(n?.responseId);if(!r)throw Error(`Message missing response id`);return{AgentId:Hw(e),SessionId:Hw(t),ResponseId:r}}function qw({agentId:e,sessionId:t,message:n,rating:r,comment:i=``}){let a=Uw(r);if(!a)throw Error(`Feedback rating must be up or down`);let o={...Kw({agentId:e,sessionId:t,message:n}),EventId:Hw(n?.eventId),Rating:a,Comment:String(i||``),TraceId:Hw(n?.traceId),RootSpanId:Hw(n?.rootSpanId)};if(!o.EventId)throw Error(`Message missing event id`);return o}function Jw(e,{messageId:t,rating:n,comment:r=``}){let i=e.find(e=>e.id===t),a=i?.feedback?{...i.feedback}:null,o=Uw(n);return{nextMessages:e.map(e=>e.id===t?{...e,feedback:{...e.feedback||{},responseId:Hw(e.responseId),eventId:Hw(e.eventId),rating:o,comment:String(r||``),pending:!0,error:``}}:e),previousFeedback:a}}function Yw(e,{messageId:t,feedback:n}){let r=Ww(n)||n;return e.map(e=>e.id===t?{...e,feedback:r?{...r,pending:!1,error:``}:void 0}:e)}function Xw(e,{messageId:t,previousFeedback:n}){return e.map(e=>{if(e.id!==t)return e;if(!n){let{feedback:t,...n}=e;return n}return{...e,feedback:n}})}function Zw(e,{messageId:t}){return e.map(e=>{if(e.id!==t)return e;let{feedback:n,...r}=e;return r})}function Qw(e){let{agentId:t,currentSessionId:n,isStreaming:r,api:i,submitDraft:a}=e;return{submitResponseFeedback:(0,b.useCallback)(async e=>{if(!n)return;let r=null;Rt.getState().patchMessages(t=>{let n=Jw(t,{messageId:e.message.id,rating:e.rating,comment:e.comment||``});return r=n.previousFeedback,n.nextMessages});try{let r=Ww((await i.upsertResponseFeedback(qw({agentId:t,sessionId:n,message:e.message,rating:e.rating,comment:e.comment||``})))?.Feedback);r&&Rt.getState().patchMessages(t=>Yw(t,{messageId:e.message.id,feedback:r}))}catch(t){console.error(`Failed to submit response feedback:`,t),Rt.getState().patchMessages(t=>Xw(t,{messageId:e.message.id,previousFeedback:r}))}},[t,n,i]),deleteResponseFeedback:(0,b.useCallback)(async e=>{if(!n)return;let r=e.feedback?{...e.feedback}:null;Rt.getState().patchMessages(t=>Zw(t,{messageId:e.id}));try{await i.deleteResponseFeedback(Kw({agentId:t,sessionId:n,message:e}))}catch(t){console.error(`Failed to delete response feedback:`,t),Rt.getState().patchMessages(t=>Xw(t,{messageId:e.id,previousFeedback:r}))}},[t,n,i]),respondToApproval:(0,b.useCallback)(e=>{!e.approvalRequestId||r||(Rt.getState().patchMessages(t=>t.map(t=>{let n=e.approve?`approved`:`rejected`,r=t=>e.approve&&t===`paused`?`running`:e.approve?t:`completed`;return{...t,tools:t.tools?Object.fromEntries(Object.entries(t.tools).map(([t,i])=>[t,i.approvalRequestId===e.approvalRequestId?{...i,status:r(i.status),approvalStatus:n}:i])):t.tools,blocks:t.blocks?.map(t=>t.type===`tool`&&t.extra?.approvalRequestId===e.approvalRequestId?{...t,status:r(t.status),extra:{...t.extra,approvalStatus:n}}:t)}})),a(``,[],[{type:`mcp_approval_response`,approval_request_id:e.approvalRequestId,approve:e.approve}],e.previousResponseId))},[r,a])}}var $w={running:`running`,completed:`completed`,failed:`error`,paused:`paused`,approved:`completed`,denied:`completed`},eT={paused:`pending`,approved:`approved`,denied:`rejected`};function tT(e){if(typeof e==`number`)return e;if(typeof e==`string`){let t=Date.parse(e);if(Number.isFinite(t))return t}return Date.now()}function nT(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`){if(typeof e.text==`string`)return e.text;if(Array.isArray(e.parts))return e.parts.map(e=>e&&typeof e==`object`&&typeof e.text==`string`?e.text:``).join(``)}return``}function rT(e){let t={},n=new Map;for(let t of e??[])t?.Name&&n.set(t.Name,(n.get(t.Name)||0)+1);for(let r of e??[]){if(!r?.Name)continue;let e=$w[String(r.Status??`completed`).toLowerCase()]??`completed`,i={name:r.Name,args:r.Args===void 0?``:typeof r.Args==`string`?r.Args:JSON.stringify(r.Args),status:e};r.Result!==void 0&&(i.output=typeof r.Result==`string`?r.Result:JSON.stringify(r.Result)),r.ApprovalRequestId&&(i.approvalRequestId=r.ApprovalRequestId,i.approvalStatus=eT[String(r.Status??`paused`).toLowerCase()]??`pending`,i.approvalProtocol=String(r.Protocol??``).toLowerCase()===`ag-ui`?`ag-ui`:`responses`,r.ApprovalMessage&&(i.approvalMessage=String(r.ApprovalMessage)),r.ApprovalLevel&&(i.approvalLevel=String(r.ApprovalLevel))),r.ToolCallId&&(i.previousResponseId=r.ToolCallId);let a=n.get(r.Name)>1&&r.ToolCallId?r.ToolCallId:r.Name;t[a]=i}return t}function iT(e){if(Array.isArray(e))return e.map(e=>({name:e.name||``,url:e.url||``,type:e.mime||``,fileUri:e.file_uri}))}function aT(e){return e==null?``:typeof e==`string`?e:JSON.stringify(e)}function oT(e){if(!(!Array.isArray(e)||!e.length))return e.flatMap((e,t)=>{let n=String(e?.Type||``).toLowerCase(),r=e?.SeqId??t;if(n===`thinking`||n===`text`){let t=String(e?.Content||``);return t?[{id:`history-${n}-${r}`,type:n,content:t,status:`done`}]:[]}if(n!==`tool`)return[];let i=$w[String(e?.Status||`completed`).toLowerCase()]??`completed`;return[{id:`history-tool-${r}`,type:`tool`,toolName:String(e?.Name||`tool`),args:aT(e?.Args),...e?.Result===void 0?{}:{output:aT(e.Result)},status:i,...e?.ToolCallId?{extra:{previousResponseId:String(e.ToolCallId)}}:{}}]})}function sT(e){let t=e.Role===`assistant`?`model`:e.Role||`user`,n=e.ToolEvents?.length?rT(e.ToolEvents):void 0,r=iT(e.Attachments),i=oT(e.Blocks),a=e.Reasoning?.length?e.Reasoning.map(e=>e.text).join(``):void 0,o={id:e.MessageId||`msg-${e.SeqId??Math.random().toString(36).slice(2)}`,role:t,content:nT(e.Content),timestamp:tT(e.Timestamp),eventType:t===`user`?`user_message`:`assistant_message`,reasoning:a,tools:n,attachments:r};return t===`model`&&(o.blocks=i??DC({reasoning:a,tools:n,content:o.content})),e.MessageId&&(o.eventId=e.MessageId),e.InvocationId&&(o.invocationId=e.InvocationId),e.ResponseId&&(o.responseId=e.ResponseId),e.TraceId&&(o.traceId=e.TraceId),e.RootSpanId&&(o.rootSpanId=e.RootSpanId),o}function cT(e){return Array.isArray(e.Activities)?e.Activities.flatMap((t,n)=>{let r=String(t?.SurfaceId||``);if(!r)return[];let i=t?.Content,a=Array.isArray(i?.a2ui_operations)?i.a2ui_operations:Array.isArray(i)?i:[];return a.length?[{id:t.MessageId||`a2ui-${e.MessageId||e.SeqId||`message`}-${n}`,role:`a2ui`,content:``,timestamp:tT(e.Timestamp),aguiActivity:{surfaceId:r,messages:aC(a)}}]:[]}):[]}function lT(e){return e.flatMap(e=>[sT(e),...cT(e)])}var uT=500,dT=30,fT=50,pT=1800*1e3;function mT(e){return new Promise(t=>{if(e.aborted){t();return}let n=globalThis.setTimeout(t,uT);e.addEventListener(`abort`,()=>{globalThis.clearTimeout(n),t()},{once:!0})})}var hT=new Set([`in_progress`,`running`,`resuming`,`starting`]);function gT(e){let t=e.ActiveRunUpdatedAt||e.UpdatedAt,n=typeof t==`number`?t>1e11?t:t*1e3:Date.parse(String(t||``));return Number.isFinite(n)&&n<=Date.now()+pT&&Date.now()-n<=pT}function _T(e){let t=sw(e);return t?t===`completed`?{status:`completed`,phase:`后台长任务已完成`}:t===`cancelled`||t===`canceled`||t===`aborted`?{status:`stopped`,phase:`后台长任务已取消`}:t===`interrupted`?{status:`stopped`,phase:`后台长任务已中断`}:t===`failed`||t===`error`?{status:`failed`,phase:`后台长任务失败`}:t===`resume_failed`?{status:`failed`,phase:`后台长任务恢复失败`}:null:null}function vT(e){let{agentId:t,api:n,isMobile:r,resetCompaction:i,uiCapabilities:a,disconnectRun:o}=e,s=(0,b.useRef)(e.currentSessionId),c=(0,b.useRef)(e.agentId),l=(0,b.useRef)(null),u=(0,b.useRef)(0),d=(0,b.useRef)(new Map),f=(0,b.useRef)(null),p=(0,b.useRef)(null),m=(0,b.useCallback)(async(e,t,r)=>{let i=r.filter(e=>Gw(e,!1,!1));if(!i.length)return;let a=await Promise.all(i.map(async r=>{try{let i=await n.getResponseFeedback({AgentId:e,SessionId:t,ResponseId:r.responseId,EventId:r.eventId}),a=i?.Feedback?Ww(i.Feedback):null;return a?{messageId:r.id,feedback:a}:null}catch(e){return console.error(`Failed to load response feedback:`,e),null}}));if(s.current!==t)return;let o=new Map(a.filter(e=>!!e).map(e=>[e.messageId,e.feedback]));o.size&&Rt.getState().patchMessages(e=>e.map(e=>o.has(e.id)?{...e,feedback:o.get(e.id)}:e))},[n]),h=(0,b.useCallback)(async e=>{l.current?.abort();let t=new AbortController;l.current=t;let r=!1,i=!1,a=e.afterSeqId,o=()=>l.current===t&&s.current===e.sessionId;try{for(D.getState().setCurrentRunId(e.invocationId),D.getState().setActiveInvocationId(e.invocationId),D.getState().setSessionStreaming(e.sessionId,!0),D.getState().updateActivity({sessionId:e.sessionId,status:`running`,phase:`后台长任务运行中`,detail:e.invocationId,countEvent:!1});!i&&o();){try{let s=await n.subscribeRunEvents({sessionId:e.sessionId,invocationId:e.invocationId,afterSeqId:a},{signal:t.signal});if(!o()){t.abort();return}let c=s.getReader(),l=new TextDecoder,u=``;for(;!i&&o();){let{value:t,done:n}=await c.read();if(n)break;u+=l.decode(t,{stream:!0});let s=cn(u);u=s.remainder;for(let t of s.chunks)if(t.trim()){for(let n of sn(t)){if(n.eventName===`__ping__`){D.getState().updateActivity({sessionId:e.sessionId,status:`running`,countEvent:!1});continue}if(n.eventName===`__done__`){i=!0,r=!0;break}if(!n.data||typeof n.data!=`object`)continue;let t=n.data;if(!o())break;if(t.InvocationId&&t.InvocationId!==e.invocationId)continue;let s=Number(t.SeqId||0);Number.isFinite(s)&&(a=Math.max(a,s)),zw({type:`stream_event`,sessionId:e.sessionId,event:t}),i||=Aw(t),r||=i;let c=_T(t);if(c&&D.getState().updateActivity({sessionId:e.sessionId,status:c.status,phase:c.phase,detail:e.invocationId,countEvent:!1}),i)break}if(i)break}}i&&c.cancel().catch(()=>{})}catch(t){if(t instanceof DOMException&&t.name===`AbortError`||!o())break;console.warn(`Run event subscription disconnected; retrying:`,t),D.getState().updateActivity({sessionId:e.sessionId,status:`waiting`,phase:`恢复连接中`,detail:e.invocationId,countEvent:!1})}!i&&o()&&await mT(t.signal)}i&&o()&&zw({type:`stream_ended`,sessionId:e.sessionId})}catch(e){e instanceof DOMException&&e.name===`AbortError`||console.error(`Failed to subscribe run events:`,e)}finally{let n=l.current===t;n&&(l.current=null),n&&s.current===e.sessionId&&(D.getState().setCurrentRunId(``),D.getState().setActiveInvocationId(``),r&&f.current?.(e.sessionId),p.current?.(c.current,e.sessionId))}},[n]),g=(0,b.useCallback)(async e=>{let t=s.current,o=++u.current;t&&t!==e&&(Rt.getState().setMessages([]),Me.getState().clearSessionMessageHistory(e),HC.getState().setSessionCheckpoints(e,[]),HC.getState().setSessionToolReceipts(e,[]),D.getState().setCurrentRunId(``),D.getState().clearActivity()),s.current=e;let d=()=>s.current===e&&u.current===o;Me.getState().setCurrentSessionId(e),Me.getState().setSessionInitialMessageHistoryLoading(e,!0),i(),l.current?.abort(),r&&w.getState().setMobileSidebarOpen(!1);try{let t=await n.listSessionMessages(e,{limit:fT,includeReasoning:!0,includeToolEvents:!0,includeAttachments:!0});if(!d())return;let r=lT(t.Messages);Rt.getState().setMessages(r),Me.getState().setSessionMessageHistory(e,{nextCursor:t.NextCursor,hasMore:t.HasMore}),m(c.current,e,r);let i=t.LatestSeqId||0,o=me.getState().capabilities||a;if(o.RunLifecycle.Enabled&&o.RunLifecycle.Checkpoints?(n.listSessionCheckpoints({agentId:c.current,sessionId:e}).then(t=>{d()&&HC.getState().setSessionCheckpoints(e,t.Checkpoints||[])}).catch(t=>{d()&&(console.warn(`[SessionLifecycle] checkpoint load failed:`,t),HC.getState().setSessionCheckpoints(e,[]))}),n.listToolReceipts({agentId:c.current,sessionId:e}).then(t=>{d()&&HC.getState().setSessionToolReceipts(e,t.ToolReceipts||[])}).catch(t=>{d()&&(console.warn(`[SessionLifecycle] tool receipt load failed:`,t),HC.getState().setSessionToolReceipts(e,[]))})):HC.getState().clearSessionCheckpoints(e),o.RunLifecycle.Enabled&&o.RunLifecycle.Resume)try{let t=await n.getSession(e);if(!d())return;let r=String(t.ActiveRunStatus||``).toLowerCase();t.ActiveInvocationId&&(hT.has(r)||r===``&&gT(t))&&h({sessionId:e,invocationId:t.ActiveInvocationId,afterSeqId:i})}catch(e){console.warn(`[SessionLifecycle] getSession for reconnect failed:`,e)}}catch(e){console.error(`Failed to load session messages:`,e)}finally{d()&&Me.getState().setSessionInitialMessageHistoryLoading(e,!1)}},[n,o,r,m,i,h,a]),_=(0,b.useCallback)(async(e=`default-agent`,t=null)=>{try{let r=Me.getState();r.sessionsAgentId&&r.sessionsAgentId!==e&&r.resetSessionPagination(e),Me.getState().setLoadingSessions(!0);let i=await n.listSessions(e,{page:1,pageSize:dT});Me.getState().upsertSessions(i.Sessions||[],{agentId:e,total:Number(i.Total??i.Sessions?.length??0),page:Number(i.Page??1),pageSize:Number(i.PageSize??dT),replace:!0});let a=Me.getState().sessions,c=s.current,d=dt(a,c||t||lt(e));d&&d!==c?g(d):!d&&c&&(u.current+=1,l.current?.abort(),o?.(),s.current=null,Me.getState().setCurrentSessionId(null),Rt.getState().setMessages([]),Me.getState().clearSessionMessageHistory(),HC.getState().clearSessionCheckpoints(),D.getState().setCurrentRunId(``),D.getState().clearActivity())}catch(e){if(e instanceof wt)return;console.error(`Failed to fetch sessions:`,e)}finally{Me.getState().setLoadingSessions(!1)}},[n,o,g]),v=(0,b.useCallback)(async()=>{let e=Me.getState();if(e.isLoadingSessions||!e.hasMoreSessions)return;let t=Te({total:e.sessionsTotal,pageSize:e.sessionsPageSize||dT,loadedPages:e.loadedPages});if(!t)return;let r=e.sessionsPageSize||dT,i=e.sessionsAgentId||c.current||`default-agent`;try{Me.getState().setLoadingSessions(!0);let a=await n.listSessions(i,{page:t,pageSize:r});Me.getState().upsertSessions(a.Sessions||[],{agentId:i,total:Number(a.Total??e.sessionsTotal),page:Number(a.Page??t),pageSize:Number(a.PageSize??r)})}catch(e){if(e instanceof wt)return;console.error(`Failed to load more sessions:`,e)}finally{Me.getState().setLoadingSessions(!1)}},[n]);(0,b.useEffect)(()=>{f.current=g},[g]),(0,b.useEffect)(()=>{p.current=_},[_]);let y=(0,b.useCallback)(async()=>{try{u.current+=1,l.current?.abort();let e=(await n.createSession(t)).SessionId;e&&(Me.getState().upsertSessions([{SessionId:e,UpdatedAt:new Date().toISOString()}]),s.current=e,Me.getState().setCurrentSessionId(e),Rt.getState().setMessages([]),Me.getState().clearSessionMessageHistory(e),HC.getState().setSessionCheckpoints(e,[]),HC.getState().setSessionToolReceipts(e,[]),D.getState().setCurrentRunId(``),D.getState().clearActivity(),r&&(w.getState().setMobileSidebarOpen(!1),w.getState().setMobileActionsOpen(!1)),_(t,e))}catch(e){if(e instanceof wt)return;console.error(`Failed to create session:`,e)}},[t,n,_,r]),x=(0,b.useCallback)(async e=>{try{await n.deleteSession(e),Me.getState().removeSession(e),Me.getState().clearSessionMessageHistory(e),s.current===e&&(u.current+=1,l.current?.abort(),o?.(),s.current=null,Rt.getState().setMessages([]),HC.getState().clearSessionCheckpoints(e),Me.getState().setCurrentSessionId(null),D.getState().setCurrentRunId(``),D.getState().clearActivity(),_(t))}catch(e){if(e instanceof wt)return;console.error(`Failed to delete session`,e)}},[t,n,o,_]);return{fetchSessions:_,loadMoreSessions:v,loadSession:g,loadOlderSessionMessages:(0,b.useCallback)(async e=>{let t=Me.getState().messageHistory[e];if(!t||!t.hasMore||t.nextCursor===null||t.isLoadingOlder)return;let r=u.current,i=Symbol(e);d.current.set(e,i);try{Me.getState().setSessionMessageHistoryLoading(e,!0);let a=await n.listSessionMessages(e,{beforeSeqId:t.nextCursor,limit:fT,includeReasoning:!0,includeToolEvents:!0,includeAttachments:!0});if(s.current!==e||u.current!==r||d.current.get(e)!==i)return;let o=lT(a.Messages),l=new Set(o.map(e=>e.id)),f=[...o,...Rt.getState().messages.filter(e=>!l.has(e.id))];Rt.getState().setMessages(f),Me.getState().setSessionMessageHistory(e,{nextCursor:a.NextCursor,hasMore:a.HasMore}),m(c.current,e,o)}catch(e){e instanceof wt||console.error(`Failed to load older session messages:`,e)}finally{d.current.get(e)===i&&(d.current.delete(e),Me.getState().setSessionMessageHistoryLoading(e,!1))}},[n,m]),createNewSession:y,deleteSession:x,currentSessionIdRef:s,agentIdRef:c,runSubscriptionAbortRef:l}}var yT=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),bT=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),xT=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),ST=e=>{let t=xT(e);return t.charAt(0).toUpperCase()+t.slice(1)},CT={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},wT=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},TT=(0,b.createContext)({}),ET=()=>(0,b.useContext)(TT),DT=(0,b.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=ET()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,b.createElement)(`svg`,{ref:c,...CT,width:t??l??CT.width,height:t??l??CT.height,stroke:e??f,strokeWidth:m,className:yT(`lucide`,p,i),...!a&&!wT(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,b.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),OT=(e,t)=>{let n=(0,b.forwardRef)(({className:n,...r},i)=>(0,b.createElement)(DT,{ref:i,iconNode:t,className:yT(`lucide-${bT(ST(e))}`,`lucide-${e}`,n),...r}));return n.displayName=ST(e),n},kT=OT(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),AT=OT(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),jT=OT(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),MT=OT(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),NT=OT(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),PT=OT(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),FT=OT(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),IT=OT(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),LT=OT(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),RT=OT(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),zT=OT(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),BT=OT(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),VT=OT(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),HT=OT(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),UT=OT(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),WT=OT(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),GT=OT(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),KT=OT(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),qT=OT(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),JT=OT(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),YT=OT(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),XT=OT(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),ZT=OT(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),QT=OT(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),$T=OT(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),eE=OT(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),tE=OT(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),nE=OT(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),rE=OT(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),iE=OT(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),aE=OT(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),oE=OT(`refresh-ccw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),sE=OT(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),cE=OT(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),lE=OT(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),uE=OT(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),dE=OT(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),fE=OT(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),pE=OT(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),mE=OT(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),hE=OT(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),gE=OT(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),_E=OT(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),vE=OT(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),yE=OT(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),bE=OT(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),xE=OT(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),SE=OT(`zap-off`,[[`path`,{d:`M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317`,key:`193nxd`}],[`path`,{d:`M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773`,key:`27a7lr`}],[`path`,{d:`M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643`,key:`1e0qe9`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),CE=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},wE=(e,t)=>({classGroupId:e,validator:t}),TE=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),EE=`-`,DE=[],OE=`arbitrary..`,kE=e=>{let t=ME(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return jE(e);let n=e.split(EE);return AE(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?CE(i,t):t:i||DE}return n[e]||DE}}},AE=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=AE(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(EE):e.slice(t).join(EE),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},jE=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?OE+r:void 0})(),ME=e=>{let{theme:t,classGroups:n}=e;return NE(n,t)},NE=(e,t)=>{let n=TE();for(let r in e){let i=e[r];PE(i,n,r,t)}return n},PE=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];FE(i,t,n,r)}},FE=(e,t,n,r)=>{if(typeof e==`string`){IE(e,t,n);return}if(typeof e==`function`){LE(e,t,n,r);return}RE(e,t,n,r)},IE=(e,t,n)=>{let r=e===``?t:zE(t,e);r.classGroupId=n},LE=(e,t,n,r)=>{if(BE(e)){PE(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(wE(n,e))},RE=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];PE(o,zE(t,a),n,r)}},zE=(e,t)=>{let n=e,r=t.split(EE),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=TE(),n.nextPart.set(t,i)),n=i}return n},BE=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,VE=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},HE=`!`,UE=`:`,WE=[],GE=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),KE=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===UE){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(HE)?(c=s.slice(0,-1),l=!0):s.startsWith(HE)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return GE(t,l,c,u)};if(t){let e=t+UE,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):GE(WE,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},qE=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},JE=e=>({cache:VE(e.cacheSize),parseClassName:KE(e),sortModifiers:qE(e),...kE(e)}),YE=/\s+/,XE=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(YE),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let m=!!p,h=r(m?f.substring(0,p):f);if(!h){if(!m){c=t+(c.length>0?` `+c:c);continue}if(h=r(f),!h){c=t+(c.length>0?` `+c:c);continue}m=!1}let g=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),_=d?g+HE:g,v=_+h;if(o.indexOf(v)>-1)continue;o.push(v);let y=i(h,m);for(let e=0;e<y.length;++e){let t=y[e];o.push(_+t)}c=t+(c.length>0?` `+c:c)}return c},ZE=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=QE(n))&&(i&&(i+=` `),i+=r);return i},QE=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=QE(e[r]))&&(n&&(n+=` `),n+=t);return n},$E=(e,...t)=>{let n,r,i,a,o=o=>(n=JE(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=XE(e,n);return i(e,a),a};return a=o,(...e)=>a(ZE(...e))},eD=[],tD=e=>{let t=t=>t[e]||eD;return t.isThemeGetter=!0,t},nD=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,rD=/^\((?:(\w[\w-]*):)?(.+)\)$/i,iD=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,aD=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,oD=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,sD=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,cD=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,lD=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,uD=e=>iD.test(e),dD=e=>!!e&&!Number.isNaN(Number(e)),fD=e=>!!e&&Number.isInteger(Number(e)),pD=e=>e.endsWith(`%`)&&dD(e.slice(0,-1)),mD=e=>aD.test(e),hD=()=>!0,gD=e=>oD.test(e)&&!sD.test(e),_D=()=>!1,vD=e=>cD.test(e),yD=e=>lD.test(e),bD=e=>!SD(e)&&!AD(e),xD=e=>RD(e,HD,_D),SD=e=>nD.test(e),CD=e=>RD(e,UD,gD),wD=e=>RD(e,WD,dD),TD=e=>RD(e,KD,hD),ED=e=>RD(e,GD,_D),DD=e=>RD(e,BD,_D),OD=e=>RD(e,VD,yD),kD=e=>RD(e,qD,vD),AD=e=>rD.test(e),jD=e=>zD(e,UD),MD=e=>zD(e,GD),ND=e=>zD(e,BD),PD=e=>zD(e,HD),FD=e=>zD(e,VD),ID=e=>zD(e,qD,!0),LD=e=>zD(e,KD,!0),RD=(e,t,n)=>{let r=nD.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},zD=(e,t,n=!1)=>{let r=rD.exec(e);return r?r[1]?t(r[1]):n:!1},BD=e=>e===`position`||e===`percentage`,VD=e=>e===`image`||e===`url`,HD=e=>e===`length`||e===`size`||e===`bg-size`,UD=e=>e===`length`,WD=e=>e===`number`,GD=e=>e===`family-name`,KD=e=>e===`number`||e===`weight`,qD=e=>e===`shadow`,JD=$E(()=>{let e=tD(`color`),t=tD(`font`),n=tD(`text`),r=tD(`font-weight`),i=tD(`tracking`),a=tD(`leading`),o=tD(`breakpoint`),s=tD(`container`),c=tD(`spacing`),l=tD(`radius`),u=tD(`shadow`),d=tD(`inset-shadow`),f=tD(`text-shadow`),p=tD(`drop-shadow`),m=tD(`blur`),h=tD(`perspective`),g=tD(`aspect`),_=tD(`ease`),v=tD(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),AD,SD],ee=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],te=()=>[`auto`,`contain`,`none`],S=()=>[AD,SD,c],C=()=>[uD,`full`,`auto`,...S()],ne=()=>[fD,`none`,`subgrid`,AD,SD],w=()=>[`auto`,{span:[`full`,fD,AD,SD]},fD,AD,SD],re=()=>[fD,`auto`,AD,SD],ie=()=>[`auto`,`min`,`max`,`fr`,AD,SD],ae=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],oe=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],se=()=>[`auto`,...S()],ce=()=>[uD,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...S()],le=()=>[uD,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...S()],ue=()=>[uD,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...S()],T=()=>[e,AD,SD],E=()=>[...b(),ND,DD,{position:[AD,SD]}],de=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],fe=()=>[`auto`,`cover`,`contain`,PD,xD,{size:[AD,SD]}],pe=()=>[pD,jD,CD],me=()=>[``,`none`,`full`,l,AD,SD],he=()=>[``,dD,jD,CD],ge=()=>[`solid`,`dashed`,`dotted`,`double`],_e=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],ve=()=>[dD,pD,ND,DD],ye=()=>[``,`none`,m,AD,SD],be=()=>[`none`,dD,AD,SD],xe=()=>[`none`,dD,AD,SD],Se=()=>[dD,AD,SD],D=()=>[uD,`full`,...S()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[mD],breakpoint:[mD],color:[hD],container:[mD],"drop-shadow":[mD],ease:[`in`,`out`,`in-out`],font:[bD],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[mD],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[mD],shadow:[mD],spacing:[`px`,dD],text:[mD],"text-shadow":[mD],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,uD,SD,AD,g]}],container:[`container`],columns:[{columns:[dD,SD,AD,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:ee()}],"overflow-x":[{"overflow-x":ee()}],"overflow-y":[{"overflow-y":ee()}],overscroll:[{overscroll:te()}],"overscroll-x":[{"overscroll-x":te()}],"overscroll-y":[{"overscroll-y":te()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:C()}],"inset-x":[{"inset-x":C()}],"inset-y":[{"inset-y":C()}],start:[{"inset-s":C(),start:C()}],end:[{"inset-e":C(),end:C()}],"inset-bs":[{"inset-bs":C()}],"inset-be":[{"inset-be":C()}],top:[{top:C()}],right:[{right:C()}],bottom:[{bottom:C()}],left:[{left:C()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[fD,`auto`,AD,SD]}],basis:[{basis:[uD,`full`,`auto`,s,...S()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[dD,uD,`auto`,`initial`,`none`,SD]}],grow:[{grow:[``,dD,AD,SD]}],shrink:[{shrink:[``,dD,AD,SD]}],order:[{order:[fD,`first`,`last`,`none`,AD,SD]}],"grid-cols":[{"grid-cols":ne()}],"col-start-end":[{col:w()}],"col-start":[{"col-start":re()}],"col-end":[{"col-end":re()}],"grid-rows":[{"grid-rows":ne()}],"row-start-end":[{row:w()}],"row-start":[{"row-start":re()}],"row-end":[{"row-end":re()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":ie()}],"auto-rows":[{"auto-rows":ie()}],gap:[{gap:S()}],"gap-x":[{"gap-x":S()}],"gap-y":[{"gap-y":S()}],"justify-content":[{justify:[...ae(),`normal`]}],"justify-items":[{"justify-items":[...oe(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...oe()]}],"align-content":[{content:[`normal`,...ae()]}],"align-items":[{items:[...oe(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...oe(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":ae()}],"place-items":[{"place-items":[...oe(),`baseline`]}],"place-self":[{"place-self":[`auto`,...oe()]}],p:[{p:S()}],px:[{px:S()}],py:[{py:S()}],ps:[{ps:S()}],pe:[{pe:S()}],pbs:[{pbs:S()}],pbe:[{pbe:S()}],pt:[{pt:S()}],pr:[{pr:S()}],pb:[{pb:S()}],pl:[{pl:S()}],m:[{m:se()}],mx:[{mx:se()}],my:[{my:se()}],ms:[{ms:se()}],me:[{me:se()}],mbs:[{mbs:se()}],mbe:[{mbe:se()}],mt:[{mt:se()}],mr:[{mr:se()}],mb:[{mb:se()}],ml:[{ml:se()}],"space-x":[{"space-x":S()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":S()}],"space-y-reverse":[`space-y-reverse`],size:[{size:ce()}],"inline-size":[{inline:[`auto`,...le()]}],"min-inline-size":[{"min-inline":[`auto`,...le()]}],"max-inline-size":[{"max-inline":[`none`,...le()]}],"block-size":[{block:[`auto`,...ue()]}],"min-block-size":[{"min-block":[`auto`,...ue()]}],"max-block-size":[{"max-block":[`none`,...ue()]}],w:[{w:[s,`screen`,...ce()]}],"min-w":[{"min-w":[s,`screen`,`none`,...ce()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...ce()]}],h:[{h:[`screen`,`lh`,...ce()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...ce()]}],"max-h":[{"max-h":[`screen`,`lh`,...ce()]}],"font-size":[{text:[`base`,n,jD,CD]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,LD,TD]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,pD,SD]}],"font-family":[{font:[MD,ED,t]}],"font-features":[{"font-features":[SD]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,AD,SD]}],"line-clamp":[{"line-clamp":[dD,`none`,AD,wD]}],leading:[{leading:[a,...S()]}],"list-image":[{"list-image":[`none`,AD,SD]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,AD,SD]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:T()}],"text-color":[{text:T()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...ge(),`wavy`]}],"text-decoration-thickness":[{decoration:[dD,`from-font`,`auto`,AD,CD]}],"text-decoration-color":[{decoration:T()}],"underline-offset":[{"underline-offset":[dD,`auto`,AD,SD]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:S()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,AD,SD]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,AD,SD]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:E()}],"bg-repeat":[{bg:de()}],"bg-size":[{bg:fe()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},fD,AD,SD],radial:[``,AD,SD],conic:[fD,AD,SD]},FD,OD]}],"bg-color":[{bg:T()}],"gradient-from-pos":[{from:pe()}],"gradient-via-pos":[{via:pe()}],"gradient-to-pos":[{to:pe()}],"gradient-from":[{from:T()}],"gradient-via":[{via:T()}],"gradient-to":[{to:T()}],rounded:[{rounded:me()}],"rounded-s":[{"rounded-s":me()}],"rounded-e":[{"rounded-e":me()}],"rounded-t":[{"rounded-t":me()}],"rounded-r":[{"rounded-r":me()}],"rounded-b":[{"rounded-b":me()}],"rounded-l":[{"rounded-l":me()}],"rounded-ss":[{"rounded-ss":me()}],"rounded-se":[{"rounded-se":me()}],"rounded-ee":[{"rounded-ee":me()}],"rounded-es":[{"rounded-es":me()}],"rounded-tl":[{"rounded-tl":me()}],"rounded-tr":[{"rounded-tr":me()}],"rounded-br":[{"rounded-br":me()}],"rounded-bl":[{"rounded-bl":me()}],"border-w":[{border:he()}],"border-w-x":[{"border-x":he()}],"border-w-y":[{"border-y":he()}],"border-w-s":[{"border-s":he()}],"border-w-e":[{"border-e":he()}],"border-w-bs":[{"border-bs":he()}],"border-w-be":[{"border-be":he()}],"border-w-t":[{"border-t":he()}],"border-w-r":[{"border-r":he()}],"border-w-b":[{"border-b":he()}],"border-w-l":[{"border-l":he()}],"divide-x":[{"divide-x":he()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":he()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...ge(),`hidden`,`none`]}],"divide-style":[{divide:[...ge(),`hidden`,`none`]}],"border-color":[{border:T()}],"border-color-x":[{"border-x":T()}],"border-color-y":[{"border-y":T()}],"border-color-s":[{"border-s":T()}],"border-color-e":[{"border-e":T()}],"border-color-bs":[{"border-bs":T()}],"border-color-be":[{"border-be":T()}],"border-color-t":[{"border-t":T()}],"border-color-r":[{"border-r":T()}],"border-color-b":[{"border-b":T()}],"border-color-l":[{"border-l":T()}],"divide-color":[{divide:T()}],"outline-style":[{outline:[...ge(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[dD,AD,SD]}],"outline-w":[{outline:[``,dD,jD,CD]}],"outline-color":[{outline:T()}],shadow:[{shadow:[``,`none`,u,ID,kD]}],"shadow-color":[{shadow:T()}],"inset-shadow":[{"inset-shadow":[`none`,d,ID,kD]}],"inset-shadow-color":[{"inset-shadow":T()}],"ring-w":[{ring:he()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:T()}],"ring-offset-w":[{"ring-offset":[dD,CD]}],"ring-offset-color":[{"ring-offset":T()}],"inset-ring-w":[{"inset-ring":he()}],"inset-ring-color":[{"inset-ring":T()}],"text-shadow":[{"text-shadow":[`none`,f,ID,kD]}],"text-shadow-color":[{"text-shadow":T()}],opacity:[{opacity:[dD,AD,SD]}],"mix-blend":[{"mix-blend":[..._e(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":_e()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[dD]}],"mask-image-linear-from-pos":[{"mask-linear-from":ve()}],"mask-image-linear-to-pos":[{"mask-linear-to":ve()}],"mask-image-linear-from-color":[{"mask-linear-from":T()}],"mask-image-linear-to-color":[{"mask-linear-to":T()}],"mask-image-t-from-pos":[{"mask-t-from":ve()}],"mask-image-t-to-pos":[{"mask-t-to":ve()}],"mask-image-t-from-color":[{"mask-t-from":T()}],"mask-image-t-to-color":[{"mask-t-to":T()}],"mask-image-r-from-pos":[{"mask-r-from":ve()}],"mask-image-r-to-pos":[{"mask-r-to":ve()}],"mask-image-r-from-color":[{"mask-r-from":T()}],"mask-image-r-to-color":[{"mask-r-to":T()}],"mask-image-b-from-pos":[{"mask-b-from":ve()}],"mask-image-b-to-pos":[{"mask-b-to":ve()}],"mask-image-b-from-color":[{"mask-b-from":T()}],"mask-image-b-to-color":[{"mask-b-to":T()}],"mask-image-l-from-pos":[{"mask-l-from":ve()}],"mask-image-l-to-pos":[{"mask-l-to":ve()}],"mask-image-l-from-color":[{"mask-l-from":T()}],"mask-image-l-to-color":[{"mask-l-to":T()}],"mask-image-x-from-pos":[{"mask-x-from":ve()}],"mask-image-x-to-pos":[{"mask-x-to":ve()}],"mask-image-x-from-color":[{"mask-x-from":T()}],"mask-image-x-to-color":[{"mask-x-to":T()}],"mask-image-y-from-pos":[{"mask-y-from":ve()}],"mask-image-y-to-pos":[{"mask-y-to":ve()}],"mask-image-y-from-color":[{"mask-y-from":T()}],"mask-image-y-to-color":[{"mask-y-to":T()}],"mask-image-radial":[{"mask-radial":[AD,SD]}],"mask-image-radial-from-pos":[{"mask-radial-from":ve()}],"mask-image-radial-to-pos":[{"mask-radial-to":ve()}],"mask-image-radial-from-color":[{"mask-radial-from":T()}],"mask-image-radial-to-color":[{"mask-radial-to":T()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[dD]}],"mask-image-conic-from-pos":[{"mask-conic-from":ve()}],"mask-image-conic-to-pos":[{"mask-conic-to":ve()}],"mask-image-conic-from-color":[{"mask-conic-from":T()}],"mask-image-conic-to-color":[{"mask-conic-to":T()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:E()}],"mask-repeat":[{mask:de()}],"mask-size":[{mask:fe()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,AD,SD]}],filter:[{filter:[``,`none`,AD,SD]}],blur:[{blur:ye()}],brightness:[{brightness:[dD,AD,SD]}],contrast:[{contrast:[dD,AD,SD]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,ID,kD]}],"drop-shadow-color":[{"drop-shadow":T()}],grayscale:[{grayscale:[``,dD,AD,SD]}],"hue-rotate":[{"hue-rotate":[dD,AD,SD]}],invert:[{invert:[``,dD,AD,SD]}],saturate:[{saturate:[dD,AD,SD]}],sepia:[{sepia:[``,dD,AD,SD]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,AD,SD]}],"backdrop-blur":[{"backdrop-blur":ye()}],"backdrop-brightness":[{"backdrop-brightness":[dD,AD,SD]}],"backdrop-contrast":[{"backdrop-contrast":[dD,AD,SD]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,dD,AD,SD]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[dD,AD,SD]}],"backdrop-invert":[{"backdrop-invert":[``,dD,AD,SD]}],"backdrop-opacity":[{"backdrop-opacity":[dD,AD,SD]}],"backdrop-saturate":[{"backdrop-saturate":[dD,AD,SD]}],"backdrop-sepia":[{"backdrop-sepia":[``,dD,AD,SD]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":S()}],"border-spacing-x":[{"border-spacing-x":S()}],"border-spacing-y":[{"border-spacing-y":S()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,AD,SD]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[dD,`initial`,AD,SD]}],ease:[{ease:[`linear`,`initial`,_,AD,SD]}],delay:[{delay:[dD,AD,SD]}],animate:[{animate:[`none`,v,AD,SD]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,AD,SD]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:be()}],"rotate-x":[{"rotate-x":be()}],"rotate-y":[{"rotate-y":be()}],"rotate-z":[{"rotate-z":be()}],scale:[{scale:xe()}],"scale-x":[{"scale-x":xe()}],"scale-y":[{"scale-y":xe()}],"scale-z":[{"scale-z":xe()}],"scale-3d":[`scale-3d`],skew:[{skew:Se()}],"skew-x":[{"skew-x":Se()}],"skew-y":[{"skew-y":Se()}],transform:[{transform:[AD,SD,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:D()}],"translate-x":[{"translate-x":D()}],"translate-y":[{"translate-y":D()}],"translate-z":[{"translate-z":D()}],"translate-none":[`translate-none`],accent:[{accent:T()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:T()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,AD,SD]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mbs":[{"scroll-mbs":S()}],"scroll-mbe":[{"scroll-mbe":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pbs":[{"scroll-pbs":S()}],"scroll-pbe":[{"scroll-pbe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,AD,SD]}],fill:[{fill:[`none`,...T()]}],"stroke-w":[{stroke:[dD,jD,CD,wD]}],stroke:[{stroke:[`none`,...T()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function YD(...e){return JD(JS(e))}var XD=new Set([`in_progress`,`running`,`queued`,`pending`]),ZD=300*1e3;function QD(e){let t=e?.UpdatedAt??e?.updated_at;if(typeof t==`string`){let e=Date.parse(t);return Number.isNaN(e)?0:e}return typeof t==`number`&&Number.isFinite(t)?t>1e11?t:t*1e3:0}function $D(e){return String(e||``).trim().toLowerCase()}function eO(e){if(!e)return``;let t=typeof e==`number`?new Date(e>1e11?e:e*1e3):new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(`zh-CN`,{timeZone:`Asia/Shanghai`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1})}function tO(e){return[e?.Title,e?.Summary,e?.FirstPrompt,e?.LastPrompt,e?.SessionId,e?.Model?.display_name,e?.Model?.id].map($D).join(` `)}function nO(e,t={}){if(!XD.has($D(e?.ActiveRunStatus)))return!1;let n=QD(e);if(!n)return!0;let r=Number.isFinite(Number(t.now))?Number(t.now):Date.now(),i=Number.isFinite(Number(t.activeStaleAfterMs))?Number(t.activeStaleAfterMs):ZD;return r-n<=i}function rO(e=[],t=``,n={}){let r=$D(t),i=new Set(Array.isArray(n.pinnedSessionIds)?n.pinnedSessionIds:[]);return(Array.isArray(e)?e:[]).filter(e=>e?.SessionId).filter(e=>!r||tO(e).includes(r)).slice().sort((e,t)=>{let r=+!!i.has(e.SessionId),a=+!!i.has(t.SessionId);if(r!==a)return a-r;let o=+!!nO(e,n),s=+!!nO(t,n);return o===s?QD(t)-QD(e):s-o})}function iO(e,t={}){let n=nO(e,t);return{running:n,label:n?``:eO(e?.UpdatedAt??e?.updated_at)}}function aO({sessions:e,currentSessionId:t,onCreateNewSession:n,onSelectSession:r,onDeleteSession:i,onTogglePinSession:a,onLoadMoreSessions:o,sessionTitle:s,pinnedSessionIds:c=[],hasMoreSessions:l=!1,isLoadingSessions:u=!1,className:d}){let[f,p]=(0,b.useState)(``),m=(0,b.useMemo)(()=>rO(e,f,{pinnedSessionIds:c}),[e,c,f]),h=(0,b.useMemo)(()=>new Set(c),[c]);return(0,U.jsxs)(`div`,{className:YD(`flex h-full min-h-0 flex-col bg-sidebar`,d),children:[(0,U.jsxs)(`div`,{className:`flex flex-shrink-0 flex-col gap-2 border-b border-black/[0.06] px-3 py-3 dark:border-white/[0.08]`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-[34px] w-full items-center justify-between rounded-[10px] px-2.5 text-sm font-medium text-sidebar-text-secondary transition-colors hover:bg-sidebar-hover hover:text-sidebar-text`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(ZT,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:`新对话`})]}),(0,U.jsx)(`span`,{className:`rounded border border-black/[0.08] px-1.5 py-0.5 text-[11px] text-sidebar-text-muted dark:border-white/[0.1]`,children:`⌘ N`})]}),(0,U.jsxs)(`label`,{className:`flex h-9 items-center gap-2 rounded-[10px] border border-black/[0.06] bg-background px-2.5 text-xs text-sidebar-text-muted focus-within:border-primary/40 dark:border-white/[0.08]`,children:[(0,U.jsx)(lE,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,U.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),className:`min-w-0 flex-1 bg-transparent text-sm text-sidebar-text outline-none placeholder:text-sidebar-text-muted`,placeholder:`搜索会话、模型或摘要`})]})]}),(0,U.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-4 pt-2 custom-scrollbar`,onScroll:e=>{if(!o||u||!l||f.trim())return;let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<200&&o()},children:[(0,U.jsxs)(`div`,{className:`px-2.5 py-2 text-xs font-medium text-sidebar-text-muted opacity-75`,children:[`历史记录`,f.trim()?` · ${m.length}`:``]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[m.length>0?m.map(e=>{let n=iO(e),o=h.has(e.SessionId),c=t===e.SessionId;return(0,U.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-current":c?`page`:void 0,onClick:()=>r(e.SessionId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(e.SessionId))},className:YD(`group relative flex h-[30px] items-center gap-1 rounded-[10px] border-l-2 border-transparent px-2 text-sm leading-5 transition-colors`,c?`border-l-2 border-primary bg-primary/10 font-medium text-sidebar-text`:n.running?`cursor-pointer bg-primary/8 text-sidebar-text`:`cursor-pointer text-sidebar-text-secondary hover:bg-sidebar-hover hover:text-sidebar-text`),children:[n.running?(0,U.jsx)(`span`,{className:`absolute left-0 top-1/2 h-3.5 w-0.5 -translate-y-1/2 rounded-full bg-primary`,"aria-hidden":`true`}):null,(0,U.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:s(e)}),n.running?(0,U.jsx)(YT,{className:`h-3.5 w-3.5 flex-shrink-0 animate-spin text-primary`}):n.label?(0,U.jsx)(`span`,{className:`flex-shrink-0 text-[11px] leading-none text-sidebar-text-muted group-hover:hidden`,children:n.label}):null,(0,U.jsxs)(`div`,{className:`pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:t=>a(e.SessionId,t),className:YD(`flex h-6 w-6 items-center justify-center rounded-md text-sidebar-text-muted hover:bg-sidebar-active hover:text-sidebar-text`,o&&`text-primary opacity-100`),title:o?`取消置顶`:`置顶会话`,"aria-label":o?`取消置顶会话`:`置顶会话`,children:o?(0,U.jsx)(iE,{className:`h-3.5 w-3.5`}):(0,U.jsx)(aE,{className:`h-3.5 w-3.5`})}),(0,U.jsx)(`button`,{type:`button`,onClick:t=>i(e.SessionId,t),className:`flex h-6 w-6 items-center justify-center rounded-md text-sidebar-text-muted hover:bg-sidebar-active hover:text-rose-500`,title:`删除会话`,children:(0,U.jsx)(_E,{className:`h-3.5 w-3.5`})})]})]},e.SessionId)}):(0,U.jsx)(`div`,{className:`rounded-xl border border-dashed border-black/[0.08] px-3 py-8 text-center text-xs text-sidebar-text-muted dark:border-white/[0.1]`,children:`没有匹配的会话`}),u?(0,U.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-3 py-3 text-xs text-sidebar-text-muted`,children:[(0,U.jsx)(YT,{className:`h-3.5 w-3.5 animate-spin`}),(0,U.jsx)(`span`,{children:`加载中`})]}):null]})]}),(0,U.jsxs)(`div`,{className:`border-t border-black/[0.06] px-4 py-3 text-center dark:border-white/[0.08]`,children:[(0,U.jsx)(`div`,{className:`text-[10px] font-medium tracking-[0.14em] text-sidebar-text-muted`,children:`POWERED BY`}),(0,U.jsx)(`div`,{className:`mt-1 bg-gradient-to-r from-blue-600 to-indigo-500 bg-clip-text text-xs font-bold text-transparent dark:from-blue-400 dark:to-indigo-300`,children:`Ksyun AgentEngine`}),(0,U.jsx)(`div`,{className:`mx-auto mt-2 max-w-[13rem] text-[10px] leading-4 text-sidebar-text-muted`,children:`Agent 可能产生不准确的信息,请独立验证。`})]})]})}typeof window<`u`&&window.document&&window.document.createElement;function oO(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function sO(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function cO(...e){return t=>{let n=!1,r=e.map(e=>{let r=sO(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():sO(e[t],null)}}}}function lO(...e){return b.useCallback(cO(...e),e)}function uO(e,t){let n=b.createContext(t),r=e=>{let{children:t,...r}=e,i=b.useMemo(()=>r,Object.values(r));return(0,U.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=b.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function dO(e,t=[]){let n=[];function r(t,r){let i=b.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=b.useMemo(()=>o,Object.values(o));return(0,U.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=b.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>b.createContext(e));return function(n){let r=n?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,fO(i,...t)]}function fO(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var pO=globalThis?.document?b.useLayoutEffect:()=>{},mO=b.useId||(()=>void 0),hO=0;function gO(e){let[t,n]=b.useState(mO());return pO(()=>{e||n(e=>e??String(hO++))},[e]),e||(t?`radix-${t}`:``)}var _O=b.useInsertionEffect||pO;function vO({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=yO({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=b.useRef(e!==void 0);b.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,b.useCallback(t=>{if(s){let n=bO(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function yO({defaultProp:e,onChange:t}){let[n,r]=b.useState(e),i=b.useRef(n),a=b.useRef(t);return _O(()=>{a.current=t},[t]),b.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function bO(e){return typeof e==`function`}function xO(e){let t=SO(e),n=b.forwardRef((e,n)=>{let{children:r,...i}=e,a=b.Children.toArray(r),o=a.find(wO);if(o){let e=o.props.children,r=a.map(t=>t===o?b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null:t);return(0,U.jsx)(t,{...i,ref:n,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,U.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function SO(e){let t=b.forwardRef((e,t)=>{let{children:n,...r}=e;if(b.isValidElement(n)){let e=EO(n),i=TO(r,n.props);return n.type!==b.Fragment&&(i.ref=t?cO(t,e):e),b.cloneElement(n,i)}return b.Children.count(n)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var CO=Symbol(`radix.slottable`);function wO(e){return b.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===CO}function TO(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function EO(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var DO=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=xO(`Primitive.${t}`),r=b.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,U.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function OO(e,t){e&&un.flushSync(()=>e.dispatchEvent(t))}function kO(e){let t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>(...e)=>t.current?.(...e),[])}function AO(e,t=globalThis?.document){let n=kO(e);b.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var jO=`DismissableLayer`,MO=`dismissableLayer.update`,NO=`dismissableLayer.pointerDownOutside`,PO=`dismissableLayer.focusOutside`,FO,IO=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),LO=b.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=b.useContext(IO),[u,d]=b.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=b.useState({}),m=lO(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),v=u?h.indexOf(u):-1,y=l.layersWithOutsidePointerEventsDisabled.size>0,x=v>=_,ee=BO(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!x||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),te=VO(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return AO(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),b.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(FO=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),HO(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=FO)}},[u,f,n,l]),b.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),HO())},[u,l]),b.useEffect(()=>{let e=()=>p({});return document.addEventListener(MO,e),()=>document.removeEventListener(MO,e)},[]),(0,U.jsx)(DO.div,{...c,ref:m,style:{pointerEvents:y?x?`auto`:`none`:void 0,...e.style},onFocusCapture:oO(e.onFocusCapture,te.onFocusCapture),onBlurCapture:oO(e.onBlurCapture,te.onBlurCapture),onPointerDownCapture:oO(e.onPointerDownCapture,ee.onPointerDownCapture)})});LO.displayName=jO;var RO=`DismissableLayerBranch`,zO=b.forwardRef((e,t)=>{let n=b.useContext(IO),r=b.useRef(null),i=lO(t,r);return b.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,U.jsx)(DO.div,{...e,ref:i})});zO.displayName=RO;function BO(e,t=globalThis?.document){let n=kO(e),r=b.useRef(!1),i=b.useRef(()=>{});return b.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){UO(NO,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function VO(e,t=globalThis?.document){let n=kO(e),r=b.useRef(!1);return b.useEffect(()=>{let e=e=>{e.target&&!r.current&&UO(PO,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function HO(){let e=new CustomEvent(MO);document.dispatchEvent(e)}function UO(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?OO(i,a):i.dispatchEvent(a)}var WO=`focusScope.autoFocusOnMount`,GO=`focusScope.autoFocusOnUnmount`,KO={bubbles:!1,cancelable:!0},qO=`FocusScope`,JO=b.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=b.useState(null),l=kO(i),u=kO(a),d=b.useRef(null),f=lO(t,e=>c(e)),p=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:tk(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||tk(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&tk(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),b.useEffect(()=>{if(s){nk.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(WO,KO);s.addEventListener(WO,l),s.dispatchEvent(t),t.defaultPrevented||(YO(ak(ZO(s)),{select:!0}),document.activeElement===e&&tk(s))}return()=>{s.removeEventListener(WO,l),setTimeout(()=>{let t=new CustomEvent(GO,KO);s.addEventListener(GO,u),s.dispatchEvent(t),t.defaultPrevented||tk(e??document.body,{select:!0}),s.removeEventListener(GO,u),nk.remove(p)},0)}}},[s,l,u,p]);let m=b.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=XO(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&tk(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&tk(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,U.jsx)(DO.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});JO.displayName=qO;function YO(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(tk(r,{select:t}),document.activeElement!==n)return}function XO(e){let t=ZO(e);return[QO(t,e),QO(t.reverse(),e)]}function ZO(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function QO(e,t){for(let n of e)if(!$O(n,{upTo:t}))return n}function $O(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function ek(e){return e instanceof HTMLInputElement&&`select`in e}function tk(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&ek(e)&&t&&e.select()}}var nk=rk();function rk(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=ik(e,t),e.unshift(t)},remove(t){e=ik(e,t),e[0]?.resume()}}}function ik(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ak(e){return e.filter(e=>e.tagName!==`A`)}var ok=`Portal`,sk=b.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=b.useState(!1);pO(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?un.createPortal((0,U.jsx)(DO.div,{...r,ref:t}),o):null});sk.displayName=ok;function ck(e,t){return b.useReducer((e,n)=>t[e][n]??e,e)}var lk=e=>{let{present:t,children:n}=e,r=uk(t),i=typeof n==`function`?n({present:r.isPresent}):b.Children.only(n),a=lO(r.ref,fk(i));return typeof n==`function`||r.isPresent?b.cloneElement(i,{ref:a}):null};lk.displayName=`Presence`;function uk(e){let[t,n]=b.useState(),r=b.useRef(null),i=b.useRef(e),a=b.useRef(`none`),[o,s]=ck(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return b.useEffect(()=>{let e=dk(r.current);a.current=o===`mounted`?e:`none`},[o]),pO(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=dk(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),pO(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=dk(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=dk(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:b.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function dk(e){return e?.animationName||`none`}function fk(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var pk=0;function mk(){b.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??hk()),document.body.insertAdjacentElement(`beforeend`,e[1]??hk()),pk++,()=>{pk===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),pk--}},[])}function hk(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var gk=`right-scroll-bar-position`,_k=`width-before-scroll-bar`,vk=`with-scroll-bars-hidden`,yk=`--removed-body-scroll-bar-size`;function bk(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function xk(e,t){var n=(0,b.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Sk=typeof window<`u`?b.useLayoutEffect:b.useEffect,Ck=new WeakMap;function wk(e,t){var n=xk(t||null,function(t){return e.forEach(function(e){return bk(e,t)})});return Sk(function(){var t=Ck.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||bk(e,null)}),i.forEach(function(e){r.has(e)||bk(e,a)})}Ck.set(n,e)},[e]),n}function Tk(e){return e}function Ek(e,t){t===void 0&&(t=Tk);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Dk(e){e===void 0&&(e={});var t=Ek(null);return t.options=so({async:!0,ssr:!1},e),t}var Ok=function(e){var t=e.sideCar,n=co(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return b.createElement(r,so({},n))};Ok.isSideCarExport=!0;function kk(e,t){return e.useMedium(t),Ok}var Ak=Dk(),jk=function(){},Mk=b.forwardRef(function(e,t){var n=b.useRef(null),r=b.useState({onScrollCapture:jk,onWheelCapture:jk,onTouchMoveCapture:jk}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,x=co(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),ee=f,te=wk([n,t]),S=so(so({},x),i);return b.createElement(b.Fragment,null,u&&b.createElement(ee,{sideCar:Ak,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?b.cloneElement(b.Children.only(s),so(so({},S),{ref:te})):b.createElement(v,so({},S,{className:c,ref:te}),s))});Mk.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Mk.classNames={fullWidth:_k,zeroRight:gk};var Nk,Pk=function(){if(Nk)return Nk;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function Fk(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Pk();return t&&e.setAttribute(`nonce`,t),e}function Ik(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Lk(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Rk=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Fk())&&(Ik(t,n),Lk(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},zk=function(){var e=Rk();return function(t,n){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Bk=function(){var e=zk();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Vk={left:0,top:0,right:0,gap:0},Hk=function(e){return parseInt(e||``,10)||0},Uk=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Hk(n),Hk(r),Hk(i)]},Wk=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Vk;var t=Uk(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Gk=Bk(),Kk=`data-scroll-locked`,qk=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
31
|
-
.${vk} {
|
|
32
|
-
overflow: hidden ${r};
|
|
33
|
-
padding-right: ${s}px ${r};
|
|
34
|
-
}
|
|
35
|
-
body[${Kk}] {
|
|
36
|
-
overflow: hidden ${r};
|
|
37
|
-
overscroll-behavior: contain;
|
|
38
|
-
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
39
|
-
padding-left: ${i}px;
|
|
40
|
-
padding-top: ${a}px;
|
|
41
|
-
padding-right: ${o}px;
|
|
42
|
-
margin-left:0;
|
|
43
|
-
margin-top:0;
|
|
44
|
-
margin-right: ${s}px ${r};
|
|
45
|
-
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.${gk} {
|
|
49
|
-
right: ${s}px ${r};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.${_k} {
|
|
53
|
-
margin-right: ${s}px ${r};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.${gk} .${gk} {
|
|
57
|
-
right: 0 ${r};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.${_k} .${_k} {
|
|
61
|
-
margin-right: 0 ${r};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
body[${Kk}] {
|
|
65
|
-
${yk}: ${s}px;
|
|
66
|
-
}
|
|
67
|
-
`},Jk=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Yk=function(){b.useEffect(function(){return document.body.setAttribute(Kk,(Jk()+1).toString()),function(){var e=Jk()-1;e<=0?document.body.removeAttribute(Kk):document.body.setAttribute(Kk,e.toString())}},[])},Xk=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Yk();var a=b.useMemo(function(){return Wk(i)},[i]);return b.createElement(Gk,{styles:qk(a,!t,i,n?``:`!important`)})},Zk=!1;if(typeof window<`u`)try{var Qk=Object.defineProperty({},"passive",{get:function(){return Zk=!0,!0}});window.addEventListener(`test`,Qk,Qk),window.removeEventListener(`test`,Qk,Qk)}catch{Zk=!1}var $k=Zk?{passive:!1}:!1,eA=function(e){return e.tagName===`TEXTAREA`},tA=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!eA(e)&&n[t]===`visible`)},nA=function(e){return tA(e,`overflowY`)},rA=function(e){return tA(e,`overflowX`)},iA=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),sA(e,r)){var i=cA(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},aA=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},oA=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},sA=function(e,t){return e===`v`?nA(t):rA(t)},cA=function(e,t){return e===`v`?aA(t):oA(t)},lA=function(e,t){return e===`h`&&t===`rtl`?-1:1},uA=function(e,t,n,r,i){var a=lA(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=cA(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&sA(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},dA=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},fA=function(e){return[e.deltaX,e.deltaY]},pA=function(e){return e&&`current`in e?e.current:e},mA=function(e,t){return e[0]===t[0]&&e[1]===t[1]},hA=function(e){return`
|
|
68
|
-
.block-interactivity-${e} {pointer-events: none;}
|
|
69
|
-
.allow-interactivity-${e} {pointer-events: all;}
|
|
70
|
-
`},gA=0,_A=[];function vA(e){var t=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),i=b.useState(gA++)[0],a=b.useState(Bk)[0],o=b.useRef(e);b.useEffect(function(){o.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=mo([e.lockRef.current],(e.shards||[]).map(pA),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=b.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=dA(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=iA(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=iA(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return uA(h,t,e,h===`h`?s:c,!0)},[]),c=b.useCallback(function(e){var n=e;if(!(!_A.length||_A[_A.length-1]!==a)){var r=`deltaY`in n?fA(n):dA(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&mA(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(pA).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=b.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:yA(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=b.useCallback(function(e){n.current=dA(e),r.current=void 0},[]),d=b.useCallback(function(t){l(t.type,fA(t),t.target,s(t,e.lockRef.current))},[]),f=b.useCallback(function(t){l(t.type,dA(t),t.target,s(t,e.lockRef.current))},[]);b.useEffect(function(){return _A.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,$k),document.addEventListener(`touchmove`,c,$k),document.addEventListener(`touchstart`,u,$k),function(){_A=_A.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,$k),document.removeEventListener(`touchmove`,c,$k),document.removeEventListener(`touchstart`,u,$k)}},[]);var p=e.removeScrollBar,m=e.inert;return b.createElement(b.Fragment,null,m?b.createElement(a,{styles:hA(i)}):null,p?b.createElement(Xk,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function yA(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var bA=kk(Ak,vA),xA=b.forwardRef(function(e,t){return b.createElement(Mk,so({},e,{ref:t,sideCar:bA}))});xA.classNames=Mk.classNames;var SA=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},CA=new WeakMap,wA=new WeakMap,TA={},EA=0,DA=function(e){return e&&(e.host||DA(e.parentNode))},OA=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=DA(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},kA=function(e,t,n,r){var i=OA(t,Array.isArray(e)?e:[e]);TA[n]||(TA[n]=new WeakMap);var a=TA[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(CA.get(e)||0)+1,l=(a.get(e)||0)+1;CA.set(e,c),a.set(e,l),o.push(e),c===1&&i&&wA.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),EA++,function(){o.forEach(function(e){var t=CA.get(e)-1,i=a.get(e)-1;CA.set(e,t),a.set(e,i),t||(wA.has(e)||e.removeAttribute(r),wA.delete(e)),i||e.removeAttribute(n)}),EA--,EA||(CA=new WeakMap,CA=new WeakMap,wA=new WeakMap,TA={})}},AA=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||SA(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),kA(r,i,n,`aria-hidden`)):function(){return null}};function jA(e){let t=MA(e),n=b.forwardRef((e,n)=>{let{children:r,...i}=e,a=b.Children.toArray(r),o=a.find(PA);if(o){let e=o.props.children,r=a.map(t=>t===o?b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null:t);return(0,U.jsx)(t,{...i,ref:n,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,U.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function MA(e){let t=b.forwardRef((e,t)=>{let{children:n,...r}=e;if(b.isValidElement(n)){let e=IA(n),i=FA(r,n.props);return n.type!==b.Fragment&&(i.ref=t?cO(t,e):e),b.cloneElement(n,i)}return b.Children.count(n)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var NA=Symbol(`radix.slottable`);function PA(e){return b.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===NA}function FA(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function IA(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var LA=`Dialog`,[RA,zA]=dO(LA),[BA,VA]=RA(LA),HA=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=b.useRef(null),c=b.useRef(null),[l,u]=vO({prop:r,defaultProp:i??!1,onChange:a,caller:LA});return(0,U.jsx)(BA,{scope:t,triggerRef:s,contentRef:c,contentId:gO(),titleId:gO(),descriptionId:gO(),open:l,onOpenChange:u,onOpenToggle:b.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};HA.displayName=LA;var UA=`DialogTrigger`,WA=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=VA(UA,n),a=lO(t,i.triggerRef);return(0,U.jsx)(DO.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":uj(i.open),...r,ref:a,onClick:oO(e.onClick,i.onOpenToggle)})});WA.displayName=UA;var GA=`DialogPortal`,[KA,qA]=RA(GA,{forceMount:void 0}),JA=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=VA(GA,t);return(0,U.jsx)(KA,{scope:t,forceMount:n,children:b.Children.map(r,e=>(0,U.jsx)(lk,{present:n||a.open,children:(0,U.jsx)(sk,{asChild:!0,container:i,children:e})}))})};JA.displayName=GA;var YA=`DialogOverlay`,XA=b.forwardRef((e,t)=>{let n=qA(YA,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=VA(YA,e.__scopeDialog);return a.modal?(0,U.jsx)(lk,{present:r||a.open,children:(0,U.jsx)(QA,{...i,ref:t})}):null});XA.displayName=YA;var ZA=jA(`DialogOverlay.RemoveScroll`),QA=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=VA(YA,n);return(0,U.jsx)(xA,{as:ZA,allowPinchZoom:!0,shards:[i.contentRef],children:(0,U.jsx)(DO.div,{"data-state":uj(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),$A=`DialogContent`,ej=b.forwardRef((e,t)=>{let n=qA($A,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=VA($A,e.__scopeDialog);return(0,U.jsx)(lk,{present:r||a.open,children:a.modal?(0,U.jsx)(tj,{...i,ref:t}):(0,U.jsx)(nj,{...i,ref:t})})});ej.displayName=$A;var tj=b.forwardRef((e,t)=>{let n=VA($A,e.__scopeDialog),r=b.useRef(null),i=lO(t,n.contentRef,r);return b.useEffect(()=>{let e=r.current;if(e)return AA(e)},[]),(0,U.jsx)(rj,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:oO(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:oO(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:oO(e.onFocusOutside,e=>e.preventDefault())})}),nj=b.forwardRef((e,t)=>{let n=VA($A,e.__scopeDialog),r=b.useRef(!1),i=b.useRef(!1);return(0,U.jsx)(rj,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),rj=b.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=VA($A,n),c=b.useRef(null),l=lO(t,c);return mk(),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(JO,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,U.jsx)(LO,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":uj(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(mj,{titleId:s.titleId}),(0,U.jsx)(gj,{contentRef:c,descriptionId:s.descriptionId})]})]})}),ij=`DialogTitle`,aj=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=VA(ij,n);return(0,U.jsx)(DO.h2,{id:i.titleId,...r,ref:t})});aj.displayName=ij;var oj=`DialogDescription`,sj=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=VA(oj,n);return(0,U.jsx)(DO.p,{id:i.descriptionId,...r,ref:t})});sj.displayName=oj;var cj=`DialogClose`,lj=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=VA(cj,n);return(0,U.jsx)(DO.button,{type:`button`,...r,ref:t,onClick:oO(e.onClick,()=>i.onOpenChange(!1))})});lj.displayName=cj;function uj(e){return e?`open`:`closed`}var dj=`DialogTitleWarning`,[fj,pj]=uO(dj,{contentName:$A,titleName:ij,docsSlug:`dialog`}),mj=({titleId:e})=>{let t=pj(dj),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
71
|
-
|
|
72
|
-
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
73
|
-
|
|
74
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},hj=`DialogDescriptionWarning`,gj=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${pj(hj).contentName}}.`;return b.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},_j=HA,vj=JA,yj=XA,bj=ej,xj=aj,Sj=sj,Cj=lj,wj=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Tj=JS,Ej=(e,t)=>n=>{if(t?.variants==null)return Tj(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=wj(t)||wj(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Tj(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},Dj=_j,Oj=vj,kj=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(yj,{className:YD(`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,ref:n}));kj.displayName=yj.displayName;var Aj=Ej(`fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500`,{variants:{side:{top:`inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,bottom:`inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,left:`inset-y-0 left-0 h-full border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left`,right:`inset-y-0 right-0 h-full border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right`}},defaultVariants:{side:`right`}}),jj=b.forwardRef(({side:e=`right`,className:t,children:n,showOverlay:r=!0,showCloseButton:i=!0,...a},o)=>(0,U.jsxs)(Oj,{children:[r?(0,U.jsx)(kj,{}):null,(0,U.jsxs)(bj,{ref:o,className:YD(Aj({side:e}),t),...a,children:[n,i?(0,U.jsxs)(Cj,{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-secondary`,children:[(0,U.jsx)(xE,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]}):null]})]}));jj.displayName=bj.displayName;var Mj=({className:e,...t})=>(0,U.jsx)(`div`,{className:YD(`flex flex-col space-y-2 text-center sm:text-left`,e),...t});Mj.displayName=`SheetHeader`;var Nj=({className:e,...t})=>(0,U.jsx)(`div`,{className:YD(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Nj.displayName=`SheetFooter`;var Pj=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(xj,{ref:n,className:YD(`text-lg font-semibold text-foreground`,e),...t}));Pj.displayName=xj.displayName;var Fj=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(Sj,{ref:n,className:YD(`text-sm text-muted-foreground`,e),...t}));Fj.displayName=Sj.displayName;function Ij(e){return String(e.Title||``).trim()||String(e.FirstPrompt||``).trim()||String(e.LastPrompt||``).trim()||String(e.Summary||``).trim()||`新对话`}function Lj({uiCapabilities:e,createNewSession:t,deleteSession:n,loadSession:r,loadMoreSessions:i}){let a=Me(e=>e.sessions),o=Me(e=>e.currentSessionId),s=Me(e=>e.pinnedSessionIds),c=Me(e=>e.isLoadingSessions),l=Me(e=>e.hasMoreSessions),u=w(e=>e.sidebarOpen),d=w(e=>e.mobileSidebarOpen),{isMobile:f}=St(),p=fe(e),{desktopSidebarVisible:m}=Ie({isMobile:f,desktopSidebarOpen:u,mobileSidebarOpen:d});return p?f?(0,U.jsx)(Dj,{open:d,onOpenChange:e=>w.getState().setMobileSidebarOpen(e),children:(0,U.jsxs)(jj,{side:`left`,className:`w-[88vw] max-w-sm border-slate-200 bg-slate-50 p-0 dark:border-slate-800 dark:bg-slate-950`,children:[(0,U.jsx)(Pj,{className:`sr-only`,children:`历史记录`}),(0,U.jsx)(Fj,{className:`sr-only`,children:`查看和切换历史对话。`}),(0,U.jsx)(aO,{sessions:a,currentSessionId:o,onCreateNewSession:t,onSelectSession:r,onDeleteSession:(e,t)=>{t.stopPropagation(),n(e)},onTogglePinSession:(e,t)=>{t.stopPropagation(),Me.getState().togglePinnedSession(e)},onLoadMoreSessions:i,sessionTitle:Ij,pinnedSessionIds:s,hasMoreSessions:l,isLoadingSessions:c})]})}):(0,U.jsx)(`aside`,{className:YD(`flex-shrink-0 overflow-hidden border-r border-slate-200 transition-[width] duration-300 ease-in-out dark:border-slate-800`,m?`w-[280px]`:`w-0 border-r-0`),children:(0,U.jsx)(aO,{sessions:a,currentSessionId:o,onCreateNewSession:t,onSelectSession:r,onDeleteSession:(e,t)=>{t.stopPropagation(),n(e)},onTogglePinSession:(e,t)=>{t.stopPropagation(),Me.getState().togglePinnedSession(e)},onLoadMoreSessions:i,sessionTitle:Ij,pinnedSessionIds:s,hasMoreSessions:l,isLoadingSessions:c})}):null}function Rj(){}function zj(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function Bj(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Vj=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Hj=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Uj={};function Wj(e,t){return((t||Uj).jsx?Hj:Vj).test(e)}var Gj=/[ \t\n\f\r]/g;function Kj(e){return typeof e==`object`?e.type===`text`?qj(e.value):!1:qj(e)}function qj(e){return e.replace(Gj,``)===``}var Jj=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Jj.prototype.normal={},Jj.prototype.property={},Jj.prototype.space=void 0;function Yj(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Jj(n,r,t)}function Xj(e){return e.toLowerCase()}var Zj=class{constructor(e,t){this.attribute=t,this.property=e}};Zj.prototype.attribute=``,Zj.prototype.booleanish=!1,Zj.prototype.boolean=!1,Zj.prototype.commaOrSpaceSeparated=!1,Zj.prototype.commaSeparated=!1,Zj.prototype.defined=!1,Zj.prototype.mustUseProperty=!1,Zj.prototype.number=!1,Zj.prototype.overloadedBoolean=!1,Zj.prototype.property=``,Zj.prototype.spaceSeparated=!1,Zj.prototype.space=void 0;var Qj=s({boolean:()=>eM,booleanish:()=>tM,commaOrSpaceSeparated:()=>aM,commaSeparated:()=>iM,number:()=>K,overloadedBoolean:()=>nM,spaceSeparated:()=>rM}),$j=0,eM=oM(),tM=oM(),nM=oM(),K=oM(),rM=oM(),iM=oM(),aM=oM();function oM(){return 2**++$j}var sM=Object.keys(Qj),cM=class extends Zj{constructor(e,t,n,r){let i=-1;if(super(e,t),lM(this,`space`,r),typeof n==`number`)for(;++i<sM.length;){let e=sM[i];lM(this,sM[i],(n&Qj[e])===Qj[e])}}};cM.prototype.defined=!0;function lM(e,t,n){n&&(e[t]=n)}function uM(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new cM(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Xj(r)]=r,n[Xj(a.attribute)]=r}return new Jj(t,n,e.space)}var dM=uM({properties:{ariaActiveDescendant:null,ariaAtomic:tM,ariaAutoComplete:null,ariaBusy:tM,ariaChecked:tM,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:rM,ariaCurrent:null,ariaDescribedBy:rM,ariaDetails:null,ariaDisabled:tM,ariaDropEffect:rM,ariaErrorMessage:null,ariaExpanded:tM,ariaFlowTo:rM,ariaGrabbed:tM,ariaHasPopup:null,ariaHidden:tM,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:rM,ariaLevel:K,ariaLive:null,ariaModal:tM,ariaMultiLine:tM,ariaMultiSelectable:tM,ariaOrientation:null,ariaOwns:rM,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:tM,ariaReadOnly:tM,ariaRelevant:null,ariaRequired:tM,ariaRoleDescription:rM,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:tM,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function fM(e,t){return t in e?e[t]:t}function pM(e,t){return fM(e,t.toLowerCase())}var mM=uM({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:iM,acceptCharset:rM,accessKey:rM,action:null,allow:null,allowFullScreen:eM,allowPaymentRequest:eM,allowUserMedia:eM,alt:null,as:null,async:eM,autoCapitalize:null,autoComplete:rM,autoFocus:eM,autoPlay:eM,blocking:rM,capture:null,charSet:null,checked:eM,cite:null,className:rM,cols:K,colSpan:null,content:null,contentEditable:tM,controls:eM,controlsList:rM,coords:K|iM,crossOrigin:null,data:null,dateTime:null,decoding:null,default:eM,defer:eM,dir:null,dirName:null,disabled:eM,download:nM,draggable:tM,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:eM,formTarget:null,headers:rM,height:K,hidden:nM,high:K,href:null,hrefLang:null,htmlFor:rM,httpEquiv:rM,id:null,imageSizes:null,imageSrcSet:null,inert:eM,inputMode:null,integrity:null,is:null,isMap:eM,itemId:null,itemProp:rM,itemRef:rM,itemScope:eM,itemType:rM,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:eM,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:eM,muted:eM,name:null,nonce:null,noModule:eM,noValidate:eM,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:eM,optimum:K,pattern:null,ping:rM,placeholder:null,playsInline:eM,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:eM,referrerPolicy:null,rel:rM,required:eM,reversed:eM,rows:K,rowSpan:K,sandbox:rM,scope:null,scoped:eM,seamless:eM,selected:eM,shadowRootClonable:eM,shadowRootDelegatesFocus:eM,shadowRootMode:null,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:tM,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:eM,useMap:null,value:tM,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:rM,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:eM,declare:eM,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:eM,noHref:eM,noShade:eM,noWrap:eM,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:tM,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:eM,disableRemotePlayback:eM,prefix:null,property:null,results:K,security:null,unselectable:null},space:`html`,transform:pM}),hM=uM({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:aM,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,className:rM,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:eM,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:iM,g2:iM,glyphName:iM,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:aM,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:rM,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:aM,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:aM,rev:aM,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:aM,requiredFeatures:aM,requiredFonts:aM,requiredFormats:aM,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:aM,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:aM,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:aM,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:fM}),gM=uM({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),_M=uM({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:pM}),vM=uM({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),yM={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},bM=/[A-Z]/g,xM=/-[a-z]/g,SM=/^data[-\w.:]+$/i;function CM(e,t){let n=Xj(t),r=t,i=Zj;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&SM.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(xM,TM);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!xM.test(e)){let n=e.replace(bM,wM);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=cM}return new i(r,t)}function wM(e){return`-`+e.toLowerCase()}function TM(e){return e.charAt(1).toUpperCase()}var EM=Yj([dM,mM,gM,_M,vM],`html`),DM=Yj([dM,hM,gM,_M,vM],`svg`);function OM(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function kM(e){return e.join(` `).trim()}var AM=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
75
|
-
`,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),te(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function ee(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function te(){ee(i)}function S(e){var t;for(e||=[];t=C();)t!==!1&&e.push(t);return e}function C(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function ne(){var e=y(),t=ee(a);if(t){if(C(),!ee(o))return x(`property missing ':'`);var r=ee(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return ee(c),i}}function w(){var e=[];S(e);for(var t;t=ne();)t!==!1&&(e.push(t),S(e));return e}return te(),w()}function _(e){return e?e.replace(l,p):p}t.exports=g})),jM=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(AM());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),MM=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),NM=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(jM()),r=MM();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),PM=IM(`end`),FM=IM(`start`);function IM(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function LM(e){let t=FM(e),n=PM(e);if(t&&n)return{start:t,end:n}}function RM(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?BM(e.position):`start`in e||`end`in e?BM(e):`line`in e||`column`in e?zM(e):``}function zM(e){return VM(e&&e.line)+`:`+VM(e&&e.column)}function BM(e){return zM(e&&e.start)+`-`+zM(e&&e.end)}function VM(e){return e&&typeof e==`number`?e:1}var HM=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=RM(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};HM.prototype.file=``,HM.prototype.name=``,HM.prototype.reason=``,HM.prototype.message=``,HM.prototype.stack=``,HM.prototype.column=void 0,HM.prototype.line=void 0,HM.prototype.ancestors=void 0,HM.prototype.cause=void 0,HM.prototype.fatal=void 0,HM.prototype.place=void 0,HM.prototype.ruleId=void 0,HM.prototype.source=void 0;var UM=l(NM(),1),WM={}.hasOwnProperty,GM=new Map,KM=/[A-Z]/g,qM=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),JM=new Set([`td`,`th`]);function YM(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=oN(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=aN(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?DM:EM,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=XM(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function XM(e,t,n){if(t.type===`element`)return ZM(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return QM(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return eN(e,t,n);if(t.type===`mdxjsEsm`)return $M(e,t);if(t.type===`root`)return tN(e,t,n);if(t.type===`text`)return nN(e,t)}function ZM(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=DM,e.schema=i),e.ancestors.push(t);let a=fN(e,t.tagName,!1),o=sN(e,t),s=lN(e,t);return qM.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!Kj(e):!0})),rN(e,o,a,t),iN(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function QM(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}pN(e,t.position)}function $M(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);pN(e,t.position)}function eN(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=DM,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:fN(e,t.name,!0),o=cN(e,t),s=lN(e,t);return rN(e,o,a,t),iN(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function tN(e,t,n){let r={};return iN(r,lN(e,t)),e.create(t,e.Fragment,r,n)}function nN(e,t){return t.value}function rN(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function iN(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function aN(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function oN(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=FM(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function sN(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&WM.call(t.properties,i)){let a=uN(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&JM.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function cN(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else pN(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else pN(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function lN(e,t){let n=[],r=-1,i=e.passKeys?new Map:GM;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=XM(e,a,o);s!==void 0&&n.push(s)}return n}function uN(e,t,n){let r=CM(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Bj(n):kM(n)),r.property===`style`){let t=typeof n==`object`?n:dN(e,String(n));return e.stylePropertyNameCase===`css`&&(t=mN(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?yM[r.property]||r.property:r.attribute,n]}}function dN(e,t){try{return(0,UM.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new HM("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function fN(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=Wj(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=Wj(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return WM.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);pN(e)}function pN(e,t){let n=new HM("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function mN(e){let t={},n;for(n in e)WM.call(e,n)&&(t[hN(n)]=e[n]);return t}function hN(e){let t=e.replace(KM,gN);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function gN(e){return`-`+e.toLowerCase()}var _N={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},vN={};function yN(e,t){let n=t||vN;return bN(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function bN(e,t,n){if(SN(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return xN(e.children,t,n)}return Array.isArray(e)?xN(e,t,n):``}function xN(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=bN(e[i],t,n);return r.join(``)}function SN(e){return!!(e&&typeof e==`object`)}var CN=document.createElement(`i`);function wN(e){let t=`&`+e+`;`;CN.innerHTML=t;let n=CN.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function TN(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function EN(e,t){return e.length>0?(TN(e,e.length,0,t),e):t}var DN={}.hasOwnProperty;function ON(e){let t={},n=-1;for(;++n<e.length;)kN(t,e[n]);return t}function kN(e,t){let n;for(n in t){let r=(DN.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){DN.call(r,a)||(r[a]=[]);let e=i[a];AN(r[a],Array.isArray(e)?e:e?[e]:[])}}}function AN(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);TN(e,0,0,r)}function jN(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function MN(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var NN=GN(/[A-Za-z]/),PN=GN(/[\dA-Za-z]/),FN=GN(/[#-'*+\--9=?A-Z^-~]/);function IN(e){return e!==null&&(e<32||e===127)}var LN=GN(/\d/),RN=GN(/[\dA-Fa-f]/),zN=GN(/[!-/:-@[-`{-~]/);function BN(e){return e!==null&&e<-2}function VN(e){return e!==null&&(e<0||e===32)}function HN(e){return e===-2||e===-1||e===32}var UN=GN(/\p{P}|\p{S}/u),WN=GN(/\s/);function GN(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function KN(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&PN(e.charCodeAt(n+1))&&PN(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function qN(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return HN(r)?(e.enter(n),s(r)):t(r)}function s(r){return HN(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var JN={tokenize:YN};function YN(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),qN(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return BN(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var XN={tokenize:QN},ZN={tokenize:$N};function QN(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return TN(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ZN,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(ZN,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return BN(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;TN(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function $N(e,t,n){return qN(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function eP(e){if(e===null||VN(e)||WN(e))return 1;if(UN(e))return 2}function tP(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var nP={name:`attention`,resolveAll:rP,tokenize:iP};function rP(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};aP(d,-c),aP(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=EN(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=EN(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=EN(l,tP(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=EN(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=EN(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,TN(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function iP(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=eP(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=eP(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function aP(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var oP={name:`autolink`,tokenize:sP};function sP(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return NN(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||PN(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||PN(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||IN(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):FN(t)?(e.consume(t),l):n(t)}function u(e){return PN(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||PN(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var cP={partial:!0,tokenize:lP};function lP(e,t,n){return r;function r(t){return HN(t)?qN(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||BN(e)?t(e):n(e)}}var uP={continuation:{tokenize:fP},exit:pP,name:`blockQuote`,tokenize:dP};function dP(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return HN(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function fP(e,t,n){let r=this;return i;function i(t){return HN(t)?qN(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(uP,t,n)(r)}}function pP(e){e.exit(`blockQuote`)}var mP={name:`characterEscape`,tokenize:hP};function hP(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return zN(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var gP={name:`characterReference`,tokenize:_P};function _P(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=PN,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=RN,u):(e.enter(`characterReferenceValue`),a=7,o=LN,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===PN&&!wN(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var vP={partial:!0,tokenize:xP},yP={concrete:!0,name:`codeFenced`,tokenize:bP};function bP(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),HN(t)?qN(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||BN(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(vP,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||BN(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):HN(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),qN(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||BN(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||BN(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&HN(t)?qN(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||BN(t)?e.check(vP,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||BN(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),HN(t)?qN(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),HN(t)?qN(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||BN(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function xP(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var SP={name:`codeIndented`,tokenize:wP},CP={partial:!0,tokenize:TP};function wP(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),qN(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):BN(t)?e.attempt(CP,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||BN(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function TP(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):BN(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):qN(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):BN(e)?i(e):n(e)}}var EP={name:`codeText`,previous:OP,resolve:DP,tokenize:kP};function DP(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function OP(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function kP(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):BN(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||BN(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var AP=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&jP(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),jP(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),jP(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);jP(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);jP(this.left,t.reverse())}}};function jP(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function MP(e){let t={},n=-1,r,i,a,o,s,c,l,u=new AP(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,NP(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return TN(e,0,1/0,u.slice(0)),!l}function NP(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var PP={resolve:IP,tokenize:LP},FP={partial:!0,tokenize:RP};function IP(e){return MP(e),e}function LP(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):BN(t)?e.check(FP,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function RP(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),qN(e,a,`linePrefix`)}function a(i){if(i===null||BN(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function zP(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||IN(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||BN(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||VN(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||IN(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function BP(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):BN(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||BN(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!HN(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function VP(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):BN(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),qN(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||BN(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function HP(e,t){let n;return r;function r(i){return BN(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):HN(i)?qN(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var UP={name:`definition`,tokenize:GP},WP={partial:!0,tokenize:KP};function GP(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return BP.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=MN(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return VN(t)?HP(e,l)(t):l(t)}function l(t){return zP(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(WP,d,d)(t)}function d(t){return HN(t)?qN(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||BN(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function KP(e,t,n){return r;function r(t){return VN(t)?HP(e,i)(t):n(t)}function i(t){return VP(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return HN(t)?qN(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||BN(e)?t(e):n(e)}}var qP={name:`hardBreakEscape`,tokenize:JP};function JP(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return BN(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var YP={name:`headingAtx`,resolve:XP,tokenize:ZP};function XP(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},TN(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function ZP(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||VN(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||BN(n)?(e.exit(`atxHeading`),t(n)):HN(n)?qN(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||VN(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var QP=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),$P=[`pre`,`script`,`style`,`textarea`],eF={concrete:!0,name:`htmlFlow`,resolveTo:rF,tokenize:iF},tF={partial:!0,tokenize:oF},nF={partial:!0,tokenize:aF};function rF(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function iF(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:T):NN(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):NN(a)?(e.consume(a),i=4,r.interrupt?t:T):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:T):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:re:m):n(i)}function h(t){return NN(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||VN(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&$P.includes(l)?(i=1,r.interrupt?t(s):re(s)):QP.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):re(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||PN(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:re):n(i)}function v(t){return HN(t)?(e.consume(t),v):ne(t)}function y(t){return t===47?(e.consume(t),ne):t===58||t===95||NN(t)?(e.consume(t),b):HN(t)?(e.consume(t),y):ne(t)}function b(t){return t===45||t===46||t===58||t===95||PN(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),ee):HN(t)?(e.consume(t),x):y(t)}function ee(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,te):HN(t)?(e.consume(t),ee):S(t)}function te(t){return t===c?(e.consume(t),c=null,C):t===null||BN(t)?n(t):(e.consume(t),te)}function S(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||VN(t)?x(t):(e.consume(t),S)}function C(e){return e===47||e===62||HN(e)?y(e):n(e)}function ne(t){return t===62?(e.consume(t),w):n(t)}function w(t){return t===null||BN(t)?re(t):HN(t)?(e.consume(t),w):n(t)}function re(t){return t===45&&i===2?(e.consume(t),se):t===60&&i===1?(e.consume(t),ce):t===62&&i===4?(e.consume(t),E):t===63&&i===3?(e.consume(t),T):t===93&&i===5?(e.consume(t),ue):BN(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(tF,de,ie)(t)):t===null||BN(t)?(e.exit(`htmlFlowData`),ie(t)):(e.consume(t),re)}function ie(t){return e.check(nF,ae,de)(t)}function ae(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),oe}function oe(t){return t===null||BN(t)?ie(t):(e.enter(`htmlFlowData`),re(t))}function se(t){return t===45?(e.consume(t),T):re(t)}function ce(t){return t===47?(e.consume(t),o=``,le):re(t)}function le(t){if(t===62){let n=o.toLowerCase();return $P.includes(n)?(e.consume(t),E):re(t)}return NN(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),le):re(t)}function ue(t){return t===93?(e.consume(t),T):re(t)}function T(t){return t===62?(e.consume(t),E):t===45&&i===2?(e.consume(t),T):re(t)}function E(t){return t===null||BN(t)?(e.exit(`htmlFlowData`),de(t)):(e.consume(t),E)}function de(n){return e.exit(`htmlFlow`),t(n)}}function aF(e,t,n){let r=this;return i;function i(t){return BN(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function oF(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(cP,t,n)}}var sF={name:`htmlText`,tokenize:cF};function cF(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):NN(t)?(e.consume(t),S):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):NN(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):BN(t)?(o=d,ce(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?se(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):BN(t)?(o=h,ce(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?se(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?se(t):BN(t)?(o=v,ce(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):BN(t)?(o=y,ce(t)):(e.consume(t),y)}function b(e){return e===62?se(e):y(e)}function x(t){return NN(t)?(e.consume(t),ee):n(t)}function ee(t){return t===45||PN(t)?(e.consume(t),ee):te(t)}function te(t){return BN(t)?(o=te,ce(t)):HN(t)?(e.consume(t),te):se(t)}function S(t){return t===45||PN(t)?(e.consume(t),S):t===47||t===62||VN(t)?C(t):n(t)}function C(t){return t===47?(e.consume(t),se):t===58||t===95||NN(t)?(e.consume(t),ne):BN(t)?(o=C,ce(t)):HN(t)?(e.consume(t),C):se(t)}function ne(t){return t===45||t===46||t===58||t===95||PN(t)?(e.consume(t),ne):w(t)}function w(t){return t===61?(e.consume(t),re):BN(t)?(o=w,ce(t)):HN(t)?(e.consume(t),w):C(t)}function re(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,ie):BN(t)?(o=re,ce(t)):HN(t)?(e.consume(t),re):(e.consume(t),ae)}function ie(t){return t===i?(e.consume(t),i=void 0,oe):t===null?n(t):BN(t)?(o=ie,ce(t)):(e.consume(t),ie)}function ae(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||VN(t)?C(t):(e.consume(t),ae)}function oe(e){return e===47||e===62||VN(e)?C(e):n(e)}function se(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function ce(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),le}function le(t){return HN(t)?qN(e,ue,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ue(t)}function ue(t){return e.enter(`htmlTextData`),o(t)}}var lF={name:`labelEnd`,resolveAll:pF,resolveTo:mF,tokenize:hF},uF={tokenize:gF},dF={tokenize:_F},fF={tokenize:vF};function pF(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&TN(e,0,e.length,n),e}function mF(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=EN(s,e.slice(a+1,a+r+3)),s=EN(s,[[`enter`,u,t]]),s=EN(s,tP(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=EN(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=EN(s,e.slice(o+1)),s=EN(s,[[`exit`,c,t]]),TN(e,a,e.length,s),e}function hF(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(MN(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(uF,u,o?u:d)(t):t===91?e.attempt(dF,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(fF,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function gF(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return VN(t)?HP(e,a)(t):a(t)}function a(t){return t===41?u(t):zP(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return VN(t)?HP(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?VP(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return VN(t)?HP(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function _F(e,t,n){let r=this;return i;function i(t){return BP.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(MN(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function vF(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var yF={name:`labelStartImage`,resolveAll:lF.resolveAll,tokenize:bF};function bF(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var xF={name:`labelStartLink`,resolveAll:lF.resolveAll,tokenize:SF};function SF(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var CF={name:`lineEnding`,tokenize:wF};function wF(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),qN(e,t,`linePrefix`)}}var TF={name:`thematicBreak`,tokenize:EF};function EF(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||BN(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),HN(t)?qN(e,s,`whitespace`)(t):s(t))}}var DF={continuation:{tokenize:jF},exit:NF,name:`list`,tokenize:AF},OF={partial:!0,tokenize:PF},kF={partial:!0,tokenize:MF};function AF(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:LN(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(TF,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return LN(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(cP,r.interrupt?n:u,e.attempt(OF,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return HN(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function jF(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(cP,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,qN(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!HN(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(kF,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,qN(e,e.attempt(DF,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function MF(e,t,n){let r=this;return qN(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function NF(e){e.exit(this.containerState.type)}function PF(e,t,n){let r=this;return qN(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!HN(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var FF={name:`setextUnderline`,resolveTo:IF,tokenize:LF};function IF(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function LF(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),HN(t)?qN(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||BN(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var RF={tokenize:zF};function zF(e){let t=this,n=e.attempt(cP,r,e.attempt(this.parser.constructs.flowInitial,i,qN(e,e.attempt(this.parser.constructs.flow,i,e.attempt(PP,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var BF={resolveAll:WF()},VF=UF(`string`),HF=UF(`text`);function UF(e){return{resolveAll:WF(e===`text`?GF:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function WF(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function GF(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var KF=s({attentionMarkers:()=>eI,contentInitial:()=>JF,disable:()=>tI,document:()=>qF,flow:()=>XF,flowInitial:()=>YF,insideSpan:()=>$F,string:()=>ZF,text:()=>QF}),qF={42:DF,43:DF,45:DF,48:DF,49:DF,50:DF,51:DF,52:DF,53:DF,54:DF,55:DF,56:DF,57:DF,62:uP},JF={91:UP},YF={[-2]:SP,[-1]:SP,32:SP},XF={35:YP,42:TF,45:[FF,TF],60:eF,61:FF,95:TF,96:yP,126:yP},ZF={38:gP,92:mP},QF={[-5]:CF,[-4]:CF,[-3]:CF,33:yF,38:gP,42:nP,60:[oP,sF],91:xF,92:[qP,mP],93:lF,95:nP,96:EP},$F={null:[nP,BF]},eI={null:[42,95]},tI={null:[]};function nI(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:te(x),check:te(ee),consume:v,enter:y,exit:b,interrupt:te(ee,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=EN(o,e),g(),o[o.length-1]===null?(S(t,0),l.events=tP(a,l.events,l),l.events):[]}function f(e,t){return iI(p(e),t)}function p(e){return rI(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,ne()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){BN(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,ne()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){S(e,t.from)}function ee(e,t){t.restore()}function te(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=C(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function S(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&TN(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function C(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,ne()}}function ne(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function rI(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function iI(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
76
|
-
`;break;case-3:o=`\r
|
|
77
|
-
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function aI(e){let t={constructs:ON([KF,...(e||{}).extensions||[]]),content:n(JN),defined:[],document:n(XN),flow:n(RF),lazy:{},string:n(VF),text:n(HF)};return t;function n(e){return n;function n(n){return nI(t,e,n)}}}function oI(e){for(;!MP(e););return e}var sI=/[\0\t\n\r]/g;function cI(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(sI.lastIndex=u,c=sI.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var lI=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function uI(e){return e.replace(lI,dI)}function dI(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return jN(n.slice(t?2:1),t?16:10)}return wN(n)||e}var fI={}.hasOwnProperty;function pI(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),mI(n)(oI(aI(n).document().write(cI()(e,t,!0))))}function mI(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(De),autolinkProtocol:C,autolinkEmail:C,atxHeading:a(Ce),blockQuote:a(ye),characterEscape:C,characterReference:C,codeFenced:a(be),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(be,o),codeText:a(xe,o),codeTextData:C,data:C,codeFlowValue:C,definition:a(Se),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(D),hardBreakEscape:a(we),hardBreakTrailing:a(we),htmlFlow:a(Te,o),htmlFlowData:C,htmlText:a(Te,o),htmlTextData:C,image:a(Ee),label:o,link:a(De),listItem:a(ke),listItemValue:f,listOrdered:a(Oe,d),listUnordered:a(Oe),paragraph:a(Ae),reference:fe,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(Ce),strong:a(je),thematicBreak:a(Ne)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:ve,autolinkProtocol:_e,blockQuote:c(),characterEscapeValue:ne,characterReferenceMarkerHexadecimal:me,characterReferenceMarkerNumeric:me,characterReferenceValue:he,characterReference:ge,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:ne,codeIndented:c(_),codeText:c(oe),codeTextData:ne,data:ne,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(re),hardBreakTrailing:c(re),htmlFlow:c(ie),htmlFlowData:ne,htmlText:c(ae),htmlTextData:ne,image:c(ce),label:ue,labelText:le,lineEnding:w,link:c(se),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:pe,resourceDestinationString:T,resourceTitleString:E,resource:de,setextHeading:c(S),setextHeadingLineSequence:te,setextHeadingText:ee,strong:c(),thematicBreak:c()}};gI(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];fI.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||vI).call(a,void 0,e[0])}for(r.position={start:hI(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:hI(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:hI(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||vI).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+RM({start:e.start,end:e.end})+`): it’s not open`);n.position.end=hI(e.end)}function u(){return yN(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=MN(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function ee(){this.data.setextHeadingSlurpLineEnding=!0}function te(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function S(){this.data.setextHeadingSlurpLineEnding=void 0}function C(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Me(),n.position={start:hI(e.start),end:void 0},t.push(n)),this.stack.push(n)}function ne(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=hI(e.end)}function w(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=hI(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(C.call(this,e),ne.call(this,e))}function re(){this.data.atHardBreak=!0}function ie(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ae(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function oe(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function se(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ce(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function le(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=uI(t),n.identifier=MN(t).toLowerCase()}function ue(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function T(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function E(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function de(){this.data.inReference=void 0}function fe(){this.data.referenceType=`collapsed`}function pe(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=MN(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function me(e){this.data.characterReferenceType=e.type}function he(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=jN(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=wN(t);let i=this.stack[this.stack.length-1];i.value+=r}function ge(e){let t=this.stack.pop();t.position.end=hI(e.end)}function _e(e){ne.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ve(e){ne.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ye(){return{type:`blockquote`,children:[]}}function be(){return{type:`code`,lang:null,meta:null,value:``}}function xe(){return{type:`inlineCode`,value:``}}function Se(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function D(){return{type:`emphasis`,children:[]}}function Ce(){return{type:`heading`,depth:0,children:[]}}function we(){return{type:`break`}}function Te(){return{type:`html`,value:``}}function Ee(){return{type:`image`,title:null,url:``,alt:null}}function De(){return{type:`link`,title:null,url:``,children:[]}}function Oe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ke(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Ae(){return{type:`paragraph`,children:[]}}function je(){return{type:`strong`,children:[]}}function Me(){return{type:`text`,value:``}}function Ne(){return{type:`thematicBreak`}}}function hI(e){return{line:e.line,column:e.column,offset:e.offset}}function gI(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?gI(e,r):_I(e,r)}}function _I(e,t){let n;for(n in t)if(fI.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function vI(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+RM({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+RM({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+RM({start:t.start,end:t.end})+`) is still open`)}function yI(e){let t=this;t.parser=n;function n(n){return pI(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function bI(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function xI(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
78
|
-
`}]}function SI(e,t){let n=t.value?t.value+`
|
|
79
|
-
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function CI(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function wI(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function TI(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=KN(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function EI(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function DI(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function OI(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function kI(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return OI(e,t);let i={src:KN(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function AI(e,t){let n={src:KN(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function jI(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function MI(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return OI(e,t);let i={href:KN(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function NI(e,t){let n={href:KN(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function PI(e,t,n){let r=e.all(t),i=n?FI(n):II(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
80
|
-
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
81
|
-
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function FI(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=II(n[r])}return t}function II(e){return e.spread??e.children.length>1}function LI(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function RI(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function zI(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function BI(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function VI(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=FM(t.children[1]),o=PM(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function HI(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function UI(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var WI=9,GI=32;function KI(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(qI(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(qI(t.slice(i),i>0,!1)),a.join(``)}function qI(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===WI||t===GI;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===WI||t===GI;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function JI(e,t){let n={type:`text`,value:KI(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function YI(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var XI={blockquote:bI,break:xI,code:SI,delete:CI,emphasis:wI,footnoteReference:TI,heading:EI,html:DI,imageReference:kI,image:AI,inlineCode:jI,linkReference:MI,link:NI,listItem:PI,list:LI,paragraph:RI,root:zI,strong:BI,table:VI,tableCell:UI,tableRow:HI,text:JI,thematicBreak:YI,toml:ZI,yaml:ZI,definition:ZI,footnoteDefinition:ZI};function ZI(){}var QI=typeof self==`object`?self:globalThis,$I=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new QI[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new QI[a](o),i)};return r},eL=e=>$I(new Map,e)(0),tL=``,{toString:nL}={},{keys:rL}=Object,iL=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=nL.call(e).slice(8,-1);switch(n){case`Array`:return[1,tL];case`Object`:return[2,tL];case`Date`:return[3,tL];case`RegExp`:return[4,tL];case`Map`:return[5,tL];case`Set`:return[6,tL];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},aL=([e,t])=>e===0&&(t===`function`||t===`symbol`),oL=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=iL(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of rL(r))(e||!aL(iL(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(aL(iL(n))||aL(iL(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!aL(iL(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},sL=(e,{json:t,lossy:n}={})=>{let r=[];return oL(!(t||n),!!t,new Map,r)(e),r},cL=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?eL(sL(e,t)):structuredClone(e):(e,t)=>eL(sL(e,t));function lL(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function uL(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function dL(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||lL,r=e.options.footnoteBackLabel||uL,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=KN(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...cL(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
82
|
-
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
83
|
-
`}]}}var fL=(function(e){if(e==null)return _L;if(typeof e==`function`)return gL(e);if(typeof e==`object`)return Array.isArray(e)?pL(e):mL(e);if(typeof e==`string`)return hL(e);throw Error(`Expected function, string, or object as test`)});function pL(e){let t=[],n=-1;for(;++n<e.length;)t[n]=fL(e[n]);return gL(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function mL(e){let t=e;return gL(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function hL(e){return gL(t);function t(t){return t&&t.type===e}}function gL(e){return t;function t(t,n,r){return!!(vL(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function _L(){return!0}function vL(e){return typeof e==`object`&&!!e&&`type`in e}function yL(e){return e}var bL=[],xL=`skip`;function SL(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=fL(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+yL(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=bL,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=CL(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function CL(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?bL:[e]}function wL(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),SL(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var TL={}.hasOwnProperty,EL={};function DL(e,t){let n=t||EL,r=new Map,i=new Map,a={all:s,applyData:kL,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...XI,...n.handlers},one:o,options:n,patch:OL,wrap:jL};return wL(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(TL.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=cL(n);return r.children=a.all(e),r}return cL(e)}return(a.options.unknownHandler||AL)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=ML(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=ML(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function OL(e,t){e.position&&(t.position=LM(e))}function kL(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,cL(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function AL(e,t){let n=t.data||{},r=`value`in t&&!(TL.call(n,`hProperties`)||TL.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function jL(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
84
|
-
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
85
|
-
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
86
|
-
`}),n}function ML(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function NL(e,t){let n=DL(e,t),r=n.one(e,void 0),i=dL(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
87
|
-
`},i)),a}function PL(e,t){return e&&`run`in e?async function(n,r){let i=NL(n,{file:r,...t});await e.run(i,r)}:function(n,r){return NL(n,{file:r,...e||t})}}function FL(e){if(e)throw e}var IL=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function LL(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function RL(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?zL(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function zL(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var BL={basename:VL,dirname:HL,extname:UL,join:WL,sep:`/`};function VL(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);qL(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function HL(e){if(qL(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function UL(e){qL(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function WL(...e){let t=-1,n;for(;++t<e.length;)qL(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:GL(n)}function GL(e){qL(e);let t=e.codePointAt(0)===47,n=KL(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function KL(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function qL(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var JL={cwd:YL};function YL(){return`/`}function XL(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function ZL(e){if(typeof e==`string`)e=new URL(e);else if(!XL(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return QL(e)}function QL(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var $L=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],eR=class{constructor(e){let t;t=e?XL(e)?{path:e}:typeof e==`string`||iR(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:JL.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<$L.length;){let e=$L[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)$L.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?BL.basename(this.path):void 0}set basename(e){nR(e,`basename`),tR(e,`basename`),this.path=BL.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?BL.dirname(this.path):void 0}set dirname(e){rR(this.basename,`dirname`),this.path=BL.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?BL.extname(this.path):void 0}set extname(e){if(tR(e,`extname`),rR(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=BL.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){XL(e)&&(e=ZL(e)),nR(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?BL.basename(this.path,this.extname):void 0}set stem(e){nR(e,`stem`),tR(e,`stem`),this.path=BL.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new HM(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function tR(e,t){if(e&&e.includes(BL.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+BL.sep+"`")}function nR(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function rR(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function iR(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var aR=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),oR=l(IL(),1),sR={}.hasOwnProperty,cR=new class e extends aR{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=RL()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,oR.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(dR(`data`,this.frozen),this.namespace[e]=t,this):sR.call(this.namespace,e)&&this.namespace[e]||void 0:e?(dR(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=mR(e),n=this.parser||this.Parser;return lR(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),lR(`process`,this.parser||this.Parser),uR(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=mR(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);gR(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),lR(`processSync`,this.parser||this.Parser),uR(`processSync`,this.compiler||this.Compiler),this.process(e,r),pR(`processSync`,`process`,t),n;function r(e,r){t=!0,FL(e),n=r}}run(e,t,n){fR(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=mR(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),pR(`runSync`,`run`,n),r;function i(e,t){FL(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=mR(t),r=this.compiler||this.Compiler;return uR(`stringify`,r),fR(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(dR(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,oR.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];LL(o)&&LL(r)&&(r=(0,oR.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function lR(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function uR(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function dR(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function fR(e){if(!LL(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function pR(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function mR(e){return hR(e)?e:new eR(e)}function hR(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function gR(e){return typeof e==`string`||_R(e)}function _R(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var vR=[],yR={allowDangerousHtml:!0},bR=/^(https?|ircs?|mailto|xmpp)$/i,xR=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function SR(e){let t=CR(e),n=wR(e);return TR(t.runSync(t.parse(n),n),e)}function CR(e){let t=e.rehypePlugins||vR,n=e.remarkPlugins||vR,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...yR}:yR;return cR().use(yI).use(n).use(PL,r).use(t)}function wR(e){let t=e.children||``,n=new eR;return typeof t==`string`?n.value=t:``+t,n}function TR(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||ER;for(let e of xR)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return wL(e,l),YM(e,{Fragment:U.Fragment,components:i,ignoreInvalidStyle:!0,jsx:U.jsx,jsxs:U.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in _N)if(Object.hasOwn(_N,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=_N[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function ER(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||bR.test(e.slice(0,t))?e:``}function DR(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function OR(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function kR(e,t,n){let r=fL((n||{}).ignore||[]),i=AR(t),a=-1;for(;++a<i.length;)SL(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function AR(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([jR(e[0]),MR(e[1])])}return t}function jR(e){return typeof e==`string`?new RegExp(OR(e),`g`):e}function MR(e){return typeof e==`function`?e:function(){return e}}var NR=`phrasing`,PR=[`autolink`,`link`,`image`,`label`];function FR(){return{transforms:[UR],enter:{literalAutolink:LR,literalAutolinkEmail:RR,literalAutolinkHttp:RR,literalAutolinkWww:RR},exit:{literalAutolink:HR,literalAutolinkEmail:VR,literalAutolinkHttp:zR,literalAutolinkWww:BR}}}function IR(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:NR,notInConstruct:PR},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:NR,notInConstruct:PR},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:NR,notInConstruct:PR}]}}function LR(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function RR(e){this.config.enter.autolinkProtocol.call(this,e)}function zR(e){this.config.exit.autolinkProtocol.call(this,e)}function BR(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function VR(e){this.config.exit.autolinkEmail.call(this,e)}function HR(e){this.exit(e)}function UR(e){kR(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,WR],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,GR]],{ignore:[`link`,`linkReference`]})}function WR(e,t,n,r,i){let a=``;if(!JR(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!KR(n)))return!1;let o=qR(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function GR(e,t,n,r){return!JR(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function KR(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function qR(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=DR(e,`(`),a=DR(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function JR(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||WN(n)||UN(n))&&(!t||n!==47)}iz.peek=rz;function YR(){this.buffer()}function XR(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function ZR(){this.buffer()}function QR(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function $R(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=MN(this.sliceSerialize(e)).toLowerCase(),n.label=t}function ez(e){this.exit(e)}function tz(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=MN(this.sliceSerialize(e)).toLowerCase(),n.label=t}function nz(e){this.exit(e)}function rz(){return`[`}function iz(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function az(){return{enter:{gfmFootnoteCallString:YR,gfmFootnoteCall:XR,gfmFootnoteDefinitionLabelString:ZR,gfmFootnoteDefinition:QR},exit:{gfmFootnoteCallString:$R,gfmFootnoteCall:ez,gfmFootnoteDefinitionLabelString:tz,gfmFootnoteDefinition:nz}}}function oz(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:iz},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
88
|
-
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?cz:sz))),s(),o}}function sz(e,t,n){return t===0?e:cz(e,t,n)}function cz(e,t,n){return(n?``:` `)+e}var lz=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];mz.peek=hz;function uz(){return{canContainEols:[`delete`],enter:{strikethrough:fz},exit:{strikethrough:pz}}}function dz(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:lz}],handlers:{delete:mz}}}function fz(e){this.enter({type:`delete`,children:[]},e)}function pz(e){this.exit(e)}function mz(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function hz(){return`~`}function gz(e){return e.length}function _z(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||gz,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=vz(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=yz(r[d]);else{let e=yz(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
89
|
-
`)}function vz(e){return e==null?``:String(e)}function yz(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function bz(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),xz);return i(),o}function xz(e,t,n){return`>`+(n?``:` `)+e}function Sz(e,t){return Cz(e,t.inConstruct,!0)&&!Cz(e,t.notInConstruct,!1)}function Cz(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function wz(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
90
|
-
`&&Sz(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
91
|
-
`}function Tz(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function Ez(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Dz(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Oz(e,t,n,r){let i=Dz(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(Ez(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,kz);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(Tz(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
92
|
-
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
93
|
-
`),a&&(u+=s.move(a+`
|
|
94
|
-
`)),u+=s.move(c),l(),u}function kz(e,t,n){return(n?``:` `)+e}function Az(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function jz(e,t,n,r){let i=Az(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
95
|
-
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function Mz(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Nz(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Pz(e,t,n){let r=eP(e),i=eP(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Fz.peek=Iz;function Fz(e,t,n,r){let i=Mz(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=Pz(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Nz(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Pz(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Nz(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Iz(e,t,n){return n.options.emphasis||`*`}function Lz(e,t){let n=!1;return wL(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&yN(e)&&(t.options.setext||n))}function Rz(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Lz(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
96
|
-
`,after:`
|
|
97
|
-
`});return r(),t(),o+`
|
|
98
|
-
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
99
|
-
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
100
|
-
`,...a.current()});return/^[\t ]/.test(l)&&(l=Nz(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}zz.peek=Bz;function zz(e){return e.value||``}function Bz(){return`<`}Vz.peek=Hz;function Vz(e,t,n,r){let i=Az(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Hz(){return`!`}Uz.peek=Wz;function Uz(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Wz(){return`!`}Gz.peek=Kz;function Gz(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Kz(){return"`"}function qz(e,t){let n=yN(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Jz.peek=Yz;function Jz(e,t,n,r){let i=Az(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(qz(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Yz(e,t,n){return qz(e,n)?`<`:`[`}Xz.peek=Zz;function Xz(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Zz(){return`[`}function Qz(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function $z(e){let t=Qz(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function eB(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function tB(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function nB(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?eB(n):Qz(n),s=e.ordered?o===`.`?`)`:`.`:$z(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),tB(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function rB(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function iB(e,t,n,r){let i=rB(n),a=n.bulletCurrent||Qz(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function aB(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var oB=fL([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function sB(e,t,n,r){return(e.children.some(function(e){return oB(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function cB(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}lB.peek=uB;function lB(e,t,n,r){let i=cB(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=Pz(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Nz(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Pz(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Nz(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function uB(e,t,n){return n.options.strong||`*`}function dB(e,t,n,r){return n.safe(e.value,r)}function fB(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function pB(e,t,n){let r=(tB(n)+(n.options.ruleSpaces?` `:``)).repeat(fB(n));return n.options.ruleSpaces?r.slice(0,-1):r}var mB={blockquote:bz,break:wz,code:Oz,definition:jz,emphasis:Fz,hardBreak:wz,heading:Rz,html:zz,image:Vz,imageReference:Uz,inlineCode:Gz,link:Jz,linkReference:Xz,list:nB,listItem:iB,paragraph:aB,root:sB,strong:lB,text:dB,thematicBreak:pB};function hB(){return{enter:{table:gB,tableData:bB,tableHeader:bB,tableRow:vB},exit:{codeText:xB,table:_B,tableData:yB,tableHeader:yB,tableRow:yB}}}function gB(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function _B(e){this.exit(e),this.data.inTable=void 0}function vB(e){this.enter({type:`tableRow`,children:[]},e)}function yB(e){this.exit(e)}function bB(e){this.enter({type:`tableCell`,children:[]},e)}function xB(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,SB));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function SB(e,t){return t===`|`?t:e}function CB(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
101
|
-
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
102
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return _z(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=mB.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function wB(){return{exit:{taskListCheckValueChecked:EB,taskListCheckValueUnchecked:EB,paragraph:DB}}}function TB(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:OB}}}function EB(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function DB(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function OB(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=mB.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function kB(){return[FR(),az(),uz(),hB(),wB()]}function AB(e){return{extensions:[IR(),oz(e),dz(),CB(e),TB()]}}var jB={tokenize:GB,partial:!0},MB={tokenize:KB,partial:!0},NB={tokenize:qB,partial:!0},PB={tokenize:JB,partial:!0},FB={tokenize:YB,partial:!0},IB={name:`wwwAutolink`,tokenize:UB,previous:XB},LB={name:`protocolAutolink`,tokenize:WB,previous:ZB},RB={name:`emailAutolink`,tokenize:HB,previous:QB},zB={};function BB(){return{text:zB}}for(var VB=48;VB<123;)zB[VB]=RB,VB++,VB===58?VB=65:VB===91&&(VB=97);zB[43]=RB,zB[45]=RB,zB[46]=RB,zB[95]=RB,zB[72]=[RB,LB],zB[104]=[RB,LB],zB[87]=[RB,IB],zB[119]=[RB,IB];function HB(e,t,n){let r=this,i,a;return o;function o(t){return!$B(t)||!QB.call(r,r.previous)||eV(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return $B(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(FB,u,l)(t):t===45||t===95||PN(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&NN(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function UB(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!XB.call(r,r.previous)||eV(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(jB,e.attempt(MB,e.attempt(NB,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function WB(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&ZB.call(r,r.previous)&&!eV(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(NN(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||IN(t)||VN(t)||WN(t)||UN(t)?n(t):e.attempt(MB,e.attempt(NB,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function GB(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function KB(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(PB,c,s)(t):t===null||VN(t)||WN(t)||t!==45&&UN(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function qB(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(PB,t,a)(o):o===null||VN(o)||WN(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function JB(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||VN(o)||WN(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||VN(e)||WN(e)?t(e):r(e)}function a(e){return NN(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):NN(t)?(e.consume(t),o):n(t)}}function YB(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return PN(e)?n(e):t(e)}}function XB(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||VN(e)}function ZB(e){return!NN(e)}function QB(e){return!(e===47||$B(e))}function $B(e){return e===43||e===45||e===46||e===95||PN(e)}function eV(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var tV={tokenize:lV,partial:!0};function nV(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:oV,continuation:{tokenize:sV},exit:cV}},text:{91:{name:`gfmFootnoteCall`,tokenize:aV},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:rV,resolveTo:iV}}}}function rV(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=MN(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function iV(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function aV(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||VN(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(MN(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return VN(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function oV(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||VN(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=MN(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return VN(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),qN(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function sV(e,t,n){return e.check(cP,t,e.attempt(tV,t,n))}function cV(e){e.exit(`gfmFootnoteDefinition`)}function lV(e,t,n){let r=this;return qN(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function uV(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&TN(o,o.length,0,tP(s,e.slice(r+1,n),t)),TN(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),TN(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=eP(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=eP(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var dV=class{constructor(){this.map=[]}add(e,t,n){fV(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function fV(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function pV(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function mV(){return{flow:{null:{name:`table`,tokenize:hV,resolveAll:gV}}}}function hV(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?ee:c;return a===ee&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):BN(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):HN(t)?qN(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||VN(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,HN(t)?qN(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return HN(t)?qN(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||BN(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return HN(t)?qN(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||BN(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function ee(t){return e.enter(`tableRow`),te(t)}function te(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),te):n===null||BN(n)?(e.exit(`tableRow`),t(n)):HN(n)?qN(e,te,`whitespace`)(n):(e.enter(`data`),S(n))}function S(t){return t===null||t===124||VN(t)?(e.exit(`data`),te(t)):(e.consume(t),t===92?C:S)}function C(t){return t===92||t===124?(e.consume(t),S):S(t)}}function gV(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new dV;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(vV(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=_V(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=_V(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=_V(f,t,o,i,n,d)):(o[0]=o[1],d=_V(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&vV(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=pV(t.events,n))}return e}function _V(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},yV(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=yV(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=yV(t.events,n[2]),a=yV(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},yV(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function vV(e,t,n,r,i){let a=[],o=yV(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function yV(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var bV={name:`tasklistCheck`,tokenize:SV};function xV(){return{text:{91:bV}}}function SV(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return VN(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return BN(r)?t(r):HN(r)?e.check({tokenize:CV},t,n)(r):n(r)}}function CV(e,t,n){return qN(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function wV(e){return ON([BB(),nV(),uV(e),mV(),xV()])}var TV={};function EV(e){let t=this,n=e||TV,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(wV(n)),a.push(kB()),o.push(AB(n))}function DV(e){kR(e,[/\r?\n|\r/g,OV])}function OV(){return{type:`break`}}function kV(){return function(e){DV(e)}}function AV(e){return e.replace(/<think>([\s\S]*?)(?:<\/think>|$)/gi,(e,t)=>`\n> 💭 **思考过程**\n>\n${String(t||``).trim().split(`
|
|
103
|
-
`).filter(Boolean).map(e=>`> ${e}`).join(`
|
|
104
|
-
`)}\n\n`)}function jV(e){return/^\s*\|(?:\s*[:\-]+\s*\|){2,}\s*$/.test(e)}function MV(e){let t=e.trim();return t.startsWith(`|`)?t.split(`|`).length>=4:!1}function NV(e){let t=e.trim();return t.startsWith(`|`)?t.replace(/^\|/,``).replace(/\|\s*$/,``).split(`|`).map(e=>e.trim()):[]}function PV(e,t=``){return`${t}| ${e.join(` | `)} |`}function FV(e){let t=e.split(`
|
|
105
|
-
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(MV(e)&&r+1<t.length&&jV(t[r+1])){let i=e.match(/^(\s*)/)?.[1]||``,a=NV(e),o=NV(t[r+1]),s=[],c=r+2,l=Math.max(a.length,o.length);for(;c<t.length&&MV(t[c]);){let e=NV(t[c]);l=Math.max(l,e.length),s.push(e),c+=1}let u=e=>{let t=[...e];for(;t.length<l;)t.push(``);return t};n.push(PV(u(a),i)),n.push(PV((e=>{let t=[...e];for(;t.length<l;)t.push(`---`);return t})(o),i));for(let e of s)n.push(PV(u(e),i));r=c}else n.push(e),r+=1}return n.join(`
|
|
106
|
-
`)}function IV(e){return jV(e)||/\|\|/.test(e)||/\|(?:\s*[:\-]+\s*\|){2,}/.test(e)&&/\|(?:[^|\n]*\|){2,}/.test(e)}function LV(e){return IV(e)?e.replace(/\|\s*\|/g,`|
|
|
107
|
-
|`).split(`
|
|
108
|
-
`).map(e=>e.trimEnd()).filter(e=>e.trim().length>0):[e]}function RV(e){return MV(e)?e.replace(/\|\s*(?:\*{1,2}|_{1,2})\s*$/u,`|`):e}function zV(e){let t=e.trim();return MV(t)?t.split(`|`).slice(1,-1).length:0}function BV(e){let t=e.match(/^(\s*)/)?.[1]||``,n=zV(e);return n<2?``:`${t}| ${Array.from({length:n},()=>`---`).join(` | `)} |`}function VV(e){let t=[];for(let n of e.split(`
|
|
109
|
-
`)){if(/^\s*\|\s*$/.test(n))continue;let e=n.match(/^(\s*)\|\s*([^|]+)$/);if(e){t.push(`${e[1]}${e[2].trim()}`);continue}t.push(...LV(n).map(RV))}let n=[];for(let e=0;e<t.length;e+=1){let r=t[e];r.trim().length===0&&MV(n[n.length-1]||``)&&jV(t[e+1]||``)||n.push(r)}let r=[];for(let e=0;e<n.length;e+=1){let t=n[e],i=n[e+1]||``;if(r.push(t),MV(t)&&MV(i)&&!jV(i)&&zV(t)===zV(i)){let i=MV(n[e-1]||``),a=t.match(/^(\s*)/)?.[1]||``;if(!i&&a.length===0){let e=BV(t);e&&r.push(e)}}}let i=[];for(let e=0;e<r.length;e+=1){let t=r[e],n=r[e+1]||``,a=i[i.length-1]||``,o=MV(t)&&(a.trim().length===0||!MV(a)),s=MV(t)&&(n.trim().length===0||!MV(n)),c=t.match(/^(\s*)/)?.[1]||``;o&&c.length===0&&a.trim().length>0&&i.push(``),i.push(t),s&&c.length===0&&n.trim().length>0&&i.push(``)}return i.join(`
|
|
110
|
-
`)}function HV(e){let t=e.replace(/^[\u200B-\u200D\uFEFF]+/u,``),n=t.match(/^([ \t\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)([##]{1,6})([ \t\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)(\S.*)?$/u);if(!n)return t;let[,r,i,,a=``]=n,o=r.replace(/[^\t ]/gu,` `),s=i.replace(/#/gu,`#`);return a?`${o}${s} ${a}`:`${o}${s}`}function UV(e){let t=e;return t=t.split(`
|
|
111
|
-
`).map(e=>HV(e)).join(`
|
|
112
|
-
`),t=t.replace(/^[ \t]+(#{1,6}\s*)/gm,`$1`),t=t.replace(/([^\n#])\s*(#{1,6}\s*[^\s|])/g,`$1
|
|
113
|
-
|
|
114
|
-
$2`),t=t.replace(/^(#{1,6}\s*[^\n]+)\n(?!\n)/gm,`$1
|
|
115
|
-
|
|
116
|
-
`),t=t.replace(/^(#{1,6}[^\n|]+?)\s*(\|)/gm,`$1
|
|
117
|
-
$2`),t=t.replace(/([。;;::])\s*(\d+\.\s*)/g,`$1
|
|
118
|
-
$2`),t=t.replace(/([^\n\s])(\d+\.\s+)/g,`$1
|
|
119
|
-
$2`),t=t.replace(/([。;;::\.])\s*-(?!-)\s*/g,`$1
|
|
120
|
-
- `),t=t.replace(/([^\n\s-])-\s+/g,`$1
|
|
121
|
-
- `),t=t.replace(/^-(?!-)(\S)/gm,`- $1`),t=VV(t),t=t.replace(/\n{3,}/g,`
|
|
122
|
-
|
|
123
|
-
`),t.trim()}function WV(e){return e.map((t,n)=>{if(n%2==1)return t;let r=UV(t),i=n>0,a=n<e.length-1;return r?(i&&!r.startsWith(`
|
|
124
|
-
`)&&(r=`\n${r}`),a&&!r.endsWith(`
|
|
125
|
-
`)&&(r=`${r}\n`),r):i&&a?`
|
|
126
|
-
|
|
127
|
-
`:i||a?`
|
|
128
|
-
`:r})}function GV(e){if(!e)return e;let t=String(e).replace(/\r\n/g,`
|
|
129
|
-
`).replace(/\r/g,`
|
|
130
|
-
`).trim();return t=AV(t),t=FV(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),WV(t.split("```")).join("```").trim()}var KV=`modulepreload`,qV=function(e,t){return new URL(e,t).href},JV={},q=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=qV(t,n),t in JV)return;JV[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`:KV,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)})},YV=b.lazy(()=>q(()=>import(`./CodeBlock-BqyqZfuB.js`).then(e=>({default:e.CodeBlock})),[],import.meta.url)),XV=b.lazy(()=>q(()=>import(`./MermaidBlock-DWuxETaJ.js`).then(e=>({default:e.MermaidBlock})),[],import.meta.url)),ZV=b.lazy(()=>q(()=>import(`./MathMessageMarkdown-BpH7jiFM.js`).then(e=>({default:e.MathMessageMarkdown})),__vite__mapDeps([0,1,2,3,4]),import.meta.url));function QV(e){return/\$[^$]+\$|\$\$[^$]+\$\$/.test(e)}var $V={h1({children:e}){return(0,U.jsx)(`h1`,{className:`mb-3.5 mt-5 text-[17px] font-semibold text-foreground`,children:e})},h2({children:e}){return(0,U.jsx)(`h2`,{className:`mb-2.5 mt-4.5 text-[15px] font-semibold text-foreground`,children:e})},h3({children:e}){return(0,U.jsx)(`h3`,{className:`mb-2 mt-3.5 text-[14px] font-semibold text-foreground`,children:e})},p({children:e}){return(0,U.jsx)(`p`,{className:`mb-2.5 min-w-0 break-words leading-[1.65] text-foreground`,children:e})},ul({children:e}){return(0,U.jsx)(`ul`,{className:`mb-3 list-disc space-y-1.5 pl-5 text-foreground`,children:e})},ol({children:e}){return(0,U.jsx)(`ol`,{className:`mb-3 list-decimal space-y-1.5 pl-8 text-foreground`,children:e})},li({children:e}){return(0,U.jsx)(`li`,{className:`min-w-0 break-words pl-1 leading-6 text-foreground`,children:e})},strong({children:e}){return(0,U.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e})},blockquote({children:e}){return(0,U.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(`
|
|
131
|
-
`))return(0,U.jsx)(`code`,{className:`rounded-md border border-border bg-muted px-1.5 py-0.5 font-mono text-[13.5px] text-text-primary before:content-none after:content-none`,...n,children:t});let a=r?r[1]:``;return a===`mermaid`?(0,U.jsx)(b.Suspense,{fallback:(0,U.jsx)(`div`,{className:`h-32 animate-pulse rounded bg-muted`}),children:(0,U.jsx)(XV,{chart:i})}):(0,U.jsx)(b.Suspense,{fallback:(0,U.jsx)(`pre`,{className:`p-4 text-sm`,children:i}),children:(0,U.jsx)(YV,{language:a,value:i})})},table({children:e,...t}){return(0,U.jsx)(`div`,{className:`mb-3 max-w-full overflow-x-auto`,children:(0,U.jsx)(`table`,{className:`w-full min-w-max border-collapse text-sm text-foreground`,...t,children:e})})},th({children:e,...t}){return(0,U.jsx)(`th`,{className:`border-b border-border px-3 py-2 text-left font-semibold text-foreground`,...t,children:e})},td({children:e,...t}){return(0,U.jsx)(`td`,{className:`border-b border-border px-3 py-2 text-text-secondary`,...t,children:e})},a({children:e,href:t,...n}){return(0,U.jsx)(`a`,{href:t,className:`text-primary hover:underline`,target:`_blank`,rel:`noopener noreferrer`,...n,children:e})}},eH=b.memo(({content:e})=>{let t=GV(e);return(0,U.jsx)(`div`,{className:`max-w-none break-words text-[14px] leading-[1.65] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,U.jsx)(SR,{remarkPlugins:[EV,kV],components:$V,children:t})})}),tH=b.memo(({content:e})=>QV(e)?(0,U.jsx)(b.Suspense,{fallback:(0,U.jsx)(eH,{content:e}),children:(0,U.jsx)(ZV,{content:e})}):(0,U.jsx)(eH,{content:e})),nH=/^diff --git "?a\/(.+?)"? "?b\/(.+?)"?$/;function rH(e){let t=[],n=new Map,r=null;for(let i of e.split(`
|
|
132
|
-
`)){let e=i.match(nH);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 iH(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 aH(e){return/^diff --git /m.test(e)}function oH({summary:e,children:t,defaultOpen:n=!1,streaming:r=!1}){let[i,a]=(0,b.useState)(n);return(0,U.jsxs)(`div`,{className:`mb-1.5`,children:[(0,U.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,U.jsx)(YT,{className:`h-3.5 w-3.5 animate-spin text-slate-400`}):(0,U.jsx)(NT,{className:YD(`h-3.5 w-3.5 text-slate-400 transition-transform`,i&&`rotate-90`)}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})]}),i&&(0,U.jsx)(`div`,{className:`mt-1.5 border-l border-slate-200 pl-3.5 dark:border-slate-700/60`,children:t})]})}function sH({block:e}){let[t,n]=(0,b.useState)(!1),r=e.status===`streaming`,i=e.content.length,a=`${e.id}-thinking-detail`;return(0,U.jsxs)(`div`,{className:`mb-1.5 min-w-0`,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":a,onClick:()=>n(e=>!e),className:`flex w-full items-center gap-1.5 rounded px-1 py-1 text-left text-[13px] leading-5 text-slate-400 transition-colors hover:bg-slate-100/70 hover:text-slate-500 dark:text-slate-500 dark:hover:bg-slate-800/40 dark:hover:text-slate-400`,children:[(0,U.jsx)(fE,{className:YD(`h-3.5 w-3.5 shrink-0`,r&&`animate-pulse motion-reduce:animate-none`)}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:r?`思考中`:`已思考`}),!r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`text-slate-300 dark:text-slate-600`,children:`·`}),(0,U.jsxs)(`span`,{className:`font-mono text-xs text-slate-400 dark:text-slate-500`,children:[i,` 字`]})]}),(0,U.jsx)(NT,{className:YD(`h-3.5 w-3.5 shrink-0 transition-transform`,t&&`rotate-180`)})]}),t&&e.content&&(0,U.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,U.jsx)(tH,{content:e.content})})]})}function cH({block:e,tool:t,isStreaming:n,onRespondToApproval:r,onRespondToAguiApproval:i}){let a=t?.status??e.status,o=t?.args??e.args,s=t?.output??e.output,c=e.extra||{},l=c.approvalStatus||t?.approvalStatus,u=c.approvalRequestId||t?.approvalRequestId,d=c.approvalMessage||t?.approvalMessage,f=c.approvalProtocol||t?.approvalProtocol,p=c.previousResponseId||t?.previousResponseId,m=a===`running`,h=a===`error`,g=a===`paused`,_=h?`执行失败`:l===`pending`?`等待确认`:l===`rejected`?`已拒绝`:m?l===`approved`?`已授权 · 执行中`:`正在运行`:l===`approved`?`已授权`:g?`已暂停`:`已完成`,v=h?`text-rose-500 dark:text-rose-400`:g?`text-amber-500 dark:text-amber-400`:m?`text-slate-500 dark:text-slate-400`:`text-slate-400 dark:text-slate-500`;return(0,U.jsx)(oH,{streaming:m&&!o,defaultOpen:l===`pending`||g,summary:(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(bE,{className:YD(`h-3.5 w-3.5 shrink-0`,v)}),(0,U.jsx)(`span`,{className:v,children:_}),(0,U.jsx)(`span`,{className:`truncate font-medium text-slate-600 dark:text-slate-300`,children:e.toolName}),m&&o&&(0,U.jsx)(`span`,{className:`ml-0.5 animate-pulse text-slate-400`,children:`…`})]}),children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2.5 py-1 text-[13px]`,children:[u&&l===`pending`&&(0,U.jsxs)(`section`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-slate-200/90 bg-white/70 px-2.5 py-2 font-sans text-[12px] text-slate-600 shadow-[0_1px_2px_rgba(15,23,42,0.03)] dark:border-slate-700/80 dark:bg-slate-900/30 dark:text-slate-300`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`shrink-0 font-medium text-slate-700 dark:text-slate-200`,children:`需要确认`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-slate-500 dark:text-slate-400`,children:d||`允许后将执行此工具调用。`})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>f===`ag-ui`?i?.({interruptId:u||``,approve:!0}):r?.({approvalRequestId:u||``,approve:!0,previousResponseId:p}),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,U.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>f===`ag-ui`?i?.({interruptId:u||``,approve:!1}):r?.({approvalRequestId:u||``,approve:!1,previousResponseId:p}),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:`拒绝`})]})]}),u&&l&&l!==`pending`&&(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 font-sans text-xs text-slate-500 dark:text-slate-400`,children:[(0,U.jsx)(`span`,{children:l===`approved`?`已授权`:`已拒绝`}),l===`approved`&&m?(0,U.jsx)(`span`,{children:`· 工具执行中`}):null,l===`approved`&&h?(0,U.jsx)(`span`,{children:`· 工具执行失败`}):null]}),o?(0,U.jsx)(pH,{label:`入参`,value:o,tone:`input`}):null,s?lH(e.toolName,s,h):null]})})}function lH(e,t,n){if(aH(t))return(0,U.jsx)(uH,{output:t});let r=e.toLowerCase();if(r.includes(`web_search`)||r.includes(`search`)){let e=dH(t);if(e.length>0)return(0,U.jsx)(fH,{sources:e})}return(0,U.jsx)(pH,{label:`输出`,value:t,tone:n?`error`:`output`})}function uH({output:e}){let t=rH(e),[n,r]=(0,b.useState)(!1),i=n?t:t.slice(0,3);return(0,U.jsxs)(`div`,{className:`my-2 overflow-hidden rounded-xl border border-border bg-background`,children:[(0,U.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,U.jsx)(WT,{className:`h-3.5 w-3.5 text-primary`}),(0,U.jsxs)(`span`,{children:[`改动 `,t.length,` 个文件`]})]}),(0,U.jsx)(`div`,{className:`flex flex-col`,children:i.map(e=>{let{added:t,removed:n}=iH(e);return(0,U.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,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[13px] text-text-primary`,children:e.path}),(0,U.jsxs)(`span`,{className:`flex-shrink-0 text-[11px] font-mono`,children:[(0,U.jsxs)(`span`,{className:`text-emerald-600`,children:[`+`,t]}),` `,(0,U.jsxs)(`span`,{className:`text-rose-500`,children:[`−`,n]})]})]},e.path)})}),t.length>3?(0,U.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 dH(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 fH({sources:e}){return(0,U.jsx)(`div`,{className:`mt-2 flex min-w-0`,children:(0,U.jsxs)(`span`,{className:`group/web-search-sources relative inline-flex min-w-0`,children:[(0,U.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,U.jsx)(zT,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7}),(0,U.jsxs)(`span`,{children:[`来源 · `,e.length]})]}),(0,U.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,U.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,U.jsx)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:e.map((e,t)=>(0,U.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,U.jsx)(zT,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]},`${e.url}-${t}`))})})})]})})}function pH({label:e,tone:t,value:n}){return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-slate-400`,children:e}),(0,U.jsx)(`pre`,{className:YD(`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 mH({block:e}){return e.content?(0,U.jsx)(`div`,{className:`w-full break-words py-0.5 text-[14px] leading-[1.65]`,children:(0,U.jsx)(tH,{content:e.content})}):null}function hH({message:e,isStreaming:t,onRespondToApproval:n,onRespondToAguiApproval:r}){return(0,U.jsx)(`div`,{className:`mb-3 min-w-0`,children:(e.blocks??[]).map(i=>i.type===`thinking`?(0,U.jsx)(sH,{block:i},i.id):i.type===`tool`?(0,U.jsx)(cH,{block:i,tool:e.tools?.[i.toolName],isStreaming:t,onRespondToApproval:n,onRespondToAguiApproval:r},i.id):(0,U.jsx)(mH,{block:i},i.id))})}function gH({onRetry:e}){let t=D(e=>e.banner);if(!t)return null;let n=t.kind===`rate_limited`?(0,U.jsx)(_H,{message:t.message,retryAfterSec:t.retryAfterSec},t.createdAt||`${t.sessionId||``}:${t.retryAfterSec||0}`):null,r={rate_limited:{icon:(0,U.jsx)(SE,{className:`h-4 w-4 text-amber-500`}),bg:`border-amber-200/70 bg-amber-50/70 dark:border-amber-900/40 dark:bg-amber-950/20`,text:`text-amber-700 dark:text-amber-200`,label:n},network:{icon:(0,U.jsx)(YT,{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,U.jsx)(yE,{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,U.jsxs)(`div`,{className:YD(`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,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.label}),t.kind===`error`&&e?(0,U.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,U.jsx)(sE,{className:`h-3 w-3`}),`重试`]}):null]})}function _H({message:e,retryAfterSec:t}){let[n,r]=(0,b.useState)(t||0);return(0,b.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 vH(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 yH(e,t,n){return Math.max(t,Math.min(n,e))}function bH({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=yH(g-l,0,e.length),_=yH(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 xH({surfaceId:e,messages:t}){let{processMessages:n}=KS();return(0,b.useEffect)(()=>{n(t)},[t,n]),(0,U.jsx)(ZS,{surfaceId:e,className:`w-full`,fallback:(0,U.jsx)(`div`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`界面内容暂不可用`}),loadingFallback:(0,U.jsx)(`div`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`正在加载界面`})})}function SH({surfaceId:e,messages:t,onAction:n}){return(0,U.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,U.jsx)(US,{catalog:rC,onAction:n,children:(0,U.jsx)(xH,{surfaceId:e,messages:t})})})}var CH=140,wH=4;function TH(e){let t=String(e||``).trim().toLowerCase();return t===`elevated`?`高风险`:t===`always`?`始终确认`:t===`confirm`?`需确认`:e||``}function EH(e){return String(e||``).trim().toLowerCase()===`elevated`?`border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900/70 dark:bg-rose-950/30 dark:text-rose-200`:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/70 dark:bg-amber-950/30 dark:text-amber-200`}function DH({messageId:e,top:t,onMeasure:n,children:r}){let i=(0,b.useRef)(null);return(0,b.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,U.jsx)(`div`,{ref:i,style:{position:`absolute`,top:t,left:0,right:0},children:r})}function OH(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),r=t%60;return n<=0?`${r}s`:`${n}m ${String(r).padStart(2,`0`)}s`}function kH(e){return e<1e3?`刚刚`:e<6e4?`${Math.floor(e/1e3)} 秒前`:`${Math.floor(e/6e4)} 分钟前`}function AH(e){return!Number.isFinite(e)||!e||e<=0?``:e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e5?0:1)}K`:String(Math.round(e))}function jH({contextIndicator:e}){let t=e?.usedTokens,n=e?.contextWindowTokens,r=AH(t),i=AH(n);if(!r)return null;let a=[r,i].filter(Boolean).join(`/`);return(0,U.jsxs)(`span`,{className:`token-count-pulse hidden text-slate-400 dark:text-slate-500 sm:inline`,title:e?.label||`估算 token ${a}`,children:[`估算 token `,a]},r)}function MH({activity:e,contextIndicator:t,onStopGeneration:n,onCancelRemote:r}){let[i,a]=(0,b.useState)(()=>Date.now());(0,b.useEffect)(()=>{let e=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let o=e.status===`connecting`||e.status===`running`||e.status===`waiting`,s=i-e.lastEventAt<2e4;return(0,U.jsxs)(`div`,{className:`inline-flex max-w-full items-center gap-2 rounded-full border border-slate-200/70 bg-white/90 px-2.5 py-1 text-[11px] leading-4 text-slate-500 shadow-sm shadow-slate-900/5 backdrop-blur dark:border-slate-700/60 dark:bg-slate-900/90 dark:text-slate-400`,children:[e.status===`failed`?(0,U.jsx)(PT,{className:`h-3 w-3 text-rose-500`}):e.status===`completed`?(0,U.jsx)(MT,{className:`h-3 w-3 text-emerald-500`}):e.status===`stopped`?(0,U.jsx)(dE,{className:`h-3 w-3 text-amber-500`}):(0,U.jsx)(oE,{className:`h-3 w-3 animate-spin text-slate-400`}),(0,U.jsx)(`span`,{className:`max-w-[16rem] truncate text-slate-600 dark:text-slate-300`,title:e.detail||e.phase,children:e.phase}),(0,U.jsxs)(`span`,{children:[e.source===`restore`?`恢复`:`运行`,` `,OH(i-e.startedAt)]}),o?(0,U.jsx)(`span`,{className:YD(`inline-block h-1.5 w-1.5 flex-shrink-0 rounded-full`,s?`bg-emerald-400`:`bg-slate-300 dark:bg-slate-600`),title:s?`连接存活`:`连接超时`}):null,(0,U.jsxs)(`span`,{className:`text-slate-400 dark:text-slate-500`,children:[e.eventCount,` ev`]}),(0,U.jsx)(`span`,{className:`hidden text-slate-400 dark:text-slate-500 sm:inline`,children:kH(i-e.lastEventAt)}),(0,U.jsx)(jH,{contextIndicator:t}),o&&(n||r)?(0,U.jsxs)(`div`,{className:`flex flex-shrink-0 gap-1`,children:[n?(0,U.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] text-slate-400 transition hover:bg-slate-100 hover:text-slate-700 dark:text-slate-500 dark:hover:bg-slate-800 dark:hover:text-slate-200`,children:[(0,U.jsx)(PT,{className:`h-3 w-3`}),`停止`]}):null,r?(0,U.jsxs)(`button`,{type:`button`,"aria-label":`取消运行并保留恢复点`,title:`取消运行并保留最近 checkpoint`,onClick:r,className:`flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] text-slate-400 transition hover:bg-rose-50 hover:text-rose-600 dark:text-slate-500 dark:hover:bg-rose-950/30 dark:hover:text-rose-300`,children:[(0,U.jsx)(FT,{className:`h-3 w-3`}),`取消`]}):null]}):null]})}function NH({agentName:e}){return(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[50vh] px-4`,children:[(0,U.jsx)(`div`,{className:`mb-6 h-16 w-16 rounded-2xl bg-gradient-to-br from-blue-500 to-indigo-600
|
|
133
|
-
flex items-center justify-center shadow-lg shadow-blue-500/20`,children:(0,U.jsx)(jT,{className:`h-8 w-8 text-white`})}),(0,U.jsx)(`h2`,{className:`text-xl font-semibold text-slate-900 dark:text-slate-50`,children:`有什么我可以帮您的吗?`}),(0,U.jsxs)(`p`,{className:`mt-2 text-sm text-slate-500`,children:[`我是 `,e,`,由 Ksyun AgentEngine 驱动`]})]})}function PH(){return(0,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[44rem] flex-col gap-5 px-2 py-8`,"aria-label":`正在加载会话历史`,children:[(0,U.jsx)(`div`,{className:`h-4 w-28 animate-pulse rounded bg-slate-200/80 dark:bg-slate-800`}),(0,U.jsx)(`div`,{className:`h-20 w-4/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,U.jsx)(`div`,{className:`ml-auto h-12 w-3/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,U.jsx)(`div`,{className:`h-16 w-11/12 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`})]})}function FH({attachments:e,isMobile:t,onOpenAttachmentPreview:n}){return(0,U.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-3`,children:e.map((e,r)=>e.type.startsWith(`image/`)?e.url?(0,U.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:YD(`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,U.jsx)(`img`,{src:e.url,alt:e.name,className:YD(`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,U.jsx)(`div`,{className:YD(`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,U.jsxs)(`div`,{className:YD(`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,U.jsx)(rE,{className:`h-4 w-4 flex-shrink-0 text-blue-500`}),e.url?(0,U.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,U.jsx)(`span`,{className:`truncate text-sm text-slate-700 dark:text-slate-300`,title:e.name,children:e.name})]},`${e.name}-${r}`))})}function IH({message:e}){return(0,U.jsx)(`div`,{className:`w-full px-0 py-2 sm:px-4`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl rounded-2xl border border-amber-200/80 bg-amber-50/80 px-4 py-3 text-sm text-amber-900 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`running`?(0,U.jsx)(oE,{className:`h-4 w-4 animate-spin text-amber-600 dark:text-amber-300`}):e.status===`failed`?(0,U.jsx)(PT,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,U.jsx)(MT,{className:`h-4 w-4 text-emerald-600 dark:text-emerald-400`}),(0,U.jsx)(`span`,{children:e.content})]}),e.compactedUntilSeqId?(0,U.jsxs)(`div`,{className:`mt-1 text-xs text-amber-700/80 dark:text-amber-200/80`,children:[`已折叠到会话事件 #`,e.compactedUntilSeqId]}):null,e.summary?(0,U.jsxs)(`details`,{className:`mt-3 rounded-xl border border-amber-200/80 bg-white/70 px-3 py-2 dark:border-amber-900/60 dark:bg-slate-950/40`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-amber-800 dark:text-amber-200`,children:`查看压缩摘要`}),(0,U.jsx)(`div`,{className:`mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200`,children:(0,U.jsx)(tH,{content:e.summary})})]}):null]})})}function LH({label:e,tone:t,value:n}){let[r,i]=(0,b.useState)(`idle`),a=$C(n);(0,b.useEffect)(()=>{if(r===`idle`)return;let e=window.setTimeout(()=>i(`idle`),1600);return()=>window.clearTimeout(e)},[r]);let o=async()=>{i(await vH(a)?`copied`:`failed`)};return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,U.jsx)(`div`,{className:YD(`text-xs font-semibold uppercase`,t===`input`?`text-blue-500`:t===`error`?`text-rose-500`:`text-emerald-500`),children:e}),(0,U.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,U.jsx)(MT,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,U.jsx)(LT,{className:`h-3.5 w-3.5`}),r===`copied`?`已复制`:r===`failed`?`复制失败`:`复制`]})]}),(0,U.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 RH({isLastMessage:e,isStreaming:t,message:n,onDeleteFeedback:r,onSubmitFeedback:i}){let[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(n.feedback?.comment||``),l=Gw(n,t,e),u=!!n.feedback?.pending,d=n.feedback?.rating,f=async()=>{let e=n.content||``;e&&vH(e)};return l?(0,U.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-text-muted`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>{f()},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,U.jsx)(LT,{className:`h-3.5 w-3.5`})}),(0,U.jsx)(`span`,{className:`text-text-muted/60`,children:`·`}),(0,U.jsx)(`span`,{className:`font-medium`,children:`本次回复有帮助吗?`}),(0,U.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>i({message:n,rating:`up`,comment:``}),className:YD(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,d===`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,U.jsx)(gE,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,U.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{c(n.feedback?.comment||``),o(e=>!e)},className:YD(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,d===`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,U.jsx)(hE,{className:`h-3.5 w-3.5`}),`需改进`]}),n.feedback?(0,U.jsxs)(`button`,{type:`button`,disabled:u,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,U.jsx)(_E,{className:`h-3.5 w-3.5`}),`删除反馈`]}):null,u?(0,U.jsx)(`span`,{className:`text-slate-400`,children:`提交中…`}):null]}),a?(0,U.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,U.jsx)(`textarea`,{value:s,onChange:e=>c(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,U.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>o(!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,U.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{i({message:n,rating:`down`,comment:s}),o(!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:`提交点踩`})]})]}):d===`down`&&n.feedback?.comment?(0,U.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,U.jsx)(`div`,{className:`text-xs text-rose-600 dark:text-rose-300`,children:n.feedback.error}):null]}):null}function zH({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,message:i,onDeleteFeedback:a,onOpenAttachmentPreview:o,onRespondToApproval:s,onRespondToAguiApproval:c,onSubmitFeedback:l,onSubmitAguiAction:u}){return i.role===`user`?(0,U.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,U.jsxs)(`div`,{className:`max-w-[80%] rounded-2xl bg-muted px-3 py-2 text-[14px] leading-relaxed text-foreground`,children:[i.attachments?.length?(0,U.jsx)(FH,{attachments:i.attachments,isMobile:t,onOpenAttachmentPreview:o}):null,i.content]})}):i.role===`a2ui`&&i.aguiActivity?(0,U.jsx)(SH,{surfaceId:i.aguiActivity.surfaceId,messages:i.aguiActivity.messages,onAction:u}):(0,U.jsxs)(`div`,{className:`group mx-auto mb-3 w-full max-w-3xl px-6`,children:[(0,U.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs text-text-muted`,children:[(0,U.jsx)(jT,{className:`w-3.5 h-3.5`}),(0,U.jsx)(`span`,{children:e})]}),i.attachments?.length?(0,U.jsx)(FH,{attachments:i.attachments,isMobile:t,onOpenAttachmentPreview:o}):null,i.blocks?.length?(0,U.jsx)(hH,{message:i,isStreaming:n,onRespondToApproval:s,onRespondToAguiApproval:c}):(0,U.jsxs)(U.Fragment,{children:[i.reasoning?(0,U.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,U.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,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[n&&r&&!i.content?(0,U.jsx)(oE,{className:`h-4 w-4 animate-spin text-slate-500`}):(0,U.jsx)(MT,{className:`h-4 w-4 text-slate-400`}),(0,U.jsx)(`span`,{className:`truncate`,children:`思考过程`}),(0,U.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:n&&r&&!i.content?`生成中`:`已完成`})]}),(0,U.jsx)(NT,{className:`h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180`})]}),(0,U.jsx)(`div`,{className:`border-t border-slate-200/70 bg-white/70 dark:border-slate-800 dark:bg-slate-950/20`,children:(0,U.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,U.jsx)(tH,{content:i.reasoning})})})]}):null,i.tools?Object.values(i.tools).map((e,t)=>(0,U.jsxs)(`details`,{open:e.approvalStatus===`pending`||e.status===`paused`?!0:void 0,className:YD(`group/details mb-2 overflow-hidden rounded-md border text-sm transition-colors`,e.status===`paused`?`border-amber-200/80 bg-amber-50/25 text-slate-700 dark:border-amber-900/60 dark:bg-amber-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,U.jsx)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-3 py-2 font-medium`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`running`?(0,U.jsx)(oE,{className:`h-4 w-4 animate-spin text-slate-500`}):e.status===`paused`?(0,U.jsx)(dE,{className:`h-4 w-4 text-amber-500`}):e.status===`error`?(0,U.jsx)(FT,{className:`h-4 w-4 text-rose-500`}):(0,U.jsx)(MT,{className:`h-4 w-4 text-slate-400`}),(0,U.jsxs)(`span`,{children:[e.approvalStatus===`pending`?`等待审批:`:e.approvalStatus===`approved`?`已批准:`:e.approvalStatus===`rejected`?`已拒绝:`:e.status===`error`?`工具调用失败:`:`工具调用:`,e.name]})]})}),(0,U.jsxs)(`div`,{className:YD(`flex flex-col gap-3 border-t px-3 py-3 font-mono text-[13px] leading-relaxed`,e.status===`paused`?`border-amber-200/70 dark:border-amber-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,U.jsxs)(`div`,{className:`font-sans text-sm text-slate-700 dark:text-slate-200`,children:[(0,U.jsx)(`div`,{className:`font-medium`,children:e.approvalStatus===`approved`?`已批准该工具调用。`:e.approvalStatus===`rejected`?`已拒绝该工具调用。`:e.approvalMessage||`该工具调用需要人工确认后继续。`}),e.approvalLevel?(0,U.jsxs)(`div`,{className:YD(`mt-2 inline-flex items-center rounded border px-1.5 py-0.5 text-xs font-medium`,EH(e.approvalLevel)),children:[`审批级别:`,TH(e.approvalLevel)]}):null,e.serverLabel?(0,U.jsxs)(`div`,{className:`mt-1 text-xs text-amber-700/80 dark:text-amber-200/80`,children:[`MCP Server: `,e.serverLabel]}):null,e.approvalStatus===`pending`?(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?c?.({interruptId:e.approvalRequestId||``,approve:!0}):s({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,U.jsx)(MT,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,U.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?c?.({interruptId:e.approvalRequestId||``,approve:!1}):s({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,U.jsx)(FT,{className:`h-3.5 w-3.5`}),`拒绝`]})]}):(0,U.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,U.jsx)(MT,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,U.jsx)(FT,{className:`h-3.5 w-3.5 text-rose-500`}),e.approvalStatus===`approved`?`已批准`:`已拒绝`]})]}):null,e.args?(0,U.jsx)(LH,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,U.jsx)(LH,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,(0,U.jsx)(`div`,{className:`w-full break-words`,children:i.content?(0,U.jsx)(tH,{content:i.content}):n&&r&&!i.reasoning&&!i.tools?(0,U.jsx)(`span`,{className:`ml-1 mt-2 inline-block h-4 w-2 animate-pulse rounded-sm bg-emerald-500 align-middle opacity-80 shadow-sm`}):null})]}),i.aguiActivities?.map(e=>(0,U.jsx)(SH,{surfaceId:e.surfaceId,messages:e.messages,onAction:u},e.surfaceId)),(0,U.jsx)(RH,{isLastMessage:r,isStreaming:n,message:i,onDeleteFeedback:a,onSubmitFeedback:l})]})}function BH({agentName:e,isMobile:t,isStreaming:n,activity:r,contextIndicator:i,messages:a,isLoadingInitialHistory:o=!1,onDeleteFeedback:s,onOpenAttachmentPreview:c,onRespondToApproval:l,onRespondToAguiApproval:u,onSubmitFeedback:d,onSubmitAguiAction:f,onStopGeneration:p,onCancelRemote:m,checkpoints:h=[],onResumeCheckpoint:g,scrollRef:_}){let[v,y]=(0,b.useState)(0),[x,ee]=(0,b.useState)(0),[te,S]=(0,b.useState)(new Map),C=(0,b.useRef)(te);(0,b.useLayoutEffect)(()=>{let e=_.current;if(!e)return;let t=()=>{y(e.scrollTop),ee(e.clientHeight)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>t());return n.observe(e),()=>n.disconnect()},[_]);let ne=(0,b.useMemo)(()=>bH({items:a,scrollTop:v,viewportHeight:x,overscan:wH,defaultItemHeight:CH,measuredHeights:te,getItemKey:(e,t)=>e?.id||String(t)}),[te,a,v,x]),w=ne.visibleItems,re=(0,b.useCallback)((e,t,n)=>{if(!e||!Number.isFinite(t)||t<=0)return;let r=C.current,i=r.get(e)??CH;if(i===t)return;let a=new Map(r);a.set(e,t),C.current=a,S(a);let o=_.current;o&&n<o.scrollTop&&(o.scrollTop+=t-i,y(o.scrollTop))},[_]);return(0,U.jsxs)(`div`,{ref:_,onScroll:e=>y(e.currentTarget.scrollTop),className:YD(`custom-scrollbar relative min-h-0 flex-1 overflow-y-auto scroll-smooth`,t?`px-3 py-3`:`px-4 py-5`),children:[(0,U.jsx)(`div`,{className:YD(`mx-auto flex w-full max-w-[64rem] flex-col`,r?`pb-10 sm:pb-10`:`pb-6 sm:pb-8`),children:a.length===0&&o?(0,U.jsx)(PH,{}):a.length===0?(0,U.jsx)(NH,{agentName:e}):(0,U.jsx)(`div`,{style:{height:ne.totalHeight},className:`relative`,children:w.map(r=>(0,U.jsx)(DH,{messageId:r.item.id||String(r.index),top:r.top,onMeasure:re,children:r.item.role===`system`?(0,U.jsx)(IH,{message:r.item}):(0,U.jsx)(zH,{agentName:e,isMobile:t,isStreaming:n,isLastMessage:r.index===a.length-1,message:r.item,onDeleteFeedback:s,onOpenAttachmentPreview:c,onRespondToApproval:l,onRespondToAguiApproval:u,onSubmitFeedback:d,onSubmitAguiAction:f})},r.item.id||r.index))})}),(0,U.jsx)(gH,{}),v>320?(0,U.jsx)(`button`,{type:`button`,onClick:()=>{let e=_.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`})},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:(0,U.jsx)(kT,{className:`h-4 w-4`})}):null,r?(0,U.jsx)(`div`,{className:`sticky bottom-1 z-20 mx-auto flex w-full max-w-[64rem] justify-end`,children:(0,U.jsx)(MH,{activity:r,contextIndicator:i,onStopGeneration:p,onCancelRemote:m})}):null]})}var VH=_j,HH=vj,UH=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(yj,{ref:n,className:YD(`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}));UH.displayName=yj.displayName;var WH=b.forwardRef(({className:e,children:t,...n},r)=>(0,U.jsxs)(HH,{children:[(0,U.jsx)(UH,{}),(0,U.jsxs)(bj,{ref:r,className:YD(`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,U.jsxs)(Cj,{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,U.jsx)(xE,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));WH.displayName=bj.displayName;var GH=({className:e,...t})=>(0,U.jsx)(`div`,{className:YD(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});GH.displayName=`DialogHeader`;var KH=({className:e,...t})=>(0,U.jsx)(`div`,{className:YD(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});KH.displayName=`DialogFooter`;var qH=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(xj,{ref:n,className:YD(`text-lg font-semibold leading-none tracking-tight`,e),...t}));qH.displayName=xj.displayName;var JH=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(Sj,{ref:n,className:YD(`text-sm text-muted-foreground`,e),...t}));JH.displayName=Sj.displayName;function YH(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function XH(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function ZH({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,U.jsx)(VH,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,U.jsxs)(WH,{className:YD(`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:XH(t,n),children:[(0,U.jsx)(`div`,{className:`flex items-center gap-3 border-b border-slate-800 px-4 py-3 pr-16`,children:(0,U.jsx)(qH,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,U.jsx)(`div`,{className:YD(`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,U.jsx)(`img`,{src:e.url,alt:e.name,className:YD(`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:YH(t,n),onLoad:e=>{let t=e.currentTarget;i({width:t.naturalWidth,height:t.naturalHeight})}}):(0,U.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 QH(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 $H(e){return/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]/u.test(e)}function eU(e){let t=String(e||``).trim();if(!t)return 0;let n=0,r=0;for(let e of t){if($H(e)){n+=1;continue}r+=1}return Math.max(1,n+Math.ceil(r/4))}function tU(e){if(!e)return 0;if(e.role===`system`)return e.eventType===`context_checkpoint`?eU(e.summary||``):0;let t=eU(e.content||``);return e.tools&&(t+=Object.values(e.tools).reduce((e,t)=>e+eU(t?.name||``)+eU(t?.args||``)+eU(t?.output||``),0)),t}function nU(e){return e?QH(e.context_window_tokens)??QH(e?.limits?.context_window_tokens):null}function rU(e){return e?QH(e.auto_compact_threshold_percentage)??84:84}function iU({messages:e,draftInput:t,selectedModel:n}){let r=nU(n);if(!r)return null;let i=[...e||[]].reverse().find(e=>e?.role===`system`&&e?.eventType===`context_checkpoint`&&e?.status===`running`);if(i){let e=tU(i);return{label:`正在压缩上下文…`,phase:`compressing`,usedTokens:e,contextWindowTokens:r,percent:Math.min(100,Math.max(0,Math.round(e/r*100)))}}let a=(e||[]).reduce((e,t)=>e+tU(t),0)+eU(t||``);if(a<=0)return null;let o=Math.min(100,Math.max(0,Math.round(a/r*100)));return o>=rU(n)?{label:`估算上下文 ${o}% · 即将压缩`,phase:`warning`,percent:o,usedTokens:a,contextWindowTokens:r}:{label:`估算上下文 ${o}%`,phase:`normal`,percent:o,usedTokens:a,contextWindowTokens:r}}function aU(e){return e.requestedSessionId===e.activeSessionId&&e.requestToken===e.activeRequestToken}function oU({agentName:e,isMobile:t,onDeleteFeedback:n,onSubmitFeedback:r,onRespondToApproval:i,onRespondToAguiApproval:a,onSubmitAguiAction:o,onStopGeneration:s,onCancelRemote:c,checkpointResumeEnabled:l=!1,onResumeCheckpoint:u,onLoadOlderSessionMessages:d}){let f=Rt(e=>e.messages),p=Me(e=>e.currentSessionId),m=Me(e=>e.isLoadingSessions),h=D(e=>!!(e.getSessionActivity(p)&&e.isSessionStreaming(p))),g=D(e=>e.getSessionActivity(p)),_=HC(e=>e.getSessionCheckpoints(p)),v=Me(e=>p?e.messageHistory[p]:null),y=m||!!v?.isLoadingInitial,x=w(e=>e.input),ee=ge(e=>e.availableModels),te=ge(e=>e.selectedModel),S=w(e=>e.previewAttachment),C=w(e=>e.previewImageSize),ne=(0,b.useRef)(null),re=(0,b.useRef)(!0),ie=(0,b.useRef)(!1),ae=(0,b.useRef)(0),oe=(0,b.useRef)(h),se=(0,b.useRef)(!1),ce=(0,b.useRef)(null),le=(0,b.useRef)(!0),ue=(0,b.useMemo)(()=>ee.find(e=>e.id===te)||null,[ee,te]),T=(0,b.useMemo)(()=>iU({messages:f,draftInput:x,selectedModel:ue}),[x,f,ue]);return(0,b.useEffect)(()=>{oe.current=h},[h]),(0,b.useEffect)(()=>{le.current=!0,re.current=!0,ie.current=!1,ae.current=0,se.current=!1,ce.current=null},[p]),(0,b.useEffect)(()=>{let e=ne.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<ae.current-2;if(ae.current=e.scrollTop,e.scrollTop<200&&p&&v?.hasMore&&!v.isLoadingOlder&&!se.current&&d){let t=e.scrollHeight,n=p,r=Symbol(n);se.current=!0,ce.current=r,d(n).then(()=>{aU({requestedSessionId:n,activeSessionId:Me.getState().currentSessionId,requestToken:r,activeRequestToken:ce.current})&&requestAnimationFrame(()=>{if(!aU({requestedSessionId:n,activeSessionId:Me.getState().currentSessionId,requestToken:r,activeRequestToken:ce.current}))return;let e=ne.current;if(!e)return;let i=e.scrollHeight-t;e.scrollTop+=i,ae.current=e.scrollTop})}).finally(()=>{ce.current===r&&(ce.current=null,se.current=!1)})}if(oe.current&&n){ie.current=!0,re.current=!1;return}if(ie.current){let e=t<=12;ie.current=!e,re.current=e;return}re.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[v,p,d]),(0,b.useEffect)(()=>{let e=ne.current;if(e){if(f.length>0&&le.current){let e=Me.getState().currentSessionId,t=ne.current,n=t?t.style.scrollBehavior:``;t&&(t.style.scrollBehavior=`auto`,t.scrollTop=t.scrollHeight,ae.current=t.scrollTop);let r=0,i=t?.scrollHeight??-1,a=!1,o=0,s=()=>{a||(a=!0,t&&(t.style.scrollBehavior=n),re.current=!0,ie.current=!1,le.current=!1)},c=()=>{if(a)return;if(Me.getState().currentSessionId!==e){a=!0;return}let t=ne.current;if(t){if(t.scrollHeight!==i)i=t.scrollHeight,t.scrollTop=t.scrollHeight,ae.current=t.scrollTop,r=0;else if(r+=1,r>=3){s();return}o=requestAnimationFrame(c)}},l=window.setTimeout(s,2e3);return o=requestAnimationFrame(c),()=>{cancelAnimationFrame(o),window.clearTimeout(l),s()}}re.current&&(e.scrollTop=e.scrollHeight,ae.current=e.scrollTop)}},[f,h]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(BH,{agentName:e,isMobile:t,isStreaming:h,activity:g,contextIndicator:T,messages:f,isLoadingInitialHistory:y,onDeleteFeedback:n,onOpenAttachmentPreview:e=>{w.getState().setPreviewAttachment(e),w.getState().setPreviewImageSize(null)},onRespondToApproval:i,onRespondToAguiApproval:a,onSubmitFeedback:r,onSubmitAguiAction:o,onStopGeneration:s,onCancelRemote:c,checkpoints:l?_:[],onResumeCheckpoint:u,scrollRef:ne}),(0,U.jsx)(ZH,{attachment:S,isMobile:t,previewImageSize:C,onClose:()=>{w.getState().setPreviewAttachment(null),w.getState().setPreviewImageSize(null)},onImageLoad:e=>w.getState().setPreviewImageSize(e)})]})}function sU({indicator:e}){let t=Math.max(0,Math.min(100,e.percent??0));return(0,U.jsxs)(`div`,{className:`group relative flex h-8 w-8 items-center justify-center`,children:[(0,U.jsx)(`div`,{className:YD(`flex h-4 w-4 items-center justify-center rounded-full`,e.phase===`warning`||e.phase===`compressing`||t>=85?`text-red-500`:`text-[#a5abb2]`),title:e.label,children:(0,U.jsx)(`div`,{className:`flex h-3 w-3 items-center justify-center rounded-full`,style:{background:`conic-gradient(currentColor ${t*3.6}deg, #edf0f2 0deg)`},children:(0,U.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-background`})})}),(0,U.jsxs)(`div`,{className:`pointer-events-auto absolute bottom-[calc(100%+0.75rem)] left-1/2 z-30 hidden w-max -translate-x-1/2 rounded-2xl border border-border/70 bg-background px-4 py-3 text-center text-sm leading-5 text-foreground shadow-[0_14px_42px_rgba(15,23,42,0.16)] group-hover:block dark:shadow-[0_14px_42px_rgba(0,0,0,0.4)]`,children:[(0,U.jsx)(`div`,{className:`mb-1 whitespace-nowrap font-light text-text-secondary`,children:`估算上下文`}),(0,U.jsxs)(`div`,{className:`whitespace-nowrap font-light`,children:[t,`% 已使用`]}),(0,U.jsx)(`div`,{className:`whitespace-nowrap font-light text-text-muted`,children:e.usedTokens&&e.contextWindowTokens?`${cU(e.usedTokens)} / ${cU(e.contextWindowTokens)}`:e.label})]})]})}function cU(e){return e>=1e6?`${(e/1e6).toFixed(1)}m`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e)}function lU({label:e,options:t,value:n,onChange:r,title:i}){let[a,o]=(0,b.useState)(!1),s=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),(0,U.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),title:i,className:`flex h-8 max-w-[12rem] items-center gap-1 overflow-hidden rounded-full px-2 text-sm font-normal leading-[18px] text-text-primary hover:bg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-center`,children:e}),(0,U.jsx)(NT,{className:YD(`h-4 w-4 shrink-0 text-text-secondary transition-transform`,a&&`rotate-180`)})]}),a?(0,U.jsx)(`div`,{className:`absolute bottom-[calc(100%+0.5rem)] left-0 z-30 max-h-[min(50vh,20rem)] min-w-[10rem] max-w-[16rem] overflow-y-auto rounded-xl border border-border bg-popover p-1.5 text-sm shadow-[0_10px_28px_rgba(0,0,0,0.18)]`,children:t.map(e=>(0,U.jsx)(`button`,{type:`button`,onClick:()=>{r(e.value),o(!1)},className:YD(`flex w-full items-center rounded-lg px-2.5 py-1.5 text-left leading-5 transition-colors`,e.value===n?`bg-muted text-text-primary`:`text-text-secondary hover:bg-muted hover:text-text-primary`),children:(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label})},e.value))}):null]})}var uU=[{value:`ask`,label:`请求批准`,description:`有副作用的操作执行前先确认`,icon:qT},{value:`risk`,label:`风险操作需确认`,description:`只对命令、写入和外部副作用确认`,icon:dE},{value:`full`,label:`完全访问`,description:`本次会话不再为默认规则弹出确认`,icon:uE}],dU={ask:`请求批准`,risk:`风险确认`,full:`完全访问`};function fU({approvalPolicy:e}){let[t,n]=(0,b.useState)(!1),r=(0,b.useRef)(null),i=be(e=>e.permissionMode),a=be(e=>e.setPermissionMode),o=uU.filter(t=>!e||e.Modes.includes(t.value));return(0,b.useEffect)(()=>{o.some(e=>e.value===i)||a(e?.DefaultMode||o[0]?.value||`risk`)},[e?.DefaultMode,i,a,o]),(0,b.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,U.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex h-8 items-center gap-1 rounded-full px-2 text-[13px] text-text-secondary transition hover:bg-muted hover:text-text-primary`,"aria-expanded":t,"aria-haspopup":`menu`,title:`设置本次会话的工具审批规则`,children:[(0,U.jsx)(dE,{className:`h-3.5 w-3.5`}),(0,U.jsx)(`span`,{children:dU[i]}),(0,U.jsx)(NT,{className:YD(`h-3.5 w-3.5 transition-transform`,t&&`rotate-180`)})]}),t?(0,U.jsxs)(`div`,{role:`menu`,"aria-label":`工具权限`,className:`absolute bottom-[calc(100%+0.6rem)] left-0 z-30 w-[19rem] rounded-2xl border border-border/80 bg-popover p-1.5 shadow-[0_12px_30px_rgba(15,23,42,0.14)]`,children:[(0,U.jsx)(`div`,{className:`px-2.5 pb-1.5 pt-1 text-[11px] text-text-muted`,children:`本次会话的默认审批规则`}),o.map(e=>{let t=e.icon,r=e.value===i;return(0,U.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,onClick:()=>{a(e.value),n(!1)},className:YD(`flex w-full items-center gap-2.5 rounded-xl px-2.5 py-2 text-left transition-colors`,r?`bg-primary/[0.08]`:`hover:bg-muted/75`),children:[(0,U.jsx)(t,{className:YD(`h-[17px] w-[17px] shrink-0`,r?`text-primary`:`text-text-muted`)}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:YD(`block text-[13px] font-medium leading-5`,r?`text-text-primary`:`text-text-secondary`),children:e.label}),(0,U.jsx)(`span`,{className:`block text-[11px] leading-4 text-text-muted`,children:e.description})]}),r?(0,U.jsx)(MT,{className:`h-4 w-4 shrink-0 text-primary`,"aria-hidden":`true`}):null]},e.value)})]}):null]})}function pU({attachments:e,composerContextIndicator:t,composerMaxHeight:n,fileInputRef:r,input:i,isMobile:a,isStreaming:o,approvalEnabled:s=!1,approvalPolicy:c,queuedDrafts:l,onAppendAttachments:u,onInputChange:d,onPaste:f,onRemoveAttachment:p,onStopGeneration:m,onCancelRemote:h,onSubmit:g,textareaRef:_}){let v=a?`发送消息...`:`发送消息…`,y=h?`保留恢复点并结束本次执行`:`停止生成`,b=ge(e=>e.availableModels),x=ge(e=>e.selectedModel),ee=ge(e=>e.thinkingMode),te=ge(e=>e.setSelectedModel),S=ge(e=>e.setThinkingMode),C=b.find(e=>e.id===x)?.display_name||x||``,ne=e=>e===`enabled`?`开启思考`:e===`disabled`?`关闭思考`:`思考自动`,w=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`;return(0,U.jsx)(`div`,{className:`relative z-10 flex-shrink-0 bg-background/95 px-3 py-3 backdrop-blur sm:px-4 sm:py-3`,children:(0,U.jsxs)(`div`,{className:`mx-auto w-full max-w-[64rem]`,children:[l.length>0?(0,U.jsxs)(`div`,{className:`mb-2 rounded-2xl border border-amber-200/80 bg-amber-50/80 px-3 py-2 text-xs text-amber-900 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100`,children:[(0,U.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`span`,{className:`font-semibold`,children:[`发送队列 · `,l.length]}),(0,U.jsx)(`span`,{className:`text-amber-700/75 dark:text-amber-200/75`,children:`当前回复完成后依次发送`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l.slice(0,3).map((e,t)=>{let n=e.text.trim()||(e.attachments.length>0?`仅附件消息`:`空消息`);return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-background/70 px-2 py-1.5`,children:[(0,U.jsx)(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-amber-100 font-mono text-[10px] text-amber-700 dark:bg-amber-900/50 dark:text-amber-100`,children:t+1}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:n}),e.attachments.length>0?(0,U.jsxs)(`span`,{className:`flex-shrink-0 rounded-full bg-amber-100 px-2 py-0.5 text-[10px] text-amber-700 dark:bg-amber-900/50 dark:text-amber-100`,children:[e.attachments.length,` 附件`]}):null]},`${t}-${n}-${e.attachments.length}`)}),l.length>3?(0,U.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-amber-700/80 dark:text-amber-200/80`,children:[`还有 `,l.length-3,` 条等待发送`]}):null]})]}):null,(0,U.jsx)(`div`,{className:`relative rounded-[26px] bg-surface shadow-[0_0_0_0.5px_rgba(15,23,42,0.08),0_3px_7.5px_rgba(0,0,0,0.04),0_0_20px_rgba(0,0,0,0.05)] dark:shadow-[0_0_0_0.5px_rgba(255,255,255,0.06),0_3px_7.5px_rgba(0,0,0,0.2)]`,children:(0,U.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,U.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),o){h?h():m();return}let n=i.trim();!n&&e.length===0||g(n,e)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files&&e.dataTransfer.files.length>0&&u(Array.from(e.dataTransfer.files))},className:`relative flex min-h-[76px] min-w-0 flex-1 flex-col rounded-[26px] border border-border/45 bg-background px-4 pb-1.5 pt-2 transition-all focus-within:border-primary/40 focus-within:ring-2 focus-within:ring-primary/15`,children:[e.length>0?(0,U.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-2`,children:e.map((e,t)=>(0,U.jsxs)(`div`,{className:YD(`group relative flex items-center gap-2 rounded-xl border border-border bg-background px-3 py-2 text-xs`,a?`max-w-full`:`max-w-[14rem]`),children:[(0,U.jsx)(`span`,{className:`flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-muted text-text-muted`,children:(0,U.jsx)(rE,{className:`h-3.5 w-3.5`})}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate font-medium text-text-primary`,children:e.name}),(0,U.jsx)(`span`,{className:`block text-[10px] text-text-muted`,children:w(e.size)})]}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>p(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,U.jsx)(`span`,{className:`text-[11px] leading-none`,children:`×`})})]},`${e.name}-${e.size}-${t}`))}):null,(0,U.jsx)(`textarea`,{ref:_,rows:1,value:i,onChange:d,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},onPaste:f,placeholder:v,className:YD(`custom-scrollbar max-h-[112px] min-h-[48px] w-full resize-none overflow-y-auto border-0 bg-transparent px-0 pb-0 pt-1 text-[14px] leading-6 text-text-primary outline-none placeholder:text-text-muted/55`,a?`text-[16px]`:`text-[14px]`),style:{maxHeight:`${n}px`,overflowY:`auto`}}),(0,U.jsxs)(`div`,{className:`mt-auto flex min-h-8 items-center justify-between gap-2 pt-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`label`,{className:`flex h-8 w-8 items-center justify-center rounded-full text-text-muted transition hover:bg-muted hover:text-text-secondary`,title:`上传附件`,children:[(0,U.jsx)(`input`,{ref:r,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(u(Array.from(e.target.files)),e.target.value=``)}}),(0,U.jsx)(rE,{className:`h-[18px] w-[18px]`})]}),s?(0,U.jsx)(fU,{approvalPolicy:c}):null,b.length>0?(0,U.jsx)(lU,{label:C||x,title:C||x,value:x,onChange:e=>te(e),options:b.map(e=>({value:e.id,label:e.display_name||e.id}))}):null,(0,U.jsx)(lU,{label:ne(ee),title:`控制模型 thinking/reasoning 参数`,value:ee,onChange:e=>S(vt(e)),options:[{value:`auto`,label:`思考自动`},{value:`enabled`,label:`开启思考`},{value:`disabled`,label:`关闭思考`}]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t?(0,U.jsx)(sU,{indicator:t}):null,(0,U.jsx)(`button`,{type:`submit`,disabled:!o&&!i.trim()&&e.length===0,className:YD(`flex h-8 w-8 items-center justify-center rounded-full transition-all`,o||i.trim()||e.length>0?`bg-[#1f1f1f] text-white hover:opacity-80`:`bg-muted text-text-muted/45`),title:o?y:`发送消息`,children:o?(0,U.jsx)(mE,{className:`h-3.5 w-3.5 fill-current`}):(0,U.jsx)(AT,{className:`h-[18px] w-[18px]`})})]})]})]})})})]})})}function mU(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function hU(e,t){let n=new Map;for(let t of e)n.set(mU(t),t);for(let e of t)n.set(mU(e),e);return Array.from(n.values())}function gU(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function _U({composerMaxHeight:e,submitDraft:t,stopGeneration:n,cancelRemote:r,isMobile:i,approvalEnabled:a=!1,approvalPolicy:o}){let s=w(e=>e.input),c=w(e=>e.attachments),l=Me(e=>e.currentSessionId),u=D(e=>!!(e.getSessionActivity(l)&&e.isSessionStreaming(l))),d=w(e=>e.queuedDrafts),f=Rt(e=>e.messages),p=ge(e=>e.availableModels),m=ge(e=>e.selectedModel),h=(0,b.useRef)(null),g=(0,b.useRef)(null),_=(0,b.useMemo)(()=>p.find(e=>e.id===m)||null,[p,m]),v=(0,b.useMemo)(()=>iU({messages:f,draftInput:s,selectedModel:_}),[s,f,_]),y=(0,b.useCallback)((e,n)=>{!e&&n.length===0||(w.getState().setInput(``),w.getState().setAttachments([]),t(e,n))},[t]);(0,b.useEffect)(()=>{g.current&&(g.current.style.height=`auto`,g.current.style.height=`${Math.min(g.current.scrollHeight,e)}px`)},[s,e]);let x=t=>{w.getState().setInput(t.target.value),t.target.style.height=`auto`,t.target.style.height=`${Math.min(t.target.scrollHeight,e)}px`},ee=e=>{e.length&&w.getState().setAttachments(t=>hU(t,e))};return(0,U.jsx)(pU,{attachments:c,composerContextIndicator:v,composerMaxHeight:e,fileInputRef:h,input:s,isMobile:i,isStreaming:u,approvalEnabled:a,approvalPolicy:o,queuedDrafts:d,onAppendAttachments:ee,onInputChange:x,onPaste:e=>{let t=gU(e);t.length&&(e.preventDefault(),e.stopPropagation(),ee(t))},onRemoveAttachment:e=>w.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:n,onCancelRemote:r,onSubmit:y,textareaRef:g})}var vU=(0,b.lazy)(()=>q(()=>import(`./NativeTerminalPanel-MDTopWMO.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function yU({availableModels:e,selectedModel:t,onSelectModel:n,selectedModelLabel:r,modelCatalogLoaded:i,modelSource:a,thinkingEnabled:o,thinkingMode:s,onSelectThinkingMode:c,compact:l=!1}){let u=YD(`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,U.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:u,children:e.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.display_name||e.id},e.id))}):r?(0,U.jsx)(`span`,{className:YD(u,`inline-flex max-w-full items-center`,l?`justify-start`:``),title:a||r,children:(0,U.jsx)(`span`,{className:`truncate`,children:r})}):(0,U.jsx)(`span`,{className:`text-sm text-slate-400`,children:i?`未配置模型`:`Loading models...`}),f=o?(0,U.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:YD(u,l?``:`max-w-[9rem]`),title:`控制模型 thinking/reasoning 参数`,children:[(0,U.jsx)(`option`,{value:`auto`,children:`思考自动`}),(0,U.jsx)(`option`,{value:`enabled`,children:`开启思考`}),(0,U.jsx)(`option`,{value:`disabled`,children:`关闭思考`})]}):null;return(0,U.jsxs)(`div`,{className:YD(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function bU({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:v,nativeManagementLink:y,nativeTerminal:x,nativeLauncherMode:ee=!1}){let[te,S]=(0,b.useState)(!1),C=!!x?.Enabled,ne=n?i?(0,U.jsx)(tE,{className:`h-5 w-5`}):(0,U.jsx)(nE,{className:`h-5 w-5`}):r?(0,U.jsx)(tE,{className:`h-5 w-5`}):(0,U.jsx)(nE,{className:`h-5 w-5`});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`header`,{className:YD(`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,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[ee?null:(0,U.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:ne}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base`,children:e}),(0,U.jsx)(`div`,{className:`text-[11px] text-slate-400 dark:text-slate-500`,children:ee?`原生运行时入口`:`智能体`})]})]}),n?(0,U.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,U.jsx)(BT,{className:`h-5 w-5`})}):(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[y?(0,U.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.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,U.jsx)(VT,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:y.label})]}):null,_?(0,U.jsxs)(`button`,{type:`button`,onClick:v,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,U.jsx)(KT,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:`Workspace`})]}):null,C?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>S(!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,U.jsx)(pE,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:`TUI`})]}):null,!ee&&n?(0,U.jsx)(yU,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0}):null,!ee&&t?(0,U.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,U.jsx)(Dj,{open:h,onOpenChange:g,children:(0,U.jsxs)(jj,{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,U.jsxs)(Mj,{className:`text-left`,children:[(0,U.jsx)(Pj,{children:`会话设置`}),(0,U.jsx)(Fj,{className:`sr-only`,children:`调整当前会话的模型和 Workspace 操作。`})]}),(0,U.jsxs)(`div`,{className:`mt-6 flex flex-col gap-4`,children:[_?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),v()},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,U.jsx)(KT,{className:`h-4 w-4`}),`工作区文件`]}):null,C?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),S(!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,U.jsx)(pE,{className:`h-4 w-4`}),`原生 TUI`]}):null,y?(0,U.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.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,U.jsx)(VT,{className:`h-4 w-4`}),y.label]}):null,ee?(0,U.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,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`模型`}),(0,U.jsx)(yU,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`当前会话`}),(0,U.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,U.jsx)(`span`,{className:`break-all font-mono`,children:t}):`新对话尚未创建会话 ID`})]})]})]})]})}):null,x&&te?(0,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(vU,{capability:x,open:te,sessionId:t,onClose:()=>S(!1)})}):null]})}var xU=(0,b.lazy)(()=>q(()=>import(`./NativeTerminalPanel-MDTopWMO.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function SU({productLabel:e=`原生运行时`,nativeManagementLink:t,nativeTerminal:n,workspaceEnabled:r,onOpenWorkspace:i}){let a=!!n?.Enabled,[o,s]=(0,b.useState)(!1);return(0,U.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,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col justify-center`,children:(0,U.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,U.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,U.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,U.jsx)(dE,{className:`h-3.5 w-3.5`}),e,` native runtime`]}),(0,U.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl`,children:`对话请使用原生管理台`}),(0,U.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,U.jsxs)(`div`,{className:`grid gap-4 p-6 md:grid-cols-3 sm:p-8`,children:[(0,U.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,U.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,U.jsx)(QT,{className:`h-5 w-5`})}),(0,U.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生管理台`}),(0,U.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。`}),t?(0,U.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,U.jsx)(VT,{className:`h-4 w-4`}),`打开`,t.label]}):(0,U.jsx)(`div`,{className:`mt-5 rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm leading-6 text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-200`,children:`当前访问模式不开放原生管理入口。需要完整对话体验时,请使用 owner/private 链接或 CLI。`})]}),(0,U.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,U.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,U.jsx)(KT,{className:`h-5 w-5`})}),(0,U.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`Workspace 文件管理`}),(0,U.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。`}),r?(0,U.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,U.jsx)(KT,{className:`h-4 w-4`}),`打开 Workspace`]}):(0,U.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,U.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,U.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,U.jsx)(pE,{className:`h-5 w-5`})}),(0,U.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生 TUI`}),(0,U.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。`}),a?(0,U.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,U.jsx)(pE,{className:`h-4 w-4`}),`打开 TUI`]}):(0,U.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,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(xU,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var CU=[],wU=[];(()=>{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?wU:CU).push(n+=e[t])})();function TU(e){if(e<768)return!1;for(let t=0,n=CU.length;;){let r=t+n>>1;if(e<CU[r])n=r;else if(e>=wU[r])t=r+1;else return!0;if(t==n)return!1}}function EU(e){return e>=127462&&e<=127487}var DU=8205;function OU(e,t,n=!0,r=!0){return(n?kU:AU)(e,t,r)}function kU(e,t,n){if(t==e.length)return t;t&&MU(e.charCodeAt(t))&&NU(e.charCodeAt(t-1))&&t--;let r=jU(e,t);for(t+=PU(r);t<e.length;){let i=jU(e,t);if(r==DU||i==DU||n&&TU(i))t+=PU(i),r=i;else if(EU(i)){let n=0,r=t-2;for(;r>=0&&EU(jU(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function AU(e,t,n){for(;t>0;){let r=kU(e,t-2,n);if(r<t)return r;t--}return 0}function jU(e,t){let n=e.charCodeAt(t);if(!NU(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return MU(r)?(n-55296<<10)+(r-56320)+65536:n}function MU(e){return e>=56320&&e<57344}function NU(e){return e>=55296&&e<56320}function PU(e){return e<65536?1:2}var FU=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]=GU(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),LU.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]=GU(this,e,t);let n=[];return this.decompose(e,t,n,0),LU.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 VU(this),i=new VU(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 VU(this,e)}iterRange(e,t=this.length){return new HU(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 UU(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 IU(t):LU.from(IU.split(t,[]))}},IU=class e extends FU{constructor(e,t=RU(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 WU(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(BU(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=zU(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]=GU(this,t,n);let i=zU(this.text,zU(r.text,BU(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):LU.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
134
|
-
`){[e,t]=GU(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}},LU=class e extends FU{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]=GU(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=`
|
|
135
|
-
`){[e,t]=GU(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 IU(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 IU&&c&&(n=u[u.length-1])instanceof IU&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new IU(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)}};FU.empty=new IU([``],0);function RU(e){let t=-1;for(let n of e)t+=n.length+1;return t}function zU(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 BU(e,t,n){return zU(e,[``],t,n)}var VU=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 IU?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 IU?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=`
|
|
136
|
-
`,this;e--}else if(r instanceof IU){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 IU?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)}},HU=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new VU(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!=``}},UU=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`&&(FU.prototype[Symbol.iterator]=function(){return this.iter()},VU.prototype[Symbol.iterator]=HU.prototype[Symbol.iterator]=UU.prototype[Symbol.iterator]=function(){return this});var WU=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 GU(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function KU(e,t,n=!0,r=!0){return OU(e,t,n,r)}function qU(e){return e>=56320&&e<57344}function JU(e){return e>=55296&&e<56320}function YU(e,t){let n=e.charCodeAt(t);if(!JU(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return qU(r)?(n-55296<<10)+(r-56320)+65536:n}function XU(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function ZU(e){return e<65536?1:2}var QU=/\r\n?|\n/,$U=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})($U||={}),eW=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){iW(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:oW(this,e)}mapDesc(e,t=!1){return e.empty?this:aW(this,e,t)}mapPos(e,t=-1,n=$U.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!=$U.Simple&&c>=e&&(n==$U.TrackDel&&r<e&&c>e||n==$U.TrackBefore&&r<e||n==$U.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)}},tW=class e extends eW{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 iW(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return aW(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(FU.empty);r.push(a?t.slice(i,i+a):FU.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:oW(this,e,!0)}map(e,t=!1){return e.empty?this:aW(this,e,t,!0)}iterChanges(e,t=!1){iW(this,e,t)}get desc(){return eW.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new sW(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);nW(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;nW(n,e,t),t>0&&rW(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);nW(n,e,-1),nW(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:eW.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&&nW(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`?FU.of(l.split(r||QU)):l:FU.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&nW(i,e-o,-1),nW(i,s-e,d),rW(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(FU.empty);r[e]=FU.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 nW(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 rW(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(FU.empty);e.push(n)}}function iW(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=FU.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 aW(e,t,n,r=!1){let i=[],a=r?[]:null,o=new sW(e),s=new sW(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);nW(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(nW(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(nW(i,0,o.ins),a&&rW(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;nW(i,t,e<o.i?o.ins:0),a&&e<o.i&&rW(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?tW.createSet(i,a):eW.create(i);else throw Error(`Mismatched change set lengths`)}function oW(e,t,n=!1){let r=[],i=n?[]:null,a=new sW(e),o=new sW(t);for(let e=!1;;)if(a.done&&o.done)return i?tW.createSet(r,i):eW.create(r);else if(a.ins==0)nW(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)nW(r,0,o.ins,e),i&&rW(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;nW(r,t,n,e),i&&n&&rW(i,r,o.text)}else o.ins==-1?(nW(r,a.off?0:a.len,t,e),i&&rW(i,r,a.textBit(t))):(nW(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&rW(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 sW=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?FU.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?FU.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)}},cW=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 J.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return J.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 J.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},J=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=>cW.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 cW.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?cW.create(t,e,48|a):cW.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 lW(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var uW=0,dW=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=uW++,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:fW),!!t.static,t.enables)}of(e){return new pW([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new pW(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new pW(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function fW(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var pW=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=uW++}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)||hW(e,c)){let r=t(e);if(a?!mW(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=OW(o,c);if(this.dependencies.every(t=>t instanceof dW?o.facet(t)===e.facet(t):t instanceof vW?o.field(t,!1)==e.field(t,!1):!0)||(a?mW(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 mW(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 hW(e,t){let n=!1;for(let r of t)DW(e,r)&1&&(n=!0);return n}function gW(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=OW(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)DW(e,t);return e.values[o]=s(e),1},update(e,n){if(!hW(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=hW(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&fW(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 _W=dW.define({static:!0}),vW=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(uW++,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(_W).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(_W),i=n.facet(_W),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,_W.of({field:this,create:e})]}get extension(){return this}},yW={lowest:4,low:3,default:2,high:1,highest:0};function bW(e){return t=>new SW(t,e)}var xW={highest:bW(yW.highest),high:bW(yW.high),default:bW(yW.default),low:bW(yW.low),lowest:bW(yW.lowest)},SW=class{constructor(e,t){this.inner=e,this.prec=t}},CW=class e{of(e){return new wW(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},wW=class{constructor(e,t){this.compartment=e,this.inner=t}},TW=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 EW(t,n,o))e instanceof vW?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,fW(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=>gW(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function EW(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 wW&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof wW){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 SW)a(e.inner,e.prec);else if(e instanceof vW)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof pW)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,yW.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,yW.default),r.reduce((e,t)=>e.concat(t))}function DW(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 OW(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var kW=dW.define(),AW=dW.define({combine:e=>e.some(e=>e),static:!0}),jW=dW.define({combine:e=>e.length?e[0]:void 0,static:!0}),MW=dW.define(),NW=dW.define(),PW=dW.define(),FW=dW.define({combine:e=>e.length?e[0]:!1}),IW=class{constructor(e,t){this.type=e,this.value=t}static define(){return new LW}},LW=class{of(e){return new IW(this,e)}},RW=class{constructor(e){this.map=e}of(e){return new zW(this,e)}},zW=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 RW(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}};zW.reconfigure=zW.define(),zW.appendConfig=zW.define();var BW=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&&lW(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]==`.`))}};BW.time=IW.define(),BW.userEvent=IW.define(),BW.addToHistory=IW.define(),BW.remote=IW.define();function VW(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 HW(e,t,n){let r,i,a;return n?(r=t.changes,i=tW.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:zW.mapEffects(e.effects,r).concat(zW.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function UW(e,t,n){let r=t.selection,i=JW(t.annotations);return t.userEvent&&(i=i.concat(BW.userEvent.of(t.userEvent))),{changes:t.changes instanceof tW?t.changes:tW.of(t.changes||[],n,e.facet(jW)),selection:r&&(r instanceof J?r:J.single(r.anchor,r.head)),effects:JW(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function WW(e,t,n){let r=UW(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=HW(r,UW(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=BW.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return KW(n?GW(i):i)}function GW(e){let t=e.startState,n=!0;for(let r of t.facet(MW)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:VW(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=tW.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=BW.create(t,r,e.selection&&e.selection.map(i),zW.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(NW);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof BW?i:Array.isArray(i)&&i.length==1&&i[0]instanceof BW?i[0]:WW(t,JW(i),!1)}return e}function KW(e){let t=e.startState,n=t.facet(PW),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=HW(r,UW(t,a,e.changes.newLength),!0))}return r==e?e:BW.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var qW=[];function JW(e){return e==null?qW:Array.isArray(e)?e:[e]}var YW=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(YW||={}),XW=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,ZW;try{ZW=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function QW(e){if(ZW)return ZW.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||XW.test(n)))return!0}return!1}function $W(e){return t=>{if(!/\S/.test(t))return YW.Space;if(QW(t))return YW.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return YW.Word;return YW.Other}}var eG=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++)DW(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 DW(this,n),OW(this,n)}update(...e){return WW(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(CW.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(zW.reconfigure)?(n=null,r=e.value):e.is(zW.appendConfig)&&(n=null,r=JW(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=TW.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(AW)?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:J.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=JW(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=zW.mapEffects(a,c).concat(zW.mapEffects(JW(o.effects),l))}return{changes:r,selection:J.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof tW?t:tW.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return FU.of(t.split(this.facet(e.lineSeparator)||QU))}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:(DW(this,t),OW(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 vW&&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:J.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=TW.resolve(t.extensions||[],new Map),r=t.doc instanceof FU?t.doc:FU.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||QU)),i=t.selection?t.selection instanceof J?t.selection:J.single(t.selection.anchor,t.selection.head):J.single(0);return lW(i,r.length),n.staticFacet(AW)||(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)||`
|
|
137
|
-
`}get readOnly(){return this.facet(FW)}phrase(t,...n){for(let n of this.facet(e.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(e,t)=>{if(t==`$`)return`$`;let r=+(t||1);return!r||r>n.length?e:n[r-1]})),t}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(kW))for(let a of i(this,t,n))Object.prototype.hasOwnProperty.call(a,e)&&r.push(a[e]);return r}charCategorizer(e){let t=this.languageDataAt(`wordChars`,e);return $W(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),a=e-n,o=e-n;for(;a>0;){let e=KU(t,a,!1);if(i(t.slice(e,a))!=YW.Word)break;a=e}for(;o<r;){let e=KU(t,o);if(i(t.slice(o,e))!=YW.Word)break;o=e}return a==o?null:J.range(a+n,o+n)}};eG.allowMultipleSelections=AW,eG.tabSize=dW.define({combine:e=>e.length?e[0]:4}),eG.lineSeparator=jW,eG.readOnly=FW,eG.phrases=dW.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),eG.languageData=kW,eG.changeFilter=MW,eG.transactionFilter=NW,eG.transactionExtender=PW,CW.reconfigure=zW.define();function tG(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],a=r[e];if(a===void 0)r[e]=i;else if(!(a===i||i===void 0))if(Object.hasOwnProperty.call(n,e))r[e]=n[e](a,i);else throw Error(`Config merge conflict for field `+e)}for(let e in t)r[e]===void 0&&(r[e]=t[e]);return r}var nG=class{eq(e){return this==e}range(e,t=e){return iG.create(e,t,this)}};nG.prototype.startSide=nG.prototype.endSide=0,nG.prototype.point=!1,nG.prototype.mapMode=$U.TrackDel;function rG(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var iG=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function aG(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var oG=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let a=r,o=i.length;;){if(a==o)return a;let r=a+o>>1,s=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==a)return s>=0?a:o;s>=0?o=r:a=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),a=this.findIndex(n,1e9,!1,i);i<a;i++)if(r(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(t,n){let r=[],i=[],a=[],o=-1,s=-1;for(let e=0;e<this.value.length;e++){let c=this.value[e],l=this.from[e]+t,u=this.to[e]+t,d,f;if(l==u){let e=n.mapPos(l,c.startSide,c.mapMode);if(e==null||(d=f=e,c.startSide!=c.endSide&&(f=n.mapPos(l,c.endSide),f<d)))continue}else if(d=n.mapPos(l,c.startSide),f=n.mapPos(u,c.endSide),d>f||d==f&&c.startSide>0&&c.endSide<=0)continue;(f-d||c.endSide-c.startSide)<0||(o<0&&(o=d),c.point&&(s=Math.max(s,f-d)),r.push(c),i.push(d-o),a.push(f-o))}return{mapped:r.length?new e(i,a,r,s):null,pos:o}}},sG=class e{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(t,n,r,i){return new e(t,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:a=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(aG)),this.isEmpty)return n.length?e.of(n):this;let s=new dG(this,null,-1).goto(0),c=0,l=[],u=new lG;for(;s.value||c<n.length;)if(c<n.length&&(s.from-n[c].from||s.startSide-n[c].value.startSide)>=0){let e=n[c++];u.addInner(e.from,e.to,e.value)||l.push(e)}else s.rangeIndex==1&&s.chunkIndex<this.chunk.length&&(c==n.length||this.chunkEnd(s.chunkIndex)<n[c].from)&&(!o||i>this.chunkEnd(s.chunkIndex)||a<this.chunkPos[s.chunkIndex])&&u.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||i>s.to||a<s.from||o(s.from,s.to,s.value))&&(u.addInner(s.from,s.to,s.value)||l.push(iG.create(s.from,s.to,s.value))),s.next());return u.finishInner(this.nextLayer.isEmpty&&!l.length?e.empty:this.nextLayer.update({add:l,filter:o,filterFrom:i,filterTo:a}))}map(t){if(t.empty||this.isEmpty)return this;let n=[],r=[],i=-1;for(let e=0;e<this.chunk.length;e++){let a=this.chunkPos[e],o=this.chunk[e],s=t.touchesRange(a,a+o.length);if(s===!1)i=Math.max(i,o.maxPoint),n.push(o),r.push(t.mapPos(a));else if(s===!0){let{mapped:e,pos:s}=o.map(a,t);e&&(i=Math.max(i,e.maxPoint),n.push(e),r.push(s))}}let a=this.nextLayer.map(t);return n.length==0?a:new e(r,n,a||e.empty,i)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],a=this.chunk[r];if(t>=i&&e<=i+a.length&&a.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return fG.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return fG.from(e).goto(t)}static compare(e,t,n,r,i=-1){let a=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=uG(a,o,n),c=new mG(a,s,i),l=new mG(o,s,i);n.iterGaps((e,t,n)=>hG(c,e,l,t,n,r)),n.empty&&n.length==0&&hG(c,0,l,0,0,r)}static eq(e,t,n=0,r){r??=999999999;let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),a=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=a.length)return!1;if(!i.length)return!0;let o=uG(i,a),s=new mG(i,o,0).goto(n),c=new mG(a,o,0).goto(n);for(;;){if(s.to!=c.to||!gG(s.active,c.active)||s.point&&(!c.point||!rG(s.point,c.point)))return!1;if(s.to>r)return!0;s.next(),c.next()}}static spans(e,t,n,r,i=-1){let a=new mG(e,null,i).goto(t),o=t,s=a.openStart;for(;;){let e=Math.min(a.to,n);if(a.point){let n=a.activeForPoint(a.to),i=a.pointFrom<t?n.length+1:a.point.startSide<0?n.length:Math.min(n.length,s);r.point(o,e,a.point,n,i,a.pointRank),s=Math.min(a.openEnd(e),n.length)}else e>o&&(r.span(o,e,a.active,s),s=a.openEnd(e));if(a.to>n)return s+(a.point&&a.to>n?1:0);o=a.to,a.next()}}static of(e,t=!1){let n=new lG;for(let r of e instanceof iG?[e]:t?cG(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return e.empty;let n=t[t.length-1];for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};sG.empty=new sG([],[],null,-1);function cG(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(aG(t,r)>0)return e.slice().sort(aG);t=r}return e}sG.empty.nextLayer=sG.empty;var lG=class e{finishChunk(e){this.chunks.push(new oG(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,n,r){this.addInner(t,n,r)||(this.nextLayer||=new e).add(t,n,r)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(sG.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=sG.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function uG(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let a=r.get(e.chunk[t]);a!=null&&(n?n.mapPos(a):a)==e.chunkPos[t]&&!n?.touchesRange(a,a+e.chunk[t].length)&&i.add(e.chunk[t])}return i}var dG=class{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},fG=class e{constructor(e){this.heap=e}static from(t,n=null,r=-1){let i=[];for(let e=0;e<t.length;e++)for(let a=t[e];!a.isEmpty;a=a.nextLayer)a.maxPoint>=r&&i.push(new dG(a,n,r,e));return i.length==1?i[0]:new e(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)pG(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)pG(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),pG(this.heap,0)}}};function pG(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var mG=class{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=fG.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){_G(this.active,e),_G(this.activeTo,e),_G(this.activeRank,e),this.minActive=yG(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;vG(this.active,t,n),vG(this.activeTo,t,r),vG(this.activeRank,t,i),e&&vG(e,t,this.cursor.from),this.minActive=yG(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&_G(n,r)}else if(!this.cursor.value){this.to=this.endSide=1e9;break}else if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(!e.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function hG(e,t,n,r,i,a){e.goto(t),n.goto(r);let o=r+i,s=r,c=r-t,l=!!a.boundChange;for(let t=!1;;){let r=e.to+c-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+c:n.to,d=Math.min(u,o);if(e.point||n.point?(e.point&&n.point&&rG(e.point,n.point)&&gG(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&a.boundChange(s),d>s&&!gG(e.active,n.active)&&a.compareRange(s,d,e.active,n.active),l&&d<o&&(r||e.openEnd(u)!=n.openEnd(u))&&(t=!0)),u>o)break;s=u,i<=0&&e.next(),i>=0&&n.next()}}function gG(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!rG(e[n],t[n]))return!1;return!0}function _G(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function vG(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function yG(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function bG(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)e.charCodeAt(i)==9?(r+=t-r%t,i++):(r++,i=KU(e,i));return r}function xG(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=e.charCodeAt(r)==9?n-i%n:1,r=KU(e,r)}return r===!0?-1:e.length}for(var SG=`ͼ`,CG=typeof Symbol>`u`?`__ͼ`:Symbol.for(SG),wG=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),TG=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{},EG=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,a,o){let s=[],c=/^@(\w+)\b/.exec(e[0]),l=c&&c[1]==`keyframes`;if(c&&t==null)return a.push(e[0]+`;`);for(let n in t){let o=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,a);else if(o&&typeof o==`object`){if(!c)throw RangeError(`The value of a property (`+n+`) should be a primitive value.`);i(r(n),o,s,l)}else o!=null&&s.push(n.replace(/_.*/,``).replace(/[A-Z]/g,e=>`-`+e.toLowerCase())+`: `+o+`;`)}(s.length||l)&&a.push((n&&!c&&!o?e.map(n):e).join(`, `)+` {`+s.join(` `)+`}`)}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join(`
|
|
138
|
-
`)}static newName(){let e=TG[CG]||1;return TG[CG]=e+1,SG+e.toString(36)}static mount(e,t,n){let r=e[wG],i=n&&n.nonce;r?i&&r.setNonce(i):r=new OG(e,i),r.mount(Array.isArray(t)?t:[t],e)}},DG=new Map,OG=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=DG.get(n);if(t)return e[wG]=t;this.sheet=new r.CSSStyleSheet,DG.set(n,this)}else this.styleTag=n.createElement(`style`),t&&this.styleTag.setAttribute(`nonce`,t);this.modules=[],e[wG]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let a=e[t],o=this.modules.indexOf(a);if(o<i&&o>-1&&(this.modules.splice(o,1),i--,o=-1),o==-1){if(this.modules.splice(i++,0,a),n)for(let e=0;e<a.rules.length;e++)n.insertRule(a.rules[e],r++)}else{for(;i<o;)r+=this.modules[i++].rules.length;r+=a.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e=``;for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+`
|
|
139
|
-
`;this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute(`nonce`)!=e&&this.styleTag.setAttribute(`nonce`,e)}},kG={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},AG={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},jG=typeof navigator<`u`&&/Mac/.test(navigator.platform),MG=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),NG=0;NG<10;NG++)kG[48+NG]=kG[96+NG]=String(NG);for(var NG=1;NG<=24;NG++)kG[NG+111]=`F`+NG;for(var NG=65;NG<=90;NG++)kG[NG]=String.fromCharCode(NG+32),AG[NG]=String.fromCharCode(NG);for(var PG in kG)AG.hasOwnProperty(PG)||(AG[PG]=kG[PG]);function FG(e){var t=!(jG&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||MG&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?AG:kG)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}function IG(){var e=arguments[0];typeof e==`string`&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&typeof n==`object`&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i==`string`?e.setAttribute(r,i):i!=null&&(e[r]=i)}t++}for(;t<arguments.length;t++)LG(e,arguments[t]);return e}function LG(e,t){if(typeof t==`string`)e.appendChild(document.createTextNode(t));else if(t!=null)if(t.nodeType!=null)e.appendChild(t);else if(Array.isArray(t))for(var n=0;n<t.length;n++)LG(e,t[n]);else throw RangeError(`Unsupported child node: `+t)}var RG=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},zG=typeof document<`u`?document:{documentElement:{style:{}}},BG=/Edge\/(\d+)/.exec(RG.userAgent),VG=/MSIE \d/.test(RG.userAgent),HG=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(RG.userAgent),UG=!!(VG||HG||BG),WG=!UG&&/gecko\/(\d+)/i.test(RG.userAgent),GG=!UG&&/Chrome\/(\d+)/.exec(RG.userAgent),KG=`webkitFontSmoothing`in zG.documentElement.style,qG=!UG&&/Apple Computer/.test(RG.vendor),JG=qG&&(/Mobile\/\w+/.test(RG.userAgent)||RG.maxTouchPoints>2),Y={mac:JG||/Mac/.test(RG.platform),windows:/Win/.test(RG.platform),linux:/Linux|X11/.test(RG.platform),ie:UG,ie_version:VG?zG.documentMode||6:HG?+HG[1]:BG?+BG[1]:0,gecko:WG,gecko_version:WG?+(/Firefox\/(\d+)/.exec(RG.userAgent)||[0,0])[1]:0,chrome:!!GG,chrome_version:GG?+GG[1]:0,ios:JG,android:/Android\b/.test(RG.userAgent),webkit:KG,webkit_version:KG?+(/\bAppleWebKit\/(\d+)/.exec(RG.userAgent)||[0,0])[1]:0,safari:qG,safari_version:qG?+(/\bVersion\/(\d+(\.\d+)?)/.exec(RG.userAgent)||[0,0])[1]:0,tabSize:zG.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function YG(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var XG=Object.create(null);function ZG(e,t,n){if(e==t)return!0;e||=XG,t||=XG;let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function QG(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function $G(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function eK(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}var tK=class{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},nK=(function(e){return e[e.Text=0]=`Text`,e[e.WidgetBefore=1]=`WidgetBefore`,e[e.WidgetAfter=2]=`WidgetAfter`,e[e.WidgetRange=3]=`WidgetRange`,e})(nK||={}),rK=class extends nG{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new iK(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new oK(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:a}=sK(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new oK(e,n,r,t,e.widget||null,!0)}static line(e){return new aK(e)}static set(e,t=!1){return sG.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};rK.none=sG.empty;var iK=class e extends rK{constructor(e){let{start:t,end:n}=sK(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?YG(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||XG}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&ZG(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};iK.prototype.point=!1;var aK=class e extends rK{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&ZG(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};aK.prototype.mapMode=$U.TrackBefore,aK.prototype.point=!0;var oK=class e extends rK{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?$U.TrackBefore:$U.TrackAfter:$U.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?nK.WidgetBefore:nK.WidgetAfter:nK.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&cK(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};oK.prototype.point=!0;function sK(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function cK(e,t){return e==t||!!(e&&t&&e.compare(t))}function lK(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var uK=class e extends nG{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&ZG(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||XG,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return sG.of(e,t)}};uK.prototype.startSide=uK.prototype.endSide=-1;function dK(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function fK(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function pK(e,t){if(!t.anchorNode)return!1;try{return fK(e,t.anchorNode)}catch{return!1}}function mK(e){return e.nodeType==3?kK(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function hK(e,t,n,r){return n?vK(e,t,n,r,-1)||vK(e,t,n,r,1):!1}function gK(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function _K(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function vK(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:yK(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||n.nodeType!=1)return!1;t=gK(e)+(i<0?0:1),e=n}else if(e.nodeType==1){if(e=e.childNodes[t+(i<0?-1:0)],e.nodeType==1&&e.contentEditable==`false`)return!1;t=i<0?yK(e):0}else return!1}}function yK(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function bK(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function xK(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function SK(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function CK(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(u.nodeType==1){let e,f=u==c.body,p=1,m=1;if(f)e=xK(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:p,scaleY:m}=SK(u,t)),e={left:t.left,right:t.left+u.clientWidth*p,top:t.top,bottom:t.top+u.clientHeight*m}}let h=0,g=0;if(i==`nearest`)t.top<e.top+o?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let r=t.bottom-t.top,a=e.bottom-e.top;g=(i==`center`&&r<=a?t.top+r/2-a/2:i==`start`||i==`center`&&n<0?t.top-o:t.bottom-a+o)-e.top}if(r==`nearest`?t.left<e.left+a?(h=t.left-(e.left+a),n>0&&t.right>e.right+h&&(h=t.right-e.right+a)):t.right>e.right-a&&(h=t.right-e.right+a,n<0&&t.left<e.left+h&&(h=t.left-(e.left+a))):h=(r==`center`?t.left+(t.right-t.left)/2-(e.right-e.left)/2:r==`start`==s?t.left-a:t.right-(e.right-e.left)+a)-e.left,h||g)if(f)l.scrollBy(h,g);else{let e=0,n=0;if(g){let e=u.scrollTop;u.scrollTop+=g/m,n=(u.scrollTop-e)*m}if(h){let t=u.scrollLeft;u.scrollLeft+=h/p,e=(u.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-h)<1&&(r=`nearest`),n&&Math.abs(n-g)<1&&(i=`nearest`)}if(f)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function wK(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(a.nodeType==1)!i&&a.scrollHeight>a.clientHeight&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var TK=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?yK(t):0),n,Math.min(e.focusOffset,n?yK(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},EK=null;Y.safari&&Y.safari_version>=26&&(EK=!1);function DK(e){if(e.setActive)return e.setActive();if(EK)return e.focus(EK);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(EK==null?{get preventScroll(){return EK={preventScroll:!0},!0}}:void 0),!EK){EK=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}var OK;function kK(e,t,n=t){let r=OK||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function AK(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function jK(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function MK(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,yK(n));;)if(r){if(n.nodeType!=1)return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=yK(n))}else if(n==e)return!0;else r=gK(n),n=n.parentNode}function NK(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function PK(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r>0)return{node:n,offset:r};else if(n.nodeType==1&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=yK(n)}else if(n.parentNode&&!_K(n))r=gK(n),n=n.parentNode;else return null}function FK(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r<n.nodeValue.length)return{node:n,offset:r};else if(n.nodeType==1&&r<n.childNodes.length){if(n.contentEditable==`false`)return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!_K(n))r=gK(n)+1,n=n.parentNode;else return null}var IK=class e{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(t,n){return new e(t.parentNode,gK(t),n)}static after(t,n){return new e(t.parentNode,gK(t)+1,n)}},LK=(function(e){return e[e.LTR=0]=`LTR`,e[e.RTL=1]=`RTL`,e})(LK||={}),RK=LK.LTR,zK=LK.RTL;function BK(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}var VK=BK(`88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008`),HK=BK(`4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333`),UK=Object.create(null),WK=[];for(let e of[`()`,`[]`,`{}`]){let t=e.charCodeAt(0),n=e.charCodeAt(1);UK[t]=n,UK[n]=-t}function GK(e){return e<=247?VK[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?HK[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var KK=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,qK=class{get dir(){return this.level%2?zK:RK}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o.from<=t&&o.to>=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.from<t:o.to>t))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function JK(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!JK(r.inner,i.inner))return!1}return!0}var YK=[];function XK(e,t,n,r,i){for(let a=0;a<=r.length;a++){let o=a?r[a-1].to:t,s=a<r.length?r[a].from:n,c=a?256:i;for(let t=o,n=c,r=c;t<s;t++){let i=GK(e.charCodeAt(t));i==512?i=n:i==8&&r==4&&(i=16),YK[t]=i==4?2:i,i&7&&(r=i),n=i}for(let e=o,t=c,r=c;e<s;e++){let i=YK[e];if(i==128)e<s-1&&t==YK[e+1]&&t&24?i=YK[e]=t:YK[e]=256;else if(i==64){let i=e+1;for(;i<s&&YK[i]==64;)i++;let a=e&&t==8||i<n&&YK[i]==8?r==1?1:8:256;for(let t=e;t<i;t++)YK[t]=a;e=i-1}else i==8&&r==1&&(YK[e]=1);t=i,i&7&&(r=i)}}}function ZK(e,t,n,r,i){let a=i==1?2:1;for(let o=0,s=0,c=0;o<=r.length;o++){let l=o?r[o-1].to:t,u=o<r.length?r[o].from:n;for(let t=l,n,r,o;t<u;t++)if(r=UK[n=e.charCodeAt(t)])if(r<0){for(let e=s-3;e>=0;e-=3)if(WK[e+1]==-r){let n=WK[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(YK[t]=YK[WK[e]]=r),s=e;break}}else if(WK.length==189)break;else WK[s++]=t,WK[s++]=n,WK[s++]=c;else if((o=YK[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=WK[t+2];if(n&2)break;if(e)WK[t+2]|=2;else{if(n&4)break;WK[t+2]|=4}}}}}function QK(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=i<n.length?n[i].from:t;for(let c=o;c<s;){let o=YK[c];if(o==256){let o=c+1;for(;;)if(o==s){if(i==n.length)break;o=n[i++].to,s=i<n.length?n[i].from:t}else if(YK[o]==256)o++;else break;let l=a==1,u=l==((o<t?YK[o]:r)==1)?l?1:2:r;for(let t=o,r=i,a=r?n[r-1].to:e;t>c;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),YK[--t]=u;c=o}else a=o,c++}}}function $K(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;c<n;){let t=!0,u=!1;if(l==a.length||c<a[l].from){let e=YK[c];e!=s&&(t=!1,u=e==16)}let d=!t&&s==1?[]:null,f=t?r:r+1,p=c;run:for(;;)if(l<a.length&&p==a[l].from){if(u)break run;let m=a[l];if(!t)for(let e=m.to,t=l+1;;){if(e==n)break run;if(t<a.length&&a[t].from==e)e=a[t++].to;else if(YK[e]==s)break run;else break}l++,d?d.push(m):(m.from>c&&o.push(new qK(c,m.from,f)),eq(e,m.direction==RK==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?YK[p]!=s:YK[p]==s))break;else p++;d?$K(e,c,p,r+1,i,d,o):c<p&&o.push(new qK(c,p,f)),c=p}else for(let c=n,l=a.length;c>t;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=YK[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(YK[e-1]==s)break run;else break}d?d.push(m):(m.to<c&&o.push(new qK(m.to,c,f)),eq(e,m.direction==RK==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.from),p=m.from}else if(p==t||(n?YK[p-1]!=s:YK[p-1]==s))break;else p--;d?$K(e,p,c,r+1,i,d,o):p<c&&o.push(new qK(p,c,f)),c=p}}function eq(e,t,n,r,i,a,o){let s=t%2?2:1;XK(e,i,a,r,s),ZK(e,i,a,r,s),QK(i,a,r,s),$K(e,i,a,t,n,r,o)}function tq(e,t,n){if(!e)return[new qK(0,0,+(t==zK))];if(t==RK&&!n.length&&!KK.test(e))return nq(e.length);if(n.length)for(;e.length>YK.length;)YK[YK.length]=256;let r=[],i=t==RK?0:1;return eq(e,i,i,n,0,e.length,r),r}function nq(e){return[new qK(0,e,0)]}var rq=``;function iq(e,t,n,r,i){let a=r.head-e.from,o=qK.find(t,a,r.bidiLevel??-1,r.assoc),s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=KU(e.text,a,s.forward(i,n));(l<s.from||l>s.to)&&(l=c),rq=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];return u&&l==c&&u.level+ +!i<s.level?J.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):J.cursor(l+e.from,s.forward(i,n)?-1:1,s.level)}function aq(e,t,n){for(let r=t;r<n;r++){let t=GK(e.charCodeAt(r));if(t==1)return RK;if(t==2||t==4)return zK}return RK}var oq=dW.define(),sq=dW.define(),cq=dW.define(),lq=dW.define(),uq=dW.define(),dq=dW.define(),fq=dW.define(),pq=dW.define(),mq=dW.define(),hq=dW.define({combine:e=>e.some(e=>e)}),gq=dW.define({combine:e=>e.some(e=>e)}),_q=dW.define(),vq=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(J.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},yq=zW.define({map:(e,t)=>e.map(t)}),bq=zW.define();function xq(e,t,n){let r=e.facet(lq);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var Sq=dW.define({combine:e=>e.length?e[0]:!0}),Cq=0,wq=dW.define({combine(e){return e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),Tq=class e{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(wq.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(wq.of({plugin:this,arg:e}))}static define(t,n){let{eventHandlers:r,eventObservers:i,provide:a,decorations:o}=n||{};return new e(Cq++,t,r,i,e=>{let t=[];return o&&t.push(kq.of(t=>{let n=t.plugin(e);return n?o(n):rK.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},Eq=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(!this.value){if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){xq(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(xq(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){xq(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},Dq=dW.define(),Oq=dW.define(),kq=dW.define(),Aq=dW.define(),jq=dW.define(),Mq=dW.define(),Nq=dW.define();function Pq(e,t){let n=e.state.facet(Nq);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return sG.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let n=r[e].spec.bidiIsolate,i;if(n??=aq(t.text,o,s),a>0&&c.length&&(i=c[c.length-1]).to==o&&i.direction==n)i.to=s,c=i.inner;else{let e={from:o,to:s,direction:n,inner:[]};c.push(e),c=e.inner}}}}),i}var Fq=dW.define();function Iq(e){let t=0,n=0,r=0,i=0;for(let a of e.state.facet(Fq)){let o=a(e);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:r,bottom:i}}var Lq=dW.define(),Rq=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(t){return new e(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(t,n){if(n.length==0)return t;let r=[];for(let i=0,a=0,o=0;;){let s=i<t.length?t[i].fromB:1e9,c=a<n.length?n[a]:1e9,l=Math.min(s,c);if(l==1e9)break;let u=l+o,d=l,f=u;for(;;)if(a<n.length&&n[a]<=d){let e=n[a+1];a+=2,d=Math.max(d,e);for(let e=i;e<t.length&&t[e].fromB<=d;e++)o=t[e].toA-t[e].toB;f=Math.max(f,e+o)}else if(i<t.length&&t[i].fromB<=d){let e=t[i++];d=Math.max(d,e.toB),f=Math.max(f,e.toA),o=e.toA-e.toB}else break;r.push(new e(u,f,l,d))}return r}},zq=class e{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=tW.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new Rq(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},Bq=[],Vq=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Bq}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&QG(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:``)+(this.breakAfter?`#`:``)}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=gK(this.dom),r=this.length?e>0:t>0;return new IK(this.parent.dom,n+ +!!r,e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Wq)return e;return null}static get(e){return e.cmTile}},Hq=class extends Vq{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=Uq(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=Uq(r);this.length=a}};function Uq(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var Wq=class extends Hq{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Vq.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof Gq)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(s<e||e==c&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,r=e-s),(c>e||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},Gq=class e extends Hq{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},Kq=class e extends Hq{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l<e.children.length&&u<=c;l++){let d=e.children[l],f=u+d.length;f>=c&&(d.isComposite()?s(d,c-u):(!a||a.isHidden&&(t>0||n&&Jq(a,d)))&&(f>c||d.flags&32)?(a=d,o=c-u):(u<c||d.flags&16&&!d.isHidden)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):qq(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new IK(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new IK(e.dom,0);e==n.tile&&(a=!0)}}return new IK(this.dom,0)}};function qq(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=mK(t);return n[n.length-1]||null}function Jq(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var Yq=class e extends Hq{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},Xq=class e extends Vq{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,a=0;e==0&&t<0||e==n&&t>=0?Y.chrome||Y.gecko||(e?(r--,a=1):i<n&&(i++,a=-1)):t<0?r--:i<n&&i++;let o=kK(this.dom,r,i).getClientRects();if(!o.length)return null;let s=o[(a?a<0:t>=0)?0:o.length-1];return Y.safari&&!a&&s.width==0&&(s=Array.prototype.find.call(o,e=>e.width)||s),a?bK(s,a<0):s||null}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},Zq=class e extends Vq{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return bK(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return bK(n,!r)}}get overrideDOMText(){if(!this.length)return FU.empty;let{root:e}=this;if(!e)return FU.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,i,a){return a||(a=t.toDOM(n),t.editable||(a.contentEditable=`false`)),new e(a,r,t,i)}},Qq=class extends Vq{constructor(e){let t=document.createElement(`img`);t.className=`cm-widgetBuffer`,t.setAttribute(`aria-hidden`,`true`),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return FU.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},$q=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite())if(i==r.length)a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++;else if(e){let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}else break;else if(a){if(!e)break;n&&n.break(),e--,a=!1}else if(i==r.children.length){if(!e&&!o.length)break;n&&n.leave(r),a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++}else{let s=r.children[i],c=s.breakAfter;(t>0?s.length<=e:s.length<e)&&(!n||n.skip(s,0,s.length)!==!1||!s.isComposite)?(a=!!c,i++,e-=s.length):(o.push({tile:r,index:i}),r=s,i=0,n&&s.isComposite()&&n.enter(s))}return this.tile=r,this.index=i,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},eJ=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},tJ=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){this.flushBuffer();let i=this.ensureMarks(t,n),a=i.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let t=i.children[i.children.length-1]=new Xq(a.dom,a.text+e);t.parent=i}else i.append(r||Xq.of(e,this.cache.find(Xq)?.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?dJ(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof Yq&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(dJ(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=Vq.get(n.dom);e&&e.setDOM(dJ(n.dom))}let e=Yq.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=Vq.get(e.text);i&&this.cache.reused.set(i,2);let a=new Xq(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=cJ;let n=Kq.start(e,t||this.cache.find(Kq)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof Yq&&a.mark.eq(i))n=a,t--;else{let e=Yq.of(i,this.cache.find(Yq,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!oJ(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(Y.ios&&oJ(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(pJ,0,32)||new Zq(pJ.toDOM(),0,pJ,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,n=new eJ(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.from<this.pos&&n instanceof Gq&&n.wrapper.eq(t.wrapper))e=n;else{let n=Gq.of(t.wrapper,this.cache.find(Gq,e=>e.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(Qq,void 0,1);return n&&(n.flags=t),n||new Qq(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},nJ=class{constructor(e){this.skipCount=0,this.text=``,this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text=``,this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},rJ=[Zq,Kq,Xq,Yq,Qq,Gq,Wq];for(let e=0;e<rJ.length;e++)rJ[e].bucket=e;var iJ=class{constructor(e){this.view=e,this.buckets=rJ.map(()=>[]),this.index=rJ.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=i.length-1;e>=0;e--){let o=(e+a)%i.length,s=i[o];if((!t||t(s))&&!this.reused.has(s))return i.splice(o,1),o<a&&this.index[r]--,this.reused.set(s,n),s}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,a=0;;i++){if(i==r.length){if(a)return null;a=1,i=0}let o=r[i];if(!this.reused.has(o)&&(a==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new Zq(o.dom,t,e,o.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},aJ=class{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new iJ(e),this.text=new nJ(e.state.doc),this.builder=new tJ(this.cache,new Wq(e,e.contentDOM),sG.iter(n)),this.cache.reused.set(t,2),this.old=new $q(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=a<e.length?e[a++]:null,s=o?o.fromA:this.old.root.length;if(s>r){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(i,o.toB)),i=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=uJ(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t<e.length?Zq.of(e.widget,this.view,n-t,e.flags&496,this.cache.maybeReuse(e)):this.cache.reuse(e);a.flags&256?(a.flags&=-2,this.builder.addBlockWidget(a)):(this.builder.ensureLine(null),this.builder.addInlineWidget(a,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),!t&&n==e.length&&!this.cache.reused.has(e)?this.builder.addText(e.text,r,i,this.cache.reuse(e)):(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof Qq)this.cache.add(e);else if(e instanceof Yq)this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length;else return!1;this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof Yq&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof Yq&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,a=sG.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof oK){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?fJ.block:fJ.inline),c=sJ(a),l=this.cache.findWidget(i,t-e,c)||Zq.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=lJ(n,a);t>e&&this.text.skip(t-e)},span:(e,t,i,a)=>{for(let o=e;o<t;){let s=this.text.next(Math.min(512,t-o));s==null?(r.addLineStartIfNotCovered(n),r.addBreak(),o++):(r.ensureLine(n),r.addText(s,i,o==e?a:i.length),o+=s.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=a>i,this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=Vq.get(r);if(r==this.view.contentDOM)break;e instanceof Yq?t.push(e):e?.isLine()?n=e:e instanceof Gq||(r.nodeName==`DIV`&&!n&&r!=this.view.contentDOM?n=new Kq(r,cJ):n||t.push(Yq.of(new iK({tagName:r.nodeName.toLowerCase(),attributes:eK(r)}),r)))}return{line:n,marks:t}}};function oJ(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function sJ(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var cJ={class:`cm-line`};function lJ(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r?e:(e||={class:`cm-line`},n&&YG(n,e),r&&(e.class+=` `+r),e)}function uJ(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof Yq&&t.push(r.mark)}return t}function dJ(e){let t=Vq.get(e);return t&&t.setDOM(e.cloneNode()),e}var fJ=class extends tK{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};fJ.inline=new fJ(`span`),fJ.block=new fJ(`div`);var pJ=new class extends tK{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},mJ=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=rK.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Wq(e,e.contentDOM),this.updateInner([new Rq(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!TJ(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?vJ(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new Rq(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(Y.ie||Y.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=xJ(i,this.decorations,e.changes);o.length&&(t=Rq.extendWithRanges(t,o));let s=CJ(a,this.blockWrappers,e.changes);return s.length&&(t=Rq.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new aJ(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Vq.get(t.text)&&r.cache.reused.set(Vq.get(t.text),2),this.tile=r.run(e,t),hJ(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+`px`,this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+`px`:``;let r=Y.chrome||Y.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof EJ&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(bq)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,a=!i&&!(this.view.state.facet(Sq)||n.tabIndex>-1)&&pK(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),Y.gecko&&s.empty&&!this.hasComposition&&gJ(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new IK(e,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!hK(c.node,c.offset,u.anchorNode,u.anchorOffset)||!hK(l.node,l.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,s))&&(this.view.observer.ignore(()=>{Y.android&&Y.chrome&&n.contains(u.focusNode)&&wJ(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=dK(this.view.root);if(e)if(s.empty){if(Y.gecko){let e=yJ(c.node,c.offset);if(e&&e!=3){let t=(e==1?PK:FK)(c.node,c.offset);t&&(c=new IK(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new IK(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new IK(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&hK(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=dK(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=yK(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!Vq.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l<e),l>=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof EJ?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&t<e.length){let n=KU(e.text,t);if(n==t)return null;let r=kK(e.dom,t,n).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,a=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==LK.LTR,c=0,l=(e,u,d)=>{for(let f=0;f<e.children.length&&!(u>r);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof Gq)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?mK(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?LK.RTL:LK.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=mK(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=mK(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(rK.replace({widget:new EJ(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return rK.set(e)}updateDeco(){let e=1,t=this.view.state.facet(kq).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(jq).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(sG.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(Aq).map(e=>typeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(_q))try{if(t(this.view,e.range,e))return!0}catch(e){xq(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc??(t.empty?0:t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=Iq(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(CK(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,s),-s),this.view.textDirection==LK.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(t.head,1);e&&e.dom.scrollIntoView({block:`nearest`})}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){hJ(this.tile)}};function hJ(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)hJ(n,t)}}function gJ(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function _J(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=PK(n.focusNode,n.focusOffset),i=FK(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=Vq.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=Vq.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function vJ(e,t,n){let r=_J(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new Rq(c.mapPos(a),c.mapPos(o),a,o),text:i}}function yJ(e,t){return e.nodeType==1?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t<e.childNodes.length&&e.childNodes[t].contentEditable==`false`?2:0):0}var bJ=class{constructor(){this.changes=[]}compareRange(e,t){lK(e,t,this.changes)}comparePoint(e,t){lK(e,t,this.changes)}boundChange(e){lK(e,e,this.changes)}};function xJ(e,t,n){let r=new bJ;return sG.compare(e,t,n,r),r.changes}var SJ=class{constructor(){this.changes=[]}compareRange(e,t){lK(e,t,this.changes)}comparePoint(){}boundChange(e){lK(e,e,this.changes)}};function CJ(e,t,n){let r=new SJ;return sG.compare(e,t,n,r),r.changes}function wJ(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable==`false`)return!0;return!1}function TJ(e,t){let n=!1;return t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)}),n}var EJ=class extends tK{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement(`div`);return e.className=`cm-gap`,this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+`px`,!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function DJ(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return J.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=KU(i.text,a,!1):s=KU(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=KU(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;s<i.length;){let e=KU(i.text,s);if(r(i.text.slice(s,e))!=c)break;s=e}return J.range(o+i.from,s+i.from)}function OJ(e,t,n,r,i){let a=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>e.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+xG(o,a,e.state.tabSize)}function kJ(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;(!e||i.type==nK.Text&&(e.type!=i.type||(n<0?i.from<t:i.to>t)))&&(e=i)}}return e||r}return r}function AJ(e,t,n,r){let i=kJ(e,t.head,t.assoc||-1),a=!r||i.type!=nK.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAtCoords({x:n==(r==LK.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o!=null)return J.cursor(o,n?-1:1)}return J.cursor(n?i.to:i.from,n?-1:1)}function jJ(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=iq(i,a,o,s,n),l=rq;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=`
|
|
140
|
-
`,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function MJ(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==YW.Space&&(i=t),i==t}}function NJ(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return J.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=RJ(e,{x:d,y:r},!1,a);if(n?r>c.bottom:r<c.top)return J.cursor(i.pos,i.assoc);let l=e.coordsAtPos(i.pos,i.assoc),u=l?(l.top+l.bottom)/2:0;if(!l||(n?u>s:u<s))return J.cursor(i.pos,i.assoc,void 0,o)}}function PJ(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,a)=>{if(t>e&&t<i){let a=r||n||(t-e<i-t?-1:1);t=a<0?e:i,r=a}});if(!r)return t}}function FJ(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],a=null;if(i.empty){let t=PJ(e,i.from,0);t!=i.from&&(a=J.cursor(t,-1))}else{let t=PJ(e,i.from,-1),n=PJ(e,i.to,1);(t!=i.from||n!=i.to)&&(a=J.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}a&&(n||=t.ranges.slice(),n[r]=a)}return n?J.create(n,t.mainIndex):t}function IJ(e,t,n){let r=PJ(e.state.facet(Mq).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:J.cursor(r,r<n.from?1:-1)}var LJ=class{constructor(e,t){this.pos=e,this.assoc=t}};function RJ(e,t,n,r){let i=e.contentDOM.getBoundingClientRect(),a=i.top+e.viewState.paddingTop,{x:o,y:s}=t,c=s-a,l;for(;;){if(c<0)return new LJ(0,1);if(c>e.viewState.docHeight)return new LJ(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==nK.Text){if(r<0?l.to<e.viewport.from:l.from>e.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==nK.Text){let t=OJ(e,i,l,o,s);return new LJ(t,t==l.from?1:-1)}}if(l.type!=nK.Text)return c<(l.top+l.bottom)/2?new LJ(l.from,1):new LJ(l.to,-1);let u=e.docView.lineAt(l.from,2);return(!u||u.length!=l.length)&&(u=e.docView.lineAt(l.from,-2)),new zJ(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var zJ=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[qK.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[qK.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t,n=!1){let r=0,i=e.length-1,a=new Set,o=this.bidiIn(e[0],e[i]),s,c,l=-1,u=1e9,d;search:for(;r<i;){let n=i-r,f=r+i>>1;adjust:if(a.has(f)){let e=r+Math.floor(Math.random()*n);for(let t=0;t<n;t++){if(!a.has(e)){f=e;break adjust}e++,e==i&&(e=r)}break search}a.add(f);let p=t(f);if(p)for(let t=0;t<p.length;t++){let n=p[t],a=0;if(!(n.width==0&&p.length>1)){if(n.bottom<this.y)(!s||s.bottom<n.bottom)&&(s=n),a=1;else if(n.top>this.y)(!c||c.top>n.top)&&(c=n),a=-1;else{let e=n.left>this.x?this.x-n.left:n.right<this.x?this.x-n.right:0,t=Math.abs(e);t<u&&(l=f,u=t,d=n),e&&(a=e<0==(this.baseDir==LK.LTR)?-1:1)}a==-1&&(!o||this.baseDirAt(e[f],1))?i=f:a==1&&(!o||this.baseDirAt(e[f+1],-1))&&(r=f+1)}}}if(!d){let n=s&&(!c||this.y-s.bottom<c.top-this.y)?s:c;return this.y=(n.top+n.bottom)/2,this.scan(e,t,!0)}if(u&&!n){let{top:n,bottom:r}=d;if(s&&s.bottom>(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==LK.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r<e.length;r=KU(e.text,r))n.push(t+r);n.push(t+e.length);let r=this.scan(n,r=>{let i=n[r]-t,a=n[r+1]-t;return kK(e.dom,i,a).getClientRects()});return r.after?new LJ(n[r.i+1],-1):new LJ(n[r.i],1)}scanTile(e,t){if(!e.length)return new LJ(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r<e.children.length;r++)n.push(i+=e.children[r].length);let r=this.scan(n,t=>{let n=e.children[t];return n.flags&48?null:(n.dom.nodeType==1?n.dom:kK(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new LJ(n[r.i+1],-1):new LJ(a,1)}},BJ=``,VJ=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(eG.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=BJ}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=Vq.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=Vq.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:_K(r))||_K(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!UJ(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=Vq.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(HJ(e,n.node,n.offset)?t:0))}};function HJ(e,t,n){for(;;){if(!t||n<yK(t))return!1;if(t==e)return!0;n=gK(t)+1,t=t.parentNode}}function UJ(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let t=Vq.get(e);if(!t?.isWidget())return!1;t&&(n||=[]).push(t)}if(n){for(let e of n)if(e.overrideDOMText?.length)return!1}return!0}var WJ=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},GJ=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text=``,this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=KJ(e.docView.tile,t,n,0))){let t=i||a?[]:ZJ(e),n=new VJ(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=QJ(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!fK(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!fK(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((Y.ios||Y.chrome)&&o.main.empty&&n!=r&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),a=s.from-t,o=s.to-i;(a==0||a==1||t==0)&&(o==0||o==-1||i==e.state.doc.length)&&(n=0,r=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(J.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=J.create([J.cursor(n,r)])}else this.newSel=J.single(r,n)}}};function KJ(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;c<e.children.length;c++){let r=e.children[c],d=l+r.length;if(l<t&&d>n)return KJ(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}else if(e.isText())return{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling};else return null}function qJ(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||Y.android&&t.text.length<r-e)&&(s=a.to,c=`end`);let l=i.doc.sliceString(e,r,BJ),u,d;!a.empty&&a.from>=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:FU.of(t.text.slice(a.from-e,u).split(BJ))}:(d=XJ(l,t.text,s-e,c))&&(Y.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==``&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:FU.of(t.text.slice(d.from,d.toB).split(BJ))})}else r&&(!e.hasFocus&&i.facet(Sq)||$J(r,a))&&(r=null);if(!n&&!r)return!1;if((Y.mac||Y.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=J.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:FU.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).to<a.to&&e.docView.lineHasWidget(a.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:Y.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==`
|
|
141
|
-
`&&e.lineWrapping&&(r&&=J.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:FU.of([` `])}),n)return JJ(e,n,r,o);if(r&&!$J(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=FJ(i.facet(Mq).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}else return!1}function JJ(e,t,n,r=-1){if(Y.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(Y.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&AK(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>i.head)&&AK(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&AK(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=YJ(e,t,n);return e.state.facet(dq).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function YJ(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.from<a.from||t.from>a.to){let n=t.from<a.from?-1:1,r=n<0?a.from:a.to,s=PJ(i.facet(Mq).map(t=>t(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:J.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.from<t.from?i.sliceDoc(a.from,t.from):``,o=a.to>t.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&_J(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?J.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function XJ(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a<i&&e.charCodeAt(a)==t.charCodeAt(a);)a++;if(a==i&&e.length==t.length)return null;let o=e.length,s=t.length;for(;o>0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o<a&&e.length<t.length){let e=n<=a&&n>=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s<a){let e=n<=a&&n>=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function ZJ(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new WJ(n,r)),(i!=n||a!=r)&&t.push(new WJ(i,a))),t}function QJ(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n>-1&&r>-1?J.single(n+t,r+t):null}function $J(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var eY=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText=``,this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Y.safari&&e.contentDOM.addEventListener(`input`,()=>null),Y.gecko&&IY(e.contentDOM.ownerDocument)}handleEvent(e){!pY(this.view,e)||this.ignoreDuringComposition(e)||e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=nY(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&aY.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Y.android&&Y.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return Y.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=rY.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||iY.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key==`Enter`&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,AK(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:Y.safari&&!Y.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function tY(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){xq(n.state,e)}}}function nY(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(tY(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(tY(t.value,r))}}for(let e in mY)n(e).handlers.push(mY[e]);for(let e in hY)n(e).observers.push(hY[e]);return t}var rY=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],iY=`dthko`,aY=[16,17,18,20,91,92,224,225],oY=6;function sY(e){return Math.max(0,e)*.7+8}function cY(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var lY=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=wK(e.contentDOM),this.atoms=e.state.facet(Mq).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(eG.allowMultipleSelections)&&uY(e,t),this.dragging=fY(e,t)&&TY(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&cY(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=Iq(this.view);e.clientX-s.left<=r+oY?t=-sY(r-e.clientX):e.clientX+s.right>=a-oY&&(t=sY(e.clientX-a)),e.clientY-s.top<=i+oY?n=-sY(i-e.clientY):e.clientY+s.bottom>=o-oY&&(n=sY(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener(`mousemove`,this.move),e.removeEventListener(`mouseup`,this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=FJ(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function uY(e,t){let n=e.state.facet(oq);return n.length?n[0](t):Y.mac?t.metaKey:t.ctrlKey}function dY(e,t){let n=e.state.facet(sq);return n.length?n[0](t):Y.mac?!t.altKey:!t.ctrlKey}function fY(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=dK(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function pY(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Vq.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var mY=Object.create(null),hY=Object.create(null),gY=Y.ie&&Y.ie_version<15||Y.ios&&Y.webkit_version<604;function _Y(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),yY(e,n.value)},50)}function vY(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function yY(e,t){t=vY(e.state,pq,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(jY!=null&&n.selection.ranges.every(e=>e.empty)&&jY==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:J.cursor(r.from+c.length)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:J.cursor(e.from+t.length)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}hY.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},hY.wheel=hY.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},mY.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),hY.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},hY.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},mY.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(cq))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=EY(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new lY(e,t,n,r)),r&&e.observer.ignore(()=>{DK(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function bY(e,t,n,r){if(r==1)return J.cursor(t,n);if(r==2)return DJ(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return o<e.state.doc.length&&o==i.to&&o++,J.range(a,o)}}var xY=Y.ie&&Y.ie_version<=11,SY=null,CY=0,wY=0;function TY(e){if(!xY)return e.detail;let t=SY,n=wY;return SY=e,wY=Date.now(),CY=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(CY+1)%3:1}function EY(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=TY(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=bY(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=bY(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i<l.from?J.range(i,a,l.assoc):J.range(a,i,l.assoc)}return a?i.replaceRange(i.main.extend(l.from,l.to,l.assoc)):o&&r==1&&i.ranges.length>1&&(c=DY(i,s.pos))?c:o?i.addRange(l):J.create([l])}}}function DY(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return J.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}mY.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=J.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,vY(e.state,mq,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},mY.dragend=e=>(e.inputState.draggedContent=null,!1);function OY(e,t,n,r){if(n=vY(e.state,pq,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&dY(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}mY.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&OY(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=a,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}else{let n=t.dataTransfer.getData(`Text`);if(n)return OY(e,t,n,!0),!0}return!1},mY.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=gY?null:t.clipboardData;return n?(yY(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(_Y(e),!1)};function kY(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function AY(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:vY(e,mq,t.join(e.lineBreak)),ranges:n,linewise:r}}var jY=null;mY.copy=mY.cut=(e,t)=>{if(!pK(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=AY(e.state);if(!n&&!i)return!1;jY=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=gY?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(kY(e,n),!1)};var MY=IW.define();function NY(e,t){let n=[];for(let r of e.facet(fq)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:MY.of(!0)}):null}function PY(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=NY(e.state,t);n?e.dispatch(n):e.update([])}},10)}hY.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),PY(e)},hY.blur=e=>{e.observer.clearSelectionRange(),PY(e)},hY.compositionstart=hY.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},hY.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Y.chrome&&Y.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},hY.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},mY.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return JJ(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(Y.chrome&&Y.android&&(n=rY.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return Y.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),Y.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>hY.compositionend(e,t),20),!1};var FY=new Set;function IY(e){FY.has(e)||(FY.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var LY=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],RY=!1;function zY(){RY=!1}var BY=class{constructor(e){this.lineWrapping=e,this.doc=FU.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return LY.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,i,a){let o=LY.indexOf(e)>-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e<a.length;e++){let t=a[e];t<0?e++:this.heightSamples[Math.floor(t*10)]=!0}}return s}},VY=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},HY=class e{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return typeof this._content==`number`?nK.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof oK?this._content.widget:null}get widgetLineBreaks(){return typeof this._content==`number`?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e(this.from,this.length+t.length,this.top,this.height+t.height,n)}},UY=(function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(UY||={}),WY=.001,GY=class e{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>WY&&(RY=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,UY.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,UY.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,s<d.from&&(d=i.lineAt(s,UY.ByPosNoHeight,n,0,0));l+=d.from-s,s=d.from;let p=eX.build(n.setDoc(a),e,l,u);i=KY(i,i.replace(s,c,p))}return i.updateHeight(n,0)}static empty(){return new YY(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,i=0,a=0;for(;;)if(n==r)if(i>a*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break;else if(i<a){let e=t[n++];e&&(i+=e.size)}else{let e=t[--r];e&&(a+=e.size)}let o=0;return t[n-1]==null?(o=1,n--):t[n]??(o=1,r++),new ZY(e.of(t.slice(0,n)),o,e.of(t.slice(r)))}};function KY(e,t){return e==t?e:(e.constructor!=t.constructor&&(RY=!0),t)}GY.prototype.size=1;var qY=rK.replace({}),JY=class extends GY{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new HY(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new HY(r,0,n,this.spaceAbove,qY):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let a=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(a):a}forEachLine(e,t,n,r,i,a){e<=i+this.length&&t>=i&&a(this.lineAt(0,UY.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},YY=class e extends JY{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new HY(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof XY&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof XY?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):GY.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:``}${this.widgetHeight?`:`+this.widgetHeight:``})`}},XY=class e extends GY{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),a=t.doc.lineAt(i),c=o+a.length*s,l=Math.max(n,e-c/2);return new HY(a.from,a.length,l,c,0)}else{let r=Math.max(0,Math.min(a-i,Math.floor((e-n)/o))),{from:s,length:c}=t.doc.line(i+r);return new HY(s,c,n+o*r,o,0)}}lineAt(e,t,n,r,i){if(t==UY.ByHeight)return this.blockAt(e,n,r,i);if(t==UY.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new HY(t,r-t,0,0,0)}let{firstLine:a,perLine:o,perChar:s}=this.heightMetrics(n,i),c=n.doc.lineAt(e),l=o+c.length*s,u=c.number-a,d=r+o*u+s*(c.from-i-u);return new HY(c.from,c.length,Math.max(r,Math.min(d,r+this.height-l)),l,0)}forEachLine(e,t,n,r,i,a){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:o,perLine:s,perChar:c}=this.heightMetrics(n,i);for(let l=e,u=r;l<=t;){let t=n.doc.lineAt(l);if(l==e){let n=t.number-o;u+=s*n+c*(e-i-n)}let r=s+c*t.length;a(new HY(t.from,t.length,u,r,0)),u+=r,l=t.to+1}}replace(t,n,r){let i=this.length-n;if(i>0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return GY.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=WY&&(s=-2);let c=new YY(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=GY.of(r);return(s<0||Math.abs(c.height-this.height)>=WY||Math.abs(s-this.heightMetrics(t,n).perLine)>=WY)&&(RY=!0),KY(this,c)}else (r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},ZY=class extends GY{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let a=r+this.left.height,o=i+this.left.length+this.break,s=t==UY.ByHeight?e<a:e<o,c=s?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,a,o);if(this.break||(s?c.to<o:c.from>o))return c;let l=t==UY.ByPosNoHeight?UY.ByPosNoHeight:UY.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e<s&&this.left.forEachLine(e,t,n,r,i,a),t>=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,UY.ByPos,n,r,i);e<c.from&&this.left.forEachLine(e,c.from-1,n,r,i,a),c.to>=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&QY(i,a-1),t<this.length){let e=i.length;this.decomposeRight(t,i),QY(i,e)}return GY.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?GY.of(this.break?[e,null,t]:[e,t]):(this.left=KY(this.left,e),this.right=KY(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function QY(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof XY&&(r=e[t+1])instanceof XY&&e.splice(t-1,3,new XY(n.length+1+r.length))}var $Y=5,eX=class e{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof YY?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new YY(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let a=t-e;n.block?this.addBlock(new JY(a,r,n)):(a||i||r>=$Y)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new YY(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new XY(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof YY)return e;let t=new YY(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof YY)&&!this.isCovered?this.nodes.push(new YY(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let e of this.nodes)e instanceof YY&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(t,n,r,i){let a=new e(r,t);return sG.spans(n,r,i,a,0),a.finish(r)}};function tX(e,t,n){let r=new nX;return sG.compare(e,t,n,r,0),r.changes}var nX=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&lK(e,t,this.changes,5)}};function rX(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,a=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),s=Math.max(0,n.top),c=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(t.nodeType==1){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&r.overflow!=`visible`){let r=n.getBoundingClientRect();a=Math.max(a,r.left),o=Math.min(o,r.right),s=Math.max(s,r.top),c=Math.min(t==e.parentNode?i.innerHeight:c,r.bottom)}t=r.position==`absolute`||r.position==`fixed`?n.offsetParent:n.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function iX(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}function aX(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var oX=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return rK.replace({widget:new sX(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},sX=class extends tK{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement(`div`);return this.vertical?e.style.height=this.size+`px`:(e.style.width=this.size+`px`,e.style.height=`2px`,e.style.display=`inline-block`),e}get estimatedHeight(){return this.vertical?this.size:-1}},cX=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=mX,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=LK.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(Oq).some(e=>typeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new BY(n),this.stateDeco=hX(t),this.heightMap=GY.empty().applyChanges(this.stateDeco,FU.empty,this.heightOracle.setDoc(t.doc),[new Rq(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=rK.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new lX(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?mX:new gX(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(_X(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=hX(this.state);let r=e.changedRanges,i=Rq.extendWithRanges(r,tX(n,this.stateDeco,e?e.changes:tW.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);zY(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||RY)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<s.from||t.range.head>s.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(gq)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?LK.RTL:LK.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=SK(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=wK(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=NK(this.scrollParent||e.win);let m=(this.printing?aX:rX)(t,this.paddingTop),h=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(s=!0)),!this.inView&&!this.scrollTarget&&!iX(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,v/o),t),a&&(e.docView.minWidth=0,c|=16)}h>0&&g>0?l=Math.max(h,g):h<0&&g<0&&(l=Math.min(h,g)),zY();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?GY.empty().applyChanges(this.stateDeco,FU.empty,this.heightOracle,[new Rq(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new VY(n.from,i))}RY&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new lX(r.lineAt(a-n*1e3,UY.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,UY.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<s.from||e>s.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,UY.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e<s.from?a.top:a.bottom-n,s=new lX(r.lineAt(o-1e3/2,UY.ByHeight,i,0,0).from,r.lineAt(o+n+1e3/2,UY.ByHeight,i,0,0).to)}}return s}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new lX(this.heightMap.lineAt(n,UY.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,UY.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,UY.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,UY.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||r<=a-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&r>a-2*1e3&&i<o+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new oX(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,a=r<<1;if(this.defaultTextDirection!=LK.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-r<i)return;let u=this.state.selection.main,d=[u.from];u.empty||d.push(u.to);for(let e of d)if(e>r&&e<a){s(r,e-10,c,l),s(e+10,a,c,l);return}let f=pX(e,e=>e.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-a)<i&&!d.some(t=>e.from<t&&e.to>t));if(!f){if(a<c.to&&t&&n&&t.visibleRanges.some(e=>e.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(J.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new oX(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length<a||t.type!=nK.Text)return;let i=uX(t.from,t.to,this.stateDeco);if(i.total<a)return;let o=this.scrollTarget?this.scrollTarget.range.head:null,c,l;if(n){let e=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,n,a;if(o!=null){let r=fX(i,o),s=((this.visibleBottom-this.visibleTop)/2+e)/t.height;n=r-s,a=r+s}else n=(this.visibleTop-t.top-e)/t.height,a=(this.visibleBottom-t.top+e)/t.height;c=dX(i,n),l=dX(i,a)}else{let n=i.total*this.heightOracle.charWidth,a=r*this.heightOracle.charWidth,s=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+s<this.pixelViewport.left&&(s=n.size-n.displaySize);let u=this.pixelViewport.left+s,d=this.pixelViewport.right+s,f,p;if(o!=null){let e=fX(i,o),t=((d-u)/2+a)/n;f=e-t,p=e+t}else f=(u-a)/n,p=(d+a)/n;c=dX(i,f),l=dX(i,p)}c>t.from&&s(t.from,c,t,i),l<t.to&&s(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(c):c(e);return o}gapSize(e,t,n,r){let i=fX(r,n)-fX(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){oX.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=rK.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];sG.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(r&8);t++){let i=this.visibleRanges[t],a=n[t];(i.from!=a.from||i.to!=a.to)&&(r|=4,e&&e.mapPos(i.from,-1)==a.from&&e.mapPos(i.to,1)==a.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||_X(this.heightMap.lineAt(e,UY.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||_X(this.heightMap.lineAt(this.scaler.fromDOM(e),UY.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return _X(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},lX=class{constructor(e,t){this.from=e,this.to=t}};function uX(e,t,n){let r=[],i=e,a=0;return sG.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),a+=t-i),{total:a,ranges:r}}function dX({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function fX(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function pX(e,t){for(let n of e)if(t(n))return n}var mX={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function hX(e){let t=e.facet(kq).filter(e=>typeof e!=`function`),n=e.facet(jq).filter(e=>typeof e!=`function`);return n.length&&t.push(sG.join(n)),t}var gX=class e{constructor(e,t,n){let r=0,i=0,a=0;this.viewports=n.map(({from:n,to:i})=>{let a=t.lineAt(n,UY.ByPos,e,0,0).top,o=t.lineAt(i,UY.ByPos,e,0,0).bottom;return r+=o-a,{from:n,to:i,top:a,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=a+(e.top-i)*this.scale,a=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(t){return t instanceof e?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to):!1}};function _X(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new HY(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>_X(e,t)):e._content)}var vX=dW.define({combine:e=>e.join(` `)}),yX=dW.define({combine:e=>e.indexOf(!0)>-1}),bX=EG.newName(),xX=EG.newName(),SX=EG.newName(),CX={"&light":`.`+xX,"&dark":`.`+SX};function wX(e,t,n){return new EG(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var TX=wX(`.`+bX,{"&":{position:`relative !important`,boxSizing:`border-box`,"&.cm-focused":{outline:`1px dotted #212121`},display:`flex !important`,flexDirection:`column`},".cm-scroller":{display:`flex !important`,alignItems:`flex-start !important`,fontFamily:`monospace`,lineHeight:1.4,height:`100%`,overflowX:`auto`,position:`relative`,zIndex:0,overflowAnchor:`none`},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:`block`,whiteSpace:`pre`,wordWrap:`normal`,boxSizing:`border-box`,minHeight:`100%`,padding:`4px 0`,outline:`none`,"&[contenteditable=true]":{WebkitUserModify:`read-write-plaintext-only`}},".cm-lineWrapping":{whiteSpace_fallback:`pre-wrap`,whiteSpace:`break-spaces`,wordBreak:`break-word`,overflowWrap:`anywhere`,flexShrink:1},"&light .cm-content":{caretColor:`black`},"&dark .cm-content":{caretColor:`white`},".cm-line":{display:`block`,padding:`0 2px 0 6px`},".cm-layer":{position:`absolute`,left:0,top:0,contain:`size style`,"& > *":{position:`absolute`}},"&light .cm-selectionBackground":{background:`#d9d9d9`},"&dark .cm-selectionBackground":{background:`#222`},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#d7d4f0`},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#233`},".cm-cursorLayer":{pointerEvents:`none`},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:`steps(1) cm-blink 1.2s infinite`},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:`1.2px solid black`,marginLeft:`-0.6px`,pointerEvents:`none`},".cm-cursor":{display:`none`},"&dark .cm-cursor":{borderLeftColor:`#ddd`},".cm-selectionHandle":{backgroundColor:`currentColor`,width:`1.5px`},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:`""`,backgroundColor:`inherit`,borderRadius:`50%`,width:`8px`,height:`8px`,position:`absolute`,left:`-3.25px`},".cm-selectionHandle-start::before":{top:`-8px`},".cm-selectionHandle-end::before":{bottom:`-8px`},".cm-dropCursor":{position:`absolute`},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:`block`},".cm-iso":{unicodeBidi:`isolate`},".cm-announced":{position:`fixed`,top:`-10000px`},"@media print":{".cm-announced":{display:`none`}},"&light .cm-activeLine":{backgroundColor:`#cceeff44`},"&dark .cm-activeLine":{backgroundColor:`#99eeff33`},"&light .cm-specialChar":{color:`red`},"&dark .cm-specialChar":{color:`#f78`},".cm-gutters":{flexShrink:0,display:`flex`,height:`100%`,boxSizing:`border-box`,zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:`#f5f5f5`,color:`#6c6c6c`,border:`0px solid #ddd`,"&.cm-gutters-before":{borderRightWidth:`1px`},"&.cm-gutters-after":{borderLeftWidth:`1px`}},"&dark .cm-gutters":{backgroundColor:`#333338`,color:`#ccc`},".cm-gutter":{display:`flex !important`,flexDirection:`column`,flexShrink:0,boxSizing:`border-box`,minHeight:`100%`,overflow:`hidden`},".cm-gutterElement":{boxSizing:`border-box`},".cm-lineNumbers .cm-gutterElement":{padding:`0 3px 0 5px`,minWidth:`20px`,textAlign:`right`,whiteSpace:`nowrap`},"&light .cm-activeLineGutter":{backgroundColor:`#e2f2ff`},"&dark .cm-activeLineGutter":{backgroundColor:`#222227`},".cm-panels":{boxSizing:`border-box`,position:`sticky`,left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:`#f5f5f5`,color:`black`},"&light .cm-panels-top":{borderBottom:`1px solid #ddd`},"&light .cm-panels-bottom":{borderTop:`1px solid #ddd`},"&dark .cm-panels":{backgroundColor:`#333338`,color:`white`},".cm-dialog":{padding:`2px 19px 4px 6px`,position:`relative`,"& label":{fontSize:`80%`}},".cm-dialog-close":{position:`absolute`,top:`3px`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,fontSize:`14px`,padding:`0`},".cm-tab":{display:`inline-block`,overflow:`hidden`,verticalAlign:`bottom`},".cm-widgetBuffer":{verticalAlign:`text-top`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{backgroundImage:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)`,backgroundPosition:`center`},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:`auto 100%`,backgroundPosition:`right 90%`,backgroundRepeat:`no-repeat`},".cm-trailingSpace":{backgroundColor:`#ff332255`},".cm-button":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,padding:`.2em 1em`,borderRadius:`1px`},"&light .cm-button":{backgroundImage:`linear-gradient(#eff1f5, #d9d9df)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#b4b4b4, #d0d3d6)`}},"&dark .cm-button":{backgroundImage:`linear-gradient(#393939, #111)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#111, #333)`}},".cm-textfield":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,border:`1px solid silver`,padding:`.2em .5em`},"&light .cm-textfield":{backgroundColor:`white`},"&dark .cm-textfield":{border:`1px solid #555`,backgroundColor:`inherit`}},CX),EX={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},DX=Y.ie&&Y.ie_version<=11,OX=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new TK,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(Y.ie&&Y.ie_version<=11||Y.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Y.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Y.chrome&&Y.chrome_version<126)&&(this.editContext=new MX(e),e.state.facet(Sq)&&(e.contentDOM.editContext=this.editContext.editContext)),DX&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia(`print`)),typeof ResizeObserver==`function`&&(this.resizeScroll=new ResizeObserver(()=>{this.view.docView?.lastUpdate<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver==`function`&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent(`Event`)))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent(`Event`))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers(`scroll`,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type==`change`||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(Sq)?n.root.activeElement!=this.dom:!pK(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(Y.ie&&Y.ie_version<=11||Y.android&&Y.chrome)&&!n.state.selection.main.empty&&r.focusNode&&hK(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=dK(e.root);if(!t)return!1;let n=Y.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&jX(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=pK(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&MK(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||=this.scrollTargets.slice(0,e),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener(`scroll`,this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||=(this.observer.observe(this.dom,EX),DX&&this.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),DX&&this.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&AK(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}(!this.delayedAndroidKey||e==`Enter`)&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!this.delayedAndroidKey?.force})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&pK(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new GJ(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=qJ(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!$J(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=kX(t,e.previousSibling||e.target.previousSibling,-1),r=kX(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else if(e.type==`characterData`)return{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue};else return null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener(`change`,this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener(`beforeprint`,this.onPrint),e.addEventListener(`scroll`,this.onScroll),e.document.addEventListener(`selectionchange`,this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener(`scroll`,this.onScroll),e.removeEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener(`change`,this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener(`beforeprint`,this.onPrint),e.document.removeEventListener(`selectionchange`,this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Sq)!=e.state.facet(Sq)&&(e.view.contentDOM.editContext=e.state.facet(Sq)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function kX(e,t,n){for(;t;){let r=Vq.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function AX(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return hK(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function jX(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return AX(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?AX(e,n):null}var MX=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&i<this.from?o=i:s==this.to&&i>this.to&&(s=i);let l=XJ(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=J.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));$J(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:FU.of(n.text.slice(l.from,l.toB).split(`
|
|
142
|
-
`))};if((Y.mac||Y.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:FU.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);JJ(e,u,J.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(rK.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:bq.of(rK.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=dK(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])}},NX=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||jK(e.parent)||document,this.viewState=new cX(this,e.state||eG.create(e)),e.scrollTo&&e.scrollTo.is(yq)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(wq).map(e=>new Eq(e));for(let e of this.plugins)e.update(this);this.observer=new OX(this),this.inputState=new eY(this),this.inputState.ensureHandlers(this.plugins),this.docView=new mJ(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 BW?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(MY))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=NY(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(eG.phrases)!=this.state.facet(eG.phrases))return this.setState(a);i=zq.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 vq(t.empty?t:J.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(yq)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=IX.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Lq)!=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(vX)!=i.state.facet(vX)&&(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(uq))try{e(i)}catch(e){xq(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!qJ(this,u)&&l.force&&AK(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 cX(this,e),this.plugins=e.facet(wq).map(e=>new Eq(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new mJ(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(wq),n=e.state.facet(wq);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new Eq(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){xq(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(NK(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 xq(this.state,e),FX}}),l=zq.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]!=FX)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){xq(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(uq))e(t)}get themeClasses(){return bX+` `+(this.state.facet(yX)?SX:xX)+` `+this.state.facet(vX)}updateAttrs(){let e=LX(this,Dq,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(Sq)?`true`:`false`,class:`cm-content`,style:`${Y.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),LX(this,Oq,t);let n=this.observer.ignore(()=>{let n=$G(this.contentDOM,this.contentAttrs,t),r=$G(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(Lq);let t=this.state.facet(e.cspNonce);EG.mount(this.root,this.styleModules.concat(TX).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 IJ(this,e,jJ(this,e,t,n))}moveByGroup(e,t){return IJ(this,e,jJ(this,e,t,t=>MJ(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 J.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return AJ(this,e,t,n)}moveVertically(e,t,n){return IJ(this,e,NJ(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=RJ(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),RJ(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[qK.find(i,e-r.from,-1,t)];return bK(n,a.dir==LK.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(hq)||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>PX)return nq(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||JK(r.isolates,n=Pq(this,e))))return r.order;n||=Pq(this,e);let r=tq(e.text,t,n);return this.bidiCache.push(new IX(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||Y.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{DK(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 yq.of(new vq(typeof e==`number`?J.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 yq.of(new vq(J.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 Tq.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Tq.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=EG.newName(),r=[vX.of(n),Lq.of(wX(`.${n}`,e))];return t&&t.dark&&r.push(yX.of(!0)),r}static baseTheme(e){return xW.lowest(Lq.of(wX(`.`+bX,e,CX)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&Vq.get(t)||Vq.get(e))?.root?.view||null}};NX.styleModule=Lq,NX.inputHandler=dq,NX.clipboardInputFilter=pq,NX.clipboardOutputFilter=mq,NX.scrollHandler=_q,NX.focusChangeEffect=fq,NX.perLineTextDirection=hq,NX.exceptionSink=lq,NX.updateListener=uq,NX.editable=Sq,NX.mouseSelectionStyle=cq,NX.dragMovesSelection=sq,NX.clickAddsSelectionRange=oq,NX.decorations=kq,NX.blockWrappers=Aq,NX.outerDecorations=jq,NX.atomicRanges=Mq,NX.bidiIsolatedRanges=Nq,NX.cursorScrollMargin=dW.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}}}),NX.scrollMargins=Fq,NX.darkTheme=yX,NX.cspNonce=dW.define({combine:e=>e.length?e[0]:``}),NX.contentAttributes=Oq,NX.editorAttributes=Dq,NX.lineWrapping=NX.contentAttributes.of({class:`cm-lineWrapping`}),NX.announce=zW.define();var PX=4096,FX={},IX=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:LK.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 LX(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&&YG(a,n)}return n}var RX=Y.mac?`mac`:Y.windows?`win`:Y.linux?`linux`:`key`;function zX(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 BX(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 VX=xW.default(NX.domEventHandlers({keydown(e,t){return XX(WX(t.state),e,t,`editor`)}})),HX=dW.define({enables:VX}),UX=new WeakMap;function WX(e){let t=e.facet(HX),n=UX.get(t);return n||UX.set(t,n=JX(t.reduce((e,t)=>e.concat(t),[]))),n}function GX(e,t,n){return XX(WX(e.state),t,e,n)}var KX=null,qX=4e3;function JX(e,t=RX){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=>zX(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=KX={view:t,prefix:n,scope:e};return setTimeout(()=>{KX==r&&(KX=null)},qX),!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,YX))}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 YX=null;function XX(e,t,n,r){YX=t;let i=FG(t),a=ZU(YU(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;KX&&KX.view==n&&KX.scope==r&&(o=KX.prefix+` `,aY.indexOf(t.keyCode)<0&&(c=!0,KX=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+BX(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(Y.windows&&t.ctrlKey&&t.altKey)&&!(Y.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=kG[t.keyCode])&&p!=i?(d(f[o+BX(p,t,!0)])||t.shiftKey&&(m=AG[t.keyCode])!=i&&m!=p&&d(f[o+BX(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+BX(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),YX=null,s}var ZX=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=QX(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return eZ(t,n,r)}};function QX(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==LK.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function $X(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 eZ(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==LK.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=QX(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=kJ(e,r,1),m=kJ(e,i,-1),h=p.type==nK.Text?p:null,g=m.type==nK.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=$X(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=$X(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==nK.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new ZX(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==LK.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 tZ(e,t){return e.constructor==t.constructor&&e.eq(t)}var nZ=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(rZ)!=e.state.facet(rZ)&&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(rZ);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)=>!tZ(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,Y.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},rZ=dW.define();function iZ(e){return[Tq.define(t=>new nZ(t,e)),rZ.of(e)]}var aZ=dW.define({combine(e){return tG(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function oZ(e={}){return[aZ.of(e),cZ,uZ,dZ,gq.of(!0)]}function sZ(e){return e.startState.facet(aZ)!=e.state.facet(aZ)}var cZ=iZ({above:!0,markers(e){let{state:t}=e,n=t.facet(aZ),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&Y.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:J.cursor(i.head,i.assoc);for(let i of ZX.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=sZ(e);return n&&lZ(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){lZ(t.state,e)},class:`cm-cursorLayer`});function lZ(e,t){t.style.animationDuration=e.facet(aZ).cursorBlinkRate+`ms`}var uZ=iZ({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 ZX.forRange(e,`cm-selectionBackground`,n))t.push(r);if(Y.ios&&!n.empty&&e.state.facet(aZ).iosSelectionHandles){for(let r of ZX.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,J.cursor(n.from,1)))t.push(r);for(let r of ZX.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,J.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||sZ(e)},class:`cm-selectionLayer`}),dZ=xW.highest(NX.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`}}}})),fZ=zW.define({map(e,t){return e==null?null:t.mapPos(e)}}),pZ=vW.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(fZ)?t.value:e,e)}}),mZ=Tq.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(pZ);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(pZ)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(pZ),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(pZ)!=e&&this.view.dispatch({effects:fZ.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 hZ(){return[pZ,mZ]}/x/.unicode;function gZ(){return vZ}var _Z=rK.line({class:`cm-activeLine`}),vZ=Tq.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(_Z.range(i.from)),t=i.from)}return rK.set(n)}},{decorations:e=>e.decorations}),yZ=2e3;function bZ(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>yZ||n.off>yZ||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(J.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=xG(n.text,o,e.tabSize,!0);if(r<0)a.push(J.cursor(n.to));else{let t=xG(n.text,s,e.tabSize);a.push(J.range(n.from+r,n.from+t))}}}return a}function xZ(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function SZ(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>yZ?-1:i==r.length?xZ(e,t.clientX):bG(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function CZ(e,t){let n=SZ(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=SZ(e,t);if(!o)return r;let s=bZ(e.state,n,o);return s.length?a?J.create(s.concat(r.ranges)):J.create(s):r}}:null}function wZ(e){let t=e?.eventFilter||(e=>e.altKey&&e.button==0);return NX.mouseSelectionStyle.of((e,n)=>t(n)?CZ(e,n):null)}var TZ={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},EZ={style:`cursor: crosshair`};function DZ(e={}){let[t,n]=TZ[e.key||`Alt`],r=Tq.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,NX.contentAttributes.of(e=>e.plugin(r)?.isDown?EZ:null)]}var OZ=`-10000px`,kZ=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 AZ(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var jZ=dW.define({combine:e=>({position:Y.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||AZ})}),MZ=new WeakMap,NZ=Tq.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(jZ);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 kZ(e,LZ,(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(jZ);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=OZ,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(Y.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=Iq(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(jZ).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=OZ;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=MZ.get(c)??d.bottom-d.top,g=c.offset||IZ,_=this.view.textDirection==LK.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=OZ;continue}MZ.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,ee=v+m;if(c.overlap!==!0)for(let e of a)e.left<ee&&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`,PZ(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,PZ(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:ee,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=OZ}},{eventObservers:{scroll(){this.maybeMeasure()}}});function PZ(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var FZ=NX.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`}}}),IZ={x:0,y:0},LZ=dW.define({enables:[NZ,FZ]});function RZ(e,t){let n=e.plugin(NZ);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var zZ=dW.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function BZ(e,t){let n=e.plugin(VZ),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var VZ=Tq.fromClass(class{constructor(e){this.input=e.state.facet(WZ),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(zZ);this.top=new HZ(e,!0,t.topContainer),this.bottom=new HZ(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(zZ);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new HZ(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new HZ(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(WZ);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=>NX.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),HZ=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=UZ(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=UZ(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 UZ(e){let t=e.nextSibling;return e.remove(),t}var WZ=dW.define({enables:VZ});function GZ(e,t){let n,r=new Promise(e=>n=e),i=e=>YZ(e,t,n);e.state.field(KZ,!1)?e.dispatch({effects:qZ.of(i)}):e.dispatch({effects:zW.appendConfig.of(KZ.init(()=>[i]))});let a=JZ.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(KZ).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var KZ=vW.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(qZ)?e=[n.value].concat(e):n.is(JZ)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>WZ.computeN([e],t=>t.field(e))}),qZ=zW.define(),JZ=zW.define();function YZ(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=IG(`form`),t.input){let e=IG(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(IG(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(IG(`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=IG(`div`,r,IG(`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 XZ=class extends nG{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};XZ.prototype.elementClass=``,XZ.prototype.toDOM=void 0,XZ.prototype.mapMode=$U.TrackBefore,XZ.prototype.startSide=XZ.prototype.endSide=-1,XZ.prototype.point=!0;var ZZ=dW.define(),QZ=dW.define(),$Z={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>sG.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},eQ=dW.define();function tQ(e){return[rQ(),eQ.of({...$Z,...e})]}var nQ=dW.define({combine:e=>e.some(e=>e)});function rQ(e){let t=[iQ];return e&&e.fixed===!1&&t.push(nQ.of(!0)),t}var iQ=Tq.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(eQ).map(t=>new cQ(e,t)),this.fixed=!e.state.facet(nQ);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(nQ)!=!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=sG.iter(this.view.state.facet(ZZ),this.view.viewport.from),r=[],i=this.gutters.map(e=>new sQ(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==nK.Text&&t){oQ(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==nK.Text){oQ(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(eQ),n=e.state.facet(eQ),r=e.docChanged||e.heightChanged||e.viewportChanged||!sG.eq(e.startState.facet(ZZ),e.state.facet(ZZ),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 cQ(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=>NX.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==LK.LTR?{left:r,right:i}:{right:r,left:i}})});function aQ(e){return Array.isArray(e)?e:[e]}function oQ(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var sQ=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=sG.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 lQ(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=[];oQ(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(QZ)){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()}}},cQ=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=aQ(t.markers(e)),t.initialSpacer&&(this.spacer=new lQ(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=aQ(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!sG.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()}},lQ=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`:``),uQ(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 uQ(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 dQ=dW.define(),fQ=dW.define(),pQ=dW.define({combine(e){return tG(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}})}}),mQ=class extends XZ{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function hQ(e,t){return e.state.facet(pQ).formatNumber(t,e.state)}var gQ=eQ.compute([pQ],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(dQ)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new mQ(hQ(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(fQ)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(pQ)!=e.state.facet(pQ),initialSpacer(e){return new mQ(hQ(e,vQ(e.state.doc.lines)))},updateSpacer(e,t){let n=hQ(t.view,vQ(t.view.state.doc.lines));return n==e.number?e:new mQ(n)},domEventHandlers:e.facet(pQ).domEventHandlers,side:`before`}));function _Q(e={}){return[pQ.of(e),rQ(),gQ]}function vQ(e){let t=9;for(;t<e;)t=t*10+9;return t}var yQ=new class extends XZ{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},bQ=ZZ.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(yQ.range(i)))}return sG.of(t)});function xQ(){return bQ}var SQ=1024,CQ=0,wQ=class{constructor(e,t){this.from=e,this.to=t}},TQ=class{constructor(e={}){this.id=CQ++,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=OQ.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};TQ.closedBy=new TQ({deserialize:e=>e.split(` `)}),TQ.openedBy=new TQ({deserialize:e=>e.split(` `)}),TQ.group=new TQ({deserialize:e=>e.split(` `)}),TQ.isolate=new TQ({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),TQ.contextHash=new TQ({perNode:!0}),TQ.lookAhead=new TQ({perNode:!0}),TQ.mounted=new TQ({perNode:!0});var EQ=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[TQ.mounted.id]}},DQ=Object.create(null),OQ=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):DQ,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(TQ.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(TQ.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};OQ.none=new OQ(``,Object.create(null),0,8);var kQ=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 OQ(e.name,r,e.id,e.flags):e)}return new e(n)}},AQ=new WeakMap,jQ=new WeakMap,MQ;(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`})(MQ||={});var NQ=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=EQ.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 qQ(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new qQ(AQ.get(this)||this.topNode);return r.moveTo(e,t),AQ.set(this,r._tree),r}get topNode(){return new zQ(this,0,0,null)}resolve(e,t=0){let n=LQ(AQ.get(this)||this.topNode,e,t,!1);return AQ.set(this,n),n}resolveInner(e,t=0){let n=LQ(jQ.get(this)||this.topNode,e,t,!0);return jQ.set(this,n),n}resolveStack(e,t=0){return KQ(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&MQ.IncludeAnonymous)>0;for(let e=this.cursor(a|MQ.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:QQ(OQ.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(OQ.none,t,n,r)))}static build(e){return YQ(e)}};NQ.empty=new NQ(OQ.none,[],[],0);var PQ=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)}},FQ=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return OQ.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&&!(IQ(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 IQ(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 LQ(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 zQ&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:MQ.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof zQ&&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 RQ=class{cursor(e=0){return new qQ(this,e)}getChild(e,t=null,n=null){let r=BQ(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return BQ(this,e,t,n)}resolve(e,t=0){return LQ(this,e,t,!1)}resolveInner(e,t=0){return LQ(this,e,t,!0)}matchContext(e){return VQ(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}},zQ=class e extends RQ{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&MQ.EnterBracketed&&l instanceof NQ&&(d=EQ.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!IQ(i,r,u,u+l.length))){if(l instanceof FQ){if(a&MQ.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new UQ(new HQ(o,l,t,u),null,e)}else if(a&MQ.IncludeAnonymous||!l.type.isAnonymous||JQ(l)){let s;if(!(a&MQ.IgnoreMounts)&&(s=EQ.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&MQ.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&MQ.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&MQ.IgnoreOverlays)&&(i=EQ.get(this._tree))&&i.overlay){let a=t-this.from,o=r&MQ.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 BQ(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 VQ(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 HQ=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},UQ=class e extends RQ{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&MQ.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 NQ(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function WQ(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 zQ&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new GQ(i,n)}var GQ=class{constructor(e,t){this.heads=e,this.node=t}get next(){return WQ(this.heads)}};function KQ(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof zQ?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=EQ.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new zQ(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(LQ(o,t,n,!1))}}return i?WQ(i):r}var qQ=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&~MQ.EnterBracketed,e instanceof zQ)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 zQ?(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&MQ.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&MQ.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&MQ.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&MQ.IncludeAnonymous||e instanceof FQ||!e.type.isAnonymous||JQ(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 UQ(this.buffer,t,this.stack[e]);return this.bufferNode=new UQ(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 VQ(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 VQ(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 JQ(e){return e.children.some(e=>e instanceof FQ||!e.type.isAnonymous||JQ(e))}function YQ(e){let{buffer:t,nodeSet:n,maxBufferLength:r=SQ,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new PQ(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:ee,end:te,size:S}=o,C=l,ne=c;if(S<0)if(o.next(),S==-1){let t=i[x];_.push(t),v.push(ee-e);return}else if(S==-3){c=x;return}else if(S==-4){l=x;return}else throw RangeError(`Unrecognized record size: ${S}`);let w=s[x],re,ie,ae=ee-e;if(te-ee<=r&&(ie=h(o.pos-t,y))){let t=new Uint16Array(ie.size-ie.skip),r=o.pos-ie.size,i=t.length;for(;o.pos>r;)i=g(ie.start,t,i);re=new FQ(t,te-ie.start,n),ae=ie.start-e}else{let e=o.pos-S;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=te;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,ee,s,o.end,c,i,C,ne),s=t.length,c=o.end),o.next()):b>2500?d(ee,e,t,n):u(ee,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,ee,s,ee,c,i,C,ne),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(w,ne);re=QQ(w,t,n,0,t.length,0,te-ee,e,e)}else re=m(w,t,n,te-ee,C-te,ne)}_.push(re),v.push(ae)}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 FQ(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 NQ){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(TQ.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=[TQ.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[TQ.lookAhead,i];o=o?[e].concat(o):[e]}return new NQ(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 NQ(s[e.topID],_.reverse(),v.reverse(),y)}var XQ=new WeakMap;function ZQ(e,t){if(!e.isAnonymous||t instanceof FQ||t.type!=e)return 1;let n=XQ.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof NQ)){n=1;break}n+=ZQ(e,r)}XQ.set(t,n)}return n}function QQ(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=ZQ(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=ZQ(e,t[s]);for(s++;s<i;s++){let n=ZQ(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(QQ(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 $Q=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 UQ?this.setBuffer(e.context.buffer,e.index,t):e instanceof zQ&&this.map.set(e.tree,t)}get(e){return e instanceof UQ?this.getBuffer(e.context.buffer,e.index):e instanceof zQ?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)}},e$=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}},t$=class{startParse(e,t,n){return typeof e==`string`&&(e=new n$(e)),n=n?n.length?n.map(e=>new wQ(e.from,e.to)):[new wQ(0,0)]:[new wQ(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}}},n$=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 r$(e){return(t,n,r,i)=>new c$(t,e,n,r,i)}var i$=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 a$(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var o$=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=[]}},s$=new TQ({perNode:!0}),c$=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 NQ(e.type,e.children,e.positions,e.length,e.propValues.concat([[s$,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[TQ.mounted.id]=new EQ(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 p$(this.fragments),t=null,n=null,r=new qQ(new zQ(this.baseTree,this.ranges[0].from,0,null),MQ.IncludeAnonymous|MQ.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=l$(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||(d$(r),t&&t.depth++,n&&n.depth++);let a=e.findMounts(r.from,i.parser);if(typeof i.overlay==`function`)t=new o$(i.parser,i.overlay,a,this.inner.length,r.from,!!i.bracketed,r.tree,t);else{let e=m$(this.ranges,i.overlay||(r.from<r.to?[new wQ(r.from,r.to)]:[]));e.length&&a$(e),(e.length||!i.overlay)&&this.inner.push(new i$(i.parser,e.length?i.parser.startParse(this.input,g$(a,e),e):i.parser.startParse(``),i.overlay?i.overlay.map(e=>new wQ(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 wQ(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=m$(this.ranges,t.ranges);e.length&&(a$(e),this.inner.splice(t.index,0,new i$(t.parser,t.parser.startParse(this.input,g$(t.mounts,e),e),t.ranges.map(e=>new wQ(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 l$(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 u$(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 d$(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=[];u$(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),u$(o,s[f+3],r,p,m,a),new NQ(i,p,m,u)}i.children[a]=l(0,s.length,OQ.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 zQ(n,r+e.from,t,e._tree))}}var f$=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(MQ.IncludeAnonymous|MQ.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,MQ.IgnoreOverlays|MQ.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 NQ)t=t.children[0];else break}return!1}},p$=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(s$)??t.to,this.inner=new f$(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(s$)??e.to,this.inner=new f$(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(TQ.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 m$(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 wQ(e.from,o),e.to>s&&n.splice(a+1,0,new wQ(s,e.to))):e.to>s?n[a--]=new wQ(s,e.to):n.splice(a--,1))}}return r}function h$(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 wQ(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 g$(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=h$(t,i.overlay.map(e=>new wQ(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 e$(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 e$(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}var _$=0,v$=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=_$++}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 b$(e);return e=>e.modified.indexOf(t)>-1?e:b$.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},y$=0,b$=class e{constructor(e){this.name=e,this.instances=[],this.id=y$++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&x$(n,e.modified));if(r)return r;let i=[],a=new v$(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=S$(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 x$(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function S$(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 C$(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 T$(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return w$.add(t)}var w$=new TQ({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 T$(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),T$=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}};T$.empty=new T$([],2,null);function E$(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 D$(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function O$(e,t,n,r=0,i=e.length){let a=new k$(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var k$=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=A$(e)||T$.empty,u=D$(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(TQ.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 A$(e){let t=e.type.prop(w$);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var X=v$.define,j$=X(),M$=X(),N$=X(M$),P$=X(M$),F$=X(),I$=X(F$),L$=X(F$),R$=X(),z$=X(R$),B$=X(),V$=X(),H$=X(),U$=X(H$),W$=X(),Z={comment:j$,lineComment:X(j$),blockComment:X(j$),docComment:X(j$),name:M$,variableName:X(M$),typeName:N$,tagName:X(N$),propertyName:P$,attributeName:X(P$),className:X(M$),labelName:X(M$),namespace:X(M$),macroName:X(M$),literal:F$,string:I$,docString:X(I$),character:X(I$),attributeValue:X(I$),number:L$,integer:X(L$),float:X(L$),bool:X(F$),regexp:X(F$),escape:X(F$),color:X(F$),url:X(F$),keyword:B$,self:X(B$),null:X(B$),atom:X(B$),unit:X(B$),modifier:X(B$),operatorKeyword:X(B$),controlKeyword:X(B$),definitionKeyword:X(B$),moduleKeyword:X(B$),operator:V$,derefOperator:X(V$),arithmeticOperator:X(V$),logicOperator:X(V$),bitwiseOperator:X(V$),compareOperator:X(V$),updateOperator:X(V$),definitionOperator:X(V$),typeOperator:X(V$),controlOperator:X(V$),punctuation:H$,separator:X(H$),bracket:U$,angleBracket:X(U$),squareBracket:X(U$),paren:X(U$),brace:X(U$),content:R$,heading:z$,heading1:X(z$),heading2:X(z$),heading3:X(z$),heading4:X(z$),heading5:X(z$),heading6:X(z$),contentSeparator:X(R$),list:X(R$),quote:X(R$),emphasis:X(R$),strong:X(R$),link:X(R$),monospace:X(R$),strikethrough:X(R$),inserted:X(),deleted:X(),changed:X(),invalid:X(),meta:W$,documentMeta:X(W$),annotation:X(W$),processingInstruction:X(W$),definition:v$.defineModifier(`definition`),constant:v$.defineModifier(`constant`),function:v$.defineModifier(`function`),standard:v$.defineModifier(`standard`),local:v$.defineModifier(`local`),special:v$.defineModifier(`special`)};for(let e in Z){let t=Z[e];t instanceof v$&&(t.name=e)}E$([{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 G$=new TQ;function K$(e){return dW.define({combine:e?t=>t.concat(e):void 0})}var q$=new TQ,J$=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,eG.prototype.hasOwnProperty(`tree`)||Object.defineProperty(eG.prototype,"tree",{get(){return Z$(this)}}),this.parser=t,this.extension=[o1.of(this),eG.languageData.of((e,t,n)=>{let r=Y$(e,t,n),i=r.type.prop(G$);if(!i)return[];let a=e.facet(i),o=r.type.prop(q$);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 Y$(e,t,n).type.prop(G$)==this.data}findRegions(e){let t=e.facet(o1);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(G$)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(TQ.mounted);if(i){if(i.tree.prop(G$)==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 NQ&&r(i,e.positions[n]+t)}};return r(Z$(e),0),n}get allowsNesting(){return!0}};J$.setState=zW.define();function Y$(e,t,n){let r=e.facet(o1),i=Z$(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,MQ.ExcludeBuffers|MQ.EnterBracketed))e.type.isTop&&(i=e);return i}var X$=class e extends J${constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=K$(t.languageData);return new e(n,t.parser.configure({props:[G$.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 Z$(e){let t=e.field(J$.state,!1);return t?t.tree:NQ.empty}var Q$=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)}},$$=null,e1=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,[],NQ.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Q$(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=NQ.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(e$.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(e$.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=$$;$$=this;try{return e()}finally{$$=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=t1(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=e$.applyChanges(r,e),i=NQ.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=t1(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 t${createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=$$;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 NQ(OQ.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 $$}};function t1(e,t,n){return e$.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var n1=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=e1.create(t.facet(o1).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};J$.state=vW.define({create:n1.init,update(e,t){for(let e of t.effects)if(e.is(J$.setState))return e.value;return t.startState.facet(o1)==t.state.facet(o1)?e.apply(t):n1.init(t.state)}});var r1=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(r1=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var i1=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,a1=Tq.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(J$.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(J$.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=r1(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(J$.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!i1?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>i1&&i1()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:J$.setState.of(new n1(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=>xq(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),o1=dW.define({combine(e){return e.length?e[0]:null},enables:e=>[J$.state,a1,NX.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),s1=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}},c1=dW.define(),l1=dW.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 u1(e){let t=e.facet(l1);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function d1(e,t){let n=``,r=e.tabSize,i=e.facet(l1)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function f1(e,t){e instanceof eG&&(e=new p1(e));for(let n of e.state.facet(c1)){let r=n(e,t);if(r!==void 0)return r}let n=Z$(e.state);return n.length>=t?h1(e,n,t):null}var p1=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=u1(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 bG(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}},m1=new TQ;function h1(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 g1(r,e,n)}function g1(e,t,n){for(let r=e;r;r=r.next){let e=v1(r.node);if(e)return e(b1.create(t,n,r))}return 0}function _1(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function v1(e){let t=e.type.prop(m1);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(TQ.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>w1(e,!0,1,void 0,n&&!_1(e)?t.from:void 0)}return e.parent==null?y1:null}function y1(){return 0}var b1=class e extends p1{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(x1(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return g1(this.context.next,this.base,this.pos)}};function x1(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function S1(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 C1({closing:e,align:t=!0,units:n=1}){return r=>w1(r,t,n,e)}function w1(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?S1(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var T1=e=>e.baseIndent;function E1({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var D1=200;function O1(){return eG.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+D1)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=f1(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=d1(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 k1=dW.define(),A1=new TQ;function j1(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 M1(e,t,n){let r=Z$(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(A1);if(s&&(i.to<r.length-50||r.length==e.doc.length||!N1(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function N1(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function P1(e,t,n){for(let r of e.facet(k1)){let i=r(e,t,n);if(i)return i}return M1(e,t,n)}function F1(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 I1=zW.define({map:F1}),L1=zW.define({map:F1});function R1(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 z1=vW.define({create(){return rK.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=B1(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(I1)&&!H1(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(Y1),i=r?rK.replace({widget:new $1(r(t.state,n.value))}):Q1;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(L1)&&(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=B1(e,t.selection.main.head)),e},provide:e=>NX.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(Q1.range(r,i))}return rK.set(t,!0)}});function B1(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 V1(e,t,n){var r;let i=null;return(r=e.field(z1,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function H1(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function U1(e,t){return e.field(z1,!1)?t:t.concat(zW.appendConfig.of(X1()))}var W1=e=>{for(let t of R1(e)){let n=P1(e.state,t.from,t.to);if(n)return e.dispatch({effects:U1(e.state,[I1.of(n),K1(e,n)])}),!0}return!1},G1=e=>{if(!e.state.field(z1,!1))return!1;let t=[];for(let n of R1(e)){let r=V1(e.state,n.from,n.to);r&&t.push(L1.of(r),K1(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function K1(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return NX.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var q1=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:W1},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:G1},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=P1(t,i.from,i.to);a&&n.push(I1.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:U1(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(z1,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(L1.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],J1={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},Y1=dW.define({combine(e){return tG(e,J1)}});function X1(e){let t=[z1,r0];return e&&t.push(Y1.of(e)),t}function Z1(e,t){let{state:n}=e,r=n.facet(Y1),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=V1(e.state,n.from,n.to);r&&e.dispatch({effects:L1.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 Q1=rK.replace({widget:new class extends tK{toDOM(e){return Z1(e,null)}}}),$1=class extends tK{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Z1(e,this.value)}},e0={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},t0=class extends XZ{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 n0(e={}){let t={...e0,...e},n=new t0(t,!0),r=new t0(t,!1),i=Tq.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(o1)!=e.state.facet(o1)||e.startState.field(z1,!1)!=e.state.field(z1,!1)||Z$(e.startState)!=Z$(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new lG;for(let i of e.viewportLineBlocks){let a=V1(e.state,i.from,i.to)?r:P1(e.state,i.from,i.to)?n:null;a&&t.add(i.from,i.from,a)}return t.finish()}}),{domEventHandlers:a}=t;return[i,tQ({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||sG.empty},initialSpacer(){return new t0(t,!1)},domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let r=V1(e.state,t.from,t.to);if(r)return e.dispatch({effects:L1.of(r)}),!0;let i=P1(e.state,t.from,t.to);return i?(e.dispatch({effects:I1.of(i)}),!0):!1}}}),X1()]}var r0=NX.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`}}),i0=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=EG.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 J$?e=>e.prop(G$)==a.data:a?e=>e==a:void 0,this.style=E$(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new EG(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},a0=dW.define(),o0=dW.define({combine(e){return e.length?[e[0]]:null}});function s0(e){let t=e.facet(a0);return t.length?t:e.facet(o0)}function c0(e,t){let n=[u0],r;return e instanceof i0&&(e.module&&n.push(NX.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(o0.of(e)):r?n.push(a0.computeN([NX.darkTheme],t=>t.facet(NX.darkTheme)==(r==`dark`)?[e]:[])):n.push(a0.of(e)),n}var l0=class{constructor(e){this.markCache=Object.create(null),this.tree=Z$(e.state),this.decorations=this.buildDeco(e,s0(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Z$(e.state),n=s0(e.state),r=n!=s0(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 rK.none;let n=new lG;for(let{from:r,to:i}of e.visibleRanges)O$(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=rK.mark({class:r})))},r,i);return n.finish()}},u0=xW.high(Tq.fromClass(l0,{decorations:e=>e.decorations})),d0=i0.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`}]),f0=NX.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),p0=1e4,m0=`()[]{}`,h0=dW.define({combine(e){return tG(e,{afterCursor:!0,brackets:m0,maxScanDistance:p0,renderMatch:v0})}}),g0=rK.mark({class:`cm-matchingBracket`}),_0=rK.mark({class:`cm-nonmatchingBracket`});function v0(e){let t=[],n=e.matched?g0:_0;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 y0(e){let t=[],n=e.facet(h0);for(let r of e.selection.ranges){if(!r.empty)continue;let i=T0(e,r.head,-1,n)||r.head>0&&T0(e,r.head-1,1,n)||n.afterCursor&&(T0(e,r.head,1,n)||r.head<e.doc.length&&T0(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return rK.set(t,!0)}var b0=[Tq.fromClass(class{constructor(e){this.paused=!1,this.decorations=y0(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=y0(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),f0];function x0(e={}){return[h0.of(e),b0]}var S0=new TQ;function C0(e,t,n){let r=e.prop(t<0?TQ.openedBy:TQ.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 w0(e){let t=e.type.prop(S0);return t?t(e.node):e}function T0(e,t,n,r={}){let i=r.maxScanDistance||p0,a=r.brackets||m0,o=Z$(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=C0(r.type,n,a);if(i&&r.from<r.to){let o=w0(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return E0(e,t,n,r,o,i,a)}}return D0(e,t,n,o,s.type,i,a)}function E0(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=w0(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(C0(u.type,n,o))l++;else if(C0(u.type,-n,o)){if(l==0){let e=w0(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 D0(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 O0(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 k0=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=O0(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??O0(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 A0(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||j0,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||z0,mergeTokens:e.mergeTokens!==!1}}function j0(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 M0=new WeakMap,N0=class e extends J${constructor(e){let t=K$(e.languageData),n=A0(e),r,i=new class extends t${createParse(e,t,n){return new L0(r,e,t,n)}};super(t,i,[],e.name),this.topNode=Y0(t,this),r=this,this.streamParser=n,this.stateAfter=new TQ({perNode:!0}),this.tokenTable=e.tokenTable?new G0(n.tokenTable):K0}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=M0.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=P0(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 k0(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)R0(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&&M0.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function P0(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 NQ&&s<i&&P0(e,o,s,r,i);if(c)return c}return null}function F0(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 NQ){if(!(c=F0(e,s,n-o,r-o,i)))break;return i?new NQ(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function I0(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&&P0(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=F0(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?u1(i):4),tree:NQ.empty}}var L0=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=e1.get(),a=r[0].from,{state:o,tree:s}=I0(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(u1(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=e1.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==`
|
|
143
|
-
`&&(t=``);else{let e=t.indexOf(`
|
|
144
|
-
`);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 k0(t,e?e.state.tabSize:4,e?u1(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=R0(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=NQ.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:V0,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new NQ(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 NQ(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function R0(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 z0=Object.create(null),B0=[OQ.none],V0=new kQ(B0),H0=[],U0=Object.create(null),W0=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`]])W0[e]=J0(z0,t);var G0=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),W0)}resolve(e){return e?this.table[e]||(this.table[e]=J0(this.extra,e)):0}},K0=new G0(z0);function q0(e,t){H0.indexOf(e)>-1||(H0.push(e),console.warn(t))}function J0(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):q0(n,`Modifier ${n} used at start of tag`):t.length?q0(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:q0(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=U0[i];if(a)return a.id;let o=U0[i]=OQ.define({id:B0.length,name:r,props:[C$({[r]:n})]});return B0.push(o),o.id}function Y0(e,t){let n=OQ.define({id:B0.length,name:`Document`,props:[G$.add(()=>e),m1.add(()=>e=>t.getIndent(e))],top:!0});return B0.push(n),n}LK.RTL,LK.LTR;var X0=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=t2(e.state,n.from);return r.line?Q0(e):r.block?e2(e):!1};function Z0(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 Q0=Z0(o2,0),$0=Z0(a2,0),e2=Z0((e,t)=>a2(e,t,i2(t)),0);function t2(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var n2=50;function r2(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-n2,r),o=e.sliceDoc(i,i+n2),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*n2?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+n2),d=e.sliceDoc(i-n2,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 i2(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 a2(e,t,n=t.selection.ranges){let r=n.map(e=>t2(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>r2(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 o2(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=t2(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 s2=IW.define(),c2=IW.define(),l2=dW.define(),u2=dW.define({combine(e){return tG(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)})}}),d2=vW.define({create(){return A2.empty},update(e,t){let n=t.state.facet(u2),r=t.annotation(s2);if(r){let i=v2.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?y2(o,o.length,n.minDepth,i):T2(o,t.startState.selection),new A2(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(c2);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(BW.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=v2.fromTransaction(t),o=t.annotation(BW.time),s=t.annotation(BW.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 A2(e.done.map(v2.fromJSON),e.undone.map(v2.fromJSON))}});function f2(e={}){return[d2,u2.of(e),NX.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?m2:e.inputType==`historyRedo`?h2:null;return n?(e.preventDefault(),n(t)):!1}})]}function p2(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(d2,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var m2=p2(0,!1),h2=p2(1,!1),g2=p2(0,!0),_2=p2(1,!0),v2=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&&tW.fromJSON(t.changes),[],t.mapped&&eW.fromJSON(t.mapped),t.startSelection&&J.fromJSON(t.startSelection),t.selectionsAfter.map(J.fromJSON))}static fromTransaction(t,n){let r=C2;for(let e of t.startState.facet(l2)){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,C2)}static selection(t){return new e(void 0,C2,void 0,void 0,t)}};function y2(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 b2(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 x2(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function S2(e,t){return e.length?t.length?e.concat(t):e:t}var C2=[],w2=200;function T2(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-w2));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),y2(e,e.length-1,1e9,n.setSelAfter(r)))}else return[v2.selection([t])]}function E2(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 D2(e,t){if(!e.length)return e;let n=e.length,r=C2;for(;n;){let i=O2(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?[v2.selection(r)]:C2}function O2(e,t,n){let r=S2(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):C2,n);if(!e.changes)return v2.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new v2(i,zW.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var k2=/^(input\.type|delete)($|\.)/,A2=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||k2.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,b2(s.changes,t.changes))||r==`input.type.compose`)?y2(o,o.length-1,i.minDepth,new v2(t.changes.compose(s.changes),S2(zW.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,C2)):y2(o,o.length,i.minDepth,t),new e(o,C2,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:C2;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&x2(a[a.length-1],t)?this:new e(T2(this.done,t),this.undone,n,r)}addMapping(t){return new e(D2(this.done,t),D2(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:s2.of({side:e,rest:E2(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?C2:r.slice(0,r.length-1);return i.mapped&&(n=D2(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:s2.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};A2.empty=new A2(C2,C2);var j2=[{key:`Mod-z`,run:m2,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:h2,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:h2,preventDefault:!0},{key:`Mod-u`,run:g2,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:_2,preventDefault:!0}];function M2(e,t){return J.create(e.ranges.map(t),e.mainIndex)}function N2(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function P2({state:e,dispatch:t},n){let r=M2(e.selection,n);return r.eq(e.selection,!0)?!1:(t(N2(e,r)),!0)}function F2(e,t){return J.cursor(t?e.to:e.from)}function I2(e,t){return P2(e,n=>n.empty?e.moveByChar(n,t):F2(n,t))}function L2(e){return e.textDirectionAt(e.state.selection.main.head)==LK.LTR}var R2=e=>I2(e,!L2(e)),z2=e=>I2(e,L2(e));function B2(e,t){return P2(e,n=>n.empty?e.moveByGroup(n,t):F2(n,t))}var V2=e=>B2(e,!L2(e)),H2=e=>B2(e,L2(e));typeof Intl<`u`&&Intl.Segmenter;function U2(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 W2(e,t,n){let r=Z$(e).resolveInner(t.head),i=n?TQ.closedBy:TQ.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;U2(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?T0(e,r.from,1):T0(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,J.cursor(s,n?-1:1)}var G2=e=>P2(e,t=>W2(e.state,t,!L2(e))),K2=e=>P2(e,t=>W2(e.state,t,L2(e)));function q2(e,t){return P2(e,n=>{if(!n.empty)return F2(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var J2=e=>q2(e,!1),Y2=e=>q2(e,!0);function X2(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(NX.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 Z2(e,t){let n=X2(e),{state:r}=e,i=M2(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):F2(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=NX.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(N2(r,i),{effects:a}),!0}var Q2=e=>Z2(e,!1),$2=e=>Z2(e,!0);function e4(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=J.cursor(r.from+n))}return i}var t4=e=>P2(e,t=>e4(e,t,!0)),n4=e=>P2(e,t=>e4(e,t,!1)),r4=e=>P2(e,t=>e4(e,t,!L2(e))),i4=e=>P2(e,t=>e4(e,t,L2(e))),a4=e=>P2(e,t=>J.cursor(e.lineBlockAt(t.head).from,1)),o4=e=>P2(e,t=>J.cursor(e.lineBlockAt(t.head).to,-1));function s4(e,t,n){let r=!1,i=M2(e.selection,t=>{let i=T0(e,t.head,-1)||T0(e,t.head,1)||t.head>0&&T0(e,t.head-1,1)||t.head<e.doc.length&&T0(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?J.range(t.anchor,a):J.cursor(a)});return r?(t(N2(e,i)),!0):!1}var c4=({state:e,dispatch:t})=>s4(e,t,!1);function l4(e,t){let n=M2(e.state.selection,e=>{let n=t(e);return J.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(N2(e.state,n)),!0)}function u4(e,t){return l4(e,n=>e.moveByChar(n,t))}var d4=e=>u4(e,!L2(e)),f4=e=>u4(e,L2(e));function p4(e,t){return l4(e,n=>e.moveByGroup(n,t))}var m4=e=>p4(e,!L2(e)),h4=e=>p4(e,L2(e)),g4=e=>l4(e,t=>W2(e.state,t,!L2(e))),_4=e=>l4(e,t=>W2(e.state,t,L2(e)));function v4(e,t){return l4(e,n=>e.moveVertically(n,t))}var y4=e=>v4(e,!1),b4=e=>v4(e,!0);function x4(e,t){return l4(e,n=>e.moveVertically(n,t,X2(e).height))}var S4=e=>x4(e,!1),C4=e=>x4(e,!0),w4=e=>l4(e,t=>e4(e,t,!0)),T4=e=>l4(e,t=>e4(e,t,!1)),E4=e=>l4(e,t=>e4(e,t,!L2(e))),D4=e=>l4(e,t=>e4(e,t,L2(e))),O4=e=>l4(e,t=>J.cursor(e.lineBlockAt(t.head).from)),k4=e=>l4(e,t=>J.cursor(e.lineBlockAt(t.head).to)),A4=({state:e,dispatch:t})=>(t(N2(e,{anchor:0})),!0),j4=({state:e,dispatch:t})=>(t(N2(e,{anchor:e.doc.length})),!0),M4=({state:e,dispatch:t})=>(t(N2(e,{anchor:e.selection.main.anchor,head:0})),!0),N4=({state:e,dispatch:t})=>(t(N2(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),P4=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),F4=({state:e,dispatch:t})=>{let n=e3(e).map(({from:t,to:n})=>J.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:J.create(n),userEvent:`select`})),!0},I4=({state:e,dispatch:t})=>{let n=M2(e.selection,t=>{let n=Z$(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 J.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(N2(e,n)),!0)};function L4(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(N2(n,J.create(i,i.length-1))),!0)}var R4=e=>L4(e,!1),z4=e=>L4(e,!0),B4=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=J.create([n.main]):n.main.empty||(r=J.create([J.cursor(n.main.head)])),r?(t(N2(e,r)),!0):!1};function V4(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=H4(e,o,!1)):o>i&&(n=`delete.forward`,o=H4(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=H4(e,i,!1),a=H4(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:J.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`?NX.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function H4(e,t,n){if(e instanceof NX)for(let r of e.state.facet(NX.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var U4=(e,t,n)=>V4(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=bG(s,a.tabSize)%u1(a)||u1(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=KU(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=KU(o.text,c-o.from,!1,!1)+o.from);return c}),W4=e=>U4(e,!1,!0),G4=e=>U4(e,!0,!1),K4=(e,t)=>V4(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=KU(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}),q4=e=>K4(e,!1),J4=e=>K4(e,!0),Y4=e=>V4(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),X4=e=>V4(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Z4=e=>V4(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Q4=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:FU.of([``,``])},range:J.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},$4=({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:KU(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:KU(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:J.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function e3(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 t3(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of e3(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(J.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(J.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:J.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var n3=({state:e,dispatch:t})=>t3(e,t,!1),r3=({state:e,dispatch:t})=>t3(e,t,!0);function i3(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of e3(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 a3=({state:e,dispatch:t})=>i3(e,t,!1),o3=({state:e,dispatch:t})=>i3(e,t,!0),s3=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(e3(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=M2(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 c3(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Z$(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(TQ.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 l3=d3(!1),u3=d3(!0);function d3(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&&c3(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new p1(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=f1(s,r);for(c??=bG(/^\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=[``,d1(t,c)];return o&&l.push(d1(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:FU.of(l)},range:J.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function f3(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:J.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var p3=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new p1(e,{overrideIndentation:e=>n[e]??-1}),i=f3(e,(t,i,a)=>{let o=f1(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=d1(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},m3=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(f3(e,(t,n)=>{n.push({from:t.from,insert:e.facet(l1)})}),{userEvent:`input.indent`})),!0),h3=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(f3(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=bG(r,e.tabSize),a=0,o=d1(e,Math.max(0,i-u1(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),g3=e=>(e.setTabFocusMode(),!0),_3=[{key:`Ctrl-b`,run:R2,shift:d4,preventDefault:!0},{key:`Ctrl-f`,run:z2,shift:f4},{key:`Ctrl-p`,run:J2,shift:y4},{key:`Ctrl-n`,run:Y2,shift:b4},{key:`Ctrl-a`,run:a4,shift:O4},{key:`Ctrl-e`,run:o4,shift:k4},{key:`Ctrl-d`,run:G4},{key:`Ctrl-h`,run:W4},{key:`Ctrl-k`,run:Y4},{key:`Ctrl-Alt-h`,run:q4},{key:`Ctrl-o`,run:Q4},{key:`Ctrl-t`,run:$4},{key:`Ctrl-v`,run:$2}],v3=[{key:`ArrowLeft`,run:R2,shift:d4,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:V2,shift:m4,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:r4,shift:E4,preventDefault:!0},{key:`ArrowRight`,run:z2,shift:f4,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:H2,shift:h4,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:i4,shift:D4,preventDefault:!0},{key:`ArrowUp`,run:J2,shift:y4,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:A4,shift:M4},{mac:`Ctrl-ArrowUp`,run:Q2,shift:S4},{key:`ArrowDown`,run:Y2,shift:b4,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:j4,shift:N4},{mac:`Ctrl-ArrowDown`,run:$2,shift:C4},{key:`PageUp`,run:Q2,shift:S4},{key:`PageDown`,run:$2,shift:C4},{key:`Home`,run:n4,shift:T4,preventDefault:!0},{key:`Mod-Home`,run:A4,shift:M4},{key:`End`,run:t4,shift:w4,preventDefault:!0},{key:`Mod-End`,run:j4,shift:N4},{key:`Enter`,run:l3,shift:l3},{key:`Mod-a`,run:P4},{key:`Backspace`,run:W4,shift:W4,preventDefault:!0},{key:`Delete`,run:G4,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:q4,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:J4,preventDefault:!0},{mac:`Mod-Backspace`,run:X4,preventDefault:!0},{mac:`Mod-Delete`,run:Z4,preventDefault:!0}].concat(_3.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),y3=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:G2,shift:g4},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:K2,shift:_4},{key:`Alt-ArrowUp`,run:n3},{key:`Shift-Alt-ArrowUp`,run:a3},{key:`Alt-ArrowDown`,run:r3},{key:`Shift-Alt-ArrowDown`,run:o3},{key:`Mod-Alt-ArrowUp`,run:R4},{key:`Mod-Alt-ArrowDown`,run:z4},{key:`Escape`,run:B4},{key:`Mod-Enter`,run:u3},{key:`Alt-l`,mac:`Ctrl-l`,run:F4},{key:`Mod-i`,run:I4,preventDefault:!0},{key:`Mod-[`,run:h3},{key:`Mod-]`,run:m3},{key:`Mod-Alt-\\`,run:p3},{key:`Shift-Mod-k`,run:s3},{key:`Shift-Mod-\\`,run:c4},{key:`Mod-/`,run:X0},{key:`Alt-A`,run:$0},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:g3}].concat(v3),b3={key:`Tab`,run:m3,shift:h3},x3=`#e5c07b`,S3=`#e06c75`,C3=`#56b6c2`,w3=`#ffffff`,T3=`#abb2bf`,E3=`#7d8799`,D3=`#61afef`,O3=`#98c379`,k3=`#d19a66`,A3=`#c678dd`,j3=`#21252b`,M3=`#2c313a`,N3=`#282c34`,P3=`#353a42`,F3=`#3E4451`,I3=`#528bff`,L3=[NX.theme({"&":{color:T3,backgroundColor:N3},".cm-content":{caretColor:I3},".cm-cursor, .cm-dropCursor":{borderLeftColor:I3},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:F3},".cm-panels":{backgroundColor:j3,color:T3},".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:N3,color:E3,border:`none`},".cm-activeLineGutter":{backgroundColor:M3},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:P3},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:P3,borderBottomColor:P3},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:M3,color:T3}}},{dark:!0}),c0(i0.define([{tag:Z.keyword,color:A3},{tag:[Z.name,Z.deleted,Z.character,Z.propertyName,Z.macroName],color:S3},{tag:[Z.function(Z.variableName),Z.labelName],color:D3},{tag:[Z.color,Z.constant(Z.name),Z.standard(Z.name)],color:k3},{tag:[Z.definition(Z.name),Z.separator],color:T3},{tag:[Z.typeName,Z.className,Z.number,Z.changed,Z.annotation,Z.modifier,Z.self,Z.namespace],color:x3},{tag:[Z.operator,Z.operatorKeyword,Z.url,Z.escape,Z.regexp,Z.link,Z.special(Z.string)],color:C3},{tag:[Z.meta,Z.comment],color:E3},{tag:Z.strong,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.link,color:E3,textDecoration:`underline`},{tag:Z.heading,fontWeight:`bold`,color:S3},{tag:[Z.atom,Z.bool,Z.special(Z.variableName)],color:k3},{tag:[Z.processingInstruction,Z.string,Z.inserted],color:O3},{tag:Z.invalid,color:w3}]))],R3=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,z3=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(R3(e)):R3,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 YU(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=XU(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=ZU(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`&&(z3.prototype[Symbol.iterator]=function(){return this});var B3={from:-1,to:-1,match:/.*/.exec(``),precise:!0},V3=`gm`+(/x/.unicode==null?``:`u`),H3=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=B3,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new G3(e,t,n,r,i);this.re=new RegExp(t,V3+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=q3(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=q3(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}}},U3=new WeakMap,W3=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=U3.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return U3.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)),U3.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},G3=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=B3,this.matchPos=q3(e,r),this.re=new RegExp(t,V3+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=W3.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=q3(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=W3.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(H3.prototype[Symbol.iterator]=G3.prototype[Symbol.iterator]=function(){return this});function K3(e){try{return new RegExp(e,V3),!0}catch{return!1}}function q3(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 J3=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=GZ(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=J.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,NX.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},Y3={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},X3=dW.define({combine(e){return tG(e,Y3,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Z3(e){let t=[r6,n6];return e&&t.push(X3.of(e)),t}var Q3=rK.mark({class:`cm-selectionMatch`}),$3=rK.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function e6(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=YW.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=YW.Word)}function t6(e,t,n,r){return e(t.sliceDoc(n,n+1))==YW.Word&&e(t.sliceDoc(r-1,r))==YW.Word}var n6=Tq.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(X3),{state:n}=e,r=n.selection;if(r.ranges.length>1)return rK.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return rK.none;let e=n.wordAt(i.head);if(!e)return rK.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 rK.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(e6(o,n,i.from,i.to)&&t6(o,n,i.from,i.to)))return rK.none}else if(a=n.sliceDoc(i.from,i.to),!a)return rK.none}let s=[];for(let r of e.visibleRanges){let e=new z3(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||e6(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push($3.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Q3.range(r,a)),s.length>t.maxMatches))return rK.none}}return rK.set(s)}},{decorations:e=>e.decorations}),r6=NX.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),i6=({state:e,dispatch:t})=>{let{selection:n}=e,r=J.create(n.ranges.map(t=>e.wordAt(t.head)||J.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function a6(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 z3(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new z3(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 o6=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return i6({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=a6(e,r);return i?(t(e.update({selection:e.selection.addRange(J.range(i.from,i.to),!1),effects:NX.scrollIntoView(i.to)})),!0):!1},s6=dW.define({combine(e){return tG(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new V6(e),scrollToMatch:e=>NX.scrollIntoView(e)})}}),c6=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||K3(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`?`
|
|
145
|
-
`: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 y6(this):new p6(this)}getCursor(e,t=0,n){let r=e.doc?e:eG.create({doc:e});return n??=r.doc.length,this.regexp?h6(this,r,t,n):d6(this,r,t,n)}},l6=class{constructor(e){this.spec=e}};function u6(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 d6(e,t,n,r){let i;return e.wholeWord&&(i=f6(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=u6(e.test,t,i)),new z3(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function f6(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(g6(i,n-a))!=YW.Word||t(_6(i,n-a))!=YW.Word)&&(t(_6(i,r-a))!=YW.Word||t(g6(i,r-a))!=YW.Word))}var p6=class extends l6{constructor(e){super(e)}nextMatch(e,t,n){let r=d6(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=d6(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=d6(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=d6(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=d6(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 m6(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function h6(e,t,n,r){let i;return e.wholeWord&&(i=v6(t.charCategorizer(t.selection.main.head))),e.test&&(i=m6(e.test,t,i)),new H3(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function g6(e,t){return e.slice(KU(e,t,!1),t)}function _6(e,t){return e.slice(t,KU(e,t))}function v6(e){return(t,n,r)=>!r[0].length||(e(g6(r.input,r.index))!=YW.Word||e(_6(r.input,r.index))!=YW.Word)&&(e(_6(r.input,r.index+r[0].length))!=YW.Word||e(g6(r.input,r.index+r[0].length))!=YW.Word)}var y6=class extends l6{nextMatch(e,t,n){let r=h6(this.spec,e,n,e.doc.length).next();return r.done&&(r=h6(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=h6(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=h6(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=h6(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)}},b6=zW.define(),x6=zW.define(),S6=vW.define({create(e){return new C6(F6(e).create(),null)},update(e,t){for(let n of t.effects)n.is(b6)?e=new C6(n.value.create(),e.panel):n.is(x6)&&(e=new C6(e.query,n.value?P6:null));return e},provide:e=>WZ.from(e,e=>e.panel)}),C6=class{constructor(e,t){this.query=e,this.panel=t}},w6=rK.mark({class:`cm-searchMatch`}),T6=rK.mark({class:`cm-searchMatch cm-searchMatch-selected`}),E6=Tq.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(S6))}update(e){let t=e.state.field(S6);(t!=e.startState.field(S6)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return rK.none;let{view:n}=this,r=new lG;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?T6:w6)})}return r.finish()}},{decorations:e=>e.decorations});function D6(e){return t=>{let n=t.state.field(S6,!1);return n&&n.query.spec.valid?e(t,n):R6(t)}}var O6=D6((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=J.single(r.from,r.to),a=e.state.facet(s6);return e.dispatch({selection:i,effects:[G6(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),L6(e),!0}),k6=D6((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=J.single(i.from,i.to),o=e.state.facet(s6);return e.dispatch({selection:a,effects:[G6(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),L6(e),!0}),A6=D6((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:J.create(n.map(e=>J.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),j6=({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 z3(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(J.range(t.value.from,t.value.to))}return t(e.update({selection:J.create(a,o),userEvent:`select.search.matches`})),!0},M6=D6((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(NX.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=J.single(o.from,o.to).map(d),u.push(G6(e,o)),u.push(n.facet(s6).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),N6=D6((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:NX.announce.of(r),userEvent:`input.replace.all`}),!0});function P6(e){return e.state.facet(s6).createPanel(e)}function F6(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(s6);return new c6({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 I6(e){let t=BZ(e,P6);return t&&t.dom.querySelector(`[main-field]`)}function L6(e){let t=I6(e);t&&t==e.root.activeElement&&t.select()}var R6=e=>{let t=e.state.field(S6,!1);if(t&&t.panel){let n=I6(e);if(n&&n!=e.root.activeElement){let r=F6(e.state,t.query.spec);r.valid&&e.dispatch({effects:b6.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[x6.of(!0),t?b6.of(F6(e.state,t.query.spec)):zW.appendConfig.of(q6)]});return!0},z6=e=>{let t=e.state.field(S6,!1);if(!t||!t.panel)return!1;let n=BZ(e,P6);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:x6.of(!1)}),!0},B6=[{key:`Mod-f`,run:R6,scope:`editor search-panel`},{key:`F3`,run:O6,shift:k6,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:O6,shift:k6,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:z6,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:j6},{key:`Mod-Alt-g`,run:J3},{key:`Mod-d`,run:o6,preventDefault:!0}],V6=class{constructor(e){this.view=e;let t=this.query=e.state.field(S6).query.spec;this.commit=this.commit.bind(this),this.searchField=IG(`input`,{value:t.search,placeholder:H6(e,`Find`),"aria-label":H6(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=IG(`input`,{value:t.replace,placeholder:H6(e,`Replace`),"aria-label":H6(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=IG(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=IG(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=IG(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return IG(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=IG(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>O6(e),[H6(e,`next`)]),n(`prev`,()=>k6(e),[H6(e,`previous`)]),n(`select`,()=>A6(e),[H6(e,`all`)]),IG(`label`,null,[this.caseField,H6(e,`match case`)]),IG(`label`,null,[this.reField,H6(e,`regexp`)]),IG(`label`,null,[this.wordField,H6(e,`by word`)]),...e.state.readOnly?[]:[IG(`br`),this.replaceField,n(`replace`,()=>M6(e),[H6(e,`replace`)]),n(`replaceAll`,()=>N6(e),[H6(e,`replace all`)])],IG(`button`,{name:`close`,onclick:()=>z6(e),"aria-label":H6(e,`close`),type:`button`},[`×`])])}commit(){let e=new c6({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:b6.of(e)}))}keydown(e){GX(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?k6:O6)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),M6(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(b6)&&!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(s6).top}};function H6(e,t){return e.state.phrase(t)}var U6=30,W6=/[\s\.,:;?!]/;function G6(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-U6),o=Math.min(i,n+U6),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<U6;e++)if(!W6.test(s[e+1])&&W6.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-U6;e--)if(!W6.test(s[e-1])&&W6.test(s[e])){s=s.slice(0,e);break}}return NX.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var K6=NX.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`}}),q6=[S6,xW.low(E6),K6],J6=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=Z$(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(t8(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 Y6(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 X6(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=Y6(t)+Y6(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function Z6(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:X6(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function Q6(e,t){return n=>{for(let t=Z$(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 $6=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function e8(e){return e.selection.main.from}function t8(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 n8=IW.define();function r8(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:J.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var i8=new WeakMap;function a8(e){if(!Array.isArray(e))return e;let t=i8.get(e);return t||i8.set(e,t=Z6(e)),t}var o8=zW.define(),s8=zW.define(),c8=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=YU(e,t),r=ZU(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(YU(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=YU(e,0),i=ZU(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=YU(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=ZU(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=YU(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=XU(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+=ZU(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?ZU(YU(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)}},l8=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)}},u8=dW.define({combine(e){return tG(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:f8,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=>d8(e(n),t(n)),optionClass:(e,t)=>n=>d8(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function d8(e,t){return e?t?e+` `+t:e:t}function f8(e,t,n,r,i,a){let o=e.textDirection==LK.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 p8=zW.define();function m8(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 h8(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 g8=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(u8);this.optionContent=m8(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=h8(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:p8.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(u8).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:s8.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=h8(r.length,i,e.state.facet(u8).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=h8(t.options.length,t.selected,this.view.state.facet(u8).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=>xq(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&&v8(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(u8).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 _8(e,t){return n=>new g8(n,e,t)}function v8(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 y8(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function b8(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(u8);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 $6(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new l8(n):new c8(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 $6(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):y8(e.completion)>y8(c)&&(s[s.length-1]=e),c=e.completion}return s}var x8=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,E8(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=b8(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(u8).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,E8(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:F8,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)}},S8=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(D8,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(u8),i=(r.override||n.languageDataAt(`autocomplete`,e8(n)).map(a8)).map(e=>(this.active.find(t=>t.source==e)||new k8(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(M8));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!C8(i,this.active)||o?a=x8.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 k8(e.source,0):e));for(let e of t.effects)e.is(p8)&&(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?w8:T8}};function C8(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 w8={"aria-autocomplete":`list`},T8={};function E8(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var D8=[];function O8(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(n8);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 k8=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=O8(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(o8))i=new e(i.source,1,n.value);else if(n.is(s8))i=new e(i.source,0);else if(n.is(M8))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(e8(e.state))}},A8=class e extends k8{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=e8(t.state);if(o>a||!r||n&2&&(e8(t.startState)==this.from||o<this.limit))return new k8(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return j8(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 J6(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??e8(t.state)):new k8(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 k8(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function j8(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):t8(e,!0).test(i)}var M8=zW.define({map(e,t){return e.map(e=>e.map(t))}}),N8=vW.define({create(){return S8.start()},update(e,t){return e.update(t)},provide:e=>[LZ.from(e,e=>e.tooltip),NX.contentAttributes.from(e,e=>e.attrs)]});function P8(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(N8).active.find(e=>e.source==t.source);return r instanceof A8?(typeof n==`string`?e.dispatch({...r8(e.state,n,r.from,r.to),annotations:n8.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var F8=_8(N8,P8);function I8(e,t=`option`){return n=>{let r=n.state.field(N8,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(u8).interactionDelay)return!1;let i=1,a;t==`page`&&(a=RZ(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:p8.of(s)}),!0}}var L8=e=>{let t=e.state.field(N8,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(u8).interactionDelay?!1:P8(e,t.open.options[t.open.selected])},R8=e=>e.state.field(N8,!1)?(e.dispatch({effects:o8.of(!0)}),!0):!1,z8=e=>{let t=e.state.field(N8,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:s8.of(null)}),!0)},B8=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},V8=50,H8=1e3,U8=Tq.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(N8).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(N8),n=e.state.facet(u8);if(!e.selectionSet&&!e.docChanged&&e.startState.field(N8)==t)return;let r=e.transactions.some(e=>{let t=O8(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>V8&&Date.now()-n.time>H8){for(let e of n.context.abortListeners)try{e()}catch(e){xq(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(o8)))&&(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(N8);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(u8).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new J6(t,e8(t),e.explicit,this.view),r=new B8(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:s8.of(null)}),xq(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(u8).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(u8),n=this.view.state.field(N8);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=e8(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new A8(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 k8(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:M8.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(N8,!1);if(t&&t.tooltip&&this.view.state.facet(u8).closeOnBlur){let n=t.open&&RZ(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:s8.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:o8.of(!1)}),20),this.composing=0}}}),W8=typeof navigator==`object`&&/Win/.test(navigator.platform),G8=xW.highest(NX.domEventHandlers({keydown(e,t){let n=t.state.field(N8,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(W8&&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&&P8(t,r),!1}})),K8=NX.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`}}}),q8=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},J8=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,$U.TrackDel),r=t.mapPos(this.to,1,$U.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},Y8=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(l1);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 J8(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 q8(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)}},X8=rK.widget({widget:new class extends tK{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),Z8=rK.mark({class:`cm-snippetField`}),Q8=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=rK.set(e.map(e=>(e.from==e.to?X8:Z8).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))}},$8=zW.define({map(e,t){return e&&e.map(t)}}),e5=zW.define(),t5=vW.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is($8))return n.value;if(n.is(e5)&&e)return new Q8(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=>NX.decorations.from(e,e=>e?e.deco:rK.none)});function n5(e,t){return J.create(e.filter(e=>e.field==t).map(e=>J.range(e.from,e.to)))}function r5(e){let t=Y8.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:FU.of(a)},scrollIntoView:!0,annotations:n?[n8.of(n),BW.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=n5(o,0)),o.some(e=>e.field>0)){let t=new Q8(o,0),n=c.effects=[$8.of(t)];e.state.field(t5,!1)===void 0&&n.push(zW.appendConfig.of([t5,s5,l5,K8]))}e.dispatch(e.state.update(c))}}function i5(e){return({state:t,dispatch:n})=>{let r=t.field(t5,!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:n5(r.ranges,i),effects:$8.of(a?null:new Q8(r.ranges,i)),scrollIntoView:!0})),!0}}var a5=[{key:`Tab`,run:i5(1),shift:i5(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(t5,!1)?(t(e.update({effects:$8.of(null)})),!0):!1}],o5=dW.define({combine(e){return e.length?e[0]:a5}}),s5=xW.highest(HX.compute([o5],e=>e.facet(o5)));function c5(e,t){return{...t,apply:r5(e)}}var l5=NX.domEventHandlers({mousedown(e,t){let n=t.state.field(t5,!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:n5(n.ranges,i.field),effects:$8.of(n.ranges.some(e=>e.field>i.field)?new Q8(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),u5={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},d5=zW.define({map(e,t){return t.mapPos(e,-1,$U.TrackAfter)??void 0}}),f5=new class extends nG{};f5.startSide=1,f5.endSide=-1;var p5=vW.define({create(){return sG.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(d5)&&(e=e.update({add:[f5.range(n.value,n.value+1)]}));return e}});function m5(){return[y5,p5]}var h5=`()[]{}<>«»»«[]{}`;function g5(e){for(let t=0;t<16;t+=2)if(h5.charCodeAt(t)==e)return h5.charAt(t+1);return XU(e<128?e:e+1)}function _5(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||u5}var v5=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),y5=NX.inputHandler.of((e,t,n,r)=>{if((v5?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&ZU(YU(r,0))==1||t!=i.from||n!=i.to)return!1;let a=x5(e.state,r);return a?(e.dispatch(a),!0):!1}),b5=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=_5(e,e.selection.main.head).brackets||u5.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=w5(e.doc,t.head);for(let i of n)if(i==r&&C5(e.doc,t.head)==g5(YU(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:J.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function x5(e,t){let n=_5(e,e.selection.main.head),r=n.brackets||u5.brackets;for(let i of r){let a=g5(YU(i,0));if(t==i)return a==i?D5(e,i,r.indexOf(i+i+i)>-1,n):T5(e,i,a,n.before||u5.before);if(t==a&&S5(e,e.selection.main.from))return E5(e,i,a)}return null}function S5(e,t){let n=!1;return e.field(p5).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function C5(e,t){let n=e.sliceString(t,t+2);return n.slice(0,ZU(YU(n,0)))}function w5(e,t){let n=e.sliceString(t-2,t);return ZU(YU(n,0))==n.length?n:n.slice(1)}function T5(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:d5.of(a.to+t.length),range:J.range(a.anchor+t.length,a.head+t.length)};let o=C5(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:d5.of(a.head+t.length),range:J.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function E5(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&C5(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:J.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function D5(e,t,n,r){let i=r.stringPrefixes||u5.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:d5.of(r.to+t.length),range:J.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=C5(e.doc,o),c;if(s==t){if(O5(e,o))return{changes:{insert:t+t,from:o},effects:d5.of(o+t.length),range:J.cursor(o+t.length)};if(S5(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:J.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=A5(e,o-2*t.length,i))>-1&&O5(e,c))return{changes:{insert:t+t+t+t,from:o},effects:d5.of(o+t.length),range:J.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=YW.Word&&A5(e,o,i)>-1&&!k5(e,o,t,i))return{changes:{insert:t+t,from:o},effects:d5.of(o+t.length),range:J.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function O5(e,t){let n=Z$(e).resolveInner(t+1);return n.parent&&n.from==t}function k5(e,t,n,r){let i=Z$(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 A5(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=YW.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))!=YW.Word)return n}return-1}function j5(e={}){return[G8,N8,u8.of(e),U8,N5,K8]}var M5=[{key:`Ctrl-Space`,run:R8},{mac:"Alt-`",run:R8},{mac:`Alt-i`,run:R8},{key:`Escape`,run:z8},{key:`ArrowDown`,run:I8(!0)},{key:`ArrowUp`,run:I8(!1)},{key:`PageDown`,run:I8(!0,`page`)},{key:`PageUp`,run:I8(!1,`page`)},{key:`Enter`,run:L8}],N5=xW.highest(HX.computeN([u8],e=>e.facet(u8).defaultKeymap?[M5]:[]));function $(e){return new s1(N0.define(e))}function P5(e){return q(()=>import(`./dist-DHn6nBzr.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var F5=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return q(()=>import(`./dist-BUHRxvDG.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 q(()=>import(`./dist-BUHRxvDG.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return P5(`Cassandra`)}}),Q.of({name:`CSS`,extensions:[`css`],load(){return q(()=>import(`./dist-DyvYLMW9.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([10,8]),import.meta.url)}}),Q.of({name:`Go`,extensions:[`go`],load(){return q(()=>import(`./dist-CVQRZjPu.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 q(()=>import(`./dist-Bs-jQcRX.js`).then(e=>e.html()),__vite__mapDeps([12,10,8,13]),import.meta.url)}}),Q.of({name:`Java`,extensions:[`java`],load(){return q(()=>import(`./dist-D82mtD2s.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 q(()=>import(`./dist-BZ9n9AjO.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 q(()=>import(`./dist-C2xjE7cO.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 q(()=>import(`./dist-eoW6tZXA.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return q(()=>import(`./dist-BZ9n9AjO.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 q(()=>import(`./dist-ivOya1LD.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return q(()=>import(`./dist-C99THtIA.js`).then(e=>e.liquid()),__vite__mapDeps([18,12,10,8,13]),import.meta.url)}}),Q.of({name:`MariaDB SQL`,load(){return P5(`MariaSQL`)}}),Q.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return q(()=>import(`./dist-Cf23NY4L.js`).then(e=>e.markdown()),__vite__mapDeps([19,12,10,8,13]),import.meta.url)}}),Q.of({name:`MS SQL`,load(){return P5(`MSSQL`)}}),Q.of({name:`MySQL`,load(){return P5(`MySQL`)}}),Q.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return q(()=>import(`./dist-6CVKuTAe.js`).then(e=>e.php()),__vite__mapDeps([20,12,10,8,13]),import.meta.url)}}),Q.of({name:`PLSQL`,extensions:[`pls`],load(){return P5(`PLSQL`)}}),Q.of({name:`PostgreSQL`,load(){return P5(`PostgreSQL`)}}),Q.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return q(()=>import(`./dist-Cwt7koer.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return q(()=>import(`./dist-BibcG1V9.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return q(()=>import(`./dist-C7-3jInC.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SCSS`,extensions:[`scss`],load(){return q(()=>import(`./dist-C7-3jInC.js`).then(e=>e.sass()),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SQL`,extensions:[`sql`],load(){return P5(`StandardSQL`)}}),Q.of({name:`SQLite`,load(){return P5(`SQLite`)}}),Q.of({name:`TSX`,extensions:[`tsx`],load(){return q(()=>import(`./dist-BZ9n9AjO.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 q(()=>import(`./dist-BZ9n9AjO.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 q(()=>import(`./dist-DF06ORQo.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 q(()=>import(`./dist-CgF3fj15.js`).then(e=>e.xml()),__vite__mapDeps([25,8]),import.meta.url)}}),Q.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return q(()=>import(`./dist-CGcp2ex8.js`).then(e=>e.yaml()),__vite__mapDeps([26,8]),import.meta.url)}}),Q.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return q(()=>import(`./apl-CnwPGSsG.js`).then(e=>$(e.apl)),[],import.meta.url)}}),Q.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return q(()=>import(`./asciiarmor-qTkVPQu6.js`).then(e=>$(e.asciiArmor)),[],import.meta.url)}}),Q.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return q(()=>import(`./asn1-Dr8qZg38.js`).then(e=>$(e.asn1({}))),[],import.meta.url)}}),Q.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return q(()=>import(`./asterisk-Bja0s6e1.js`).then(e=>$(e.asterisk)),[],import.meta.url)}}),Q.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return q(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[],import.meta.url)}}),Q.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return q(()=>import(`./cobol-B_OZ4V-R.js`).then(e=>$(e.cobol)),[],import.meta.url)}}),Q.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return q(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.csharp)),[],import.meta.url)}}),Q.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return q(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`ClojureScript`,extensions:[`cljs`],load(){return q(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return q(()=>import(`./css-CYpP4FRV.js`).then(e=>$(e.gss)),[],import.meta.url)}}),Q.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return q(()=>import(`./cmake-CyVbuzPu.js`).then(e=>$(e.cmake)),[],import.meta.url)}}),Q.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return q(()=>import(`./coffeescript-B2pKbFk8.js`).then(e=>$(e.coffeeScript)),[],import.meta.url)}}),Q.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return q(()=>import(`./commonlisp-CcllspGY.js`).then(e=>$(e.commonLisp)),[],import.meta.url)}}),Q.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return q(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[],import.meta.url)}}),Q.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return q(()=>import(`./python-BqYw9LYJ.js`).then(e=>$(e.cython)),[],import.meta.url)}}),Q.of({name:`Crystal`,extensions:[`cr`],load(){return q(()=>import(`./crystal-M5-qzICs.js`).then(e=>$(e.crystal)),[],import.meta.url)}}),Q.of({name:`D`,extensions:[`d`],load(){return q(()=>import(`./d-BhMjBjQP.js`).then(e=>$(e.d)),[],import.meta.url)}}),Q.of({name:`Dart`,extensions:[`dart`],load(){return q(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.dart)),[],import.meta.url)}}),Q.of({name:`diff`,extensions:[`diff`,`patch`],load(){return q(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[],import.meta.url)}}),Q.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return q(()=>import(`./dockerfile-BLkNEvjs.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([27,28]),import.meta.url)}}),Q.of({name:`DTD`,extensions:[`dtd`],load(){return q(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[],import.meta.url)}}),Q.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return q(()=>import(`./dylan-C6jEEEk-.js`).then(e=>$(e.dylan)),[],import.meta.url)}}),Q.of({name:`EBNF`,load(){return q(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[],import.meta.url)}}),Q.of({name:`ECL`,extensions:[`ecl`],load(){return q(()=>import(`./ecl-BSZaIHnp.js`).then(e=>$(e.ecl)),[],import.meta.url)}}),Q.of({name:`edn`,extensions:[`edn`],load(){return q(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Eiffel`,extensions:[`e`],load(){return q(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[],import.meta.url)}}),Q.of({name:`Elm`,extensions:[`elm`],load(){return q(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[],import.meta.url)}}),Q.of({name:`Erlang`,extensions:[`erl`],load(){return q(()=>import(`./erlang-DaB2Rkuy.js`).then(e=>$(e.erlang)),[],import.meta.url)}}),Q.of({name:`Esper`,load(){return q(()=>import(`./sql-DcCJ9jop.js`).then(e=>$(e.esper)),[],import.meta.url)}}),Q.of({name:`Factor`,extensions:[`factor`],load(){return q(()=>import(`./factor-D7LVTn2l.js`).then(e=>$(e.factor)),__vite__mapDeps([29,28]),import.meta.url)}}),Q.of({name:`FCL`,load(){return q(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[],import.meta.url)}}),Q.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return q(()=>import(`./forth-Cezjo90N.js`).then(e=>$(e.forth)),[],import.meta.url)}}),Q.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return q(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[],import.meta.url)}}),Q.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return q(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[],import.meta.url)}}),Q.of({name:`Gas`,extensions:[`s`],load(){return q(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[],import.meta.url)}}),Q.of({name:`Gherkin`,extensions:[`feature`],load(){return q(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[],import.meta.url)}}),Q.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return q(()=>import(`./groovy-BC3IOsC8.js`).then(e=>$(e.groovy)),[],import.meta.url)}}),Q.of({name:`Haskell`,extensions:[`hs`],load(){return q(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[],import.meta.url)}}),Q.of({name:`Haxe`,extensions:[`hx`],load(){return q(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.haxe)),[],import.meta.url)}}),Q.of({name:`HXML`,extensions:[`hxml`],load(){return q(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.hxml)),[],import.meta.url)}}),Q.of({name:`HTTP`,load(){return q(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[],import.meta.url)}}),Q.of({name:`IDL`,extensions:[`pro`],load(){return q(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[],import.meta.url)}}),Q.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return q(()=>import(`./javascript-9Tg8ixDm.js`).then(e=>$(e.jsonld)),[],import.meta.url)}}),Q.of({name:`Julia`,extensions:[`jl`],load(){return q(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[],import.meta.url)}}),Q.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return q(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.kotlin)),[],import.meta.url)}}),Q.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return q(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[],import.meta.url)}}),Q.of({name:`Lua`,extensions:[`lua`],load(){return q(()=>import(`./lua-CiA1ziua.js`).then(e=>$(e.lua)),[],import.meta.url)}}),Q.of({name:`mIRC`,extensions:[`mrc`],load(){return q(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[],import.meta.url)}}),Q.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return q(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[],import.meta.url)}}),Q.of({name:`Modelica`,extensions:[`mo`],load(){return q(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[],import.meta.url)}}),Q.of({name:`MUMPS`,extensions:[`mps`],load(){return q(()=>import(`./mumps-CW_TBmxz.js`).then(e=>$(e.mumps)),[],import.meta.url)}}),Q.of({name:`Mbox`,extensions:[`mbox`],load(){return q(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[],import.meta.url)}}),Q.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return q(()=>import(`./nginx-BMaDbqW3.js`).then(e=>$(e.nginx)),[],import.meta.url)}}),Q.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return q(()=>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 q(()=>import(`./ntriples-d28e9m0E.js`).then(e=>$(e.ntriples)),[],import.meta.url)}}),Q.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return q(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveC)),[],import.meta.url)}}),Q.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return q(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveCpp)),[],import.meta.url)}}),Q.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return q(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[],import.meta.url)}}),Q.of({name:`Octave`,extensions:[`m`],load(){return q(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[],import.meta.url)}}),Q.of({name:`Oz`,extensions:[`oz`],load(){return q(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[],import.meta.url)}}),Q.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return q(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[],import.meta.url)}}),Q.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return q(()=>import(`./perl-CdEHsPfU.js`).then(e=>$(e.perl)),[],import.meta.url)}}),Q.of({name:`Pig`,extensions:[`pig`],load(){return q(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[],import.meta.url)}}),Q.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return q(()=>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 q(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[],import.meta.url)}}),Q.of({name:`ProtoBuf`,extensions:[`proto`],load(){return q(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[],import.meta.url)}}),Q.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return q(()=>import(`./pug-Bugr-47h.js`).then(e=>$(e.pug)),__vite__mapDeps([31,32]),import.meta.url)}}),Q.of({name:`Puppet`,extensions:[`pp`],load(){return q(()=>import(`./puppet-B4hC2X4m.js`).then(e=>$(e.puppet)),[],import.meta.url)}}),Q.of({name:`Q`,extensions:[`q`],load(){return q(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[],import.meta.url)}}),Q.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return q(()=>import(`./r-DADKenSm.js`).then(e=>$(e.r)),[],import.meta.url)}}),Q.of({name:`RPM Changes`,load(){return q(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[],import.meta.url)}}),Q.of({name:`RPM Spec`,extensions:[`spec`],load(){return q(()=>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 q(()=>import(`./ruby-DsYpTuWg.js`).then(e=>$(e.ruby)),[],import.meta.url)}}),Q.of({name:`SAS`,extensions:[`sas`],load(){return q(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[],import.meta.url)}}),Q.of({name:`Scala`,extensions:[`scala`],load(){return q(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.scala)),[],import.meta.url)}}),Q.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return q(()=>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 q(()=>import(`./shell-Du5Qg9im.js`).then(e=>$(e.shell)),[],import.meta.url)}}),Q.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return q(()=>import(`./sieve-BAxa3IjF.js`).then(e=>$(e.sieve)),[],import.meta.url)}}),Q.of({name:`Smalltalk`,extensions:[`st`],load(){return q(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[],import.meta.url)}}),Q.of({name:`Solr`,load(){return q(()=>import(`./solr-BBopId9w.js`).then(e=>$(e.solr)),[],import.meta.url)}}),Q.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return q(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[],import.meta.url)}}),Q.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return q(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[],import.meta.url)}}),Q.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return q(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[],import.meta.url)}}),Q.of({name:`Squirrel`,extensions:[`nut`],load(){return q(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.squirrel)),[],import.meta.url)}}),Q.of({name:`Stylus`,extensions:[`styl`],load(){return q(()=>import(`./stylus-DLLZ8dgm.js`).then(e=>$(e.stylus)),[],import.meta.url)}}),Q.of({name:`Swift`,extensions:[`swift`],load(){return q(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[],import.meta.url)}}),Q.of({name:`sTeX`,load(){return q(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return q(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return q(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`Tcl`,extensions:[`tcl`],load(){return q(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[],import.meta.url)}}),Q.of({name:`Textile`,extensions:[`textile`],load(){return q(()=>import(`./textile-DWBqthVk.js`).then(e=>$(e.textile)),[],import.meta.url)}}),Q.of({name:`TiddlyWiki`,load(){return q(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[],import.meta.url)}}),Q.of({name:`Tiki wiki`,load(){return q(()=>import(`./tiki-CxVlf5KZ.js`).then(e=>$(e.tiki)),[],import.meta.url)}}),Q.of({name:`TOML`,extensions:[`toml`],load(){return q(()=>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 q(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[],import.meta.url)}}),Q.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return q(()=>import(`./ttcn-BePYh-hG.js`).then(e=>$(e.ttcn)),[],import.meta.url)}}),Q.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return q(()=>import(`./ttcn-cfg-CY0aot7Q.js`).then(e=>$(e.ttcnCfg)),[],import.meta.url)}}),Q.of({name:`Turtle`,extensions:[`ttl`],load(){return q(()=>import(`./turtle-BDLWE2cD.js`).then(e=>$(e.turtle)),[],import.meta.url)}}),Q.of({name:`Web IDL`,extensions:[`webidl`],load(){return q(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[],import.meta.url)}}),Q.of({name:`VB.NET`,extensions:[`vb`],load(){return q(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[],import.meta.url)}}),Q.of({name:`VBScript`,extensions:[`vbs`],load(){return q(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[],import.meta.url)}}),Q.of({name:`Velocity`,extensions:[`vtl`],load(){return q(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[],import.meta.url)}}),Q.of({name:`Verilog`,extensions:[`v`],load(){return q(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return q(()=>import(`./vhdl-CMrOq2q1.js`).then(e=>$(e.vhdl)),[],import.meta.url)}}),Q.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return q(()=>import(`./xquery-fj_R-kMw.js`).then(e=>$(e.xQuery)),[],import.meta.url)}}),Q.of({name:`Yacas`,extensions:[`ys`],load(){return q(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[],import.meta.url)}}),Q.of({name:`Z80`,extensions:[`z80`],load(){return q(()=>import(`./z80-CL1naaMV.js`).then(e=>$(e.z80)),[],import.meta.url)}}),Q.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return q(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[],import.meta.url)}}),Q.of({name:`Xù`,extensions:[`xu`],load(){return q(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[],import.meta.url)}}),Q.of({name:`MsGenny`,extensions:[`msgenny`],load(){return q(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[],import.meta.url)}}),Q.of({name:`Vue`,extensions:[`vue`],load(){return q(()=>import(`./dist-DqNnNFrw.js`).then(e=>e.vue()),__vite__mapDeps([33,12,10,8,13]),import.meta.url)}}),Q.of({name:`Angular Template`,load(){return q(()=>import(`./dist-Djgl2wVZ.js`).then(e=>e.angular()),__vite__mapDeps([34,12,10,8,13]),import.meta.url)}})];function I5(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function L5(e){return Q.matchFilename(F5,`file${e}`)}function R5({content:e,path:t,readOnly:n=!1,onSave:r,onDirtyChange:i,onContentChange:a,getContentRef:o}){let s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(new CW),u=(0,b.useRef)(new CW),d=(0,b.useRef)(new CW),f=(0,b.useRef)(!1),p=(0,b.useRef)(r),m=(0,b.useRef)(i),h=(0,b.useRef)(a);(0,b.useEffect)(()=>{p.current=r,m.current=i,h.current=a},[r,i,a]);let g=(0,b.useCallback)(e=>{f.current!==e&&(f.current=e,m.current?.(e))},[]);return(0,b.useEffect)(()=>{if(!s.current)return;let r=document.documentElement.classList.contains(`dark`),i=HX.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new NX({state:eG.create({doc:e,extensions:[_Q(),xQ(),f2(),n0(),oZ(),hZ(),eG.allowMultipleSelections.of(!0),O1(),c0(d0,{fallback:!0}),x0(),m5(),j5(),wZ(),DZ(),gZ(),Z3(),HX.of([...b5,...y3,...B6,...j2,...q1,...M5,b3]),i,NX.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(eG.readOnly.of(n)),l.current.of([]),u.current.of(r?L3:[]),NX.theme({"&":{height:`100%`},".cm-scroller":{overflow:`auto`}})]}),parent:s.current});c.current=a,o&&(o.current=()=>a.state.doc.toString());let f=L5(I5(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,b.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,b.useEffect)(()=>{let e=c.current;if(!e)return;let n=L5(I5(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,b.useEffect)(()=>{let e=c.current;e&&e.dispatch({effects:d.current.reconfigure(eG.readOnly.of(n))})},[n]),(0,b.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?L3:[])})});return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]),(0,U.jsx)(`div`,{ref:s,className:`h-full w-full overflow-hidden [&_.cm-editor]:h-full [&_.cm-scroller]:auto`})}function z5({content:e,objectUrl:t,kind:n,filename:r,path:i}){return n===`markdown`?(0,U.jsx)(tH,{content:e||``}):n===`image`&&t?(0,U.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,U.jsx)(`img`,{src:t,alt:r,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n===`pdf`&&t?(0,U.jsx)(`iframe`,{src:t,title:r,className:`h-full w-full border-0`}):(n===`text`||n===`code`)&&e!==null?(0,U.jsx)(R5,{content:e,path:i||r,readOnly:!0,onSave:()=>{},onDirtyChange:()=>{},getContentRef:{current:()=>e||``}}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,U.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 B5(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function V5(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 H5(...e){return Array.from(new Set(e.filter(e=>!!e))).join(` `)}function U5(e){let t=e?V5(e):void 0,n=H5(`'unsafe-inline'`,`'unsafe-eval'`,`'self'`,`https:`,t),r=H5(`'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 W5(e){try{let t=new URL(e,window.location.href);return[`http:`,`https:`,`mailto:`].includes(t.protocol)}catch{return!1}}function G5(e,t={}){let{channelId:n,basePath:r}=typeof t==`string`?{channelId:t}:t,i=U5(r),a=`<script>
|
|
146
|
-
function ksadkScrollToHash(rawHref) {
|
|
147
|
-
if (!rawHref || rawHref === '#') return;
|
|
148
|
-
var rawId = rawHref.slice(1);
|
|
149
|
-
var id = rawId;
|
|
150
|
-
try {
|
|
151
|
-
id = decodeURIComponent(rawId);
|
|
152
|
-
} catch (_) {}
|
|
153
|
-
var target = document.getElementById(id) || document.getElementsByName(id)[0];
|
|
154
|
-
if (target) {
|
|
155
|
-
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
document.addEventListener('click', function(event) {
|
|
159
|
-
var target = event.target && event.target.closest ? event.target.closest('a') : null;
|
|
160
|
-
if (!target) return;
|
|
161
|
-
var rawHref = target.getAttribute('href') || '';
|
|
162
|
-
if (rawHref.charAt(0) === '#') {
|
|
163
|
-
event.preventDefault();
|
|
164
|
-
ksadkScrollToHash(rawHref);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
if (target.href) {
|
|
168
|
-
event.preventDefault();
|
|
169
|
-
window.parent.postMessage({
|
|
170
|
-
type: 'ksadk:linkClick',
|
|
171
|
-
channelId: ${JSON.stringify(n||``)},
|
|
172
|
-
href: target.href,
|
|
173
|
-
target: target.target || '_self'
|
|
174
|
-
}, '*');
|
|
175
|
-
}
|
|
176
|
-
}, true);
|
|
177
|
-
<\/script>`,o=`${`<meta http-equiv="Content-Security-Policy" content="${B5(i)}">`}${r?`<base href="${B5(r)}">`:``}${a}`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,`$&${o}`):`${o}${e}`}function K5(e,t){let n=(0,b.useRef)(null);(0,b.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&&W5(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function q5({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let o=(0,b.useRef)(null),s=(0,b.useId)(),[c,l]=(0,b.useState)(`preview`),u=qe(t),d=Ke(t),f=(0,b.useCallback)(()=>G5(e,{basePath:u,channelId:s}),[e,u,s]),[p,m]=(0,b.useState)(f());(0,b.useEffect)(()=>{let e=setTimeout(()=>{m(f())},300);return()=>clearTimeout(e)},[f]),K5(o,s);let h=(0,b.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,U.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700`,children:[(0,U.jsxs)(`button`,{onClick:()=>l(`editor`),className:YD(`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,U.jsx)(IT,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,U.jsxs)(`button`,{onClick:()=>l(`preview`),className:YD(`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,U.jsx)(HT,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,U.jsx)(R5,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,U.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,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.jsx)(R5,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,U.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,U.jsx)(HT,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.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,U.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex gap-1.5`,children:[(0,U.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,U.jsx)(VT,{className:`h-3.5 w-3.5`}),`新窗口`]}),(0,U.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,U.jsx)(IT,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function J5(e){e.current&&clearTimeout(e.current)}function Y5({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let[o,s]=(0,b.useState)(`editor`),[c,l]=(0,b.useState)(e),u=(0,b.useRef)(null);return(0,b.useEffect)(()=>(J5(u),u.current=setTimeout(()=>l(e),300),()=>J5(u)),[e]),a?(0,U.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,U.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,U.jsxs)(`button`,{onClick:()=>s(`editor`),className:YD(`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,U.jsx)(IT,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,U.jsxs)(`button`,{onClick:()=>s(`preview`),className:YD(`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,U.jsx)(HT,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,U.jsx)(R5,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,U.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,U.jsx)(tH,{content:c})})]}):o===`editor`?(0,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.jsx)(R5,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,U.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,U.jsx)(HT,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,U.jsx)(tH,{content:c})}),(0,U.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,U.jsx)(IT,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var X5=`/agentengine/api/v1/GetWorkspaceFileContent`,Z5=4e3;function Q5(e){let t=We(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function $5(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function e7(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 t7=[{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 n7(e){return Ke(e)}function r7({label:e,showSupportedTypes:t=!1}){return(0,U.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center`,children:(0,U.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,U.jsx)(`div`,{children:e}),t?(0,U.jsxs)(`div`,{className:`mt-4 text-left`,children:[(0,U.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.12em] text-slate-400`,children:`支持在线预览`}),(0,U.jsx)(`div`,{className:`mt-2 grid gap-2`,children:t7.map(e=>(0,U.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,U.jsx)(`div`,{className:`text-sm font-medium text-slate-700 dark:text-slate-200`,children:e.label}),(0,U.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-slate-400`,children:e.detail})]},e.label))}),(0,U.jsx)(`div`,{className:`mt-3 text-xs leading-5 text-slate-400`,children:`Word、Excel、PPT 当前不支持在线预览,可下载后查看。`})]}):null]})})}function i7({agentId:e,capability:t,open:n,onClose:r,isFullscreen:i=!1,onToggleFullscreen:a,isMobile:o=!1,api:s}){let c=(0,b.useRef)(null),l=(0,b.useRef)(null),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(`.`),[m,h]=(0,b.useState)([]),[g,_]=(0,b.useState)(!1),[v,y]=(0,b.useState)(!1),[x,ee]=(0,b.useState)(!1),[te,S]=(0,b.useState)(``),[C,ne]=(0,b.useState)(null),[w,re]=(0,b.useState)(null),[ie,ae]=(0,b.useState)(!1),[oe,se]=(0,b.useState)(!1),ce=(0,b.useRef)(null),le=(0,b.useRef)(null),ue=(0,b.useRef)(`selection`),T=(0,b.useRef)(rt()),E=(0,b.useMemo)(()=>m.find(e=>e.Path===C)??null,[m,C]),de=(0,b.useMemo)(()=>E?tt({path:E.Path,mimeType:E.MimeType}):null,[E]),fe=(0,b.useCallback)(()=>ie?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[ie]),pe=t.ContentPath||X5,me=t.RootLabel||`Workspace`,he=me?`${me.charAt(0).toUpperCase()}${me.slice(1)}`:`Workspace`,ge=Ye(f),_e=(0,b.useCallback)(()=>{l.current&&=(URL.revokeObjectURL(l.current),null)},[]);(0,b.useEffect)(()=>()=>_e(),[_e]);let ve=(0,b.useCallback)(async(t,n={})=>{let r=!!n.background;r?y(!0):_(!0),r||S(``);try{let n=await s.listWorkspaceFiles(e,t,!1),i=We(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),ue.current=r?`background-refresh`:`selection`,ne(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||S(e instanceof Error?e.message:String(e))}finally{r?y(!1):_(!1)}},[e,s]);(0,b.useEffect)(()=>{!n||u||(d(!0),ve(`.`))},[u,ve,n]),(0,b.useEffect)(()=>{if(!n||ie||!u)return;let e=window.setInterval(()=>{ve(f,{background:!0})},Z5);return()=>window.clearInterval(e)},[f,ie,u,ve,n]);let ye=(0,b.useCallback)(async t=>{let n=T.current.next(t.Path),r=$e({path:t.Path,mimeType:t.MimeType});if(le.current=t.Path,r===`unsupported`){_e(),re({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}_e(),re({path:t.Path,kind:r,status:`loading`,mimeType:t.MimeType??void 0});try{let r=await s.getWorkspaceFileContent(e,t.Path,{asText:!1});if(!T.current.isCurrent(n))return;if(r instanceof Blob){let e=t.MimeType||``,i=$e({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,re({path:t.Path,kind:i,status:`ready`,mimeType:e,objectUrl:n});return}let a=await r.text();if(!T.current.isCurrent(n))return;let o=$e({path:t.Path,mimeType:e});re({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=$e({path:t.Path,mimeType:e});re({path:t.Path,kind:n,status:`ready`,mimeType:e,content:r})}}catch(e){if(!T.current.isCurrent(n))return;console.error(`Failed to preview workspace file:`,e),re({path:t.Path,kind:r,status:`error`,mimeType:t.MimeType??void 0,error:e instanceof Error?e.message:String(e)})}},[e,s,_e]);(0,b.useEffect)(()=>{if(!E||E.Type!==`file`){_e(),re(null),ae(!1),le.current=null;return}if(ue.current===`background-refresh`&&le.current===E.Path){ue.current=`selection`;return}ue.current=`selection`,ye(E)},[_e,ye,E]);let be=async n=>{if(!(!n||n.length===0)){ee(!0),S(``);try{for(let r of Array.from(n)){if(r.size>t.MaxUploadBytes)throw Error(`文件 ${r.name} 超过上传上限`);let n=Je(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 ve(f)}catch(e){console.error(`Failed to upload workspace files:`,e),S(e instanceof Error?e.message:String(e))}finally{c.current&&(c.current.value=``),ee(!1)}}},xe=async n=>{if(!t.SupportsDelete)return;let r=We(n.Path);if(window.confirm(`删除 ${r} ?`)){S(``);try{await s.deleteWorkspaceFile(e,r),C&&We(C)===r&&(ne(null),ae(!1)),await ve(n.Type===`directory`&&(We(f)===r||We(f).startsWith(`${r}/`))?Q5(r):f)}catch(e){console.error(`Failed to delete workspace file:`,e),S(e instanceof Error?e.message:String(e))}}},Se=()=>!E||E.Type!==`file`?(0,U.jsx)(r7,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!w||w.path!==E.Path||w.status===`loading`?(0,U.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center`,children:(0,U.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,U.jsx)(YT,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):w.status===`error`?(0,U.jsx)(r7,{label:w.error||`文件预览加载失败。`}):w.kind===`markdown`?(0,U.jsx)(Y5,{content:w.content||``,path:E.Path,onSave:D,onDirtyChange:ae,getContentRef:ce,isMobile:o}):w.kind===`image`&&w.objectUrl?(0,U.jsx)(z5,{content:null,objectUrl:w.objectUrl,kind:`image`,filename:E.Name,mimeType:w.mimeType||``}):w.kind===`pdf`&&w.objectUrl?(0,U.jsx)(z5,{content:null,objectUrl:w.objectUrl,kind:`pdf`,filename:E.Name,mimeType:w.mimeType||``}):w.kind===`html`?(0,U.jsx)(q5,{content:w.content||``,path:E.Path,onSave:D,onDirtyChange:ae,getContentRef:ce,isMobile:o,agentId:e,contentPath:pe}):w.kind===`text`||w.kind===`code`?(0,U.jsx)(R5,{content:w.content||``,path:E.Path,onSave:D,onDirtyChange:ae,getContentRef:ce}):(0,U.jsx)(z5,{content:null,kind:`unsupported`,filename:E.Name,mimeType:w.mimeType||``}),D=async t=>{if(E){se(!0),S(``);try{let n=new Blob([t],{type:E.MimeType||`text/plain`}),r=new FormData;r.append(`file`,n,E.Name),r.append(`AgentId`,e),r.append(`Path`,E.Path),await s.addWorkspaceFile(r),T.current.invalidate(),ae(!1),re(e=>e&&e.path===E.Path?{...e,content:t}:e),le.current=E.Path,await ve(f,{background:!0})}catch(e){console.error(`Failed to save workspace file:`,e),S(e instanceof Error?e.message:String(e))}finally{se(!1)}}},Ce=E?.Type===`file`&&w?.path===E.Path&&w.status===`ready`&&(w.kind===`text`||w.kind===`code`||w.kind===`html`||w.kind===`markdown`),we=E?.Type===`file`&&w?.path===E.Path&&w.status===`ready`&&w.kind===`pdf`;return(0,U.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,U.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,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:he}),(0,U.jsx)(`div`,{className:`hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`flex-shrink-0 text-xs text-slate-400`,children:`当前目录`}),(0,U.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:`${ge},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,children:ge})]}),(0,U.jsx)(`div`,{className:`hidden truncate text-[11px] text-slate-400 xl:block`,children:`工作区内相对路径,不是宿主机绝对路径。`})]}),(0,U.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[(0,U.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void be(e.target.files)}),(0,U.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,U.jsx)(vE,{className:`h-3.5 w-3.5`}),x?`上传中`:`上传`]}),(0,U.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,U.jsx)(eE,{className:`h-3.5 w-3.5`}),`导出`]}),a?(0,U.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,U.jsx)($T,{className:`h-4 w-4`}):(0,U.jsx)(XT,{className:`h-4 w-4`})}):null,r?(0,U.jsx)(`button`,{type:`button`,onClick:()=>{fe()&&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,U.jsx)(xE,{className:`h-4 w-4`})}):null]})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,U.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,U.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,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-slate-900 dark:text-slate-100`,children:`文件`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-slate-400`,children:[(0,U.jsxs)(`span`,{children:[m.length,` 项`]}),v?(0,U.jsx)(sE,{className:`h-3 w-3 animate-spin`,"aria-label":`正在同步 Workspace 目录`}):null]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>{fe()&&ve(Q5(f))},disabled:g||Je(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,U.jsx)(AT,{className:`h-4 w-4`})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>{fe()&&ve(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,U.jsx)(sE,{className:`h-4 w-4 ${g?`animate-spin`:``}`})})]})]}),te?(0,U.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:te}):null]}),(0,U.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:!u&&!n?(0,U.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`打开面板后加载 workspace 文件。`}):g?(0,U.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`正在加载目录...`}):m.length===0?(0,U.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`当前目录为空。`}):(0,U.jsx)(`div`,{className:`space-y-0.5`,children:m.map(e=>{let n=$e({path:e.Path,mimeType:e.MimeType}),r=C===e.Path,i=e.Type===`file`?n7(e.Path):``;return(0,U.jsxs)(`div`,{title:e.Path,className:YD(`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,U.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){ve(e.Path);return}C!==e.Path&&!fe()||ne(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,U.jsx)(`div`,{className:YD(`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,U.jsx)(KT,{className:`h-3.5 w-3.5`}):n===`image`?(0,U.jsx)(JT,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,U.jsx)(UT,{className:`h-3.5 w-3.5`}):(0,U.jsx)(GT,{className:`h-3.5 w-3.5`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-[13px] leading-5`,children:e.Name}),(0,U.jsx)(`div`,{className:YD(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:e7(e.SizeBytes)})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100`,children:[e.Type===`file`?(0,U.jsx)(`a`,{href:i,download:e.Name,className:YD(`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,U.jsx)(RT,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,U.jsx)(`button`,{type:`button`,onClick:()=>void xe(e),className:YD(`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,U.jsx)(_E,{className:`h-3.5 w-3.5`})}):null]})]},e.Path)})})})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,U.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:E?(0,U.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:E.Name}),(0,U.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-slate-400`,children:E.Path}),(0,U.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-400`,children:[e7(E.SizeBytes),E.MimeType?` · ${E.MimeType}`:``,E.ModifiedAt?` · ${$5(E.ModifiedAt)}`:``]})]}),de===`text`||de===`code`||de===`html`||de===`markdown`?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{let e=ce.current;e&&D(e())},disabled:!ie||oe,className:YD(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition`,ie&&!oe?`bg-blue-600 text-white hover:bg-blue-700`:`text-slate-400 dark:text-slate-500 cursor-not-allowed`),children:[(0,U.jsx)(cE,{className:`h-3.5 w-3.5`}),oe?`保存中`:ie?`保存`:`已保存`]}):null]}):(0,U.jsxs)(`div`,{className:`w-full`,children:[(0,U.jsx)(`div`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100`,children:`文件预览`}),(0,U.jsx)(`div`,{className:`mt-0.5 text-xs text-slate-500 dark:text-slate-400`,children:`选择左侧文件后可在此查看内容。`})]})}),(0,U.jsx)(`div`,{className:YD(`custom-scrollbar min-h-0 flex-1`,we||Ce?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:Se()})]})]})]})}function a7({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,U.jsxs)(U.Fragment,{children:[f?(0,U.jsxs)(U.Fragment,{children:[n&&!i?(0,U.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,U.jsx)(`aside`,{style:n&&!i?{width:`${r}px`}:void 0,className:YD(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,U.jsx)(i7,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>w.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,U.jsx)(Dj,{open:n,onOpenChange:e=>{e||w.getState().setWorkspacePanelFullscreen(!1),w.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,U.jsxs)(jj,{side:c.side,showOverlay:c.showOverlay,onInteractOutside:e=>{c.preventOutsideClose&&e.preventDefault()},showCloseButton:!1,className:YD(`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,U.jsx)(Pj,{className:`sr-only`,children:`Workspace 文件`}),(0,U.jsx)(Fj,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,U.jsx)(i7,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}async function o7(e,t){let n=await Ot(`ListSessions`,{AgentId:e,Page:t?.page,PageSize:t?.pageSize},t);return{Sessions:n.Sessions??[],Total:Number.isFinite(Number(n.Total))?Number(n.Total):n.Sessions?.length??0,Page:Number.isFinite(Number(n.Page))?Number(n.Page):t?.page??1,PageSize:Number.isFinite(Number(n.PageSize))?Number(n.PageSize):t?.pageSize??n.Sessions?.length??0}}async function s7(e,t){return(await Ot(`CreateSession`,{AgentId:e},t)).Session}async function c7(e,t){await Ot(`DeleteSession`,{SessionId:e},t)}async function l7(e,t){return(await Ot(`GetSession`,{SessionId:e},t)).Session}async function u7(e,t){let n=await Ot(`ListSessionEvents`,{SessionId:e,Offset:t?.offset,Limit:t?.limit},t);return{Events:n.Events??[],Total:Number.isFinite(Number(n.Total))?Number(n.Total):n.Events?.length??0,Offset:Number.isFinite(Number(n.Offset))?Number(n.Offset):t?.offset??0,Limit:Number.isFinite(Number(n.Limit))?Number(n.Limit):t?.limit??n.Events?.length??0}}async function d7(e,t){let n=await Ot(`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 function f7(e,t){return jt(`RunAgent`,e,t)}async function p7(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId};return e.runId&&(n.RunId=e.runId),Ot(`ListSessionCheckpoints`,n,t)}async function m7(e,t){return Ot(`GetCheckpointResumePreview`,{AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId},t)}async function h7(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId};return e.runId&&(n.RunId=e.runId),e.checkpointId&&(n.CheckpointId=e.checkpointId),Ot(`ListToolReceipts`,n,t)}async function g7(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId,Stream:!0};return e.resumeAttemptId&&(n.ResumeAttemptId=e.resumeAttemptId),e.invocationId&&(n.InvocationId=e.invocationId),jt(`ResumeRun`,n,t)}async function _7(e,t,n){return Ot(`ListWorkspaceFiles`,{AgentId:e,Path:t,Recursive:n})}async function v7(e){return kt(`AddWorkspaceFile`,e)}async function y7(e,t){return Ot(`DeleteWorkspaceFile`,{AgentId:e,Path:t})}async function b7(e,t,n){return At(`GetWorkspaceFileContent`,{AgentId:e,FilePath:t},{signal:n?.signal,asText:n?.asText??!0})}async function x7(e,t){return kt(`UploadFile`,e,t)}var S7=new class{async listSessions(e,t){return o7(e,t)}async createSession(e,t){return{SessionId:(await s7(e,t)).SessionId}}async deleteSession(e,t){await c7(e,t)}async getSession(e,t){return l7(e,t)}async listSessionEvents(e,t){return u7(e,t)}async listSessionMessages(e,t){return d7(e,t)}async listSessionCheckpoints(e,t){return p7(e,t)}async previewCheckpointResume(e,t){return m7(e,t)}async listToolReceipts(e,t){return h7(e,t)}async runAgent(e,t){return f7(e,t)}async resumeRun(e,t){return g7(e,t)}async subscribeRunEvents(e,t){return Mt(`SubscribeRunEvents`,{SessionId:e.sessionId,InvocationId:e.invocationId,AfterSeqId:String(e.afterSeqId)},t)}async cancelRun(e,t,n,r){return Ot(`CancelRun`,{AgentId:e,SessionId:t,InvocationId:n},r)}async getResponseFeedback(e,t){return Ot(`GetResponseFeedback`,e,t)}async upsertResponseFeedback(e,t){return Ot(`UpsertResponseFeedback`,e,t)}async deleteResponseFeedback(e,t){await Ot(`DeleteResponseFeedback`,e,t)}async listWorkspaceFiles(e,t,n){return _7(e,t,n)}async addWorkspaceFile(e){return v7(e)}async deleteWorkspaceFile(e,t){await y7(e,t)}async getWorkspaceFileContent(e,t,n){return b7(e,t,n)}async listAgentModels(e){return Pt(e)}async getAgentUiBootstrap(){return Nt()}async uploadFile(e,t){return x7(e,t)}},C7=b.lazy(()=>q(()=>import(`./ArtifactsPanel-Cjnqt-8W.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url)),w7=b.lazy(()=>q(()=>import(`./NativeTerminalPanel-MDTopWMO.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function T7({apiAdapter:e,initialSurface:t=`chat`,routeShell:n}={}){let r=e||S7,i=me(e=>e.agentId),a=Me(e=>e.currentSessionId),o=D(e=>e.isStreaming),s=w(e=>e.sidebarOpen),c=w(e=>e.mobileSidebarOpen),l=w(e=>e.mobileActionsOpen),u=me(e=>e.agentName),d=ge(e=>e.selectedModel),f=ge(e=>e.availableModels),p=ge(e=>e.modelSource),m=ge(e=>e.modelCatalogLoaded),h=ge(e=>e.thinkingMode),g=be(e=>e.permissionMode),_=me(e=>e.agentFramework),v=me(e=>e.workspaceFiles),y=me(e=>e.accessMode),x=w(e=>e.workspacePanelOpen),ee=w(e=>e.workspacePanelWidth),te=w(e=>e.workspacePanelFullscreen),S=me(e=>e.apiFormats),C=me(e=>e.capabilities),ne=Ne(e=>e.visible&&!!e.content),re=(0,b.useRef)([]),ie=(0,b.useRef)(null),{isMobile:ae,viewportHeight:oe}=St(),se=Le({isMobile:ae,viewportHeight:oe}),{fetchSessions:ce,loadMoreSessions:le,loadSession:ue,loadOlderSessionMessages:T,createNewSession:E,deleteSession:de,currentSessionIdRef:pe,agentIdRef:he,runSubscriptionAbortRef:_e}=vT({agentId:i,currentSessionId:a,isMobile:ae,uiCapabilities:C,api:r,resetCompaction:()=>{},disconnectRun:()=>ie.current?.()}),ve=(0,b.useCallback)(e=>{if(!e)return;let t=()=>{Me.getState().clearSessionMessageHistory(e),ce(he.current,e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[he,ce]),ye=f.find(e=>e.id===d)||null,{submitDraft:xe,stopGeneration:Se,disconnectRun:Ce,resumeCheckpoint:we,submitAguiAction:Te,respondToAguiApproval:Ee}=Vw({agentId:i,currentSessionId:a,agentFramework:_,apiFormats:S,selectedModel:d,selectedModelMetadata:ye,thinkingMode:h,permissionMode:g,uiCapabilities:C,isMobile:ae,api:r,currentSessionIdRef:pe,agentIdRef:he,queuedDraftRef:re,onRunSettled:ve});(0,b.useEffect)(()=>{ie.current=Ce},[Ce]);let De=(0,b.useCallback)(()=>{let e=pe.current;_e.current?.abort(),D.getState().stopActivity(),D.getState().stopSessionActivity(e),Se()},[pe,_e,Se]),Oe=(0,b.useCallback)(async()=>{let e=pe.current,t=D.getState(),n=t.getSessionActivity(e)?.runId||t.currentRunId||``;if(e&&n)try{await r.cancelRun(i,e,n),D.getState().stopSessionActivity(e,`取消请求已发送,后台运行会停在最近 checkpoint。`)}catch(t){console.warn(`[App] cancelRun failed:`,t),D.getState().updateActivity({sessionId:e,status:`failed`,phase:`取消请求失败`,detail:t instanceof Error?t.message:String(t),countEvent:!1})}ve(e)},[r,i,pe,ve]),{submitResponseFeedback:ke,deleteResponseFeedback:Ae,respondToApproval:je}=Qw({agentId:i,currentSessionId:a,isStreaming:o,api:r,submitDraft:xe});Lt({fetchSessions:ce}),(0,b.useEffect)(()=>{he.current=i,pe.current=a,ut(i,a)},[i,a,he,pe]),(0,b.useEffect)(()=>{ae?w.getState().setWorkspacePanelFullscreen(!1):(w.getState().setMobileSidebarOpen(!1),w.getState().setMobileActionsOpen(!1))},[ae]),(0,b.useEffect)(()=>{x||w.getState().setWorkspacePanelFullscreen(!1)},[x]),(0,b.useEffect)(()=>()=>{_e.current?.abort()},[_e]);let Pe=fe(C),Fe=!!C.Thinking,Ie=it({workspaceFiles:v,accessMode:y}),Re=nt({isMobile:ae}),ze=gt({capability:C.NativeDashboard,agentFramework:_,accessMode:y,origin:window.location.origin}),Be=!Pe,Ve=_===`openclaw`?`OpenClaw`:_===`hermes`?`Hermes`:`原生运行时`,He=ye?.display_name||d||``,Ue=!ae&&s&&Pe,We=(0,b.useRef)(!1),[Ge,Ke]=(0,b.useState)(t===`tui`),qe=Ge&&!!C.NativeTerminal?.Enabled;(0,b.useEffect)(()=>{We.current||t!==`workspace`||!Ie||(We.current=!0,w.getState().setWorkspacePanelOpen(!0),w.getState().setWorkspacePanelFullscreen(!0))},[t,Ie]);let Je=(0,U.jsxs)(`div`,{className:`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,U.jsx)(Lj,{uiCapabilities:C,createNewSession:E,deleteSession:de,loadSession:ue,loadMoreSessions:le}),(0,U.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,U.jsx)(bU,{agentName:u,currentSessionId:a,nativeLauncherMode:Be,isMobile:ae,sidebarOpen:s,mobileSidebarOpen:c,onToggleSidebar:()=>{ae?w.getState().toggleMobileSidebar():w.getState().toggleSidebar()},availableModels:f,selectedModel:d,onSelectModel:e=>{ge.getState().setSelectedModel(e),ae&&w.getState().setMobileActionsOpen(!1)},selectedModelLabel:He,modelCatalogLoaded:m,modelSource:p,thinkingEnabled:Fe,thinkingMode:h,onSelectThinkingMode:e=>ge.getState().setThinkingMode(vt(e)),mobileActionsOpen:l,onMobileActionsOpenChange:e=>w.getState().setMobileActionsOpen(e),workspaceEnabled:Ie,onOpenWorkspace:()=>w.getState().setWorkspacePanelOpen(!0),nativeManagementLink:ze,nativeTerminal:C.NativeTerminal}),Be?(0,U.jsx)(SU,{productLabel:Ve,nativeManagementLink:ze,nativeTerminal:C.NativeTerminal,workspaceEnabled:Ie,onOpenWorkspace:()=>w.getState().setWorkspacePanelOpen(!0)}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(oU,{agentName:u,isMobile:ae,onDeleteFeedback:Ae,onSubmitFeedback:ke,onRespondToApproval:je,onRespondToAguiApproval:Ee,onSubmitAguiAction:Te,onStopGeneration:De,onCancelRemote:C.StopRun?Oe:void 0,checkpointResumeEnabled:C.RunLifecycle.Enabled&&C.RunLifecycle.Checkpoints&&C.RunLifecycle.CheckpointResume,onResumeCheckpoint:we,onLoadOlderSessionMessages:T}),(0,U.jsx)(_U,{composerMaxHeight:se,submitDraft:xe,stopGeneration:De,cancelRemote:C.StopRun?Oe:void 0,isMobile:ae,approvalEnabled:!!C.Approval&&C.ApprovalPolicy?.RuntimeOverride!==!1,approvalPolicy:C.ApprovalPolicy})]})]}),(0,U.jsx)(a7,{agentId:i,capability:v,workspacePanelOpen:x,workspacePanelWidth:ee,workspacePanelFullscreen:te,isMobile:ae,workspaceEnabled:Ie,workspaceFiles:v,workspacePanelPresentation:Re,closeWorkspacePanel:()=>{w.getState().setWorkspacePanelFullscreen(!1),w.getState().setWorkspacePanelOpen(!1)},handleWorkspacePanelResizeStart:e=>{if(te||ae)return;e.preventDefault();let t=e.clientX,n=ee,r=Pe&&Ue?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;w.getState().setWorkspacePanelWidth(pn(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:r}),ne&&(0,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(C7,{})}),qe?(0,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(w7,{capability:C.NativeTerminal,open:!0,sessionId:a,onClose:()=>Ke(!1)})}):null]});return n?(0,U.jsx)(n,{children:Je}):Je}function E7(){return(0,U.jsx)(T7,{})}function D7(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 O7=`agentengine-ui:chunk-reload-attempted`,k7=class extends b.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),D7(e))try{window.sessionStorage.getItem(O7)||(window.sessionStorage.setItem(O7,String(Date.now())),window.location.reload())}catch{window.location.reload()}}handleReload=()=>{try{window.sessionStorage.removeItem(O7)}catch{}this.setState({hasError:!1,error:null}),window.location.reload()};render(){return this.state.hasError?(0,U.jsx)(`div`,{className:`flex h-screen w-screen items-center justify-center bg-slate-50 dark:bg-slate-900`,children:(0,U.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,U.jsx)(`div`,{className:`mb-4 text-4xl`,children:`⚠`}),(0,U.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-red-600 dark:text-red-400`,children:`页面渲染出错`}),(0,U.jsx)(`p`,{className:`mb-6 text-sm text-slate-600 dark:text-slate-400`,children:this.state.error?.message||`发生了未知错误,请刷新页面重试。`}),(0,U.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 A7(){let e=w(e=>e.toasts),t=w(e=>e.dismissToast);return(0,b.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,U.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,U.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,U.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,U.jsx)(`button`,{onClick:()=>t(e.id),className:`shrink-0 rounded p-0.5 opacity-70 hover:opacity-100`,children:(0,U.jsx)(xE,{size:14})})]},e.id))}):null}C.createRoot(document.getElementById(`root`)).render((0,U.jsxs)(k7,{children:[(0,U.jsx)(E7,{}),(0,U.jsx)(A7,{})]}));export{qN as $,TQ as A,eG as B,q$ as C,s as Ct,Z as D,C$ as E,NQ as F,GV as G,bG as H,r$ as I,Tz as J,kV as K,NX as L,OQ as M,$Q as N,SQ as O,t$ as P,fL as Q,HX as R,G$ as S,o as St,v$ as T,vH as U,xW as V,q as W,xL as X,SR as Y,SL as Z,j1 as _,MT as _t,Q6 as a,CM as at,m1 as b,Ne as bt,J$ as c,Rj as ct,e1 as d,_E as dt,BN as et,S0 as f,pE as ft,T1 as g,LT as gt,C1 as h,RT as ht,Z6 as i,DM as it,kQ as j,MQ as k,Q as l,YD as lt,K$ as m,HT as mt,K5 as n,OM as nt,c5 as o,Xj as ot,E1 as p,sE as pt,EV as q,J6 as r,EM as rt,X$ as s,zj as st,G5 as t,wN as tt,s1 as u,xE as ut,A1 as v,OT as vt,Z$ as w,l as wt,l1 as x,p as xt,k1 as y,Tv as yt,J as z};
|