@kingsoftcloud/ksadk-web 0.3.2 → 0.3.4
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 +77 -0
- package/README.md +77 -4
- package/RELEASE_PROVENANCE.json +2 -2
- package/dist-ksadk/assets/{ArtifactsPanel-DSU1sWD_.js → ArtifactsPanel-10GPXIJ6.js} +1 -1
- package/dist-ksadk/assets/{CodeBlock-DOH6MVcn.js → CodeBlock-BXk1l-G1.js} +1 -1
- package/dist-ksadk/assets/{MathMessageMarkdown-BL8my1R2.js → MathMessageMarkdown-D9uB55Oh.js} +1 -1
- package/dist-ksadk/assets/{MermaidBlock-Dz4IP-Tx.js → MermaidBlock--OEYoXIJ.js} +6 -6
- package/dist-ksadk/assets/{NativeTerminalPanel-DUrK0JpZ.js → NativeTerminalPanel-DrEe1syq.js} +1 -1
- package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-g20pFzNV.js → abnfDiagram-VCTEODGH-eeTFJLvo.js} +1 -1
- package/dist-ksadk/assets/{arc-C4FzinUA.js → arc-S3ZNbIAd.js} +1 -1
- package/dist-ksadk/assets/architecture-7GRP2DOG-Dk9nRQ6-.js +1 -0
- package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-DpIqL5h4.js → architectureDiagram-5GKGNRK7-CRjgEJDX.js} +1 -1
- package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-BjkljTNz.js → blockDiagram-NRAW4CY4-C7bsBoNH.js} +1 -1
- package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-Dk_ieq2X.js → c4Diagram-UCG6FXSJ-BX3c33Ob.js} +1 -1
- package/dist-ksadk/assets/channel-s354Yo6o.js +1 -0
- package/dist-ksadk/assets/chunk-2Q5K7J3B-CDpPpKR5.js +1 -0
- package/dist-ksadk/assets/{chunk-5VM5RSS4-BVHAchFb.js → chunk-5VM5RSS4-bZ7ws-8m.js} +1 -1
- package/dist-ksadk/assets/{chunk-F27PBJKO-C-ipQzuS.js → chunk-F27PBJKO-D2r0pvhY.js} +1 -1
- package/dist-ksadk/assets/{chunk-G27WJ6UU-C2EyJbIK.js → chunk-G27WJ6UU-CZwF3oUP.js} +1 -1
- package/dist-ksadk/assets/{chunk-JWPE2WC7-vYvVJb_M.js → chunk-JWPE2WC7-DigFYCML.js} +1 -1
- package/dist-ksadk/assets/{chunk-LCL6LL3I-BcI6ysPT.js → chunk-LCL6LL3I-CnorGV5q.js} +1 -1
- package/dist-ksadk/assets/{chunk-POPQ4Y6H-C030x_Z1.js → chunk-POPQ4Y6H-CexntQA-.js} +1 -1
- package/dist-ksadk/assets/{chunk-RHFEMEQ7-yyGpsz4n.js → chunk-RHFEMEQ7-CHTC7UxA.js} +1 -1
- package/dist-ksadk/assets/{chunk-SVP7TREG-BLTlmMU7.js → chunk-SVP7TREG-BC1EWt_-.js} +1 -1
- package/dist-ksadk/assets/{chunk-XXDRQBXY-C_32ArgP.js → chunk-XXDRQBXY-BTG24xN0.js} +1 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-Dd0nucl9.js +1 -0
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-Dd0nucl9.js +1 -0
- package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-9YQYwdl0.js → cose-bilkent-JH36ORCC-CkonRdAS.js} +1 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-BBlT4uMf.js +1 -0
- package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-ErLF5N13.js → cynefinDiagram-5FMLGOSQ-DEOCBe15.js} +1 -1
- package/dist-ksadk/assets/{dagre-3AP2YEHR-DFiQF-6f.js → dagre-3AP2YEHR-DBThPuLa.js} +1 -1
- package/dist-ksadk/assets/{dagre-BuhGnRI1.js → dagre-ClTPrTht.js} +1 -1
- package/dist-ksadk/assets/{diagram-S7CK7UJ4-Bt1v8-GC.js → diagram-S7CK7UJ4-DsZHrnpJ.js} +1 -1
- package/dist-ksadk/assets/{diagram-UQ7AKVKN-DSCxJdBK.js → diagram-UQ7AKVKN-BJR4nhVr.js} +1 -1
- package/dist-ksadk/assets/{diagram-VSXAHHWV-DHfYwp_9.js → diagram-VSXAHHWV-xzcERX0a.js} +1 -1
- package/dist-ksadk/assets/{diagram-VX7I27RA-DdzD-4Le.js → diagram-VX7I27RA-tn2xM1xu.js} +1 -1
- package/dist-ksadk/assets/{diagram-Z3DM3KII-Du-nAJ9F.js → diagram-Z3DM3KII-BZPGBkw5.js} +1 -1
- package/dist-ksadk/assets/{dist-ClxGviKw.js → dist-4zN1_tq5.js} +1 -1
- package/dist-ksadk/assets/{dist-BE7bu-DL.js → dist-8VWI-2bZ.js} +1 -1
- package/dist-ksadk/assets/{dist-BX8z72IC.js → dist-B-46q3Hk.js} +1 -1
- package/dist-ksadk/assets/{dist-BjU6y-A2.js → dist-B0gdk4rl.js} +1 -1
- package/dist-ksadk/assets/{dist-C_wsv-Qd.js → dist-B1oWRmrH.js} +1 -1
- package/dist-ksadk/assets/{dist-ngtN0DJB.js → dist-BI1qQH4n.js} +1 -1
- package/dist-ksadk/assets/{dist-dydu68Fl.js → dist-BJLUwH6W.js} +1 -1
- package/dist-ksadk/assets/{dist-Dq9gLD7L.js → dist-Bbwqa8TG.js} +1 -1
- package/dist-ksadk/assets/{dist-CttYUqzS.js → dist-Btyo4vX4.js} +1 -1
- package/dist-ksadk/assets/{dist-CXYYBw3_.js → dist-C71CsujO.js} +1 -1
- package/dist-ksadk/assets/{dist-dDdADKFA.js → dist-CXpH_Rdd.js} +1 -1
- package/dist-ksadk/assets/{dist-CSh_DE14.js → dist-Cq4OL6nO.js} +1 -1
- package/dist-ksadk/assets/{dist-8hqcx0sU.js → dist-D1V3f1B4.js} +1 -1
- package/dist-ksadk/assets/{dist-BVDffZ0U.js → dist-DJmCPRVB.js} +1 -1
- package/dist-ksadk/assets/{dist-DnfXs8Vn.js → dist-DQAB0qn_.js} +1 -1
- package/dist-ksadk/assets/{dist-DNp6rLRA.js → dist-DUwKa_l6.js} +1 -1
- package/dist-ksadk/assets/{dist-B7seoj3d.js → dist-DdRBIceA.js} +1 -1
- package/dist-ksadk/assets/{dist-BytlxIDT.js → dist-DfGFrb0v.js} +1 -1
- package/dist-ksadk/assets/{dist-Bf2M8m3N.js → dist-DjhwGUgZ.js} +1 -1
- package/dist-ksadk/assets/{dist-W-TIVntx.js → dist-DyqV4fL4.js} +1 -1
- package/dist-ksadk/assets/{dist-DUX-id_F.js → dist-M67Hwu0n.js} +1 -1
- package/dist-ksadk/assets/{dist-DmldrHd_.js → dist-u8tVH5Ak.js} +1 -1
- package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-Da9C9NO1.js → ebnfDiagram-PWID7BFC-DVfMsLge.js} +1 -1
- package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-EAGqqR79.js → erDiagram-SSCWMZ5O-CWEZSYaw.js} +1 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-Dr5okd8V.js +1 -0
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-VEO-cVcO.js +1 -0
- package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-DqJsKb59.js → ganttDiagram-EL5Y4UJY-TWIxoyYL.js} +1 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-CKiKY9Cf.js +1 -0
- package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-B6g4dtDi.js → gitGraphDiagram-WWUBYQGX-DDh2hd2S.js} +1 -1
- package/dist-ksadk/assets/index-B2k_urY8.js +241 -0
- package/dist-ksadk/assets/index-ILPt6IWF.css +2 -0
- package/dist-ksadk/assets/info-A6RAGUB7-ubA4Nm_p.js +1 -0
- package/dist-ksadk/assets/{infoDiagram-RXCK75RN-Djm_nbd5.js → infoDiagram-RXCK75RN-CgoyWiDR.js} +1 -1
- package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-DWya9SG2.js → ishikawaDiagram-5VMMS53U-CyRIu_om.js} +1 -1
- package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-DutxhSNI.js → journeyDiagram-EYS64GPL-DN5JXHzN.js} +1 -1
- package/dist-ksadk/assets/{kanban-definition-3QL26DDD-DJdOF8Fm.js → kanban-definition-3QL26DDD-CNP3ui66.js} +1 -1
- package/dist-ksadk/assets/{katex-vFWytM5c.js → katex-DWEzQy1d.js} +1 -1
- package/dist-ksadk/assets/{linear-BHjG8b-J.js → linear-C-qHp7d2.js} +1 -1
- package/dist-ksadk/assets/{mermaid-parser.core-KGSy4jWT.js → mermaid-parser.core-Cl-K943T.js} +2 -2
- package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-9-HC88D4.js → mindmap-definition-FBJOCRG2-D5DB5mYm.js} +1 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-C7R3NUlK.js +1 -0
- package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-DrEZd4fD.js → pegDiagram-XKGWAZYB-BQVc9ia_.js} +1 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-BIT6qjr3.js +1 -0
- package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-DpjqOFFp.js → pieDiagram-E7YTZNPT-B6UCAvtY.js} +1 -1
- package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-BiNhgOXX.js → quadrantDiagram-AXDQQJYC-mIr2d3eb.js} +1 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-l5noef9X.js +1 -0
- package/dist-ksadk/assets/railroad-74A4TZTK-Baea6ZvM.js +1 -0
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-OKn8zZnU.js +1 -0
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-DdKAKC4l.js +1 -0
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-Bds8udlG.js +1 -0
- package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-_Y3Ojg6G.js → railroadDiagram-O6MQD6OU-Dt3FFDmK.js} +1 -1
- package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-DeCFdg9K.js → requirementDiagram-EFPCY7ZU-Cz_vQtgF.js} +1 -1
- package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-CPH75rhw.js → sankeyDiagram-P5KCCOFB-wlO1TsH5.js} +1 -1
- package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-OEpQQdr4.js → sequenceDiagram-WJ2MYXX4-CHRbElYq.js} +1 -1
- package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-heUErzhI.js → sizeCapture-X5ZJPWSS-DXX54iyO.js} +1 -1
- package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-DvA3jSMB.js → stateDiagram-HBIQ2CUA-Dp_lw9II.js} +1 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-5b-8o2iS.js +1 -0
- package/dist-ksadk/assets/{swimlanes-XN3QIQJK-CR-dfN_t.js → swimlanes-XN3QIQJK-D8O5UlLG.js} +1 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-uf6WPRA4.js +8 -0
- package/dist-ksadk/assets/{timeline-definition-24CTP7MA-DAVJf1TX.js → timeline-definition-24CTP7MA-8mfKcxvG.js} +1 -1
- package/dist-ksadk/assets/treeView-Q6P3EWNA-CK5CSrSO.js +1 -0
- package/dist-ksadk/assets/treemap-WGGIJYW6-Ch2BKgAM.js +1 -0
- package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-DwM8eDkh.js → vennDiagram-4TSXK5OY-EnNl0DE7.js} +1 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-YW3Q0ml_.js +1 -0
- package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-DZL-Zz2t.js → wardleyDiagram-VM6X3IG4-DBu5fbYr.js} +1 -1
- package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-Dy6Yh_hu.js → xychartDiagram-S5SC5T6Z-BSVXs4IY.js} +1 -1
- package/dist-ksadk/index.html +2 -2
- package/dist-lib/App.d.ts.map +1 -1
- package/dist-lib/{ArtifactsPanel-DDCKcvaL.js → ArtifactsPanel-D36BykpN.js} +1 -1
- package/dist-lib/{CodeBlock-BS9DcS5a.js → CodeBlock-BlEkUJ8C.js} +1 -1
- package/dist-lib/{MathMessageMarkdown-CpCcJFjZ.js → MathMessageMarkdown-CcnPvEgd.js} +2 -2
- package/dist-lib/{NativeTerminalPanel-CDqCdIly.js → NativeTerminalPanel-Dix1UX_z.js} +1 -1
- package/dist-lib/{WorkspacePanelContainer-DzbAkIfx.js → WorkspacePanelContainer-Cr1BwR1P.js} +1391 -1609
- package/dist-lib/components/chat/A2UIActivityMessage.d.ts.map +1 -1
- package/dist-lib/components/chat/ChatMessageList.d.ts +9 -0
- package/dist-lib/components/chat/ChatMessageList.d.ts.map +1 -1
- package/dist-lib/components/chat/ProcessingBlocksView.d.ts.map +1 -1
- package/dist-lib/components.js +4 -4
- package/dist-lib/conversation.js +28 -0
- package/dist-lib/core/conversation/client.d.ts +26 -0
- package/dist-lib/core/conversation/client.d.ts.map +1 -0
- package/dist-lib/core/conversation/contracts.d.ts +20 -0
- package/dist-lib/core/conversation/contracts.d.ts.map +1 -0
- package/dist-lib/core/conversation/errors.d.ts +12 -0
- package/dist-lib/core/conversation/errors.d.ts.map +1 -0
- package/dist-lib/core/conversation/hosted.d.ts +25 -0
- package/dist-lib/core/conversation/hosted.d.ts.map +1 -0
- package/dist-lib/core/conversation/index.d.ts +8 -0
- package/dist-lib/core/conversation/index.d.ts.map +1 -0
- package/dist-lib/core/conversation/presentation.d.ts +16 -0
- package/dist-lib/core/conversation/presentation.d.ts.map +1 -0
- package/dist-lib/core/conversation/reducer.d.ts +19 -0
- package/dist-lib/core/conversation/reducer.d.ts.map +1 -0
- package/dist-lib/core/conversation/renderer-registry.d.ts +20 -0
- package/dist-lib/core/conversation/renderer-registry.d.ts.map +1 -0
- package/dist-lib/core/conversation/types.d.ts +176 -0
- package/dist-lib/core/conversation/types.d.ts.map +1 -0
- package/dist-lib/core/run/blocks.d.ts +7 -0
- package/dist-lib/core/run/blocks.d.ts.map +1 -1
- package/dist-lib/core/run/dispatcher.d.ts.map +1 -1
- package/dist-lib/core/run/engine.d.ts +3 -0
- package/dist-lib/core/run/engine.d.ts.map +1 -1
- package/dist-lib/core/run/types.d.ts +8 -0
- package/dist-lib/core/run/types.d.ts.map +1 -1
- package/dist-lib/core/stream/kernel-events.d.ts.map +1 -1
- package/dist-lib/hooks/useRunAgent.d.ts.map +1 -1
- package/dist-lib/hooks/useSessionLifecycle.d.ts.map +1 -1
- package/dist-lib/persisted-session-history-C0N8TrMb.js +2033 -0
- package/dist-lib/public/conversation.d.ts +13 -0
- package/dist-lib/public/conversation.d.ts.map +1 -0
- package/dist-lib/public/runtime.d.ts +2 -0
- package/dist-lib/public/runtime.d.ts.map +1 -1
- package/dist-lib/public/types.d.ts +1 -0
- package/dist-lib/public/types.d.ts.map +1 -1
- package/dist-lib/runtime.js +1362 -2197
- package/dist-lib/styles.css +1 -1
- package/dist-lib/tool-display-C4tPXce0.js +0 -0
- package/dist-lib/utils/persisted-session-history.d.ts +27 -0
- package/dist-lib/utils/persisted-session-history.d.ts.map +1 -0
- package/dist-lib/utils/recovered-run.d.ts.map +1 -1
- package/dist-lib/utils/session-event-history.d.ts.map +1 -1
- package/dist-lib/utils/session-events.d.ts.map +1 -1
- package/package.json +14 -3
- package/schemas/release-provenance.schema.json +34 -0
- package/dist-ksadk/assets/architecture-7GRP2DOG-DjKratdf.js +0 -1
- package/dist-ksadk/assets/channel-4cQHKtx1.js +0 -1
- package/dist-ksadk/assets/chunk-2Q5K7J3B-DmgWkESh.js +0 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-DLFd9Xi0.js +0 -1
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-DLFd9Xi0.js +0 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-DjEM48Qp.js +0 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-CMgMaJrC.js +0 -1
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-BBKL0x3P.js +0 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-Dw63mrhw.js +0 -1
- package/dist-ksadk/assets/index-8ipRcQ-M.js +0 -240
- package/dist-ksadk/assets/index-ByFCqjlh.css +0 -2
- package/dist-ksadk/assets/info-A6RAGUB7-B6iAblII.js +0 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-BOYAipuq.js +0 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-Ctq0Kbku.js +0 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-DN0-ul_0.js +0 -1
- package/dist-ksadk/assets/railroad-74A4TZTK-C6cC_to0.js +0 -1
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-BimjIuRc.js +0 -1
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-CvY65ABq.js +0 -1
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-D72Iq_Tv.js +0 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-BgQY03nz.js +0 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-DLVw3q5Q.js +0 -8
- package/dist-ksadk/assets/treeView-Q6P3EWNA-BMpO0wsB.js +0 -1
- package/dist-ksadk/assets/treemap-WGGIJYW6-Et0aqzU3.js +0 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-CbY0mhpl.js +0 -1
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MathMessageMarkdown-BL8my1R2.js","./CodeBlock-DOH6MVcn.js","./MermaidBlock-Dz4IP-Tx.js","./katex-vFWytM5c.js","./MathMessageMarkdown-BorAY7qD.css","./NativeTerminalPanel-DUrK0JpZ.js","./NativeTerminalPanel-CHOd7Rch.css","./dist-BE7bu-DL.js","./dist-C_wsv-Qd.js","./dist-DmldrHd_.js","./dist-B7seoj3d.js","./dist-CSh_DE14.js","./dist-BjU6y-A2.js","./dist-DnfXs8Vn.js","./dist-8hqcx0sU.js","./dist-BX8z72IC.js","./dist-BVDffZ0U.js","./dist-DNp6rLRA.js","./dist-ngtN0DJB.js","./dist-CttYUqzS.js","./dist-CXYYBw3_.js","./dist-dDdADKFA.js","./dist-DUX-id_F.js","./dist-dydu68Fl.js","./dist-ClxGviKw.js","./dist-Bf2M8m3N.js","./dist-W-TIVntx.js","./dockerfile-BLkNEvjs.js","./simple-mode-DRpGK0lJ.js","./factor-D7LVTn2l.js","./nsis-AQ_alPln.js","./pug-Bugr-47h.js","./javascript-9Tg8ixDm.js","./dist-Dq9gLD7L.js","./dist-BytlxIDT.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,w());else{var t=n(l);t!==null&&oe(x,t.startTime-e)}}var ee=!1,te=-1,S=5,ne=-1;function re(){return g?!0:!(e.unstable_now()-ne<S)}function C(){if(g=!1,ee){var t=e.unstable_now();ne=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&&re());){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?w():ee=!1}}}var w;if(typeof y==`function`)w=function(){y(C)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=C,w=function(){ae.postMessage(null)}}else w=function(){_(C,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,w()))),r},e.unstable_shouldYield=re,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},ne=Object.prototype.hasOwnProperty;function re(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function C(e,t){return re(e.type,t,e.props)}function w(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&&(w(o)&&(o=C(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(!w(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)!ne.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 re(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)ne.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 re(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=w,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`),ne=Symbol.for(`react.suspense`),re=Symbol.for(`react.suspense_list`),C=Symbol.for(`react.memo`),w=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 ne:return`Suspense`;case re: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 C:return t=e.displayName||null,t===null?le(e.type)||`Memo`:t;case w: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)?cf(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=cf(t),e=lf(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 Ce(e){e.memoizedState!==null&&ge(be,e);var t=_e.current,n=lf(t,e.type);t!==n&&(ge(ve,e),ge(_e,n))}function we(e){ve.current===e&&(he(_e),he(ve)),be.current===e&&(he(be),_p._currentValue=de)}var Te,Ee;function De(e){if(Te===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Te=t&&t[1]||``,Ee=-1<e.stack.indexOf(`
|
|
3
|
-
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
|
-
`+Te+e+Ee}var Oe=!1;function ke(e,t){if(!e||Oe)return``;Oe=!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{Oe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?De(n):``}function Ae(e,t){switch(e.tag){case 26:case 27:case 5:return De(e.type);case 16:return De(`Lazy`);case 13:return e.child!==t&&t!==null?De(`Suspense Fallback`):De(`Suspense`);case 19:return De(`SuspenseList`);case 0:case 15:return ke(e.type,!1);case 11:return ke(e.type.render,!1);case 1:return ke(e.type,!0);case 31:return De(`Activity`);default:return``}}function je(e){try{var t=``,n=null;do t+=Ae(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
8
|
-
Error generating stack: `+e.message+`
|
|
9
|
-
`+e.stack}}var Me=Object.prototype.hasOwnProperty,Ne=t.unstable_scheduleCallback,Pe=t.unstable_cancelCallback,Fe=t.unstable_shouldYield,Ie=t.unstable_requestPaint,Le=t.unstable_now,Re=t.unstable_getCurrentPriorityLevel,ze=t.unstable_ImmediatePriority,Be=t.unstable_UserBlockingPriority,Ve=t.unstable_NormalPriority,D=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:Np(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=Af(e);e!==null;){if(n=e[_t])return n;e=Af(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 Me.call(Lt,e)?!0:Me.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 O(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 sn=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`]]),cn=/^[\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 ln(e){return cn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function un(){}var dn=null;function fn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var pn=null,mn=null;function hn(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 gn=!1;function _n(e,t,n){if(gn)return e(t,n);gn=!0;try{return e(t)}finally{if(gn=!1,(pn!==null||mn!==null)&&(Ru(),pn&&(t=pn,e=mn,mn=pn=null,hn(t),e)))for(t=0;t<e.length;t++)hn(e[t])}}function vn(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 yn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),bn=!1;if(yn)try{var xn={};Object.defineProperty(xn,"passive",{get:function(){bn=!0}}),window.addEventListener(`test`,xn,xn),window.removeEventListener(`test`,xn,xn)}catch{bn=!1}var Sn=null,Cn=null,wn=null;function Tn(){if(wn)return wn;var e,t=Cn,n=t.length,r,i=`value`in Sn?Sn.value:Sn.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 wn=i.slice(e,1<r?1-r:void 0)}function En(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 Dn(){return!0}function On(){return!1}function kn(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)?Dn:On,this.isPropagationStopped=On,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=Dn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Dn)},persist:function(){},isPersistent:Dn}),t}var An={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},jn=kn(An),Mn=m({},An,{view:0,detail:0}),Nn=kn(Mn),Pn,Fn,In,Ln=m({},Mn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Jn,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!==In&&(In&&e.type===`mousemove`?(Pn=e.screenX-In.screenX,Fn=e.screenY-In.screenY):Fn=Pn=0,In=e),Pn)},movementY:function(e){return`movementY`in e?e.movementY:Fn}}),Rn=kn(Ln),zn=kn(m({},Ln,{dataTransfer:0})),Bn=kn(m({},Mn,{relatedTarget:0})),Vn=kn(m({},An,{animationName:0,elapsedTime:0,pseudoElement:0})),Hn=kn(m({},An,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Un=kn(m({},An,{data:0})),Wn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Gn={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`},Kn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function qn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Kn[e])?!!t[e]:!1}function Jn(){return qn}var Yn=kn(m({},Mn,{key:function(e){if(e.key){var t=Wn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=En(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Gn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Jn,charCode:function(e){return e.type===`keypress`?En(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?En(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Xn=kn(m({},Ln,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Zn=kn(m({},Mn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Jn})),Qn=kn(m({},An,{propertyName:0,elapsedTime:0,pseudoElement:0})),$n=kn(m({},Ln,{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})),er=kn(m({},An,{newState:0,oldState:0})),tr=[9,13,27,32],nr=yn&&`CompositionEvent`in window,rr=null;yn&&`documentMode`in document&&(rr=document.documentMode);var ir=yn&&`TextEvent`in window&&!rr,ar=yn&&(!nr||rr&&8<rr&&11>=rr),or=` `,sr=!1;function cr(e,t){switch(e){case`keyup`:return tr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function lr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var ur=!1;function dr(e,t){switch(e){case`compositionend`:return lr(t);case`keypress`:return t.which===32?(sr=!0,or):null;case`textInput`:return e=t.data,e===or&&sr?null:e;default:return null}}function fr(e,t){if(ur)return e===`compositionend`||!nr&&cr(e,t)?(e=Tn(),wn=Cn=Sn=null,ur=!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 ar&&t.locale!==`ko`?null:t.data;default:return null}}var pr={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 mr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!pr[e.type]:t===`textarea`}function hr(e,t,n,r){pn?mn?mn.push(r):mn=[r]:pn=r,t=Gd(t,`onChange`),0<t.length&&(n=new jn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var gr=null,_r=null;function vr(e){Ld(e,0)}function yr(e){if(Kt(Ot(e)))return e}function br(e,t){if(e===`change`)return t}var xr=!1;if(yn){var Sr;if(yn){var Cr=`oninput`in document;if(!Cr){var wr=document.createElement(`div`);wr.setAttribute(`oninput`,`return;`),Cr=typeof wr.oninput==`function`}Sr=Cr}else Sr=!1;xr=Sr&&(!document.documentMode||9<document.documentMode)}function Tr(){gr&&(gr.detachEvent(`onpropertychange`,Er),_r=gr=null)}function Er(e){if(e.propertyName===`value`&&yr(_r)){var t=[];hr(t,_r,e,fn(e)),_n(vr,t)}}function Dr(e,t,n){e===`focusin`?(Tr(),gr=t,_r=n,gr.attachEvent(`onpropertychange`,Er)):e===`focusout`&&Tr()}function Or(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return yr(_r)}function kr(e,t){if(e===`click`)return yr(t)}function Ar(e,t){if(e===`input`||e===`change`)return yr(t)}function jr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Mr=typeof Object.is==`function`?Object.is:jr;function Nr(e,t){if(Mr(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(!Me.call(t,i)||!Mr(e[i],t[i]))return!1}return!0}function Pr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Fr(e,t){var n=Pr(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=Pr(n)}}function Ir(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ir(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Lr(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 Rr(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 zr=yn&&`documentMode`in document&&11>=document.documentMode,Br=null,Vr=null,Hr=null,Ur=!1;function Wr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ur||Br==null||Br!==qt(r)||(r=Br,`selectionStart`in r&&Rr(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}),Hr&&Nr(Hr,r)||(Hr=r,r=Gd(Vr,`onSelect`),0<r.length&&(t=new jn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Br)))}function Gr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Kr={animationend:Gr(`Animation`,`AnimationEnd`),animationiteration:Gr(`Animation`,`AnimationIteration`),animationstart:Gr(`Animation`,`AnimationStart`),transitionrun:Gr(`Transition`,`TransitionRun`),transitionstart:Gr(`Transition`,`TransitionStart`),transitioncancel:Gr(`Transition`,`TransitionCancel`),transitionend:Gr(`Transition`,`TransitionEnd`)},qr={},Jr={};yn&&(Jr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Kr.animationend.animation,delete Kr.animationiteration.animation,delete Kr.animationstart.animation),`TransitionEvent`in window||delete Kr.transitionend.transition);function Yr(e){if(qr[e])return qr[e];if(!Kr[e])return e;var t=Kr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Jr)return qr[e]=t[n];return e}var Xr=Yr(`animationend`),Zr=Yr(`animationiteration`),Qr=Yr(`animationstart`),$r=Yr(`transitionrun`),ei=Yr(`transitionstart`),ti=Yr(`transitioncancel`),ni=Yr(`transitionend`),ri=new Map,ii=`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(` `);ii.push(`scrollEnd`);function ai(e,t){ri.set(e,t),Nt(t,[e])}var oi=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)},si=[],ci=0,li=0;function ui(){for(var e=ci,t=li=ci=0;t<e;){var n=si[t];si[t++]=null;var r=si[t];si[t++]=null;var i=si[t];si[t++]=null;var a=si[t];if(si[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&&mi(n,i,a)}}function di(e,t,n,r){si[ci++]=e,si[ci++]=t,si[ci++]=n,si[ci++]=r,li|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function fi(e,t,n,r){return di(e,t,n,r),hi(e)}function pi(e,t){return di(e,null,null,t),hi(e)}function mi(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 hi(e){if(50<ku)throw ku=0,Au=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var gi={};function _i(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 vi(e,t,n,r){return new _i(e,t,n,r)}function yi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function bi(e,t){var n=e.alternate;return n===null?(n=vi(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 xi(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 Si(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)yi(e)&&(s=1);else if(typeof e==`string`)s=cp(e,n,_e.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case ie:return e=vi(31,n,t,a),e.elementType=ie,e.lanes=o,e;case y:return Ci(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=vi(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case ne:return e=vi(13,n,t,a),e.elementType=ne,e.lanes=o,e;case re:return e=vi(19,n,t,a),e.elementType=re,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 C:s=14;break a;case w:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=vi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Ci(e,t,n,r){return e=vi(7,e,r,t),e.lanes=n,e}function wi(e,t,n){return e=vi(6,e,null,t),e.lanes=n,e}function Ti(e){var t=vi(18,null,null,0);return t.stateNode=e,t}function Ei(e,t,n){return t=vi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Di=new WeakMap;function Oi(e,t){if(typeof e==`object`&&e){var n=Di.get(e);return n===void 0?(t={value:e,source:t,stack:je(t)},Di.set(e,t),t):n}return{value:e,source:t,stack:je(t)}}var ki=[],Ai=0,ji=null,Mi=0,Ni=[],Pi=0,Fi=null,Ii=1,Li=``;function Ri(e,t){ki[Ai++]=Mi,ki[Ai++]=ji,ji=e,Mi=t}function zi(e,t,n){Ni[Pi++]=Ii,Ni[Pi++]=Li,Ni[Pi++]=Fi,Fi=e;var r=Ii;e=Li;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,Ii=1<<32-Je(t)+i|n<<i|r,Li=a+e}else Ii=1<<a|n<<i|r,Li=e}function Bi(e){e.return!==null&&(Ri(e,1),zi(e,1,0))}function Vi(e){for(;e===ji;)ji=ki[--Ai],ki[Ai]=null,Mi=ki[--Ai],ki[Ai]=null;for(;e===Fi;)Fi=Ni[--Pi],Ni[Pi]=null,Li=Ni[--Pi],Ni[Pi]=null,Ii=Ni[--Pi],Ni[Pi]=null}function Hi(e,t){Ni[Pi++]=Ii,Ni[Pi++]=Li,Ni[Pi++]=Fi,Ii=t.id,Li=t.overflow,Fi=e}var Ui=null,Wi=null,Gi=!1,Ki=null,qi=!1,Ji=Error(i(519));function Yi(e){throw ta(Oi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ji}function Xi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[_t]=e,t[vt]=r,n){case`dialog`:Rd(`cancel`,t),Rd(`close`,t);break;case`iframe`:case`object`:case`embed`:Rd(`load`,t);break;case`video`:case`audio`:for(n=0;n<Fd.length;n++)Rd(Fd[n],t);break;case`source`:Rd(`error`,t);break;case`img`:case`image`:case`link`:Rd(`error`,t),Rd(`load`,t);break;case`details`:Rd(`toggle`,t);break;case`input`:Rd(`invalid`,t),Zt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Rd(`invalid`,t);break;case`textarea`:Rd(`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||Zd(t.textContent,n)?(r.popover!=null&&(Rd(`beforetoggle`,t),Rd(`toggle`,t)),r.onScroll!=null&&Rd(`scroll`,t),r.onScrollEnd!=null&&Rd(`scrollend`,t),r.onClick!=null&&(t.onclick=un),t=!0):t=!1,t||Yi(e,!0)}function Zi(e){for(Ui=e.return;Ui;)switch(Ui.tag){case 5:case 31:case 13:qi=!1;return;case 27:case 3:qi=!0;return;default:Ui=Ui.return}}function Qi(e){if(e!==Ui)return!1;if(!Gi)return Zi(e),Gi=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||uf(e.type,e.memoizedProps)),n=!n),n&&Wi&&Yi(e),Zi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Wi=kf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Wi=kf(e)}else t===27?(t=Wi,_f(e.type)?(e=Of,Of=null,Wi=e):Wi=t):Wi=Ui?Df(e.stateNode.nextSibling):null;return!0}function $i(){Wi=Ui=null,Gi=!1}function ea(){var e=Ki;return e!==null&&(hu===null?hu=e:hu.push.apply(hu,e),Ki=null),e}function ta(e){Ki===null?Ki=[e]:Ki.push(e)}var na=me(null),ra=null,ia=null;function aa(e,t,n){ge(na,t._currentValue),t._currentValue=n}function oa(e){e._currentValue=na.current,he(na)}function sa(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 ca(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),sa(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),sa(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 la(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;Mr(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=[_p]:e.push(_p))}a=a.return}e!==null&&ca(t,e,n,r),t.flags|=262144}function ua(e){for(e=e.firstContext;e!==null;){if(!Mr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function da(e){ra=e,ia=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function fa(e){return ma(ra,e)}function pa(e,t){return ra===null&&da(e),ma(e,t)}function ma(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ia===null){if(e===null)throw Error(i(308));ia=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ia=ia.next=t;return n}var ha=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()})}},ga=t.unstable_scheduleCallback,_a=t.unstable_NormalPriority,va={$$typeof:te,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ya(){return{controller:new ha,data:new Map,refCount:0}}function ba(e){e.refCount--,e.refCount===0&&ga(_a,function(){e.controller.abort()})}var xa=null,Sa=0,Ca=0,wa=null;function Ta(e,t){if(xa===null){var n=xa=[];Sa=0,Ca=kd(),wa={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Sa++,t.then(Ea,Ea),t}function Ea(){if(--Sa===0&&xa!==null){wa!==null&&(wa.status=`fulfilled`);var e=xa;xa=null,Ca=0,wa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Da(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 Oa=T.S;T.S=function(e,t){vu=Le(),typeof t==`object`&&t&&typeof t.then==`function`&&Ta(e,t),Oa!==null&&Oa(e,t)};var ka=me(null);function Aa(){var e=ka.current;return e===null?M.pooledCache:e}function ja(e,t){t===null?ge(ka,ka.current):ge(ka,t.pool)}function Ma(){var e=Aa();return e===null?null:{parent:va._currentValue,pool:e}}var Na=Error(i(460)),Pa=Error(i(474)),Fa=Error(i(542)),Ia={then:function(){}};function La(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Ra(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(un,un),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ha(e),e;default:if(typeof t.status==`string`)t.then(un,un);else{if(e=M,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,Ha(e),e}throw Ba=t,Na}}function za(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Ba=e,Na):e}}var Ba=null;function Va(){if(Ba===null)throw Error(i(459));var e=Ba;return Ba=null,e}function Ha(e){if(e===Na||e===Fa)throw Error(i(483))}var Ua=null,Wa=0;function Ga(e){var t=Wa;return Wa+=1,Ua===null&&(Ua=[]),Ra(Ua,e,t)}function Ka(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function qa(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 Ja(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=bi(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=wi(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===w&&za(i)===t.type)?(t=a(t,n.props),Ka(t,n),t.return=e,t):(t=Si(n.type,n.key,n.props,null,e.mode,r),Ka(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=Ei(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=Ci(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=wi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=Si(t.type,t.key,t.props,null,e.mode,n),Ka(n,t),n.return=e,n;case v:return t=Ei(t,e.mode,n),t.return=e,t;case w:return t=za(t),f(e,t,n)}if(ue(t)||se(t))return t=Ci(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Ga(t),n);if(t.$$typeof===te)return f(e,pa(e,t),n);qa(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 w:return n=za(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,Ga(n),r);if(n.$$typeof===te)return p(e,t,pa(e,n),r);qa(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 w:return r=za(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,Ga(r),i);if(r.$$typeof===te)return m(e,t,n,pa(t,r),i);qa(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),Gi&&Ri(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 Gi&&Ri(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)}),Gi&&Ri(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),Gi&&Ri(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 Gi&&Ri(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)}),Gi&&Ri(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===w&&za(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ka(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=Ci(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=Si(o.type,o.key,o.props,null,e.mode,c),Ka(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=Ei(o,e.mode,c),c.return=e,e=c}return s(e);case w:return o=za(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,Ga(o),c);if(o.$$typeof===te)return b(e,r,pa(e,o),c);qa(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=wi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Wa=0;var i=b(e,t,n,r);return Ua=null,i}catch(t){if(t===Na||t===Fa)throw t;var a=vi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ya=Ja(!0),Xa=Ja(!1),Za=!1;function Qa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function $a(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 eo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function to(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,$l&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=hi(e),mi(e,null,n),t}return di(e,r,t,n),hi(e)}function no(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 ro(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 io=!1;function ao(){if(io){var e=wa;if(e!==null)throw e}}function oo(e,t,n,r){io=!1;var i=e.updateQueue;Za=!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?(tu&f)===f:(r&f)===f){f!==0&&f===Ca&&(io=!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:Za=!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),lu|=o,e.lanes=o,e.memoizedState=d}}function so(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function co(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)so(n[e],t)}var lo=me(null),uo=me(0);function fo(e,t){e=su,ge(uo,e),ge(lo,t),su=e|t.baseLanes}function po(){ge(uo,su),ge(lo,lo.current)}function mo(){su=uo.current,he(lo),he(uo)}var ho=me(null),go=null;function _o(e){var t=e.alternate;ge(So,So.current&1),ge(ho,e),go===null&&(t===null||lo.current!==null||t.memoizedState!==null)&&(go=e)}function vo(e){ge(So,So.current),ge(ho,e),go===null&&(go=e)}function yo(e){e.tag===22?(ge(So,So.current),ge(ho,e),go===null&&(go=e)):bo(e)}function bo(){ge(So,So.current),ge(ho,ho.current)}function xo(e){he(ho),go===e&&(go=null),he(So)}var So=me(0);function Co(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||wf(n)||Tf(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 wo=0,To=null,Eo=null,Do=null,Oo=!1,ko=!1,Ao=!1,jo=0,Mo=0,No=null,Po=0;function Fo(){throw Error(i(321))}function Io(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Mr(e[n],t[n]))return!1;return!0}function Lo(e,t,n,r,i,a){return wo=a,To=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,T.H=e===null||e.memoizedState===null?ec:tc,Ao=!1,a=n(r,i),Ao=!1,ko&&(a=zo(t,n,r,i)),Ro(e),a}function Ro(e){T.H=$s;var t=Eo!==null&&Eo.next!==null;if(wo=0,Do=Eo=To=null,Oo=!1,Mo=0,No=null,t)throw Error(i(300));e===null||vc||(e=e.dependencies,e!==null&&ua(e)&&(vc=!0))}function zo(e,t,n,r){To=e;var a=0;do{if(ko&&(No=null),Mo=0,ko=!1,25<=a)throw Error(i(301));if(a+=1,Do=Eo=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=nc,o=t(n,r)}while(ko);return o}function Bo(){var e=T.H,t=e.useState()[0];return t=typeof t.then==`function`?qo(t):t,e=e.useState()[0],(Eo===null?null:Eo.memoizedState)!==e&&(To.flags|=1024),t}function Vo(){var e=jo!==0;return jo=0,e}function Ho(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Uo(e){if(Oo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Oo=!1}wo=0,Do=Eo=To=null,ko=!1,Mo=jo=0,No=null}function Wo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Do===null?To.memoizedState=Do=e:Do=Do.next=e,Do}function Go(){if(Eo===null){var e=To.alternate;e=e===null?null:e.memoizedState}else e=Eo.next;var t=Do===null?To.memoizedState:Do.next;if(t!==null)Do=t,Eo=e;else{if(e===null)throw To.alternate===null?Error(i(467)):Error(i(310));Eo=e,e={memoizedState:Eo.memoizedState,baseState:Eo.baseState,baseQueue:Eo.baseQueue,queue:Eo.queue,next:null},Do===null?To.memoizedState=Do=e:Do=Do.next=e}return Do}function Ko(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function qo(e){var t=Mo;return Mo+=1,No===null&&(No=[]),e=Ra(No,e,t),t=To,(Do===null?t.memoizedState:Do.next)===null&&(t=t.alternate,T.H=t===null||t.memoizedState===null?ec:tc),e}function Jo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return qo(e);if(e.$$typeof===te)return fa(e)}throw Error(i(438,String(e)))}function Yo(e){var t=null,n=To.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=To.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=Ko(),To.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 Xo(e,t){return typeof t==`function`?t(e):t}function Zo(e){return Qo(Go(),Eo,e)}function Qo(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?(wo&f)===f:(tu&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===Ca&&(d=!0);else if((wo&p)===p){u=u.next,p===Ca&&(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,To.lanes|=p,lu|=p;f=u.action,Ao&&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,To.lanes|=f,lu|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Mr(o,e.memoizedState)&&(vc=!0,d&&(n=wa,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 $o(e){var t=Go(),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);Mr(o,t.memoizedState)||(vc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function es(e,t,n){var r=To,a=Go(),o=Gi;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Mr((Eo||a).memoizedState,n);if(s&&(a.memoizedState=n,vc=!0),a=a.queue,Ts(rs.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||Do!==null&&Do.memoizedState.tag&1){if(r.flags|=2048,bs(9,{destroy:void 0},ns.bind(null,r,a,n,t),null),M===null)throw Error(i(349));o||wo&127||ts(r,t,n)}return n}function ts(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=To.updateQueue,t===null?(t=Ko(),To.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function ns(e,t,n,r){t.value=n,t.getSnapshot=r,is(t)&&as(e)}function rs(e,t,n){return n(function(){is(t)&&as(e)})}function is(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Mr(e,n)}catch{return!0}}function as(e){var t=pi(e,2);t!==null&&Nu(t,e,2)}function os(e){var t=Wo();if(typeof e==`function`){var n=e;if(e=n(),Ao){qe(!0);try{n()}finally{qe(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xo,lastRenderedState:e},t}function ss(e,t,n,r){return e.baseState=n,Qo(e,Eo,typeof r==`function`?r:Xo)}function cs(e,t,n,r,a){if(Xs(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,ls(t,o)):(o.next=n.next,t.pending=n.next=o)}}function ls(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),us(e,t,s)}catch(n){fs(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),T.T=a}}else try{a=n(i,r),us(e,t,a)}catch(n){fs(e,t,n)}}function us(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){ds(e,t,n)},function(n){return fs(e,t,n)}):ds(e,t,n)}function ds(e,t,n){t.status=`fulfilled`,t.value=n,ps(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,ls(e,n)))}function fs(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,ps(t),t=t.next;while(t!==r)}e.action=null}function ps(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function ms(e,t){return t}function hs(e,t){if(Gi){var n=M.formState;if(n!==null){a:{var r=To;if(Gi){if(Wi){b:{for(var i=Wi,a=qi;i.nodeType!==8;){if(!a){i=null;break b}if(i=Df(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Wi=Df(i.nextSibling),r=i.data===`F!`;break a}}Yi(r)}r=!1}r&&(t=n[0])}}return n=Wo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:t},n.queue=r,n=qs.bind(null,To,r),r.dispatch=n,r=os(!1),a=Ys.bind(null,To,!1,r.queue),r=Wo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=cs.bind(null,To,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function gs(e){return _s(Go(),Eo,e)}function _s(e,t,n){if(t=Qo(e,t,ms)[0],e=Zo(Xo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=qo(t)}catch(e){throw e===Na?Fa:e}else r=t;t=Go();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(To.flags|=2048,bs(9,{destroy:void 0},vs.bind(null,i,n),null)),[r,a,e]}function vs(e,t){e.action=t}function ys(e){var t=Go(),n=Eo;if(n!==null)return _s(t,n,e);Go(),t=t.memoizedState,n=Go();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function bs(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=To.updateQueue,t===null&&(t=Ko(),To.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 xs(){return Go().memoizedState}function Ss(e,t,n,r){var i=Wo();To.flags|=e,i.memoizedState=bs(1|t,{destroy:void 0},n,r===void 0?null:r)}function Cs(e,t,n,r){var i=Go();r=r===void 0?null:r;var a=i.memoizedState.inst;Eo!==null&&r!==null&&Io(r,Eo.memoizedState.deps)?i.memoizedState=bs(t,a,n,r):(To.flags|=e,i.memoizedState=bs(1|t,a,n,r))}function ws(e,t){Ss(8390656,8,e,t)}function Ts(e,t){Cs(2048,8,e,t)}function Es(e){To.flags|=4;var t=To.updateQueue;if(t===null)t=Ko(),To.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Ds(e){var t=Go().memoizedState;return Es({ref:t,nextImpl:e}),function(){if($l&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Os(e,t){return Cs(4,2,e,t)}function ks(e,t){return Cs(4,4,e,t)}function As(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 js(e,t,n){n=n==null?null:n.concat([e]),Cs(4,4,As.bind(null,t,e),n)}function Ms(){}function Ns(e,t){var n=Go();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Io(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Ps(e,t){var n=Go();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Io(t,r[1]))return r[0];if(r=e(),Ao){qe(!0);try{e()}finally{qe(!1)}}return n.memoizedState=[r,t],r}function Fs(e,t,n){return n===void 0||wo&1073741824&&!(tu&261930)?e.memoizedState=t:(e.memoizedState=n,e=Mu(),To.lanes|=e,lu|=e,n)}function Is(e,t,n,r){return Mr(n,t)?n:lo.current===null?!(wo&42)||wo&1073741824&&!(tu&261930)?(vc=!0,e.memoizedState=n):(e=Mu(),To.lanes|=e,lu|=e,t):(e=Fs(e,n,r),Mr(e,t)||(vc=!0),e)}function Ls(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,Ys(e,!1,t,n);try{var c=i(),l=T.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Js(e,t,Da(c,r),ju(e)):Js(e,t,r,ju(e))}catch(n){Js(e,t,{then:function(){},status:`rejected`,reason:n},ju())}finally{E.p=a,o!==null&&s.types!==null&&(o.types=s.types),T.T=o}}function Rs(){}function zs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Bs(e).queue;Ls(e,a,t,de,n===null?Rs:function(){return Vs(e),n(r)})}function Bs(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:Xo,lastRenderedState:de},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Vs(e){var t=Bs(e);t.next===null&&(t=e.alternate.memoizedState),Js(e,t.next.queue,{},ju())}function Hs(){return fa(_p)}function Us(){return Go().memoizedState}function Ws(){return Go().memoizedState}function Gs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=ju();e=eo(n);var r=to(t,e,n);r!==null&&(Nu(r,t,n),no(r,t,n)),t={cache:ya()},e.payload=t;return}t=t.return}}function Ks(e,t,n){var r=ju();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Xs(e)?Zs(t,n):(n=fi(e,t,n,r),n!==null&&(Nu(n,e,r),Qs(n,t,r)))}function qs(e,t,n){Js(e,t,n,ju())}function Js(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Xs(e))Zs(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,Mr(s,o))return di(e,t,i,0),M===null&&ui(),!1}catch{}if(n=fi(e,t,i,r),n!==null)return Nu(n,e,r),Qs(n,t,r),!0}return!1}function Ys(e,t,n,r){if(r={lane:2,revertLane:kd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Xs(e)){if(t)throw Error(i(479))}else t=fi(e,n,r,2),t!==null&&Nu(t,e,2)}function Xs(e){var t=e.alternate;return e===To||t!==null&&t===To}function Zs(e,t){ko=Oo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Qs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ut(e,n)}}var $s={readContext:fa,use:Jo,useCallback:Fo,useContext:Fo,useEffect:Fo,useImperativeHandle:Fo,useLayoutEffect:Fo,useInsertionEffect:Fo,useMemo:Fo,useReducer:Fo,useRef:Fo,useState:Fo,useDebugValue:Fo,useDeferredValue:Fo,useTransition:Fo,useSyncExternalStore:Fo,useId:Fo,useHostTransitionStatus:Fo,useFormState:Fo,useActionState:Fo,useOptimistic:Fo,useMemoCache:Fo,useCacheRefresh:Fo};$s.useEffectEvent=Fo;var ec={readContext:fa,use:Jo,useCallback:function(e,t){return Wo().memoizedState=[e,t===void 0?null:t],e},useContext:fa,useEffect:ws,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Ss(4194308,4,As.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ss(4194308,4,e,t)},useInsertionEffect:function(e,t){Ss(4,2,e,t)},useMemo:function(e,t){var n=Wo();t=t===void 0?null:t;var r=e();if(Ao){qe(!0);try{e()}finally{qe(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Wo();if(n!==void 0){var i=n(t);if(Ao){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=Ks.bind(null,To,e),[r.memoizedState,e]},useRef:function(e){var t=Wo();return e={current:e},t.memoizedState=e},useState:function(e){e=os(e);var t=e.queue,n=qs.bind(null,To,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Ms,useDeferredValue:function(e,t){return Fs(Wo(),e,t)},useTransition:function(){var e=os(!1);return e=Ls.bind(null,To,e.queue,!0,!1),Wo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=To,a=Wo();if(Gi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),M===null)throw Error(i(349));tu&127||ts(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ws(rs.bind(null,r,o,e),[e]),r.flags|=2048,bs(9,{destroy:void 0},ns.bind(null,r,o,n,t),null),n},useId:function(){var e=Wo(),t=M.identifierPrefix;if(Gi){var n=Li,r=Ii;n=(r&~(1<<32-Je(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=jo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Po++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Hs,useFormState:hs,useActionState:hs,useOptimistic:function(e){var t=Wo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Ys.bind(null,To,!0,n),n.dispatch=t,[e,t]},useMemoCache:Yo,useCacheRefresh:function(){return Wo().memoizedState=Gs.bind(null,To)},useEffectEvent:function(e){var t=Wo(),n={impl:e};return t.memoizedState=n,function(){if($l&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},tc={readContext:fa,use:Jo,useCallback:Ns,useContext:fa,useEffect:Ts,useImperativeHandle:js,useInsertionEffect:Os,useLayoutEffect:ks,useMemo:Ps,useReducer:Zo,useRef:xs,useState:function(){return Zo(Xo)},useDebugValue:Ms,useDeferredValue:function(e,t){return Is(Go(),Eo.memoizedState,e,t)},useTransition:function(){var e=Zo(Xo)[0],t=Go().memoizedState;return[typeof e==`boolean`?e:qo(e),t]},useSyncExternalStore:es,useId:Us,useHostTransitionStatus:Hs,useFormState:gs,useActionState:gs,useOptimistic:function(e,t){return ss(Go(),Eo,e,t)},useMemoCache:Yo,useCacheRefresh:Ws};tc.useEffectEvent=Ds;var nc={readContext:fa,use:Jo,useCallback:Ns,useContext:fa,useEffect:Ts,useImperativeHandle:js,useInsertionEffect:Os,useLayoutEffect:ks,useMemo:Ps,useReducer:$o,useRef:xs,useState:function(){return $o(Xo)},useDebugValue:Ms,useDeferredValue:function(e,t){var n=Go();return Eo===null?Fs(n,e,t):Is(n,Eo.memoizedState,e,t)},useTransition:function(){var e=$o(Xo)[0],t=Go().memoizedState;return[typeof e==`boolean`?e:qo(e),t]},useSyncExternalStore:es,useId:Us,useHostTransitionStatus:Hs,useFormState:ys,useActionState:ys,useOptimistic:function(e,t){var n=Go();return Eo===null?(n.baseState=e,[e,n.queue.dispatch]):ss(n,Eo,e,t)},useMemoCache:Yo,useCacheRefresh:Ws};nc.useEffectEvent=Ds;function rc(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 ic={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=ju(),i=eo(r);i.payload=t,n!=null&&(i.callback=n),t=to(e,i,r),t!==null&&(Nu(t,e,r),no(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=ju(),i=eo(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=to(e,i,r),t!==null&&(Nu(t,e,r),no(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=ju(),r=eo(n);r.tag=2,t!=null&&(r.callback=t),t=to(e,r,n),t!==null&&(Nu(t,e,n),no(t,e,n))}};function ac(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?!Nr(n,r)||!Nr(i,a):!0}function oc(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&&ic.enqueueReplaceState(t,t.state,null)}function sc(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 cc(e){oi(e)}function lc(e){console.error(e)}function uc(e){oi(e)}function dc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function fc(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 pc(e,t,n){return n=eo(n),n.tag=3,n.payload={element:null},n.callback=function(){dc(e,t)},n}function mc(e){return e=eo(e),e.tag=3,e}function hc(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(){fc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){fc(t,n,r),typeof i!=`function`&&(xu===null?xu=new Set([this]):xu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function gc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&la(t,n,a,!0),n=ho.current,n!==null){switch(n.tag){case 31:case 13:return go===null?Gu():n.alternate===null&&cu===0&&(cu=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Ia?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),ud(e,r,a)),!1;case 22:return n.flags|=65536,r===Ia?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)),ud(e,r,a)),!1}throw Error(i(435,n.tag))}return ud(e,r,a),Gu(),!1}if(Gi)return t=ho.current,t===null?(r!==Ji&&(t=Error(i(423),{cause:r}),ta(Oi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Oi(r,n),a=pc(e.stateNode,r,a),ro(e,a),cu!==4&&(cu=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ji&&(e=Error(i(422),{cause:r}),ta(Oi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Oi(o,n),mu===null?mu=[o]:mu.push(o),cu!==4&&(cu=2),t===null)return!0;r=Oi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=pc(n.stateNode,r,e),ro(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`&&(xu===null||!xu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=mc(a),hc(a,e,n,r),ro(n,a),!1}n=n.return}while(n!==null);return!1}var _c=Error(i(461)),vc=!1;function yc(e,t,n,r){t.child=e===null?Xa(t,null,n,r):Ya(t,e.child,n,r)}function bc(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 da(t),r=Lo(e,t,n,o,a,i),s=Vo(),e!==null&&!vc?(Ho(e,t,i),Wc(e,t,i)):(Gi&&s&&Bi(t),t.flags|=1,yc(e,t,r,i),t.child)}function xc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!yi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Sc(e,t,a,r,i)):(e=Si(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Gc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Nr:n,n(o,r)&&e.ref===t.ref)return Wc(e,t,i)}return t.flags|=1,e=bi(a,r),e.ref=t.ref,e.return=t,t.child=e}function Sc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Nr(a,r)&&e.ref===t.ref)if(vc=!1,t.pendingProps=r=a,Gc(e,i))e.flags&131072&&(vc=!0);else return t.lanes=e.lanes,Wc(e,t,i)}return Ac(e,t,n,r,i)}function Cc(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 Tc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ja(t,a===null?null:a.cachePool),a===null?po():fo(t,a),yo(t);else return r=t.lanes=536870912,Tc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ja(t,null),po(),bo(t)):(ja(t,a.cachePool),fo(t,a),bo(t),t.memoizedState=null);return yc(e,t,i,n),t.child}function wc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Tc(e,t,n,r,i){var a=Aa();return a=a===null?null:{parent:va._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ja(t,null),po(),yo(t),e!==null&&la(e,t,r,!0),t.childLanes=i,null}function Ec(e,t){return t=zc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Dc(e,t,n){return Ya(t,e.child,null,n),e=Ec(t,t.pendingProps),e.flags|=2,xo(t),t.memoizedState=null,e}function Oc(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Gi){if(r.mode===`hidden`)return e=Ec(t,r),t.lanes=536870912,wc(null,e);if(vo(t),(e=Wi)?(e=Cf(e,qi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Fi===null?null:{id:Ii,overflow:Li},retryLane:536870912,hydrationErrors:null},n=Ti(e),n.return=t,t.child=n,Ui=t,Wi=null)):e=null,e===null)throw Yi(t);return t.lanes=536870912,null}return Ec(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(vo(t),a)if(t.flags&256)t.flags&=-257,t=Dc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(vc||la(e,t,n,!1),a=(n&e.childLanes)!==0,vc||a){if(r=M,r!==null&&(s=dt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,pi(e,s),Nu(r,e,s),_c;Gu(),t=Dc(e,t,n)}else e=o.treeContext,Wi=Df(s.nextSibling),Ui=t,Gi=!0,Ki=null,qi=!1,e!==null&&Hi(t,e),t=Ec(t,r),t.flags|=4096;return t}return e=bi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function kc(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 Ac(e,t,n,r,i){return da(t),n=Lo(e,t,n,r,void 0,i),r=Vo(),e!==null&&!vc?(Ho(e,t,i),Wc(e,t,i)):(Gi&&r&&Bi(t),t.flags|=1,yc(e,t,n,i),t.child)}function jc(e,t,n,r,i,a){return da(t),t.updateQueue=null,n=zo(t,r,n,i),Ro(e),r=Vo(),e!==null&&!vc?(Ho(e,t,a),Wc(e,t,a)):(Gi&&r&&Bi(t),t.flags|=1,yc(e,t,n,a),t.child)}function Mc(e,t,n,r,i){if(da(t),t.stateNode===null){var a=gi,o=n.contextType;typeof o==`object`&&o&&(a=fa(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=ic,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Qa(t),o=n.contextType,a.context=typeof o==`object`&&o?fa(o):gi,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(rc(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&&ic.enqueueReplaceState(a,a.state,null),oo(t,r,a,i),ao(),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=sc(n,s);a.props=c;var l=a.context,u=n.contextType;o=gi,typeof u==`object`&&u&&(o=fa(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)&&oc(t,a,r,o),Za=!1;var f=t.memoizedState;a.state=f,oo(t,r,a,i),ao(),l=t.memoizedState,s||f!==l||Za?(typeof d==`function`&&(rc(t,n,d,r),l=t.memoizedState),(c=Za||ac(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,$a(e,t),o=t.memoizedProps,u=sc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=gi,typeof l==`object`&&l&&(c=fa(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)&&oc(t,a,r,c),Za=!1,f=t.memoizedState,a.state=f,oo(t,r,a,i),ao();var p=t.memoizedState;o!==d||f!==p||Za||e!==null&&e.dependencies!==null&&ua(e.dependencies)?(typeof s==`function`&&(rc(t,n,s,r),p=t.memoizedState),(u=Za||ac(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&ua(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,kc(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=Ya(t,e.child,null,i),t.child=Ya(t,null,n,i)):yc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Wc(e,t,i),e}function Nc(e,t,n,r){return $i(),t.flags|=256,yc(e,t,n,r),t.child}var Pc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Fc(e){return{baseLanes:e,cachePool:Ma()}}function Ic(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=fu),e}function Lc(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:(So.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Gi){if(a?_o(t):bo(t),(e=Wi)?(e=Cf(e,qi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Fi===null?null:{id:Ii,overflow:Li},retryLane:536870912,hydrationErrors:null},n=Ti(e),n.return=t,t.child=n,Ui=t,Wi=null)):e=null,e===null)throw Yi(t);return Tf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(bo(t),a=t.mode,c=zc({mode:`hidden`,children:c},a),r=Ci(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=Fc(n),r.childLanes=Ic(e,s,n),t.memoizedState=Pc,wc(null,r)):(_o(t),Rc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(_o(t),t.flags&=-257,t=Bc(e,t,n)):t.memoizedState===null?(bo(t),c=r.fallback,a=t.mode,r=zc({mode:`visible`,children:r.children},a),c=Ci(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Ya(t,e.child,null,n),r=t.child,r.memoizedState=Fc(n),r.childLanes=Ic(e,s,n),t.memoizedState=Pc,t=wc(null,r)):(bo(t),t.child=e.child,t.flags|=128,t=null);else if(_o(t),Tf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,ta({value:r,source:null,stack:null}),t=Bc(e,t,n)}else if(vc||la(e,t,n,!1),s=(n&e.childLanes)!==0,vc||s){if(s=M,s!==null&&(r=dt(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,pi(e,r),Nu(s,e,r),_c;wf(c)||Gu(),t=Bc(e,t,n)}else wf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Wi=Df(c.nextSibling),Ui=t,Gi=!0,Ki=null,qi=!1,e!==null&&Hi(t,e),t=Rc(t,r.children),t.flags|=4096);return t}return a?(bo(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=bi(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=Ci(c,a,n,null),c.flags|=2):c=bi(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,wc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=Fc(n):(a=c.cachePool,a===null?a=Ma():(l=va._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=Ic(e,s,n),t.memoizedState=Pc,wc(e.child,r)):(_o(t),n=e.child,e=n.sibling,n=bi(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 Rc(e,t){return t=zc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function zc(e,t){return e=vi(22,e,null,t),e.lanes=0,e}function Bc(e,t,n){return Ya(t,e.child,null,n),e=Rc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Vc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),sa(e.return,t,n)}function Hc(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 Uc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=So.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,ge(So,o),yc(e,t,r,n),r=Gi?Mi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Vc(e,n,t);else if(e.tag===19)Vc(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&&Co(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Hc(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&&Co(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Hc(t,!0,n,null,a,r);break;case`together`:Hc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Wc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),lu|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(la(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=bi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=bi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Gc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&ua(e))):!0}function Kc(e,t,n){switch(t.tag){case 3:xe(t,t.stateNode.containerInfo),aa(t,va,e.memoizedState.cache),$i();break;case 27:case 5:Ce(t);break;case 4:xe(t,t.stateNode.containerInfo);break;case 10:aa(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,vo(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(_o(t),e=Wc(e,t,n),e===null?null:e.sibling):Lc(e,t,n):(_o(t),t.flags|=128,null);_o(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(la(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Uc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ge(So,So.current),r)break;return null;case 22:return t.lanes=0,Cc(e,t,n,t.pendingProps);case 24:aa(t,va,e.memoizedState.cache)}return Wc(e,t,n)}function qc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)vc=!0;else{if(!Gc(e,n)&&!(t.flags&128))return vc=!1,Kc(e,t,n);vc=!!(e.flags&131072)}else vc=!1,Gi&&t.flags&1048576&&zi(t,Mi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=za(t.elementType),t.type=e,typeof e==`function`)yi(e)?(r=sc(e,r),t.tag=1,t=Mc(null,t,e,r,n)):(t.tag=0,t=Ac(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===S){t.tag=11,t=bc(null,t,e,r,n);break a}else if(a===C){t.tag=14,t=xc(null,t,e,r,n);break a}}throw t=le(e)||e,Error(i(306,t,``))}}return t;case 0:return Ac(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=sc(r,t.pendingProps),Mc(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,$a(e,t),oo(t,r,null,n);var s=t.memoizedState;if(r=s.cache,aa(t,va,r),r!==o.cache&&ca(t,[va],n,!0),ao(),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=Nc(e,t,r,n);break a}else if(r!==a){a=Oi(Error(i(424)),t),ta(a),t=Nc(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(Wi=Df(e.firstChild),Ui=t,Gi=!0,Ki=null,qi=!0,n=Xa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if($i(),r===a){t=Wc(e,t,n);break a}yc(e,t,r,n)}t=t.child}return t;case 26:return kc(e,t),e===null?(n=Jf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Gi||(n=t.type,e=t.pendingProps,r=sf(ye.current).createElement(n),r[_t]=t,r[vt]=e,ef(r,n,e),At(r),t.stateNode=r):t.memoizedState=Jf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Ce(t),e===null&&Gi&&(r=t.stateNode=jf(t.type,t.pendingProps,ye.current),Ui=t,qi=!0,a=Wi,_f(t.type)?(Of=a,Wi=Df(r.firstChild)):Wi=a),yc(e,t,t.pendingProps.children,n),kc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Gi&&((a=r=Wi)&&(r=xf(r,t.type,t.pendingProps,qi),r===null?a=!1:(t.stateNode=r,Ui=t,Wi=Df(r.firstChild),qi=!1,a=!0)),a||Yi(t)),Ce(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,uf(a,o)?r=null:s!==null&&uf(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=Lo(e,t,Bo,null,null,n),_p._currentValue=a),kc(e,t),yc(e,t,r,n),t.child;case 6:return e===null&&Gi&&((e=n=Wi)&&(n=Sf(n,t.pendingProps,qi),n===null?e=!1:(t.stateNode=n,Ui=t,Wi=null,e=!0)),e||Yi(t)),null;case 13:return Lc(e,t,n);case 4:return xe(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ya(t,null,r,n):yc(e,t,r,n),t.child;case 11:return bc(e,t,t.type,t.pendingProps,n);case 7:return yc(e,t,t.pendingProps,n),t.child;case 8:return yc(e,t,t.pendingProps.children,n),t.child;case 12:return yc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,aa(t,t.type,r.value),yc(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,da(t),a=fa(a),r=r(a),t.flags|=1,yc(e,t,r,n),t.child;case 14:return xc(e,t,t.type,t.pendingProps,n);case 15:return Sc(e,t,t.type,t.pendingProps,n);case 19:return Uc(e,t,n);case 31:return Oc(e,t,n);case 22:return Cc(e,t,n,t.pendingProps);case 24:return da(t),r=fa(va),e===null?(a=Aa(),a===null&&(a=M,o=ya(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Qa(t),aa(t,va,a)):((e.lanes&n)!==0&&($a(e,t),oo(t,null,null,n),ao()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,aa(t,va,r),r!==a.cache&&ca(t,[va],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),aa(t,va,r))),yc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Jc(e){e.flags|=4}function Yc(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(Hu())e.flags|=8192;else throw Ba=Ia,Pa}else e.flags&=-16777217}function Xc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!lp(t))if(Hu())e.flags|=8192;else throw Ba=Ia,Pa}function Zc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:at(),e.lanes|=t,pu|=t)}function Qc(e,t){if(!Gi)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 $c(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 el(e,t,n){var r=t.pendingProps;switch(Vi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return $c(t),null;case 1:return $c(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),oa(va),Se(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Qi(t)?Jc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ea())),$c(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Jc(t),o===null?($c(t),Yc(t,a,null,r,n)):($c(t),Xc(t,o))):o?o===e.memoizedState?($c(t),t.flags&=-16777217):(Jc(t),$c(t),Xc(t,o)):(e=e.memoizedProps,e!==r&&Jc(t),$c(t),Yc(t,a,e,r,n)),null;case 27:if(we(t),n=ye.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Jc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return $c(t),null}e=_e.current,Qi(t)?Xi(t,e):(e=jf(a,r,n),t.stateNode=e,Jc(t))}return $c(t),null;case 5:if(we(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Jc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return $c(t),null}if(o=_e.current,Qi(t))Xi(t,o);else{var s=sf(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(ef(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&&Jc(t)}}return $c(t),Yc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Jc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ye.current,Qi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Ui,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[_t]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Zd(e.nodeValue,n)),e||Yi(t,!0)}else e=sf(e).createTextNode(r),e[_t]=t,t.stateNode=e}return $c(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Qi(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 $i(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;$c(t),e=!1}else n=ea(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(xo(t),t):(xo(t),null);if(t.flags&128)throw Error(i(558))}return $c(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Qi(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 $i(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;$c(t),a=!1}else a=ea(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(xo(t),t):(xo(t),null)}return xo(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),Zc(t,t.updateQueue),$c(t),null);case 4:return Se(),e===null&&Vd(t.stateNode.containerInfo),$c(t),null;case 10:return oa(t.type),$c(t),null;case 19:if(he(So),r=t.memoizedState,r===null)return $c(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Qc(r,!1);else{if(cu!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Co(e),o!==null){for(t.flags|=128,Qc(r,!1),e=o.updateQueue,t.updateQueue=e,Zc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)xi(n,e),n=n.sibling;return ge(So,So.current&1|2),Gi&&Ri(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Le()>yu&&(t.flags|=128,a=!0,Qc(r,!1),t.lanes=4194304)}else{if(!a)if(e=Co(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Zc(t,e),Qc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Gi)return $c(t),null}else 2*Le()-r.renderingStartTime>yu&&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?($c(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Le(),e.sibling=null,n=So.current,ge(So,a?n&1|2:n&1),Gi&&Ri(t,r.treeForkCount),e);case 22:case 23:return xo(t),mo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&($c(t),t.subtreeFlags&6&&(t.flags|=8192)):$c(t),n=t.updateQueue,n!==null&&Zc(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(ka),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),oa(va),$c(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function tl(e,t){switch(Vi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return oa(va),Se(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return we(t),null;case 31:if(t.memoizedState!==null){if(xo(t),t.alternate===null)throw Error(i(340));$i()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(xo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));$i()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return he(So),null;case 4:return Se(),null;case 10:return oa(t.type),null;case 22:case 23:return xo(t),mo(),e!==null&&he(ka),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return oa(va),null;case 25:return null;default:return null}}function nl(e,t){switch(Vi(t),t.tag){case 3:oa(va),Se();break;case 26:case 27:case 5:we(t);break;case 4:Se();break;case 31:t.memoizedState!==null&&xo(t);break;case 13:xo(t);break;case 19:he(So);break;case 10:oa(t.type);break;case 22:case 23:xo(t),mo(),e!==null&&he(ka);break;case 24:oa(va)}}function rl(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){ld(t,t.return,e)}}function il(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){ld(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){ld(t,t.return,e)}}function al(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{co(t,n)}catch(t){ld(e,e.return,t)}}}function ol(e,t,n){n.props=sc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){ld(e,t,n)}}function sl(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){ld(e,t,n)}}function cl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){ld(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){ld(e,t,n)}else n.current=null}function ll(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){ld(e,e.return,t)}}function ul(e,t,n){try{var r=e.stateNode;tf(r,e.type,n,t),r[vt]=t}catch(t){ld(e,e.return,t)}}function dl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&_f(e.type)||e.tag===4}function fl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||dl(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&&_f(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 pl(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=un));else if(r!==4&&(r===27&&_f(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(pl(e,t,n),e=e.sibling;e!==null;)pl(e,t,n),e=e.sibling}function ml(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&&_f(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(ml(e,t,n),e=e.sibling;e!==null;)ml(e,t,n),e=e.sibling}function hl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);ef(t,r,n),t[_t]=e,t[vt]=n}catch(t){ld(e,e.return,t)}}var gl=!1,_l=!1,vl=!1,yl=typeof WeakSet==`function`?WeakSet:Set,bl=null;function xl(e,t){if(e=e.containerInfo,af=Ep,e=Lr(e),Rr(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(of={focusedElem:e,selectionRange:n},Ep=!1,bl=t;bl!==null;)if(t=bl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,bl=e;else for(;bl!==null;){switch(t=bl,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=sc(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){ld(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)bf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:bf(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,bl=e;break}bl=t.return}}function Sl(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Ll(e,n),r&4&&rl(5,n);break;case 1:if(Ll(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){ld(n,n.return,e)}else{var i=sc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){ld(n,n.return,e)}}r&64&&al(n),r&512&&sl(n,n.return);break;case 3:if(Ll(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{co(e,t)}catch(e){ld(n,n.return,e)}}break;case 27:t===null&&r&4&&hl(n);case 26:case 5:Ll(e,n),t===null&&r&4&&ll(n),r&512&&sl(n,n.return);break;case 12:Ll(e,n);break;case 31:Ll(e,n),r&4&&Ol(e,n);break;case 13:Ll(e,n),r&4&&kl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=pd.bind(null,n),Ef(e,n))));break;case 22:if(r=n.memoizedState!==null||gl,!r){t=t!==null&&t.memoizedState!==null||_l,i=gl;var a=_l;gl=r,(_l=t)&&!a?zl(e,n,(n.subtreeFlags&8772)!=0):Ll(e,n),gl=i,_l=a}break;case 30:break;default:Ll(e,n)}}function Cl(e){var t=e.alternate;t!==null&&(e.alternate=null,Cl(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 wl=null,Tl=!1;function El(e,t,n){for(n=n.child;n!==null;)Dl(e,t,n),n=n.sibling}function Dl(e,t,n){if(Ke&&typeof Ke.onCommitFiberUnmount==`function`)try{Ke.onCommitFiberUnmount(Ge,n)}catch{}switch(n.tag){case 26:_l||cl(n,t),El(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:_l||cl(n,t);var r=wl,i=Tl;_f(n.type)&&(wl=n.stateNode,Tl=!1),El(e,t,n),Mf(n.stateNode),wl=r,Tl=i;break;case 5:_l||cl(n,t);case 6:if(r=wl,i=Tl,wl=null,El(e,t,n),wl=r,Tl=i,wl!==null)if(Tl)try{(wl.nodeType===9?wl.body:wl.nodeName===`HTML`?wl.ownerDocument.body:wl).removeChild(n.stateNode)}catch(e){ld(n,t,e)}else try{wl.removeChild(n.stateNode)}catch(e){ld(n,t,e)}break;case 18:wl!==null&&(Tl?(e=wl,vf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Qp(e)):vf(wl,n.stateNode));break;case 4:r=wl,i=Tl,wl=n.stateNode.containerInfo,Tl=!0,El(e,t,n),wl=r,Tl=i;break;case 0:case 11:case 14:case 15:il(2,n,t),_l||il(4,n,t),El(e,t,n);break;case 1:_l||(cl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&ol(n,t,r)),El(e,t,n);break;case 21:El(e,t,n);break;case 22:_l=(r=_l)||n.memoizedState!==null,El(e,t,n),_l=r;break;default:El(e,t,n)}}function Ol(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Qp(e)}catch(e){ld(t,t.return,e)}}}function kl(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){ld(t,t.return,e)}}function Al(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new yl),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new yl),t;default:throw Error(i(435,e.tag))}}function jl(e,t){var n=Al(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=md.bind(null,e,t);t.then(r,r)}})}function Ml(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(_f(c.type)){wl=c.stateNode,Tl=!1;break a}break;case 5:wl=c.stateNode,Tl=!1;break a;case 3:case 4:wl=c.stateNode.containerInfo,Tl=!0;break a}c=c.return}if(wl===null)throw Error(i(160));Dl(o,s,a),wl=null,Tl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Pl(t,e),t=t.sibling}var Nl=null;function Pl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ml(t,e),Fl(e),r&4&&(il(3,e,e.return),rl(3,e),il(5,e,e.return));break;case 1:Ml(t,e),Fl(e),r&512&&(_l||n===null||cl(n,n.return)),r&64&&gl&&(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=Nl;if(Ml(t,e),Fl(e),r&512&&(_l||n===null||cl(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`))),ef(o,r,n),o[_t]=e,At(o),r=o;break a;case`link`:var s=op(`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),ef(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=op(`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),ef(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 sp(a,e.type,e.stateNode);else e.stateNode=tp(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&ul(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?sp(a,e.type,e.stateNode):tp(a,r,e.memoizedProps))}break;case 27:Ml(t,e),Fl(e),r&512&&(_l||n===null||cl(n,n.return)),n!==null&&r&4&&ul(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Ml(t,e),Fl(e),r&512&&(_l||n===null||cl(n,n.return)),e.flags&32){a=e.stateNode;try{nn(a,``)}catch(t){ld(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,ul(e,a,n===null?a:n.memoizedProps)),r&1024&&(vl=!0);break;case 6:if(Ml(t,e),Fl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){ld(e,e.return,t)}}break;case 3:if(ap=null,a=Nl,Nl=Ff(t.containerInfo),Ml(t,e),Nl=a,Fl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Qp(t.containerInfo)}catch(t){ld(e,e.return,t)}vl&&(vl=!1,Il(e));break;case 4:r=Nl,Nl=Ff(e.stateNode.containerInfo),Ml(t,e),Fl(e),Nl=r;break;case 12:Ml(t,e),Fl(e);break;case 31:Ml(t,e),Fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,jl(e,r)));break;case 13:Ml(t,e),Fl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(_u=Le()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,jl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=gl,d=_l;if(gl=u||a,_l=d||l,Ml(t,e),_l=d,gl=u,Fl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||gl||_l||Rl(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){ld(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){ld(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?yf(m,!0):yf(l.stateNode,!1)}catch(e){ld(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,jl(e,n))));break;case 19:Ml(t,e),Fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,jl(e,r)));break;case 30:break;case 21:break;default:Ml(t,e),Fl(e)}}function Fl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(dl(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;ml(e,fl(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(nn(o,``),n.flags&=-33),ml(e,fl(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;pl(e,fl(e),s);break;default:throw Error(i(161))}}catch(t){ld(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Il(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Il(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Ll(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Sl(e,t.alternate,t),t=t.sibling}function Rl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:il(4,t,t.return),Rl(t);break;case 1:cl(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&ol(t,t.return,n),Rl(t);break;case 27:Mf(t.stateNode);case 26:case 5:cl(t,t.return),Rl(t);break;case 22:t.memoizedState===null&&Rl(t);break;case 30:Rl(t);break;default:Rl(t)}e=e.sibling}}function zl(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:zl(i,a,n),rl(4,a);break;case 1:if(zl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){ld(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++)so(c[i],s)}catch(e){ld(r,r.return,e)}}n&&o&64&&al(a),sl(a,a.return);break;case 27:hl(a);case 26:case 5:zl(i,a,n),n&&r===null&&o&4&&ll(a),sl(a,a.return);break;case 12:zl(i,a,n);break;case 31:zl(i,a,n),n&&o&4&&Ol(i,a);break;case 13:zl(i,a,n),n&&o&4&&kl(i,a);break;case 22:a.memoizedState===null&&zl(i,a,n),sl(a,a.return);break;case 30:break;default:zl(i,a,n)}t=t.sibling}}function Bl(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&&ba(n))}function Vl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ba(e))}function Hl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Ul(e,t,n,r),t=t.sibling}function Ul(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Hl(e,t,n,r),i&2048&&rl(9,t);break;case 1:Hl(e,t,n,r);break;case 3:Hl(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&&ba(e)));break;case 12:if(i&2048){Hl(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){ld(t,t.return,e)}}else Hl(e,t,n,r);break;case 31:Hl(e,t,n,r);break;case 13:Hl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Hl(e,t,n,r):(a._visibility|=2,Wl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?Hl(e,t,n,r):Gl(e,t),i&2048&&Bl(o,t);break;case 24:Hl(e,t,n,r),i&2048&&Vl(t.alternate,t);break;default:Hl(e,t,n,r)}}function Wl(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:Wl(a,o,s,c,i),rl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Wl(a,o,s,c,i)):u._visibility&2?Wl(a,o,s,c,i):Gl(a,o),i&&l&2048&&Bl(o.alternate,o);break;case 24:Wl(a,o,s,c,i),i&&l&2048&&Vl(o.alternate,o);break;default:Wl(a,o,s,c,i)}t=t.sibling}}function Gl(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:Gl(n,r),i&2048&&Bl(r.alternate,r);break;case 24:Gl(n,r),i&2048&&Vl(r.alternate,r);break;default:Gl(n,r)}t=t.sibling}}var Kl=8192;function k(e,t,n){if(e.subtreeFlags&Kl)for(e=e.child;e!==null;)ql(e,t,n),e=e.sibling}function ql(e,t,n){switch(e.tag){case 26:k(e,t,n),e.flags&Kl&&e.memoizedState!==null&&up(n,Nl,e.memoizedState,e.memoizedProps);break;case 5:k(e,t,n);break;case 3:case 4:var r=Nl;Nl=Ff(e.stateNode.containerInfo),k(e,t,n),Nl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Kl,Kl=16777216,k(e,t,n),Kl=r):k(e,t,n));break;default:k(e,t,n)}}function A(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 Jl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];bl=r,Zl(r,e)}A(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Yl(e),e=e.sibling}function Yl(e){switch(e.tag){case 0:case 11:case 15:Jl(e),e.flags&2048&&il(9,e,e.return);break;case 3:Jl(e);break;case 12:Jl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Xl(e)):Jl(e);break;default:Jl(e)}}function Xl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];bl=r,Zl(r,e)}A(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:il(8,t,t.return),Xl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Xl(t));break;default:Xl(t)}e=e.sibling}}function Zl(e,t){for(;bl!==null;){var n=bl;switch(n.tag){case 0:case 11:case 15:il(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:ba(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,bl=r;else a:for(n=e;bl!==null;){r=bl;var i=r.sibling,a=r.return;if(Cl(r),r===n){bl=null;break a}if(i!==null){i.return=a,bl=i;break a}bl=a}}}var Ql={getCacheForType:function(e){var t=fa(va),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return fa(va).controller.signal}},j=typeof WeakMap==`function`?WeakMap:Map,$l=0,M=null,eu=null,tu=0,nu=0,ru=null,iu=!1,au=!1,ou=!1,su=0,cu=0,lu=0,uu=0,du=0,fu=0,pu=0,mu=null,hu=null,gu=!1,_u=0,vu=0,yu=1/0,bu=null,xu=null,Su=0,Cu=null,wu=null,Tu=0,Eu=0,Du=null,Ou=null,ku=0,Au=null;function ju(){return $l&2&&tu!==0?tu&-tu:T.T===null?mt():kd()}function Mu(){if(fu===0)if(!(tu&536870912)||Gi){var e=$e;$e<<=1,!($e&3932160)&&($e=262144),fu=e}else fu=536870912;return e=ho.current,e!==null&&(e.flags|=32),fu}function Nu(e,t,n){(e===M&&(nu===2||nu===9)||e.cancelPendingCommit!==null)&&(Bu(e,0),Lu(e,tu,fu,!1)),st(e,n),(!($l&2)||e!==M)&&(e===M&&(!($l&2)&&(uu|=n),cu===4&&Lu(e,tu,fu,!1)),Sd(e))}function Pu(e,t,n){if($l&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||rt(e,t),a=r?Ju(e,t):Ku(e,t,!0),o=r;do{if(a===0){au&&!r&&Lu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!Iu(n)){a=Ku(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=mu;var l=c.current.memoizedState.isDehydrated;if(l&&(Bu(c,s).flags|=256),s=Ku(c,s,!1),s!==2){if(ou&&!l){c.errorRecoveryDisabledLanes|=o,uu|=o,a=4;break a}o=hu,hu=a,o!==null&&(hu===null?hu=o:hu.push.apply(hu,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Bu(e,0),Lu(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:Lu(r,t,fu,!iu);break a;case 2:hu=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=_u+300-Le(),10<a)){if(Lu(r,t,fu,!iu),nt(r,0,!0)!==0)break a;Tu=t,r.timeoutHandle=pf(Fu.bind(null,r,n,hu,bu,gu,t,fu,uu,pu,iu,o,`Throttled`,-0,0),a);break a}Fu(r,n,hu,bu,gu,t,fu,uu,pu,iu,o,null,-0,0)}}break}while(1);Sd(e)}function Fu(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:un},ql(t,a,d);var m=(a&62914560)===a?_u-Le():(a&4194048)===a?vu-Le():0;if(m=fp(d,m),m!==null){Tu=a,e.cancelPendingCommit=m(td.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Lu(e,a,o,!l);return}}td(e,t,a,n,r,i,o,s,c)}function Iu(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(!Mr(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 Lu(e,t,n,r){t&=~du,t&=~uu,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 Ru(){return $l&6?!0:(N(0,!1),!1)}function zu(){if(eu!==null){if(nu===0)var e=eu.return;else e=eu,ia=ra=null,Uo(e),Ua=null,Wa=0,e=eu;for(;e!==null;)nl(e.alternate,e),e=e.return;eu=null}}function Bu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,mf(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Tu=0,zu(),M=e,eu=n=bi(e.current,null),tu=t,nu=0,ru=null,iu=!1,au=rt(e,t),ou=!1,pu=fu=du=uu=lu=cu=0,hu=mu=null,gu=!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 su=t,ui(),n}function Vu(e,t){To=null,T.H=$s,t===Na||t===Fa?(t=Va(),nu=3):t===Pa?(t=Va(),nu=4):nu=t===_c?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,ru=t,eu===null&&(cu=1,dc(e,Oi(t,e.current)))}function Hu(){var e=ho.current;return e===null?!0:(tu&4194048)===tu?go===null:(tu&62914560)===tu||tu&536870912?e===go:!1}function Uu(){var e=T.H;return T.H=$s,e===null?$s:e}function Wu(){var e=T.A;return T.A=Ql,e}function Gu(){cu=4,iu||(tu&4194048)!==tu&&ho.current!==null||(au=!0),!(lu&134217727)&&!(uu&134217727)||M===null||Lu(M,tu,fu,!1)}function Ku(e,t,n){var r=$l;$l|=2;var i=Uu(),a=Wu();(M!==e||tu!==t)&&(bu=null,Bu(e,t)),t=!1;var o=cu;a:do try{if(nu!==0&&eu!==null){var s=eu,c=ru;switch(nu){case 8:zu(),o=6;break a;case 3:case 2:case 9:case 6:ho.current===null&&(t=!0);var l=nu;if(nu=0,ru=null,Qu(e,s,c,l),n&&au){o=0;break a}break;default:l=nu,nu=0,ru=null,Qu(e,s,c,l)}}qu(),o=cu;break}catch(t){Vu(e,t)}while(1);return t&&e.shellSuspendCounter++,ia=ra=null,$l=r,T.H=i,T.A=a,eu===null&&(M=null,tu=0,ui()),o}function qu(){for(;eu!==null;)Xu(eu)}function Ju(e,t){var n=$l;$l|=2;var r=Uu(),a=Wu();M!==e||tu!==t?(bu=null,yu=Le()+500,Bu(e,t)):au=rt(e,t);a:do try{if(nu!==0&&eu!==null){t=eu;var o=ru;b:switch(nu){case 1:nu=0,ru=null,Qu(e,t,o,1);break;case 2:case 9:if(La(o)){nu=0,ru=null,Zu(t);break}t=function(){nu!==2&&nu!==9||M!==e||(nu=7),Sd(e)},o.then(t,t);break a;case 3:nu=7;break a;case 4:nu=5;break a;case 7:La(o)?(nu=0,ru=null,Zu(t)):(nu=0,ru=null,Qu(e,t,o,7));break;case 5:var s=null;switch(eu.tag){case 26:s=eu.memoizedState;case 5:case 27:var c=eu;if(s?lp(s):c.stateNode.complete){nu=0,ru=null;var l=c.sibling;if(l!==null)eu=l;else{var u=c.return;u===null?eu=null:(eu=u,$u(u))}break b}}nu=0,ru=null,Qu(e,t,o,5);break;case 6:nu=0,ru=null,Qu(e,t,o,6);break;case 8:zu(),cu=6;break a;default:throw Error(i(462))}}Yu();break}catch(t){Vu(e,t)}while(1);return ia=ra=null,T.H=r,T.A=a,$l=n,eu===null?(M=null,tu=0,ui(),cu):0}function Yu(){for(;eu!==null&&!Fe();)Xu(eu)}function Xu(e){var t=qc(e.alternate,e,su);e.memoizedProps=e.pendingProps,t===null?$u(e):eu=t}function Zu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=jc(n,t,t.pendingProps,t.type,void 0,tu);break;case 11:t=jc(n,t,t.pendingProps,t.type.render,t.ref,tu);break;case 5:Uo(t);default:nl(n,t),t=eu=xi(t,su),t=qc(n,t,su)}e.memoizedProps=e.pendingProps,t===null?$u(e):eu=t}function Qu(e,t,n,r){ia=ra=null,Uo(t),Ua=null,Wa=0;var i=t.return;try{if(gc(e,i,t,n,tu)){cu=1,dc(e,Oi(n,e.current)),eu=null;return}}catch(t){if(i!==null)throw eu=i,t;cu=1,dc(e,Oi(n,e.current)),eu=null;return}t.flags&32768?(Gi||r===1?e=!0:au||tu&536870912?e=!1:(iu=e=!0,(r===2||r===9||r===3||r===6)&&(r=ho.current,r!==null&&r.tag===13&&(r.flags|=16384))),ed(t,e)):$u(t)}function $u(e){var t=e;do{if(t.flags&32768){ed(t,iu);return}e=t.return;var n=el(t.alternate,t,su);if(n!==null){eu=n;return}if(t=t.sibling,t!==null){eu=t;return}eu=t=e}while(t!==null);cu===0&&(cu=5)}function ed(e,t){do{var n=tl(e.alternate,e);if(n!==null){n.flags&=32767,eu=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){eu=e;return}eu=e=n}while(e!==null);cu=6,eu=null}function td(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do od();while(Su!==0);if($l&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=li,ct(e,n,o,s,c,l),e===M&&(eu=M=null,tu=0),wu=t,Cu=e,Tu=n,Eu=o,Du=a,Ou=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,hd(Ve,function(){return sd(),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=$l,$l|=4;try{xl(e,t,n)}finally{$l=s,E.p=a,T.T=r}}Su=1,nd(),rd(),id()}}function nd(){if(Su===1){Su=0;var e=Cu,t=wu,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=$l;$l|=4;try{Pl(t,e);var a=of,o=Lr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&Ir(s.ownerDocument.documentElement,s)){if(c!==null&&Rr(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 _=Fr(s,h),v=Fr(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}}Ep=!!af,of=af=null}finally{$l=i,E.p=r,T.T=n}}e.current=t,Su=2}}function rd(){if(Su===2){Su=0;var e=Cu,t=wu,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=$l;$l|=4;try{Sl(e,t.alternate,t)}finally{$l=i,E.p=r,T.T=n}}Su=3}}function id(){if(Su===4||Su===3){Su=0,Ie();var e=Cu,t=wu,n=Tu,r=Ou;t.subtreeFlags&10256||t.flags&10256?Su=5:(Su=0,wu=Cu=null,ad(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(xu=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}}Tu&3&&od(),Sd(e),i=e.pendingLanes,n&261930&&i&42?e===Au?ku++:(ku=0,Au=e):ku=0,N(0,!1)}}function ad(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,ba(t)))}function od(){return nd(),rd(),id(),sd()}function sd(){if(Su!==5)return!1;var e=Cu,t=Eu;Eu=0;var n=pt(Tu),r=T.T,a=E.p;try{E.p=32>n?32:n,T.T=null,n=Du,Du=null;var o=Cu,s=Tu;if(Su=0,wu=Cu=null,Tu=0,$l&6)throw Error(i(331));var c=$l;if($l|=4,Yl(o.current),Ul(o,o.current,s,n),$l=c,N(0,!1),Ke&&typeof Ke.onPostCommitFiberRoot==`function`)try{Ke.onPostCommitFiberRoot(Ge,o)}catch{}return!0}finally{E.p=a,T.T=r,ad(e,t)}}function cd(e,t,n){t=Oi(n,t),t=pc(e.stateNode,t,2),e=to(e,t,2),e!==null&&(st(e,2),Sd(e))}function ld(e,t,n){if(e.tag===3)cd(e,e,n);else for(;t!==null;){if(t.tag===3){cd(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(xu===null||!xu.has(r))){e=Oi(n,e),n=mc(2),r=to(t,n,2),r!==null&&(hc(n,r,t,e),st(r,2),Sd(r));break}}t=t.return}}function ud(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new j;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)||(ou=!0,i.add(n),e=dd.bind(null,e,t,n),t.then(e,e))}function dd(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,M===e&&(tu&n)===n&&(cu===4||cu===3&&(tu&62914560)===tu&&300>Le()-_u?!($l&2)&&Bu(e,0):du|=n,pu===tu&&(pu=0)),Sd(e)}function fd(e,t){t===0&&(t=at()),e=pi(e,t),e!==null&&(st(e,t),Sd(e))}function pd(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),fd(e,n)}function md(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),fd(e,n)}function hd(e,t){return Ne(e,t)}var gd=null,_d=null,vd=!1,yd=!1,bd=!1,xd=0;function Sd(e){e!==_d&&e.next===null&&(_d===null?gd=_d=e:_d=_d.next=e),yd=!0,vd||(vd=!0,Od())}function N(e,t){if(!bd&&yd){bd=!0;do for(var n=!1,r=gd;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,Dd(r,a))}else a=tu,a=nt(r,r===M?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||rt(r,a)||(n=!0,Dd(r,a));r=r.next}while(n);bd=!1}}function Cd(){wd()}function wd(){yd=vd=!1;var e=0;xd!==0&&ff()&&(e=xd);for(var t=Le(),n=null,r=gd;r!==null;){var i=r.next,a=Td(r,t);a===0?(r.next=null,n===null?gd=i:n.next=i,i===null&&(_d=n)):(n=r,(e!==0||a&3)&&(yd=!0)),r=i}Su!==0&&Su!==5||N(e,!1),xd!==0&&(xd=0)}function Td(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=M,n=tu,n=nt(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(nu===2||nu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Pe(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&&Pe(r),pt(n)){case 2:case 8:n=Be;break;case 32:n=Ve;break;case 268435456:n=He;break;default:n=Ve}return r=Ed.bind(null,e),n=Ne(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Pe(r),e.callbackPriority=2,e.callbackNode=null,2}function Ed(e,t){if(Su!==0&&Su!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(od()&&e.callbackNode!==n)return null;var r=tu;return r=nt(e,e===M?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Pu(e,r,t),Td(e,Le()),e.callbackNode!=null&&e.callbackNode===n?Ed.bind(null,e):null)}function Dd(e,t){if(od())return null;Pu(e,t,!0)}function Od(){gf(function(){$l&6?Ne(ze,Cd):wd()})}function kd(){if(xd===0){var e=Ca;e===0&&(e=Qe,Qe<<=1,!(Qe&261888)&&(Qe=256)),xd=e}return xd}function Ad(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:ln(``+e)}function jd(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 Md(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Ad((i[vt]||null).action),o=r.submitter;o&&(t=(t=o[vt]||null)?Ad(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new jn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(xd!==0){var e=o?jd(i,o):new FormData(i);zs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?jd(i,o):new FormData(i),zs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Nd=0;Nd<ii.length;Nd++){var Pd=ii[Nd];ai(Pd.toLowerCase(),`on`+(Pd[0].toUpperCase()+Pd.slice(1)))}ai(Xr,`onAnimationEnd`),ai(Zr,`onAnimationIteration`),ai(Qr,`onAnimationStart`),ai(`dblclick`,`onDoubleClick`),ai(`focusin`,`onFocus`),ai(`focusout`,`onBlur`),ai($r,`onTransitionRun`),ai(ei,`onTransitionStart`),ai(ti,`onTransitionCancel`),ai(ni,`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 Fd=`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(` `),Id=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Fd));function Ld(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){oi(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){oi(e)}i.currentTarget=null,a=c}}}}function Rd(e,t){var n=t[bt];n===void 0&&(n=t[bt]=new Set);var r=e+`__bubble`;n.has(r)||(Hd(t,e,2,!1),n.add(r))}function zd(e,t,n){var r=0;t&&(r|=4),Hd(n,e,r,t)}var Bd=`_reactListening`+Math.random().toString(36).slice(2);function Vd(e){if(!e[Bd]){e[Bd]=!0,jt.forEach(function(t){t!==`selectionchange`&&(Id.has(t)||zd(t,!1,e),zd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Bd]||(t[Bd]=!0,zd(`selectionchange`,!1,t))}}function Hd(e,t,n,r){switch(Np(t)){case 2:var i=Dp;break;case 8:i=Op;break;default:i=kp}n=i.bind(null,t,n,e),i=void 0,!bn||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 Ud(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}_n(function(){var r=a,i=fn(n),s=[];a:{var c=ri.get(e);if(c!==void 0){var l=jn,u=e;switch(e){case`keypress`:if(En(n)===0)break a;case`keydown`:case`keyup`:l=Yn;break;case`focusin`:u=`focus`,l=Bn;break;case`focusout`:u=`blur`,l=Bn;break;case`beforeblur`:case`afterblur`:l=Bn;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=Rn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=zn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Zn;break;case Xr:case Zr:case Qr:l=Vn;break;case ni:l=Qn;break;case`scroll`:case`scrollend`:l=Nn;break;case`wheel`:l=$n;break;case`copy`:case`cut`:case`paste`:l=Hn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Xn;break;case`toggle`:case`beforetoggle`:l=er}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=vn(m,p),g!=null&&d.push(Wd(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!==dn&&(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=Rn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Xn,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=Kd,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&&qd(s,c,l,d,!1),u!==null&&f!==null&&qd(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=br;else if(mr(c))if(xr)v=Ar;else{v=Or;var y=Dr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&O(r.elementType)&&(v=br):v=kr;if(v&&=v(e,r)){hr(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`:(mr(y)||y.contentEditable===`true`)&&(Br=y,Vr=r,Hr=null);break;case`focusout`:Hr=Vr=Br=null;break;case`mousedown`:Ur=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Ur=!1,Wr(s,n,i);break;case`selectionchange`:if(zr)break;case`keydown`:case`keyup`:Wr(s,n,i)}var b;if(nr)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 ur?cr(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(ar&&n.locale!==`ko`&&(ur||x!==`onCompositionStart`?x===`onCompositionEnd`&&ur&&(b=Tn()):(Sn=i,Cn=`value`in Sn?Sn.value:Sn.textContent,ur=!0)),y=Gd(r,x),0<y.length&&(x=new Un(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=lr(n),b!==null&&(x.data=b)))),(b=ir?dr(e,n):fr(e,n))&&(x=Gd(r,`onBeforeInput`),0<x.length&&(y=new Un(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),Md(s,e,r,n,i)}Ld(s,t)})}function Wd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Gd(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=vn(e,n),i!=null&&r.unshift(Wd(e,i,a)),i=vn(e,t),i!=null&&r.push(Wd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Kd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function qd(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=vn(n,a),l!=null&&o.unshift(Wd(n,l,c))):i||(l=vn(n,a),l!=null&&o.push(Wd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Jd=/\r\n?/g,Yd=/\u0000|\uFFFD/g;function Xd(e){return(typeof e==`string`?e:``+e).replace(Jd,`
|
|
10
|
-
`).replace(Yd,``)}function Zd(e,t){return t=Xd(t),Xd(e)===t}function Qd(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=ln(``+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`&&Qd(e,t,`name`,a.name,a,null),Qd(e,t,`formEncType`,a.formEncType,a,null),Qd(e,t,`formMethod`,a.formMethod,a,null),Qd(e,t,`formTarget`,a.formTarget,a,null)):(Qd(e,t,`encType`,a.encType,a,null),Qd(e,t,`method`,a.method,a,null),Qd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=ln(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=un);break;case`onScroll`:r!=null&&Rd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Rd(`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=ln(``+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`:Rd(`beforetoggle`,e),Rd(`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=sn.get(n)||n,zt(e,n,r))}}function $d(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&&Rd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Rd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=un);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 ef(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Rd(`error`,e),Rd(`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:Qd(e,t,o,s,n,null)}}a&&Qd(e,t,`srcSet`,n.srcSet,n,null),r&&Qd(e,t,`src`,n.src,n,null);return;case`input`:Rd(`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:Qd(e,t,r,d,n,null)}}Zt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Rd(`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:Qd(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 Rd(`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:Qd(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:Qd(e,t,l,r,n,null)}return;case`dialog`:Rd(`beforetoggle`,e),Rd(`toggle`,e),Rd(`cancel`,e),Rd(`close`,e);break;case`iframe`:case`object`:Rd(`load`,e);break;case`video`:case`audio`:for(r=0;r<Fd.length;r++)Rd(Fd[r],e);break;case`image`:Rd(`error`,e),Rd(`load`,e);break;case`details`:Rd(`toggle`,e);break;case`embed`:case`source`:case`link`:Rd(`error`,e),Rd(`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:Qd(e,t,u,r,n,null)}return;default:if(O(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&$d(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Qd(e,t,c,r,n,null))}function tf(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)||Qd(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&&Qd(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)||Qd(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&&Qd(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:Qd(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&&Qd(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:Qd(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:Qd(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)&&Qd(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:Qd(e,t,u,p,r,m)}return;default:if(O(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&$d(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||$d(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Qd(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||Qd(e,t,f,p,r,m)}function nf(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function rf(){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&&nf(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&&nf(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 af=null,of=null;function sf(e){return e.nodeType===9?e:e.ownerDocument}function cf(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 lf(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 uf(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 df=null;function ff(){var e=window.event;return e&&e.type===`popstate`?e===df?!1:(df=e,!0):(df=null,!1)}var pf=typeof setTimeout==`function`?setTimeout:void 0,mf=typeof clearTimeout==`function`?clearTimeout:void 0,hf=typeof Promise==`function`?Promise:void 0,gf=typeof queueMicrotask==`function`?queueMicrotask:hf===void 0?pf:function(e){return hf.resolve(null).then(e).catch(P)};function P(e){setTimeout(function(){throw e})}function _f(e){return e===`head`}function vf(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`)Mf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Mf(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`&&Mf(e.ownerDocument.body);n=i}while(n);Qp(t)}function yf(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 bf(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`:bf(n),Tt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function xf(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=Df(e.nextSibling),e===null)break}return null}function Sf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=Df(e.nextSibling),e===null))return null;return e}function Cf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=Df(e.nextSibling),e===null))return null;return e}function wf(e){return e.data===`$?`||e.data===`$~`}function Tf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function Ef(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 Df(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 Of=null;function kf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return Df(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function Af(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 jf(e,t,n){switch(t=sf(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 Mf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Tt(e)}var Nf=new Map,Pf=new Set;function Ff(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var If=E.d;E.d={f:Lf,r:Rf,D:Vf,C:Hf,L:Uf,m:Wf,X:Kf,S:Gf,M:qf};function Lf(){var e=If.f(),t=Ru();return e||t}function Rf(e){var t=Dt(e);t!==null&&t.tag===5&&t.type===`form`?Vs(t):If.r(e)}var zf=typeof document>`u`?null:document;function Bf(e,t,n){var r=zf;if(r&&typeof t==`string`&&t){var i=Yt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Pf.has(i)||(Pf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),ef(t,`link`,e),At(t),r.head.appendChild(t)))}}function Vf(e){If.D(e),Bf(`dns-prefetch`,e,null)}function Hf(e,t){If.C(e,t),Bf(`preconnect`,e,t)}function Uf(e,t,n){If.L(e,t,n);var r=zf;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=Yf(e);break;case`script`:a=$f(e)}Nf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Nf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Xf(a))||t===`script`&&r.querySelector(ep(a))||(t=r.createElement(`link`),ef(t,`link`,e),At(t),r.head.appendChild(t)))}}function Wf(e,t){If.m(e,t);var n=zf;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=$f(e)}if(!Nf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),Nf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(ep(a)))return}r=n.createElement(`link`),ef(r,`link`,e),At(r),n.head.appendChild(r)}}}function Gf(e,t,n){If.S(e,t,n);var r=zf;if(r&&e){var i=kt(r).hoistableStyles,a=Yf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Xf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Nf.get(a))&&rp(e,n);var c=o=r.createElement(`link`);At(c),ef(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,np(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Kf(e,t){If.X(e,t);var n=zf;if(n&&e){var r=kt(n).hoistableScripts,i=$f(e),a=r.get(i);a||(a=n.querySelector(ep(i)),a||(e=m({src:e,async:!0},t),(t=Nf.get(i))&&ip(e,t),a=n.createElement(`script`),At(a),ef(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function qf(e,t){If.M(e,t);var n=zf;if(n&&e){var r=kt(n).hoistableScripts,i=$f(e),a=r.get(i);a||(a=n.querySelector(ep(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=Nf.get(i))&&ip(e,t),a=n.createElement(`script`),At(a),ef(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Jf(e,t,n,r){var a=(a=ye.current)?Ff(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=Yf(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=Yf(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(Xf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),Nf.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},Nf.set(e,n),o||Qf(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=$f(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 Yf(e){return`href="`+Yt(e)+`"`}function Xf(e){return`link[rel="stylesheet"][`+e+`]`}function Zf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Qf(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}),ef(t,`link`,n),At(t),e.head.appendChild(t))}function $f(e){return`[src="`+Yt(e)+`"]`}function ep(e){return`script[async]`+e}function tp(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),ef(r,`style`,a),np(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Yf(n.href);var o=e.querySelector(Xf(a));if(o)return t.state.loading|=4,t.instance=o,At(o),o;r=Zf(n),(a=Nf.get(a))&&rp(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}),ef(o,`link`,r),t.state.loading|=4,np(o,n.precedence,e),t.instance=o;case`script`:return o=$f(n.src),(a=e.querySelector(ep(o)))?(t.instance=a,At(a),a):(r=n,(a=Nf.get(o))&&(r=m({},n),ip(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),At(a),ef(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,np(r,n.precedence,e));return t.instance}function np(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 rp(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function ip(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var ap=null;function op(e,t,n){if(ap===null){var r=new Map,i=ap=new Map;i.set(n,r)}else i=ap,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 sp(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function cp(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 lp(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function up(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=Yf(r.href),a=t.querySelector(Xf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=pp.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,At(a);return}a=t.ownerDocument||t,r=Zf(r),(i=Nf.get(i))&&rp(r,i),a=a.createElement(`link`),At(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),ef(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=pp.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var dp=0;function fp(e,t){return e.stylesheets&&e.count===0&&hp(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&hp(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&dp===0&&(dp=62500*rf());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&hp(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>dp?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function pp(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)hp(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var mp=null;function hp(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,mp=new Map,t.forEach(gp,e),mp=null,pp.call(e))}function gp(e,t){if(!(t.state.loading&4)){var n=mp.get(e);if(n)var r=n.get(null);else{n=new Map,mp.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=pp.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 _p={$$typeof:te,Provider:null,Consumer:null,_currentValue:de,_currentValue2:de,_threadCount:0};function vp(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 yp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new vp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=vi(3,null,null,t),e.current=a,a.stateNode=e,t=ya(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Qa(a),e}function bp(e){return e?(e=gi,e):gi}function xp(e,t,n,r,i,a){i=bp(i),r.context===null?r.context=i:r.pendingContext=i,r=eo(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=to(e,r,t),n!==null&&(Nu(n,e,t),no(n,e,t))}function Sp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Cp(e,t){Sp(e,t),(e=e.alternate)&&Sp(e,t)}function wp(e){if(e.tag===13||e.tag===31){var t=pi(e,67108864);t!==null&&Nu(t,e,67108864),Cp(e,67108864)}}function Tp(e){if(e.tag===13||e.tag===31){var t=ju();t=ft(t);var n=pi(e,t);n!==null&&Nu(n,e,t),Cp(e,t)}}var Ep=!0;function Dp(e,t,n,r){var i=T.T;T.T=null;var a=E.p;try{E.p=2,kp(e,t,n,r)}finally{E.p=a,T.T=i}}function Op(e,t,n,r){var i=T.T;T.T=null;var a=E.p;try{E.p=8,kp(e,t,n,r)}finally{E.p=a,T.T=i}}function kp(e,t,n,r){if(Ep){var i=Ap(r);if(i===null)Ud(e,t,r,jp,n),Hp(e,r);else if(Wp(i,e,t,n,r))r.stopPropagation();else if(Hp(e,r),t&4&&-1<Vp.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}Sd(a),!($l&6)&&(yu=Le()+500,N(0,!1))}}break;case 31:case 13:s=pi(a,2),s!==null&&Nu(s,a,2),Ru(),Cp(a,2)}if(a=Ap(r),a===null&&Ud(e,t,r,jp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Ud(e,t,r,null,n)}}function Ap(e){return e=fn(e),Mp(e)}var jp=null;function Mp(e){if(jp=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 jp=e,null}function Np(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(Re()){case ze:return 2;case Be:return 8;case Ve:case D:return 32;case He:return 268435456;default:return 32}default:return 32}}var Pp=!1,Fp=null,Ip=null,Lp=null,Rp=new Map,zp=new Map,Bp=[],Vp=`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 Hp(e,t){switch(e){case`focusin`:case`focusout`:Fp=null;break;case`dragenter`:case`dragleave`:Ip=null;break;case`mouseover`:case`mouseout`:Lp=null;break;case`pointerover`:case`pointerout`:Rp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:zp.delete(t.pointerId)}}function Up(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&&wp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Wp(e,t,n,r,i){switch(t){case`focusin`:return Fp=Up(Fp,e,t,n,r,i),!0;case`dragenter`:return Ip=Up(Ip,e,t,n,r,i),!0;case`mouseover`:return Lp=Up(Lp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Rp.set(a,Up(Rp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,zp.set(a,Up(zp.get(a)||null,e,t,n,r,i)),!0}return!1}function Gp(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(){Tp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,ht(e.priority,function(){Tp(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 Kp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Ap(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);dn=r,n.target.dispatchEvent(r),dn=null}else return t=Dt(n),t!==null&&wp(t),e.blockedOn=n,!1;t.shift()}return!0}function qp(e,t,n){Kp(e)&&n.delete(t)}function Jp(){Pp=!1,Fp!==null&&Kp(Fp)&&(Fp=null),Ip!==null&&Kp(Ip)&&(Ip=null),Lp!==null&&Kp(Lp)&&(Lp=null),Rp.forEach(qp),zp.forEach(qp)}function Yp(e,n){e.blockedOn===n&&(e.blockedOn=null,Pp||(Pp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Jp)))}var Xp=null;function Zp(e){Xp!==e&&(Xp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Xp===e&&(Xp=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(Mp(r||n)===null)continue;break}var a=Dt(n);a!==null&&(e.splice(t,3),t-=3,zs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Qp(e){function t(t){return Yp(t,e)}Fp!==null&&Yp(Fp,e),Ip!==null&&Yp(Ip,e),Lp!==null&&Yp(Lp,e),Rp.forEach(t),zp.forEach(t);for(var n=0;n<Bp.length;n++){var r=Bp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Bp.length&&(n=Bp[0],n.blockedOn===null);)Gp(n),n.blockedOn===null&&Bp.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||Zp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[vt]||null)s=o.formAction;else if(Mp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Zp(n)}}}function $p(){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 em(e){this._internalRoot=e}tm.prototype.render=em.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;xp(n,ju(),e,t,null,null)},tm.prototype.unmount=em.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;xp(e.current,2,null,e,null,null),Ru(),t[yt]=null}};function tm(e){this._internalRoot=e}tm.prototype.unstable_scheduleHydration=function(e){if(e){var t=mt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Bp.length&&t!==0&&t<Bp[n].priority;n++);Bp.splice(n,0,e),n===0&&Gp(e)}};var nm=n.version;if(nm!==`19.2.4`)throw Error(i(527,nm,`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 rm={bundleType:0,version:`19.2.4`,rendererPackageName:`react-dom`,currentDispatcherRef:T,reconcilerVersion:`19.2.4`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var im=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!im.isDisabled&&im.supportsFiber)try{Ge=im.inject(rm),Ke=im}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=cc,s=lc,c=uc;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=yp(e,1,!1,null,null,n,r,null,o,s,c,$p),e[yt]=t.current,Vd(e),new em(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),ne=l(_(),1);function re(e,t){return typeof t==`function`?t(e):t}var C=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:re(e.attachments,t)})),setPreviewAttachment:t=>e({previewAttachment:t}),setPreviewImageSize:t=>e({previewImageSize:t}),setQueuedDrafts:t=>e(e=>({queuedDrafts:re(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)}))})),w=[`cancel`,`pause`,`resume`,`submit_interaction`,`attach`,`steer`,`inject`,`checkpoint`,`durable_restore`],ie=[`goal`,`loop`,`plan`],ae=new Set([`native`,`emulated`,`unavailable`]),oe=new Set([`supported`,`mode`,`reason`]),se=new Set([`schema_version`,...w,...ie]);function ce(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`${t} must be an object`);return e}function le(e,t){let n=ce(e,t);if(typeof n.supported!=`boolean`)throw Error(`${t}.supported must be a boolean`);if(!ae.has(n.mode))throw Error(`${t}.mode must be native, emulated, or unavailable`);if(n.reason!==void 0&&n.reason!==null&&(typeof n.reason!=`string`||n.reason.length===0))throw Error(`${t}.reason must be a non-empty string or null`);if(!n.supported&&(n.mode!==`unavailable`||!n.reason))throw Error(`${t}: unsupported capability requires mode=unavailable and reason`);return{supported:n.supported,mode:n.mode,reason:n.reason??null,extensions:Object.fromEntries(Object.entries(n).filter(([e])=>!oe.has(e)))}}function ue(e){let t=ce(e,`RuntimeCapabilityMatrix/v1`);if(t.schema_version!==1)throw Error(`schema_version must equal 1`);for(let e of w)if(!(e in t))throw Error(`${e} is required`);let n={schema_version:1,extensions:Object.fromEntries(Object.entries(t).filter(([e])=>!se.has(e)))};for(let e of w)n[e]=le(t[e],e);for(let e of ie)t[e]!==void 0&&t[e]!==null&&(n[e]=le(t[e],e));return n}var T=[`responses`,`chat_completions`],E=new Map([[`openclaw`,`OpenClaw`],[`hermes`,`Hermes`]]);function de(e){return String(e||``).trim().toLowerCase()}function fe(...e){for(let t of e){let e=de(t);if(e)return e}return``}function pe(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function me(e){if(!Array.isArray(e))return T;let t=e.filter(e=>e===`responses`||e===`chat_completions`);return t.length>0?t:T}function he(e,t){return typeof e==`boolean`?e:t}function ge(e){return Array.isArray(e)?e.map(e=>pe(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:he(e.enabled,!0)};return typeof e.description==`string`&&(t.description=e.description),t}):[]}function _e(e){let t=pe(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:he(t.RuntimeOverride,!0)}}function ve(e){if(e!=null)try{return ue(e)}catch{return}}function ye(e){return Array.isArray(e)?e.flatMap(e=>{let t=pe(e),n=String(t.Protocol||``).trim().toLowerCase(),r=String(t.Endpoint||``).trim();if(![`ag-ui`,`responses`].includes(n)||!r.startsWith(`/`))return[];let i=pe(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 be(e){let t=e?.Data||e||{},n=pe(t.Capabilities),r=pe(t.HostedRuntime),i=fe(t.Agent?.Framework,r.Framework,r.Type),a=E.get(i)||``,o=me(t.ApiFormats||n.HostedChat?.ApiFormats),s=i!==`openclaw`,c=!!a,l=!!a,u=pe(n.HostedChat),d=pe(n.NativeDashboard),f=pe(n.NativeTerminal),p=pe(n.RunLifecycle),m=pe(t.HostedChat),h=ye(u.Transports||m.Transports),g=String(u.PreferredTransport||m.PreferredTransport||`responses`).trim().toLowerCase(),_=h.some(e=>e.Protocol===g)?g:`responses`,v=he(u.Enabled,s),y=he(d.Enabled,c),b=he(f.Enabled,l),x=he(p.Enabled,v),ee=!!(n.interaction_v1?.enabled??n.Interaction?.V1??n.InteractionV1??!1),te=ve(n.RuntimeCapabilityMatrix??t.RuntimeCapabilityMatrix);return{...n,RuntimeCapabilityMatrix:te,InteractionV1:ee,HostedChat:{Enabled:v,ApiFormats:me(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:he(p.Resume,x),Abort:he(p.Abort,x),Checkpoints:he(p.Checkpoints,!1),CheckpointResume:he(p.CheckpointResume,!1),CheckpointResumePreview:he(p.CheckpointResumePreview,!1)},ApprovalPolicy:_e(n.ApprovalPolicy),BuiltinTools:ge(n.BuiltinTools)}}function xe(e){return be({Data:{Capabilities:e}}).HostedChat.Enabled}function Se(e,t={}){let n=be({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 Ce=S()(e=>({agentId:`default-agent`,agentName:`Agent`,agentFramework:``,capabilities:be({}),apiFormats:[`responses`,`chat_completions`],accessMode:`Owner`,workspaceFiles:null,status:`loading`,errorMessage:``,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}),setStatus:(t,n=``)=>e({status:t,errorMessage:n})}));function we(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 Te=S()(e=>({availableModels:[],selectedModel:``,modelSource:``,modelCatalogLoaded:!1,thinkingMode:`auto`,upsertModels:t=>e(e=>({availableModels:we(e.availableModels,t)})),setSelectedModel:t=>e({selectedModel:t}),setModelSource:t=>e({modelSource:t}),setModelCatalogLoaded:t=>e({modelCatalogLoaded:t}),setThinkingMode:t=>e({thinkingMode:t})})),Ee=`ksadk.web.permission-mode`;function De(){try{let e=globalThis.localStorage?.getItem(Ee);return e===`ask`||e===`full`||e===`risk`?e:`risk`}catch{return`risk`}}function Oe(e){try{globalThis.localStorage?.setItem(Ee,e)}catch{}}var ke=S()(e=>({permissionMode:De(),setPermissionMode:t=>{Oe(t),e({permissionMode:t})}}));function Ae(e,t){return`${e}${t}`}function je(e){return{...e}}var Me=class{runId=null;status=null;items=new Map;seenEventIds=new Set;apply(e){if(e.eventId){if(this.seenEventIds.has(e.eventId))return;this.seenEventIds.add(e.eventId)}switch(e.type){case`run_started`:this.runId=e.runId,this.status=`running`;return;case`run_interrupted`:this.status=`interrupted`;return;case`run_completed`:this.status=`completed`;return;case`run_failed`:this.status=`failed`;return;case`run_canceled`:this.status=`canceled`;return;case`item_started`:this.startItem(e);return;case`item_updated`:this.updateItem(e);return;case`item_snapshot_replaced`:this.replaceSnapshot(e);return;case`item_completed`:case`item_failed`:this.closeItem(e);return}}applyAll(e){for(let t of e)this.apply(t)}snapshot(){return{runId:this.runId,status:this.status,items:Array.from(this.items.values()).map(e=>({...e,parts:e.parts.map(je)}))}}ensureItem(e){this.runId===null&&(this.runId=e.runId);let t=Ae(e.scopeId,e.itemId),n=this.items.get(t);return n||(n={runId:e.runId,scopeId:e.scopeId,itemId:e.itemId,itemKind:e.itemKind||`message`,status:`open`,parts:[]},this.items.set(t,n)),n}startItem(e){let t=Ae(e.scopeId,e.itemId),n=this.items.get(t);if(n){e.phase!==void 0&&(n.phase=e.phase);return}let r=this.ensureItem(e);r.phase=e.phase,e.initialParts&&(r.parts=e.initialParts.map(je))}updateItem(e){let t=this.ensureItem(e),n=t.parts.findIndex(t=>t.partId===e.partId);if(n<0){t.parts.push(je(e.part));return}let r=t.parts[n];if(e.op===`replace`){t.parts[n]=je(e.part);return}t.parts[n]={...r,text:`${r.text||``}${e.part.text||``}`}}replaceSnapshot(e){let t=this.ensureItem(e);t.parts=e.parts.map(je)}closeItem(e){let t=this.ensureItem(e);e.parts&&(t.parts=e.parts.map(je)),t.status=e.type===`item_completed`?`completed`:`failed`}};function Ne(e,t){return{partId:e,contentType:`text`,text:t}}var Pe=`text-0`;function Fe(e,t){return String(e?.id||e?.item_id||t?.item_id||t?.output_index||``)}function Ie(e){let t=e?.content;return Array.isArray(t)?t.map(e=>typeof e==`string`?e:String(e?.text||``)).join(``):String(e?.output_text||e?.text||``)}function Le(e,t,n,r){let i=String(t?.type||e||``).trim(),a=t?.id?String(t.id):void 0,o=t?.item||t?.output_item||{},s=Fe(o,t),c=String(o?.type||``),l=c.includes(`reasoning`)?`reasoning`:`message`;if(i===`response.output_item.added`)return!s||c!==`message`&&!c.includes(`reasoning`)?[]:[{type:`item_started`,runId:n,scopeId:r,itemId:s,itemKind:l,phase:`final_answer`,eventId:a}];if(i===`response.output_text.delta`||i===`response.content_part.delta`){if(!s)return[];let e=String(t?.delta||t?.text||``);return e?[{type:`item_updated`,runId:n,scopeId:r,itemId:s,itemKind:l,partId:Pe,op:`append`,part:Ne(Pe,e),eventId:a}]:[]}return i===`response.output_item.done`||i===`response.output_text.done`?s?[{type:`item_completed`,runId:n,scopeId:r,itemId:s,itemKind:l,parts:[Ne(Pe,Ie(o)||String(t?.text||``))],eventId:a}]:[]:i===`response.completed`?[{type:`run_completed`,runId:n,scopeId:r,eventId:a}]:[]}var Re=e=>Object.keys(e).length>0,ze={runId:null,status:null,items:[]},Be=new Me,Ve=(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:``,runtimeItems:ze,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=Ve(e.sessionStreaming,r),a=n?{...i,[r]:!0}:i;return{sessionStreaming:a,isStreaming:Re(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:Re(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=Ve(e.sessionStreaming,r);return{isStreaming:Re(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=Ve(e.sessionStreaming,n);return{sessionActivities:i,sessionStreaming:a,isStreaming:Re(a),activity:e.activity===r?null:e.activity}}),applyRuntimeItemOperations:t=>{Be.applyAll(t),e({runtimeItems:Be.snapshot()})},resetRun:()=>{Be=new Me,e({isStreaming:!1,currentRunId:``,stopRequested:!1,activity:null,sessionActivities:{},sessionStreaming:{},lastSeqId:0,activeInvocationId:``,runtimeItems:ze})}}));function He(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 Ue({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:He(i),hasMore:o<a}}function We({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 Ge(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 Ke=`ksadk.pinnedSessionIds`;function qe(){try{let e=globalThis.localStorage?.getItem(Ke),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Je(e){try{globalThis.localStorage?.setItem(Ke,JSON.stringify(e))}catch{}}function Ye(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?Ge(t)-Ge(e):i-r})}function Xe(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 Ye(Array.from(r.values()),n)}var Ze=S()(e=>({sessions:[],currentSessionId:null,sessionsAgentId:``,sessionsTotal:0,sessionsPage:0,sessionsPageSize:30,loadedPages:new Set,hasMoreSessions:!1,isLoadingSessions:!0,pinnedSessionIds:qe(),messageHistory:{},setSessions:t=>e(e=>({sessions:Ye(t,e.pinnedSessionIds)})),setCurrentSessionId:t=>e({currentSessionId:t}),upsertSessions:(t,n)=>e(e=>{let r=Xe(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?He(new Set,[i]):He(e.loadedPages,[i]),c=Ue({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:Ue({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 Je(r),{pinnedSessionIds:r,sessions:Ye(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}})})),Qe=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}))})),$e=.28;function et(e,t=768){return Number(e)<=t}function tt({isMobile:e,desktopSidebarOpen:t,mobileSidebarOpen:n}){return{desktopSidebarVisible:!e&&!!t,mobileDrawerVisible:!!(e&&n)}}function nt({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*$e);return Math.max(120,Math.min(n,i))}var rt=`/_ksadk/workspace/v1/files`,it=new Set([`.md`,`.markdown`,`.mdx`]),at=new Set([`.pdf`]),ot=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.svg`,`.bmp`,`.ico`]),st=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(`,`)),ct=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 lt(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 ut(e){let t=lt(e);return t===`.`?``:t.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function dt(e){let t=ut(e);return t?`${rt}/${t}`:rt}function ft(e){let t=lt(e);if(t===`.`||!t.includes(`/`))return`${rt}/`;let n=ut(t.substring(0,t.lastIndexOf(`/`)));return n?`${rt}/${n}/`:`${rt}/`}function pt(e){return lt(e)===`.`}function mt(e){let t=lt(e);return t===`.`?`/`:`/${t}`}function ht(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n).toLowerCase():``}function gt(e){return String(e||``).split(`;`)[0].trim().toLowerCase()}var _t=new Set([`.html`,`.htm`]);function vt({path:e,mimeType:t}){let n=ht(e),r=gt(t);return r===`text/html`||_t.has(n)?`html`:r===`text/markdown`||it.has(n)?`markdown`:r===`application/pdf`||at.has(n)?`pdf`:r.startsWith(`image/`)||ot.has(n)?`image`:r.startsWith(`text/`)||ct.has(r)||st.has(n)?`text`:`unsupported`}var yt=new Set([`.txt`,`.log`,`.csv`,`.tsv`,`.env`,`.ini`,`.conf`,`.lock`]);function bt({path:e,mimeType:t}){let n=ht(e),r=gt(t);return _t.has(n)||r===`text/html`?`html`:r===`text/markdown`||it.has(n)?`markdown`:r===`application/pdf`||at.has(n)||r.startsWith(`image/`)||ot.has(n)?null:yt.has(n)||r===`text/plain`?`text`:r.startsWith(`text/`)||ct.has(r)||st.has(n)?`code`:null}function xt({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 St(){let e=0;return{next(t){return e+=1,{path:t,version:e}},invalidate(){e+=1},isCurrent(t){return!!t&&t.version===e}}}function Ct({workspaceFiles:e,accessMode:t}){if(!e?.Enabled)return!1;let n=String(t||``).trim().toLowerCase();return n===`owner`||n===`private`}var wt=`ksadk:webui:selected-session:`;function Tt(e){return String(e||``).trim()||`default-agent`}function Et(e){if(e&&typeof e.getItem==`function`)return e;try{if(typeof window<`u`&&window.localStorage)return window.localStorage}catch{}return null}function Dt(e){return`${wt}${Tt(e)}`}function Ot(e,t){let n=Et(t);if(!n)return null;try{return String(n.getItem(Dt(e))||``).trim()||null}catch{return null}}function kt(e,t,n){let r=Et(n);if(!r)return;let i=Dt(e),a=String(t||``).trim();try{if(a){r.setItem(i,a);return}r.removeItem(i)}catch{}}function At(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 jt=new Map([[`openclaw`,`OpenClaw`],[`hermes`,`Hermes`]]);function Mt(e){return String(e||``).trim().toLowerCase()}function Nt(e){return String(e||``).trim().toLowerCase()}function Pt(e){try{return new URL(`/`,e).toString()}catch{return`/`}}function Ft({capability:e,agentFramework:t,accessMode:n,origin:r}){let i=Mt(n);if(i!==`owner`&&i!==`private`||!e?.Enabled)return null;let a=jt.get(Nt(t))||`运行时`;return{href:typeof e.Href==`string`&&e.Href?new URL(e.Href,Pt(r)).toString():Pt(r),label:typeof e.Label==`string`&&e.Label?e.Label:`管理平台`,title:`打开 ${a} 原生管理平台`}}var It=new Set([`auto`,`enabled`,`disabled`]);function Lt(e){let t=String(e||``).trim().toLowerCase();return It.has(t)?t:`auto`}function Rt(e){let t=Lt(e);if(t===`disabled`)return{thinking:{type:`disabled`}};if(t===`enabled`)return{thinking:{type:`enabled`}}}function zt(){return typeof window>`u`?900:Math.round(window.visualViewport?.height||window.innerHeight||900)}function Bt(){return typeof window>`u`?{isMobile:!1,viewportHeight:900}:{isMobile:et(window.innerWidth,768),viewportHeight:zt()}}function Vt(){let[e,t]=(0,b.useState)(()=>Bt());return(0,b.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: 768px)`),n=()=>{t(Bt())};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 Ht=class extends Error{code;detail;constructor(e,t,n){super(t),this.name=`ApiError`,this.code=e,this.detail=n}},Ut=class extends Error{constructor(e=`请求已取消`){super(e),this.name=`CancelledError`}},Wt=`/agentengine/api/v1`;async function Gt(e){let t=await e.text(),n={};try{n=t?JSON.parse(t):{}}catch{let n=e.headers.get(`content-type`)?.toLowerCase()||``;if((e.status===401||e.status===403)&&(n.includes(`text/html`)||t.trimStart().startsWith(`<`)))throw new Ht(e.status,`访问会话已失效,请从 Dashboard 或 Studio 的云端会话重新打开 Agent。`);if(!e.ok){let n=t.trim();throw new Ht(e.status,n&&n.length<=256&&!n.startsWith(`<`)?n:e.statusText||`HTTP ${e.status}`,t)}throw new Ht(-2,`响应格式异常`)}if(!e.ok)throw new Ht(e.status,n?.Message||`HTTP ${e.status}`,n);if(n?.Code!==void 0&&n.Code!==0)throw new Ht(n.Code,n.Message||`请求失败`,n);return n.Data}function Kt(e){throw e instanceof DOMException&&e.name===`AbortError`?new Ut:e}async function qt(e,t,n){let r;try{r=await fetch(`${Wt}/${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t),signal:n?.signal})}catch(e){throw Kt(e)}return Gt(r)}async function Jt(e,t,n){let r;try{r=await fetch(`${Wt}/${e}`,{method:`POST`,body:t,signal:n?.signal})}catch(e){throw Kt(e)}return Gt(r)}async function Yt(e,t,n){let r=new URLSearchParams(t).toString(),i=r?`${Wt}/${e}?${r}`:`${Wt}/${e}`,a;try{a=await fetch(i,{signal:n?.signal})}catch(e){throw Kt(e)}if(!a.ok)throw new Ht(a.status,`资源获取失败: ${a.statusText}`);try{return n?.asText?await a.text():await a.blob()}catch{throw new Ht(-3,`文件读取失败`)}}async function Xt(e,t,n){let r;try{r=await fetch(`${Wt}/${e}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`text/event-stream`},body:JSON.stringify(t),signal:n?.signal})}catch(e){throw Kt(e)}if(!r.ok)throw new Ht(r.status,`流式请求失败: ${r.statusText}`);if((r.headers.get(`content-type`)?.toLowerCase()||``).includes(`application/json`)&&await Gt(r.clone()),!r.body)throw new Ht(-1,`无法获取响应流`);return r.body}async function Zt(e,t,n){let r=new URLSearchParams(t).toString(),i=r?`${Wt}/${e}?${r}`:`${Wt}/${e}`,a;try{a=await fetch(i,{headers:{Accept:`text/event-stream`},signal:n?.signal})}catch(e){throw Kt(e)}if(!a.ok)throw new Ht(a.status,`流式订阅失败: ${a.statusText}`);if(!a.body)throw new Ht(-1,`无法获取响应流`);return a.body}async function Qt(){return qt(`GetAgentUiBootstrap`,{})}async function $t(e){return qt(`ListAgentModels`,{AgentId:e})}function en(e){return e instanceof Ht&&(e.code===401||e.code===403)?`auth-required`:`error`}function tn(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 nn(e){try{let t=await $t(e),n=t?.Models;Array.isArray(n)&&Te.getState().upsertModels(n);let r=t;r?.Current&&!Te.getState().selectedModel&&Te.getState().setSelectedModel(String(r.Current)),r?.Source&&Te.getState().setModelSource(String(r.Source))}catch(e){console.error(`Failed to fetch models:`,e)}finally{Te.getState().setModelCatalogLoaded(!0)}}function rn(e){(0,b.useEffect)(()=>{(async()=>{Ce.getState().setStatus(`loading`);try{let t=await Qt(),n=t,r=n?.Agent,i=String(r?.AgentId||`default-agent`);if(Ce.getState().setAgentId(i),r?.Name){let e=String(r.Name);Ce.getState().setAgentName(e),document.title=e}let a=String(r?.Framework||``).trim().toLowerCase();Ce.getState().setAgentFramework(a);let o=be(t);Ce.getState().setCapabilities(o),Ce.getState().setApiFormats(tn(o.HostedChat.ApiFormats)),Ce.getState().setAccessMode(String(n?.AccessMode||`Owner`));let s=o.WorkspaceFiles&&n?.WorkspaceFiles?n.WorkspaceFiles:null;Ce.getState().setWorkspaceFiles(s),s||C.getState().setWorkspacePanelOpen(!1),xe(o)&&e.fetchSessions(i,Ot(i));let c=n?.Model;c?.id&&(Te.getState().setSelectedModel(c.id),Te.getState().upsertModels([c]),Te.getState().setModelSource(c.source||``)),nn(i),Ce.getState().setStatus(`ready`)}catch(e){console.error(`Failed to fetch bootstrap:`,e);let t=en(e);Ce.getState().setStatus(t,t===`auth-required`?`当前访问链接未授权或已过期。`:`无法加载 Agent 配置,请稍后重试。`)}})()},[])}var an=S()(e=>({messages:[],setMessages:t=>e({messages:t}),patchMessages:t=>e(e=>({messages:t(e.messages)}))})),on;function O(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var sn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},cn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(on=globalThis).__zod_globalConfig??(on.__zod_globalConfig={});var ln=globalThis.__zod_globalConfig;function un(e){return e&&Object.assign(ln,e),ln}function dn(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function fn(e,t){return typeof t==`bigint`?t.toString():t}function pn(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function mn(e){return e==null}function hn(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function gn(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var _n=Symbol(`evaluating`);function vn(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==_n)return r===void 0&&(r=_n,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function yn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function bn(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function xn(e){return JSON.stringify(e)}function Sn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Cn=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function wn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Tn=pn(()=>{if(ln.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function En(e){if(wn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(wn(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Dn(e){return En(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var On=new Set([`string`,`number`,`symbol`]);function kn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function An(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function jn(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Mn(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Nn={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Pn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return An(e,bn(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return yn(this,`shape`,e),e},checks:[]}))}function Fn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return An(e,bn(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return yn(this,`shape`,r),r},checks:[]}))}function In(e,t){if(!En(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return An(e,bn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return yn(this,`shape`,n),n}}))}function Ln(e,t){if(!En(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return An(e,bn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return yn(this,`shape`,n),n}}))}function Rn(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return An(e,bn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return yn(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function zn(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return An(t,bn(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return yn(this,`shape`,i),i},checks:[]}))}function Bn(e,t,n){return An(t,bn(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return yn(this,`shape`,i),i}}))}function Vn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Hn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Un(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Wn(e){return typeof e==`string`?e:e?.message}function Gn(e,t,n){let r=e.message?e.message:Wn(e.inst?._zod.def?.error?.(e))??Wn(t?.error?.(e))??Wn(n.customError?.(e))??Wn(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Kn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function qn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Jn=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,fn,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Yn=O(`$ZodError`,Jn),Xn=O(`$ZodError`,Jn,{Parent:Error});function Zn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Qn(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var $n=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new sn;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Gn(e,a,un())));throw Cn(t,i?.callee),t}return o.value},er=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Gn(e,a,un())));throw Cn(t,i?.callee),t}return o.value},tr=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new sn;return a.issues.length?{success:!1,error:new(e??Yn)(a.issues.map(e=>Gn(e,i,un())))}:{success:!0,data:a.value}},nr=tr(Xn),rr=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Gn(e,i,un())))}:{success:!0,data:a.value}},ir=rr(Xn),ar=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return $n(e)(t,n,i)},or=e=>(t,n,r)=>$n(e)(t,n,r),sr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return er(e)(t,n,i)},cr=e=>async(t,n,r)=>er(e)(t,n,r),lr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return tr(e)(t,n,i)},ur=e=>(t,n,r)=>tr(e)(t,n,r),dr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return rr(e)(t,n,i)},fr=e=>async(t,n,r)=>rr(e)(t,n,r),pr=/^[cC][0-9a-z]{6,}$/,mr=/^[0-9a-z]+$/,hr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,gr=/^[0-9a-vA-V]{20}$/,_r=/^[A-Za-z0-9]{27}$/,vr=/^[a-zA-Z0-9_-]{21}$/,yr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,br=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,xr=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Sr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Cr=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function wr(){return new RegExp(Cr,`u`)}var Tr=/^(?:(?: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])$/,Er=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,Dr=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,Or=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ar=/^[A-Za-z0-9_-]*$/,jr=/^https?$/,Mr=/^\+[1-9]\d{6,14}$/,Nr=`(?:(?:\\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])))`,Pr=RegExp(`^${Nr}$`);function Fr(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ir(e){return RegExp(`^${Fr(e)}$`)}function Lr(e){let t=Fr({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Nr}T(?:${r})$`)}var Rr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},zr=/^-?\d+$/,Br=/^-?\d+(?:\.\d+)?$/,Vr=/^(?:true|false)$/i,Hr=/^[^A-Z]*$/,Ur=/^[^a-z]*$/,Wr=O(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Gr={number:`number`,bigint:`bigint`,object:`date`},Kr=O(`$ZodCheckLessThan`,(e,t)=>{Wr.init(e,t);let n=Gr[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),qr=O(`$ZodCheckGreaterThan`,(e,t)=>{Wr.init(e,t);let n=Gr[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jr=O(`$ZodCheckMultipleOf`,(e,t)=>{Wr.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):gn(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Yr=O(`$ZodCheckNumberFormat`,(e,t)=>{Wr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Nn[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=zr)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Xr=O(`$ZodCheckMaxLength`,(e,t)=>{var n;Wr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!mn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Kn(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Zr=O(`$ZodCheckMinLength`,(e,t)=>{var n;Wr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!mn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Kn(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Qr=O(`$ZodCheckLengthEquals`,(e,t)=>{var n;Wr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!mn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Kn(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$r=O(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Wr.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ei=O(`$ZodCheckRegex`,(e,t)=>{$r.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ti=O(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Hr,$r.init(e,t)}),ni=O(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Ur,$r.init(e,t)}),ri=O(`$ZodCheckIncludes`,(e,t)=>{Wr.init(e,t);let n=kn(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),ii=O(`$ZodCheckStartsWith`,(e,t)=>{Wr.init(e,t);let n=RegExp(`^${kn(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),ai=O(`$ZodCheckEndsWith`,(e,t)=>{Wr.init(e,t);let n=RegExp(`.*${kn(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),oi=O(`$ZodCheckOverwrite`,(e,t)=>{Wr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),si=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
11
|
-
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
12
|
-
`))}},ci={major:4,minor:4,patch:3},li=O(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ci;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Vn(e),i;for(let a of t){if(a._zod.def.when){if(Hn(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new sn;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Vn(e,t))});else{if(e.issues.length===t)continue;r||=Vn(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Vn(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new sn;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new sn;return o.then(e=>t(e,r,a))}return t(o,r,a)}}vn(e,`~standard`,()=>({validate:t=>{try{let n=nr(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return ir(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),ui=O(`$ZodString`,(e,t)=>{li.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Rr(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),di=O(`$ZodStringFormat`,(e,t)=>{$r.init(e,t),ui.init(e,t)}),fi=O(`$ZodGUID`,(e,t)=>{t.pattern??=br,di.init(e,t)}),pi=O(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=xr(e)}else t.pattern??=xr();di.init(e,t)}),mi=O(`$ZodEmail`,(e,t)=>{t.pattern??=Sr,di.init(e,t)}),hi=O(`$ZodURL`,(e,t)=>{di.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===jr.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),gi=O(`$ZodEmoji`,(e,t)=>{t.pattern??=wr(),di.init(e,t)}),_i=O(`$ZodNanoID`,(e,t)=>{t.pattern??=vr,di.init(e,t)}),vi=O(`$ZodCUID`,(e,t)=>{t.pattern??=pr,di.init(e,t)}),yi=O(`$ZodCUID2`,(e,t)=>{t.pattern??=mr,di.init(e,t)}),bi=O(`$ZodULID`,(e,t)=>{t.pattern??=hr,di.init(e,t)}),xi=O(`$ZodXID`,(e,t)=>{t.pattern??=gr,di.init(e,t)}),Si=O(`$ZodKSUID`,(e,t)=>{t.pattern??=_r,di.init(e,t)}),Ci=O(`$ZodISODateTime`,(e,t)=>{t.pattern??=Lr(t),di.init(e,t)}),wi=O(`$ZodISODate`,(e,t)=>{t.pattern??=Pr,di.init(e,t)}),Ti=O(`$ZodISOTime`,(e,t)=>{t.pattern??=Ir(t),di.init(e,t)}),Ei=O(`$ZodISODuration`,(e,t)=>{t.pattern??=yr,di.init(e,t)}),Di=O(`$ZodIPv4`,(e,t)=>{t.pattern??=Tr,di.init(e,t),e._zod.bag.format=`ipv4`}),Oi=O(`$ZodIPv6`,(e,t)=>{t.pattern??=Er,di.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),ki=O(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Dr,di.init(e,t)}),Ai=O(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Or,di.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function ji(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Mi=O(`$ZodBase64`,(e,t)=>{t.pattern??=kr,di.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{ji(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Ni(e){if(!Ar.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ji(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Pi=O(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ar,di.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Ni(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Fi=O(`$ZodE164`,(e,t)=>{t.pattern??=Mr,di.init(e,t)});function Ii(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Li=O(`$ZodJWT`,(e,t)=>{di.init(e,t),e._zod.check=n=>{Ii(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Ri=O(`$ZodNumber`,(e,t)=>{li.init(e,t),e._zod.pattern=e._zod.bag.pattern??Br,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),zi=O(`$ZodNumberFormat`,(e,t)=>{Yr.init(e,t),Ri.init(e,t)}),Bi=O(`$ZodBoolean`,(e,t)=>{li.init(e,t),e._zod.pattern=Vr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Vi=O(`$ZodUnknown`,(e,t)=>{li.init(e,t),e._zod.parse=e=>e}),Hi=O(`$ZodNever`,(e,t)=>{li.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Ui(e,t,n){e.issues.length&&t.issues.push(...Un(n,e.issues)),t.value[n]=e.value}var Wi=O(`$ZodArray`,(e,t)=>{li.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Ui(t,n,e))):Ui(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Gi(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Un(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Ki(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Mn(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function qi(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Gi(e,n,i,t,u,d))):Gi(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Ji=O(`$ZodObject`,(e,t)=>{if(li.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=pn(()=>Ki(t));vn(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=wn,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Gi(n,t,e,s,r,i))):Gi(a,t,e,s,r,i)}return i?qi(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Yi=O(`$ZodObjectJIT`,(e,t)=>{Ji.init(e,t);let n=e._zod.parse,r=pn(()=>Ki(t)),i=e=>{let t=new si([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=xn(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=xn(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
13
|
-
if (${n}.issues.length) {
|
|
14
|
-
if (${o} in input) {
|
|
15
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
16
|
-
...iss,
|
|
17
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
18
|
-
})));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (${n}.value === undefined) {
|
|
23
|
-
if (${o} in input) {
|
|
24
|
-
newResult[${o}] = undefined;
|
|
25
|
-
}
|
|
26
|
-
} else {
|
|
27
|
-
newResult[${o}] = ${n}.value;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
`):c?t.write(`
|
|
31
|
-
if (${n}.issues.length) {
|
|
32
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
33
|
-
...iss,
|
|
34
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
35
|
-
})));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (${n}.value === undefined) {
|
|
39
|
-
if (${o} in input) {
|
|
40
|
-
newResult[${o}] = undefined;
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
newResult[${o}] = ${n}.value;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
`):t.write(`
|
|
47
|
-
const ${n}_present = ${o} in input;
|
|
48
|
-
if (${n}.issues.length) {
|
|
49
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
50
|
-
...iss,
|
|
51
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
52
|
-
})));
|
|
53
|
-
}
|
|
54
|
-
if (!${n}_present && !${n}.issues.length) {
|
|
55
|
-
payload.issues.push({
|
|
56
|
-
code: "invalid_type",
|
|
57
|
-
expected: "nonoptional",
|
|
58
|
-
input: undefined,
|
|
59
|
-
path: [${o}]
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (${n}_present) {
|
|
64
|
-
if (${n}.value === undefined) {
|
|
65
|
-
newResult[${o}] = undefined;
|
|
66
|
-
} else {
|
|
67
|
-
newResult[${o}] = ${n}.value;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=wn,s=!ln.jitless,c=s&&Tn.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?qi([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Xi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Vn(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Gn(e,r,un())))}),t)}var Zi=O(`$ZodUnion`,(e,t)=>{li.init(e,t),vn(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),vn(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),vn(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),vn(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>hn(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Xi(t,r,e,i)):Xi(o,r,e,i)}}),Qi=O(`$ZodIntersection`,(e,t)=>{li.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>ea(e,t,n)):ea(e,i,a)}});function $i(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(En(e)&&En(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=$i(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=$i(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ea(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Vn(e))return e;let o=$i(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var ta=O(`$ZodRecord`,(e,t)=>{li.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!En(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Gn(e,r,un())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Un(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Un(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Br.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Gn(e,r,un())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Un(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Un(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),na=O(`$ZodEnum`,(e,t)=>{li.init(e,t);let n=dn(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>On.has(typeof e)).map(e=>typeof e==`string`?kn(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),ra=O(`$ZodLiteral`,(e,t)=>{if(li.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?kn(e):e?kn(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),ia=O(`$ZodTransform`,(e,t)=>{li.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new cn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new sn;return n.value=i,n.fallback=!0,n}});function aa(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var oa=O(`$ZodOptional`,(e,t)=>{li.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,vn(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),vn(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${hn(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>aa(e,r)):aa(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),sa=O(`$ZodExactOptional`,(e,t)=>{oa.init(e,t),vn(e._zod,`values`,()=>t.innerType._zod.values),vn(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ca=O(`$ZodNullable`,(e,t)=>{li.init(e,t),vn(e._zod,`optin`,()=>t.innerType._zod.optin),vn(e._zod,`optout`,()=>t.innerType._zod.optout),vn(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${hn(e.source)}|null)$`):void 0}),vn(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),la=O(`$ZodDefault`,(e,t)=>{li.init(e,t),e._zod.optin=`optional`,vn(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>ua(e,t)):ua(r,t)}});function ua(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var da=O(`$ZodPrefault`,(e,t)=>{li.init(e,t),e._zod.optin=`optional`,vn(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),fa=O(`$ZodNonOptional`,(e,t)=>{li.init(e,t),vn(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>pa(t,e)):pa(i,e)}});function pa(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var ma=O(`$ZodCatch`,(e,t)=>{li.init(e,t),e._zod.optin=`optional`,vn(e._zod,`optout`,()=>t.innerType._zod.optout),vn(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Gn(e,n,un()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Gn(e,n,un()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),ha=O(`$ZodPipe`,(e,t)=>{li.init(e,t),vn(e._zod,`values`,()=>t.in._zod.values),vn(e._zod,`optin`,()=>t.in._zod.optin),vn(e._zod,`optout`,()=>t.out._zod.optout),vn(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ga(e,t.in,n)):ga(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ga(e,t.out,n)):ga(r,t.out,n)}});function ga(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var _a=O(`$ZodReadonly`,(e,t)=>{li.init(e,t),vn(e._zod,`propValues`,()=>t.innerType._zod.propValues),vn(e._zod,`values`,()=>t.innerType._zod.values),vn(e._zod,`optin`,()=>t.innerType?._zod?.optin),vn(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(va):va(r)}});function va(e){return e.value=Object.freeze(e.value),e}var ya=O(`$ZodCustom`,(e,t)=>{Wr.init(e,t),li.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ba(t,n,r,e));ba(i,n,r,e)}});function ba(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(qn(e))}}var xa,Sa=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ca(){return new Sa}(xa=globalThis).__zod_globalRegistry??(xa.__zod_globalRegistry=Ca());var wa=globalThis.__zod_globalRegistry;function Ta(e,t){return new e({type:`string`,...jn(t)})}function Ea(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...jn(t)})}function Da(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...jn(t)})}function Oa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...jn(t)})}function ka(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...jn(t)})}function Aa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...jn(t)})}function ja(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...jn(t)})}function Ma(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...jn(t)})}function Na(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...jn(t)})}function Pa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...jn(t)})}function Fa(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...jn(t)})}function Ia(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...jn(t)})}function La(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...jn(t)})}function Ra(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...jn(t)})}function za(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...jn(t)})}function Ba(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...jn(t)})}function Va(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...jn(t)})}function Ha(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...jn(t)})}function Ua(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...jn(t)})}function Wa(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...jn(t)})}function Ga(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...jn(t)})}function Ka(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...jn(t)})}function qa(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...jn(t)})}function Ja(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...jn(t)})}function Ya(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...jn(t)})}function Xa(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...jn(t)})}function Za(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...jn(t)})}function Qa(e,t){return new e({type:`number`,checks:[],...jn(t)})}function $a(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...jn(t)})}function eo(e,t){return new e({type:`boolean`,...jn(t)})}function to(e){return new e({type:`unknown`})}function no(e,t){return new e({type:`never`,...jn(t)})}function ro(e,t){return new Kr({check:`less_than`,...jn(t),value:e,inclusive:!1})}function io(e,t){return new Kr({check:`less_than`,...jn(t),value:e,inclusive:!0})}function ao(e,t){return new qr({check:`greater_than`,...jn(t),value:e,inclusive:!1})}function oo(e,t){return new qr({check:`greater_than`,...jn(t),value:e,inclusive:!0})}function so(e,t){return new Jr({check:`multiple_of`,...jn(t),value:e})}function co(e,t){return new Xr({check:`max_length`,...jn(t),maximum:e})}function lo(e,t){return new Zr({check:`min_length`,...jn(t),minimum:e})}function uo(e,t){return new Qr({check:`length_equals`,...jn(t),length:e})}function fo(e,t){return new ei({check:`string_format`,format:`regex`,...jn(t),pattern:e})}function po(e){return new ti({check:`string_format`,format:`lowercase`,...jn(e)})}function mo(e){return new ni({check:`string_format`,format:`uppercase`,...jn(e)})}function ho(e,t){return new ri({check:`string_format`,format:`includes`,...jn(t),includes:e})}function go(e,t){return new ii({check:`string_format`,format:`starts_with`,...jn(t),prefix:e})}function _o(e,t){return new ai({check:`string_format`,format:`ends_with`,...jn(t),suffix:e})}function vo(e){return new oi({check:`overwrite`,tx:e})}function yo(e){return vo(t=>t.normalize(e))}function bo(){return vo(e=>e.trim())}function xo(){return vo(e=>e.toLowerCase())}function So(){return vo(e=>e.toUpperCase())}function Co(){return vo(e=>Sn(e))}function wo(e,t,n){return new e({type:`array`,element:t,...jn(n)})}function To(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...jn(n)})}function Eo(e,t){let n=Do(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(qn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(qn(r))}},e(t.value,t)),t);return n}function Do(e,t){let n=new Wr({check:`custom`,...jn(t)});return n._zod.check=e,n}function Oo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??wa,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function ko(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,ko(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Mo(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ao(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
72
|
-
|
|
73
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function jo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Po(t,`input`,e.processors),output:Po(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Mo(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Mo(r.element,n);if(r.type===`set`)return Mo(r.valueType,n);if(r.type===`lazy`)return Mo(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Mo(r.innerType,n);if(r.type===`intersection`)return Mo(r.left,n)||Mo(r.right,n);if(r.type===`record`||r.type===`map`)return Mo(r.keyType,n)||Mo(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Mo(r.in,n)||Mo(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Mo(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Mo(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Mo(e,n))return!0;return!!(r.rest&&Mo(r.rest,n))}return!1}var No=(e,t={})=>n=>{let r=Oo({...n,processors:t});return ko(e,r),Ao(r,e),jo(r,e)},Po=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Oo({...i??{},target:a,io:t,processors:n});return ko(e,o),Ao(o,e),jo(o,e)},Fo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Io=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Fo[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Lo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Ro=(e,t,n,r)=>{n.type=`boolean`},zo=(e,t,n,r)=>{n.not={}},Bo=(e,t,n,r)=>{let i=e._zod.def,a=dn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Vo=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Ho=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Uo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Wo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=ko(a.element,t,{...r,path:[...r.path,`items`]})},Go=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=ko(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=ko(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ko=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>ko(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},qo=(e,t,n,r)=>{let i=e._zod.def,a=ko(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=ko(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Jo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=ko(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=ko(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=ko(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Yo=(e,t,n,r)=>{let i=e._zod.def,a=ko(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Xo=(e,t,n,r)=>{let i=e._zod.def;ko(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Zo=(e,t,n,r)=>{let i=e._zod.def;ko(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Qo=(e,t,n,r)=>{let i=e._zod.def;ko(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},$o=(e,t,n,r)=>{let i=e._zod.def;ko(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},es=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;ko(o,t,r);let s=t.seen.get(e);s.ref=o},ts=(e,t,n,r)=>{let i=e._zod.def;ko(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ns=(e,t,n,r)=>{let i=e._zod.def;ko(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},rs=O(`ZodISODateTime`,(e,t)=>{Ci.init(e,t),As.init(e,t)});function is(e){return Ja(rs,e)}var as=O(`ZodISODate`,(e,t)=>{wi.init(e,t),As.init(e,t)});function os(e){return Ya(as,e)}var ss=O(`ZodISOTime`,(e,t)=>{Ti.init(e,t),As.init(e,t)});function cs(e){return Xa(ss,e)}var ls=O(`ZodISODuration`,(e,t)=>{Ei.init(e,t),As.init(e,t)});function us(e){return Za(ls,e)}var ds=O(`ZodError`,(e,t)=>{Yn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Qn(e,t)},flatten:{value:t=>Zn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,fn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,fn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),fs=$n(ds),ps=er(ds),ms=tr(ds),hs=rr(ds),gs=ar(ds),_s=or(ds),vs=sr(ds),ys=cr(ds),bs=lr(ds),xs=ur(ds),Ss=dr(ds),Cs=fr(ds),ws=new WeakMap;function Ts(e,t,n){let r=Object.getPrototypeOf(e),i=ws.get(r);if(i||(i=new Set,ws.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Es=O(`ZodType`,(e,t)=>(li.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Po(e,`input`),output:Po(e,`output`)}}),e.toJSONSchema=No(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>fs(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ms(e,t,n),e.parseAsync=async(t,n)=>ps(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>hs(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>gs(e,t,n),e.decode=(t,n)=>_s(e,t,n),e.encodeAsync=async(t,n)=>vs(e,t,n),e.decodeAsync=async(t,n)=>ys(e,t,n),e.safeEncode=(t,n)=>bs(e,t,n),e.safeDecode=(t,n)=>xs(e,t,n),e.safeEncodeAsync=async(t,n)=>Ss(e,t,n),e.safeDecodeAsync=async(t,n)=>Cs(e,t,n),Ts(e,`ZodType`,{check(...e){let t=this.def;return this.clone(bn(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return An(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Vc(e,t))},superRefine(e,t){return this.check(Hc(e,t))},overwrite(e){return this.check(vo(e))},optional(){return Cc(this)},exactOptional(){return Tc(this)},nullable(){return Dc(this)},nullish(){return Cc(Dc(this))},nonoptional(e){return Nc(this,e)},array(){return sc(this)},or(e){return dc([this,e])},and(e){return pc(this,e)},transform(e){return Lc(this,xc(e))},default(e){return kc(this,e)},prefault(e){return jc(this,e)},catch(e){return Fc(this,e)},pipe(e){return Lc(this,e)},readonly(){return zc(this)},describe(e){let t=this.clone();return wa.add(t,{description:e}),t},meta(...e){if(e.length===0)return wa.get(this);let t=this.clone();return wa.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return wa.get(e)?.description},configurable:!0}),e)),Ds=O(`_ZodString`,(e,t)=>{ui.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ts(e,`_ZodString`,{regex(...e){return this.check(fo(...e))},includes(...e){return this.check(ho(...e))},startsWith(...e){return this.check(go(...e))},endsWith(...e){return this.check(_o(...e))},min(...e){return this.check(lo(...e))},max(...e){return this.check(co(...e))},length(...e){return this.check(uo(...e))},nonempty(...e){return this.check(lo(1,...e))},lowercase(e){return this.check(po(e))},uppercase(e){return this.check(mo(e))},trim(){return this.check(bo())},normalize(...e){return this.check(yo(...e))},toLowerCase(){return this.check(xo())},toUpperCase(){return this.check(So())},slugify(){return this.check(Co())}})}),Os=O(`ZodString`,(e,t)=>{ui.init(e,t),Ds.init(e,t),e.email=t=>e.check(Ea(js,t)),e.url=t=>e.check(Ma(Ps,t)),e.jwt=t=>e.check(qa(Ys,t)),e.emoji=t=>e.check(Na(Fs,t)),e.guid=t=>e.check(Da(Ms,t)),e.uuid=t=>e.check(Oa(Ns,t)),e.uuidv4=t=>e.check(ka(Ns,t)),e.uuidv6=t=>e.check(Aa(Ns,t)),e.uuidv7=t=>e.check(ja(Ns,t)),e.nanoid=t=>e.check(Pa(Is,t)),e.guid=t=>e.check(Da(Ms,t)),e.cuid=t=>e.check(Fa(Ls,t)),e.cuid2=t=>e.check(Ia(Rs,t)),e.ulid=t=>e.check(La(zs,t)),e.base64=t=>e.check(Wa(Ks,t)),e.base64url=t=>e.check(Ga(qs,t)),e.xid=t=>e.check(Ra(Bs,t)),e.ksuid=t=>e.check(za(Vs,t)),e.ipv4=t=>e.check(Ba(Hs,t)),e.ipv6=t=>e.check(Va(Us,t)),e.cidrv4=t=>e.check(Ha(Ws,t)),e.cidrv6=t=>e.check(Ua(Gs,t)),e.e164=t=>e.check(Ka(Js,t)),e.datetime=t=>e.check(is(t)),e.date=t=>e.check(os(t)),e.time=t=>e.check(cs(t)),e.duration=t=>e.check(us(t))});function ks(e){return Ta(Os,e)}var As=O(`ZodStringFormat`,(e,t)=>{di.init(e,t),Ds.init(e,t)}),js=O(`ZodEmail`,(e,t)=>{mi.init(e,t),As.init(e,t)}),Ms=O(`ZodGUID`,(e,t)=>{fi.init(e,t),As.init(e,t)}),Ns=O(`ZodUUID`,(e,t)=>{pi.init(e,t),As.init(e,t)}),Ps=O(`ZodURL`,(e,t)=>{hi.init(e,t),As.init(e,t)}),Fs=O(`ZodEmoji`,(e,t)=>{gi.init(e,t),As.init(e,t)}),Is=O(`ZodNanoID`,(e,t)=>{_i.init(e,t),As.init(e,t)}),Ls=O(`ZodCUID`,(e,t)=>{vi.init(e,t),As.init(e,t)}),Rs=O(`ZodCUID2`,(e,t)=>{yi.init(e,t),As.init(e,t)}),zs=O(`ZodULID`,(e,t)=>{bi.init(e,t),As.init(e,t)}),Bs=O(`ZodXID`,(e,t)=>{xi.init(e,t),As.init(e,t)}),Vs=O(`ZodKSUID`,(e,t)=>{Si.init(e,t),As.init(e,t)}),Hs=O(`ZodIPv4`,(e,t)=>{Di.init(e,t),As.init(e,t)}),Us=O(`ZodIPv6`,(e,t)=>{Oi.init(e,t),As.init(e,t)}),Ws=O(`ZodCIDRv4`,(e,t)=>{ki.init(e,t),As.init(e,t)}),Gs=O(`ZodCIDRv6`,(e,t)=>{Ai.init(e,t),As.init(e,t)}),Ks=O(`ZodBase64`,(e,t)=>{Mi.init(e,t),As.init(e,t)}),qs=O(`ZodBase64URL`,(e,t)=>{Pi.init(e,t),As.init(e,t)}),Js=O(`ZodE164`,(e,t)=>{Fi.init(e,t),As.init(e,t)}),Ys=O(`ZodJWT`,(e,t)=>{Li.init(e,t),As.init(e,t)}),Xs=O(`ZodNumber`,(e,t)=>{Ri.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),Ts(e,`ZodNumber`,{gt(e,t){return this.check(ao(e,t))},gte(e,t){return this.check(oo(e,t))},min(e,t){return this.check(oo(e,t))},lt(e,t){return this.check(ro(e,t))},lte(e,t){return this.check(io(e,t))},max(e,t){return this.check(io(e,t))},int(e){return this.check($s(e))},safe(e){return this.check($s(e))},positive(e){return this.check(ao(0,e))},nonnegative(e){return this.check(oo(0,e))},negative(e){return this.check(ro(0,e))},nonpositive(e){return this.check(io(0,e))},multipleOf(e,t){return this.check(so(e,t))},step(e,t){return this.check(so(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Zs(e){return Qa(Xs,e)}var Qs=O(`ZodNumberFormat`,(e,t)=>{zi.init(e,t),Xs.init(e,t)});function $s(e){return $a(Qs,e)}var ec=O(`ZodBoolean`,(e,t)=>{Bi.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r)});function tc(e){return eo(ec,e)}var nc=O(`ZodUnknown`,(e,t)=>{Vi.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function rc(){return to(nc)}var ic=O(`ZodNever`,(e,t)=>{Hi.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zo(e,t,n,r)});function ac(e){return no(ic,e)}var oc=O(`ZodArray`,(e,t)=>{Wi.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r),e.element=t.element,Ts(e,`ZodArray`,{min(e,t){return this.check(lo(e,t))},nonempty(e){return this.check(lo(1,e))},max(e,t){return this.check(co(e,t))},length(e,t){return this.check(uo(e,t))},unwrap(){return this.element}})});function sc(e,t){return wo(oc,e,t)}var cc=O(`ZodObject`,(e,t)=>{Yi.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r),vn(e,`shape`,()=>t.shape),Ts(e,`ZodObject`,{keyof(){return _c(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:rc()})},loose(){return this.clone({...this._zod.def,catchall:rc()})},strict(){return this.clone({...this._zod.def,catchall:ac()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return In(this,e)},safeExtend(e){return Ln(this,e)},merge(e){return Rn(this,e)},pick(e){return Pn(this,e)},omit(e){return Fn(this,e)},partial(...e){return zn(Sc,this,e[0])},required(...e){return Bn(Mc,this,e[0])}})});function lc(e,t){return new cc({type:`object`,shape:e??{},...jn(t)})}var uc=O(`ZodUnion`,(e,t)=>{Zi.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(e,t,n,r),e.options=t.options});function dc(e,t){return new uc({type:`union`,options:e,...jn(t)})}var fc=O(`ZodIntersection`,(e,t)=>{Qi.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r)});function pc(e,t){return new fc({type:`intersection`,left:e,right:t})}var mc=O(`ZodRecord`,(e,t)=>{ta.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function hc(e,t,n){return!t||!t._zod?new mc({type:`record`,keyType:ks(),valueType:e,...jn(t)}):new mc({type:`record`,keyType:e,valueType:t,...jn(n)})}var gc=O(`ZodEnum`,(e,t)=>{na.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new gc({...t,checks:[],...jn(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new gc({...t,checks:[],...jn(r),entries:i})}});function _c(e,t){return new gc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...jn(t)})}var vc=O(`ZodLiteral`,(e,t)=>{ra.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function yc(e,t){return new vc({type:`literal`,values:Array.isArray(e)?e:[e],...jn(t)})}var bc=O(`ZodTransform`,(e,t)=>{ia.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new cn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(qn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(qn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function xc(e){return new bc({type:`transform`,transform:e})}var Sc=O(`ZodOptional`,(e,t)=>{oa.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cc(e){return new Sc({type:`optional`,innerType:e})}var wc=O(`ZodExactOptional`,(e,t)=>{sa.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Tc(e){return new wc({type:`optional`,innerType:e})}var Ec=O(`ZodNullable`,(e,t)=>{ca.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Dc(e){return new Ec({type:`nullable`,innerType:e})}var Oc=O(`ZodDefault`,(e,t)=>{la.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function kc(e,t){return new Oc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Dn(t)}})}var Ac=O(`ZodPrefault`,(e,t)=>{da.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function jc(e,t){return new Ac({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Dn(t)}})}var Mc=O(`ZodNonOptional`,(e,t)=>{fa.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Nc(e,t){return new Mc({type:`nonoptional`,innerType:e,...jn(t)})}var Pc=O(`ZodCatch`,(e,t)=>{ma.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Fc(e,t){return new Pc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Ic=O(`ZodPipe`,(e,t)=>{ha.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r),e.in=t.in,e.out=t.out});function Lc(e,t){return new Ic({type:`pipe`,in:e,out:t})}var Rc=O(`ZodReadonly`,(e,t)=>{_a.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`readonly`,innerType:e})}var Bc=O(`ZodCustom`,(e,t)=>{ya.init(e,t),Es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r)});function Vc(e,t={}){return To(Bc,e,t)}function Hc(e,t){return Eo(e,t)}var Uc=class extends Error{constructor(e){super(e),this.name=`ContractMismatchError`}},Wc=new Set([`schema_version`,`command_id`,`status`,`message_id`,`run_id`,`accepted_seq`,`error`]),Gc=lc({code:ks().min(1),message:ks(),retryable:tc(),details:hc(ks(),rc()).optional()});function Kc(e){let t=lc({schema_version:yc(1),command_id:ks().min(1),status:_c([`accepted`,`duplicate`,`rejected`,`unsupported`,`queue_full`,`persistence_uncertain`]),message_id:ks().min(1).nullable().optional(),run_id:ks().min(1).nullable().optional(),accepted_seq:Zs().int().min(0).nullable().optional(),error:Gc.nullable().optional()}).passthrough().safeParse(e);if(!t.success)throw new Uc(`AgentControlReceipt/v1 mismatch: ${t.error.message}`);let n=t.data;if((n.status===`rejected`||n.status===`unsupported`||n.status===`queue_full`||n.status===`persistence_uncertain`)&&!n.error)throw new Uc(`AgentControlReceipt/v1 mismatch: status ${n.status} requires error`);let r={};for(let[e,t]of Object.entries(n))Wc.has(e)||(r[e]=t);let i=n.error?{...n.error,extensions:{}}:null;return{schema_version:1,command_id:n.command_id,status:n.status,message_id:n.message_id??null,run_id:n.run_id??null,accepted_seq:n.accepted_seq??null,error:i,extensions:r}}var qc=new Set([`schema_version`,`event_id`,`session_id`,`seq`,`timestamp`,`family`,`family_version`,`event_type`,`payload`,`run_id`,`causation_id`,`correlation_id`,`actor_ref`]),Jc=new Map([[`control`,1],[`runtime`,2]]),Yc=lc({schema_version:yc(1),event_id:ks().min(1),session_id:ks().min(1),seq:Zs().int().min(0),timestamp:ks().min(1),family:ks().min(1),family_version:Zs().int().min(1),event_type:ks().min(1),payload:hc(ks(),rc()),run_id:ks().min(1).nullable().optional(),causation_id:ks().min(1).nullable().optional(),correlation_id:ks().min(1).nullable().optional(),actor_ref:ks().min(1).nullable().optional()}).passthrough();function Xc(e){let t=Yc.safeParse(e);if(!t.success)return{ok:!1,error:new Uc(`SessionEventEnvelope/v1 mismatch: ${t.error.message}`)};let n=t.data,r=Jc.get(n.family);if(r!==void 0&&n.family_version!==r)return{ok:!1,error:new Uc(`SessionEventEnvelope/v1 mismatch: family ${n.family} requires family_version ${r}`)};let i={};for(let[e,t]of Object.entries(n))qc.has(e)||(i[e]=t);return{ok:!0,value:{schema_version:1,event_id:n.event_id,session_id:n.session_id,seq:n.seq,timestamp:n.timestamp,family:n.family,family_version:n.family_version,event_type:n.event_type,payload:n.payload,run_id:n.run_id??null,causation_id:n.causation_id??null,correlation_id:n.correlation_id??null,actor_ref:n.actor_ref??null,extensions:i}}}function Zc(){return{toolNames:new Map,toolArguments:new Map,callIds:new Map,currentResponseId:``}}function Qc(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 $c(e){return e==null?``:typeof e==`string`?e:typeof e==`object`?JSON.stringify(e,null,2):String(e)}function el(...e){for(let t of e){let e=Qc(t);if(e)return e}return``}function tl(e,t){return String(e?.id||e?.item_id||e?.call_id||t?.item_id||t?.call_id||t?.output_index||``)}function nl(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 rl(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 il(e){if(!e||typeof e!=`object`)return``;let t=Qc(e.content);return el(e.output_text,e.text,e.summary_text,e.summary,e.delta,t)}function al(e){let t=e?.response&&typeof e.response==`object`?e.response:e,n=el(t?.output_text,t?.text);if(n)return n;let r=Array.isArray(t?.output)?t.output:[];for(let e of r){let t=il(e);if(t)return t}return``}function ol(e){let t=e?.response&&typeof e.response==`object`?e.response:e;return Array.isArray(t?.output)?t.output:[]}function sl(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 cl({data:e,state:t,status:n}){let r=e?.item||e?.output_item||e||{},i=String(r.type||``).trim(),a=tl(r,e);if(i===`function_call`){let e=rl(t,a,r),i=$c(r.arguments??r.args??r.input);return nl(t,a,r,e,i),[{type:`tool_upsert`,name:e,args:i,status:n}]}if(i===`function_call_output`)return[{type:`tool_result`,name:rl(t,a,r),output:$c(r.output??r.result??r.content)}];if(i===`mcp_approval_request`){let n=String(r.name||`approval`),i=$c(r.arguments??r.args),a=String(r.id||r.approval_request_id||``);return[{type:`tool_upsert`,name:n,args:i,status:`paused`,approvalRequestId:a,previousResponseId:String(e?.response_id||t.currentResponseId||``),serverLabel:String(r.server_label||``)},{type:`approval_request`,approvalRequestId:a,previousResponseId:String(e?.response_id||t.currentResponseId||``),name:n,args:i}]}if(i===`reasoning`||i===`reasoning_summary`||i===`reasoning_summary_text`){let e=il(r);return e?[{type:`reasoning_delta`,text:e}]:[]}if(i===`message`){let e=il(r);return e?[{type:n===`completed`?`text_final`:`text_delta`,text:e}]:[]}return[]}function ll({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:$c(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:$c(t?.output??t?.result)}];if(r===`response.output_item.added`)return cl({data:t,state:n,status:`running`});if(r===`response.output_item.done`)return cl({data:t,state:n,status:`completed`});if(r===`response.function_call_arguments.delta`){let e=String(t?.item_id||t?.call_id||``),r=rl(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=rl(n,e,t),i=$c(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=el(t?.delta,t?.text);return e?[{type:`reasoning_delta`,text:e}]:[]}if(r===`response.output_text.delta`){let e=el(t?.delta,t?.text);return e?[{type:`text_delta`,text:e}]:[]}if(r===`response.output_text.done`){let e=el(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=el(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=al(t),r=ol(t).flatMap(e=>cl({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=sl(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:[];if(o.length>0){let e=o.map(e=>({type:`tool_upsert`,name:String(e?.name||`tool`),args:JSON.stringify(e?.args??{}),status:`paused`,approvalRequestId:r,previousResponseId:i})),t=o[0]||{};return[...e,{type:`approval_request`,approvalRequestId:r,previousResponseId:i,name:String(t?.name||`人工确认`),args:JSON.stringify(t?.args??{})}]}return[{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 ul=class{id=`responses`;createState(){return Zc()}parseItemOperations(e,t,n){return Le(e.eventName,e.data,t,n)}parse(e,t){return ll({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 dl(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 fl(e){return e&&typeof e==`object`?e:{}}function pl(e){let t=fl(e).choices,n=fl(Array.isArray(t)?t[0]:null),r=fl(n.delta),i=fl(n.message);return{content:dl(r.content),reasoning:dl(r.reasoning_content),finalText:dl(i.content)}}var ml=class{id=`chat_completions`;createState(){return{}}parse(e){let t=e.data;if(typeof t!=`object`||!t)return[];let n=pl(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}},hl=new Map;hl.set(`responses`,new ul),hl.set(`chat_completions`,new ml);function gl(e){return hl.get(e)||hl.get(`responses`)}function _l(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 vl(e){let t=[],n=e.trim();if(!n)return t;let r=n.split(`
|
|
74
|
-
`);if(r.every(e=>e.startsWith(`:`)))return t.push({eventName:`__ping__`,data:null}),t;let i=`message`,a=[];for(let e of r)e.startsWith(`:`)||(e.startsWith(`event:`)?i=e.substring(6).trim()||`message`:e.startsWith(`data:`)&&a.push(e.substring(5).trim()));let o=a.join(`
|
|
75
|
-
`).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 yl(e){let t=e.split(`
|
|
76
|
-
|
|
77
|
-
`);return{chunks:t,remainder:t.pop()||``}}function bl(e){return e instanceof Error?e.message:String(e)}var xl=l(h(),1),Sl=1280;function Cl(e){let{apiFormats:t}=e;return t.includes(`responses`)?`responses`:t.includes(`chat_completions`)?`chat_completions`:`responses`}function wl(e,t,n){let r=Math.min(Sl,Math.max(420,t-n-360));return Math.min(Math.max(e,420),r)}var Tl={"run.started":`in_progress`,"run.progress":`in_progress`,"run.completed":`completed`,"run.failed":`failed`,"run.canceled":`cancelled`,"run.interrupted":`interrupted`},El=new Set([`completed`,`failed`,`cancelled`,`canceled`]);function Dl(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Ol(e){let t=Dl(e.source),n=t?Dl(t.metadata):null;return String(n?.native_item_kind||``)}function kl(e,t){let n=Dl(e[t])?.parts;return Array.isArray(n)?n:[]}function Al(e){let t=Dl(e);if(!t)return``;if(typeof t.text==`string`)return t.text;let n=Dl(t.data);if(n){let e=n.content;if(Array.isArray(e))return e.map(e=>String(Dl(e)?.text||``)).join(``);for(let e of[`text`,`output`,`stdout`,`stderr`])if(n[e]!=null)return String(n[e])}return``}function jl(e){return e.map(Al).join(``)}function Ml(e){return e.some(e=>Dl(Dl(e)?.data)?.type===`userMessage`)}function Nl(e){if(e.length===1){let t=Dl(Dl(e[0])?.data);if(t)return t}return jl(e)||null}var Pl=class{textByPart=new Map;sessionId;constructor(e){this.sessionId=e}translate(e){if(!Dl(e))return null;let t=Number(e.seq);if(!Number.isFinite(t)||t<=0)return null;let n=String(e.family||``),r=String(e.event_type||``),i=String(e.run_id||``),a=()=>({EventId:e.event_id?String(e.event_id):`kernel-${t}`,SessionId:this.sessionId,InvocationId:i||void 0,SeqId:t});if(n===`interaction`)return{...a(),EventType:r,payload:e};if(n===`control`){if(r===`control.run_transition`){let t=String(e.state||``).toLowerCase();if(El.has(t))return{...a(),EventType:`run_status`,Content:{status:t}}}return null}if(n!==`runtime`)return null;let o=Tl[r];if(o)return{...a(),EventType:`run_status`,Content:{status:o}};let s=Ol(e);if(r===`item.started`){let t=kl(e,`initial`);return s===`userMessage`||Ml(t)?null:s===`agentMessage`||!s&&e.item_kind===`message`?{...a(),EventType:`assistant_stream_snapshot`,Content:{parts:[{text:``}]}}:s&&s!==`notification`?{...a(),EventType:`tool_call`,Metadata:{call_id:String(e.item_id||``),tool_name:s,run_id:i,tool_args:Nl(t)}}:null}if(r===`item.updated`){let n=kl(e,`snapshot`),r=Dl(n[0]),i=String(r?.part_id||e.item_id||t),o=String(e.op||`replace`),c=jl(n),l=this.textByPart.get(i)||``,u=o===`append`?l+c:c;return this.textByPart.set(i,u),s===`agentMessage`||!s&&e.item_kind===`message`?{...a(),EventType:`assistant_stream_snapshot`,Content:{parts:[{text:u}]}}:s===`reasoning`||e.item_kind===`reasoning`?{...a(),EventType:`reasoning`,Content:{text:u}}:null}if(r===`item.completed`){let n=kl(e,`snapshot`);if(s===`userMessage`||Ml(n))return{...a(),EventType:`user_message`,Content:{parts:[{text:jl(n)}]}};if(s===`agentMessage`||!s&&e.item_kind===`message`){let r=jl(n);return this.textByPart.set(String(Dl(n[0])?.part_id||e.item_id||t),r),{...a(),EventType:`assistant_message`,Content:{parts:[{text:r}]}}}return s===`reasoning`||e.item_kind===`reasoning`?{...a(),EventType:`reasoning`,Content:{text:jl(n)}}:s&&s!==`notification`?{...a(),EventType:`tool_result`,Metadata:{call_id:String(e.item_id||``),tool_name:s,run_id:i,tool_output:Nl(n)}}:null}return null}};async function Fl(e){let t=e.getReader(),n=new TextDecoder,r=``,i=null,a=!1,o=e=>e.includes(`data:`)||e.includes(`event:`)||e.includes(`:`);try{for(;;){let{value:e,done:s}=await t.read();if(e&&(r+=n.decode(e,{stream:!0})),s){a=!0;break}if(r.trimStart().startsWith(`{`)){if(Il(r)){i=Ll(r);break}}else if(o(r))break}}catch{}let s=new TextEncoder().encode(r),c=new ReadableStream({start(e){if(s.length>0&&e.enqueue(s),a||i){e.close();return}let n=()=>t.read().then(({value:t,done:r})=>{if(t&&e.enqueue(t),r){e.close();return}return n()}).catch(()=>{try{e.close()}catch{}});n()},cancel(){t.cancel()}});return{receipt:i,stream:c}}function Il(e){let t=e.trim();if(!t.endsWith(`}`))return!1;let n=0,r=!1,i=!1;for(let e of t){if(i){i=!1;continue}if(e===`\\`){i=!0;continue}e===`"`&&(r=!r),!r&&((e===`{`||e===`[`)&&(n+=1),(e===`}`||e===`]`)&&--n)}return n===0}function Ll(e){try{let t=Dl(JSON.parse(e).Data),n=String(t?.ReceiptStatus||``);if(!n)return null;let r=Dl(t?.Error);return{status:n,messageId:t?.MessageId??null,runId:t?.RunId??null,acceptedSeq:t?.AcceptedSeq??null,error:r?{code:String(r.code||``),message:String(r.message||``)}:null}}catch{return null}}var Rl=[];for(let e=0;e<256;++e)Rl.push((e+256).toString(16).slice(1));function zl(e,t=0){return(Rl[e[t+0]]+Rl[e[t+1]]+Rl[e[t+2]]+Rl[e[t+3]]+`-`+Rl[e[t+4]]+Rl[e[t+5]]+`-`+Rl[e[t+6]]+Rl[e[t+7]]+`-`+Rl[e[t+8]]+Rl[e[t+9]]+`-`+Rl[e[t+10]]+Rl[e[t+11]]+Rl[e[t+12]]+Rl[e[t+13]]+Rl[e[t+14]]+Rl[e[t+15]]).toLowerCase()}var Bl,Vl=new Uint8Array(16);function Hl(){if(!Bl){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);Bl=crypto.getRandomValues.bind(crypto)}return Bl(Vl)}var Ul={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Wl(e,t,n){if(Ul.randomUUID&&!t&&!e)return Ul.randomUUID();e||={};let r=e.random??e.rng?.()??Hl();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 zl(r)}var Gl;(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})(Gl||={});var Kl;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Kl||={});var k=Gl.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),ql=e=>{switch(typeof e){case`undefined`:return k.undefined;case`string`:return k.string;case`number`:return Number.isNaN(e)?k.nan:k.number;case`boolean`:return k.boolean;case`function`:return k.function;case`bigint`:return k.bigint;case`symbol`:return k.symbol;case`object`:return Array.isArray(e)?k.array:e===null?k.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?k.promise:typeof Map<`u`&&e instanceof Map?k.map:typeof Set<`u`&&e instanceof Set?k.set:typeof Date<`u`&&e instanceof Date?k.date:k.object;default:return k.unknown}},A=Gl.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`]),Jl=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,Gl.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()}};Jl.create=e=>new Jl(e);var Yl=(e,t)=>{let n;switch(e.code){case A.invalid_type:n=e.received===k.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case A.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Gl.jsonStringifyReplacer)}`;break;case A.unrecognized_keys:n=`Unrecognized key(s) in object: ${Gl.joinValues(e.keys,`, `)}`;break;case A.invalid_union:n=`Invalid input`;break;case A.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Gl.joinValues(e.options)}`;break;case A.invalid_enum_value:n=`Invalid enum value. Expected ${Gl.joinValues(e.options)}, received '${e.received}'`;break;case A.invalid_arguments:n=`Invalid function arguments`;break;case A.invalid_return_type:n=`Invalid function return type`;break;case A.invalid_date:n=`Invalid date`;break;case A.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}"`:Gl.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case A.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 A.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 A.custom:n=`Invalid input`;break;case A.invalid_intersection_types:n=`Intersection results could not be merged`;break;case A.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case A.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,Gl.assertNever(e)}return{message:n}},Xl=Yl;function Zl(){return Xl}var Ql=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 j(e,t){let n=Zl(),r=Ql({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Yl?void 0:Yl].filter(e=>!!e)});e.common.issues.push(r)}var $l=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 M;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 M;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}}},M=Object.freeze({status:`aborted`}),eu=e=>({status:`dirty`,value:e}),tu=e=>({status:`valid`,value:e}),nu=e=>e.status===`aborted`,ru=e=>e.status===`dirty`,iu=e=>e.status===`valid`,au=e=>typeof Promise<`u`&&e instanceof Promise,ou;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(ou||={});var su=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}},cu=(e,t)=>{if(iu(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 Jl(e.common.issues);return this._error=t,this._error}}};function lu(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 uu=class{get description(){return this._def.description}_getType(e){return ql(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ql(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $l,ctx:{common:e.parent.common,data:e.data,parsedType:ql(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(au(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:ql(e)};return cu(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:ql(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return iu(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=>iu(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:ql(e)},r=this._parse({data:e,path:n.path,parent:n});return cu(n,await(au(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:A.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 pd({schema:this,typeName:Sd.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 md.create(this,this._def)}nullable(){return hd.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ju.create(this)}promise(){return fd.create(this,this._def)}or(e){return Zu.create([this,e],this._def)}and(e){return td.create(this,e,this._def)}transform(e){return new pd({...lu(this._def),schema:this,typeName:Sd.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new gd({...lu(this._def),innerType:this,defaultValue:t,typeName:Sd.ZodDefault})}brand(){return new yd({typeName:Sd.ZodBranded,type:this,...lu(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new _d({...lu(this._def),innerType:this,catchValue:t,typeName:Sd.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return bd.create(this,e)}readonly(){return xd.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},du=/^c[^\s-]{8,}$/i,fu=/^[0-9a-z]+$/,pu=/^[0-9A-HJKMNP-TV-Z]{26}$/i,mu=/^[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,hu=/^[a-z0-9_-]{21}$/i,gu=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_u=/^[-+]?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)?)??$/,vu=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yu=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,bu,xu=/^(?:(?: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])$/,Su=/^(?:(?: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])$/,Cu=/^(([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]))$/,wu=/^(([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])$/,Tu=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Eu=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Du=`((\\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])))`,Ou=RegExp(`^${Du}$`);function ku(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 Au(e){return RegExp(`^${ku(e)}$`)}function ju(e){let t=`${Du}T${ku(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Mu(e,t){return!!((t===`v4`||!t)&&xu.test(e)||(t===`v6`||!t)&&Cu.test(e))}function Nu(e,t){if(!gu.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 Pu(e,t){return!!((t===`v4`||!t)&&Su.test(e)||(t===`v6`||!t)&&wu.test(e))}var Fu=class e extends uu{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==k.string){let t=this._getOrReturnCtx(e);return j(t,{code:A.invalid_type,expected:k.string,received:t.parsedType}),M}let t=new $l,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),j(n,{code:A.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),j(n,{code:A.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?j(n,{code:A.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&j(n,{code:A.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)vu.test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`email`,code:A.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)bu||=new RegExp(yu,`u`),bu.test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`emoji`,code:A.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)mu.test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`uuid`,code:A.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)hu.test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`nanoid`,code:A.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)du.test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`cuid`,code:A.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)fu.test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`cuid2`,code:A.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)pu.test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`ulid`,code:A.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),j(n,{validation:`url`,code:A.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),j(n,{validation:`regex`,code:A.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),j(n,{code:A.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),j(n,{code:A.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),j(n,{code:A.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?ju(r).test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{code:A.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Ou.test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{code:A.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Au(r).test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{code:A.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?_u.test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`duration`,code:A.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Mu(e.data,r.version)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`ip`,code:A.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Nu(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`jwt`,code:A.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?Pu(e.data,r.version)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`cidr`,code:A.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Tu.test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`base64`,code:A.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Eu.test(e.data)||(n=this._getOrReturnCtx(e,n),j(n,{validation:`base64url`,code:A.invalid_string,message:r.message}),t.dirty()):Gl.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:A.invalid_string,...ou.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...ou.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...ou.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...ou.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...ou.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...ou.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...ou.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...ou.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...ou.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...ou.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...ou.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...ou.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...ou.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...ou.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,...ou.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,...ou.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...ou.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...ou.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...ou.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...ou.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...ou.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...ou.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...ou.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...ou.errToObj(t)})}nonempty(e){return this.min(1,ou.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}};Fu.create=e=>new Fu({checks:[],typeName:Sd.ZodString,coerce:e?.coerce??!1,...lu(e)});function Iu(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 Lu=class e extends uu{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)!==k.number){let t=this._getOrReturnCtx(e);return j(t,{code:A.invalid_type,expected:k.number,received:t.parsedType}),M}let t,n=new $l;for(let r of this._def.checks)r.kind===`int`?Gl.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),j(t,{code:A.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),j(t,{code:A.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),j(t,{code:A.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Iu(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),j(t,{code:A.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),j(t,{code:A.not_finite,message:r.message}),n.dirty()):Gl.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,ou.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,ou.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,ou.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,ou.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ou.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:ou.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:ou.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:ou.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:ou.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:ou.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:ou.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:ou.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:ou.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:ou.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`&&Gl.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)}};Lu.create=e=>new Lu({checks:[],typeName:Sd.ZodNumber,coerce:e?.coerce||!1,...lu(e)});var Ru=class e extends uu{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)!==k.bigint)return this._getInvalidInput(e);let t,n=new $l;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),j(t,{code:A.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),j(t,{code:A.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),j(t,{code:A.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Gl.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return j(t,{code:A.invalid_type,expected:k.bigint,received:t.parsedType}),M}gte(e,t){return this.setLimit(`min`,e,!0,ou.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,ou.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,ou.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,ou.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ou.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:ou.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:ou.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:ou.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:ou.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:ou.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}};Ru.create=e=>new Ru({checks:[],typeName:Sd.ZodBigInt,coerce:e?.coerce??!1,...lu(e)});var zu=class extends uu{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==k.boolean){let t=this._getOrReturnCtx(e);return j(t,{code:A.invalid_type,expected:k.boolean,received:t.parsedType}),M}return tu(e.data)}};zu.create=e=>new zu({typeName:Sd.ZodBoolean,coerce:e?.coerce||!1,...lu(e)});var Bu=class e extends uu{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==k.date){let t=this._getOrReturnCtx(e);return j(t,{code:A.invalid_type,expected:k.date,received:t.parsedType}),M}if(Number.isNaN(e.data.getTime()))return j(this._getOrReturnCtx(e),{code:A.invalid_date}),M;let t=new $l,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),j(n,{code:A.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),j(n,{code:A.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):Gl.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:ou.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:ou.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)}};Bu.create=e=>new Bu({checks:[],coerce:e?.coerce||!1,typeName:Sd.ZodDate,...lu(e)});var Vu=class extends uu{_parse(e){if(this._getType(e)!==k.symbol){let t=this._getOrReturnCtx(e);return j(t,{code:A.invalid_type,expected:k.symbol,received:t.parsedType}),M}return tu(e.data)}};Vu.create=e=>new Vu({typeName:Sd.ZodSymbol,...lu(e)});var Hu=class extends uu{_parse(e){if(this._getType(e)!==k.undefined){let t=this._getOrReturnCtx(e);return j(t,{code:A.invalid_type,expected:k.undefined,received:t.parsedType}),M}return tu(e.data)}};Hu.create=e=>new Hu({typeName:Sd.ZodUndefined,...lu(e)});var Uu=class extends uu{_parse(e){if(this._getType(e)!==k.null){let t=this._getOrReturnCtx(e);return j(t,{code:A.invalid_type,expected:k.null,received:t.parsedType}),M}return tu(e.data)}};Uu.create=e=>new Uu({typeName:Sd.ZodNull,...lu(e)});var Wu=class extends uu{constructor(){super(...arguments),this._any=!0}_parse(e){return tu(e.data)}};Wu.create=e=>new Wu({typeName:Sd.ZodAny,...lu(e)});var Gu=class extends uu{constructor(){super(...arguments),this._unknown=!0}_parse(e){return tu(e.data)}};Gu.create=e=>new Gu({typeName:Sd.ZodUnknown,...lu(e)});var Ku=class extends uu{_parse(e){let t=this._getOrReturnCtx(e);return j(t,{code:A.invalid_type,expected:k.never,received:t.parsedType}),M}};Ku.create=e=>new Ku({typeName:Sd.ZodNever,...lu(e)});var qu=class extends uu{_parse(e){if(this._getType(e)!==k.undefined){let t=this._getOrReturnCtx(e);return j(t,{code:A.invalid_type,expected:k.void,received:t.parsedType}),M}return tu(e.data)}};qu.create=e=>new qu({typeName:Sd.ZodVoid,...lu(e)});var Ju=class e extends uu{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==k.array)return j(t,{code:A.invalid_type,expected:k.array,received:t.parsedType}),M;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(j(t,{code:e?A.too_big:A.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&&(j(t,{code:A.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&&(j(t,{code:A.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 su(t,e,t.path,n)))).then(e=>$l.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new su(t,e,t.path,n)));return $l.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:ou.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:ou.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:ou.toString(n)}})}nonempty(e){return this.min(1,e)}};Ju.create=(e,t)=>new Ju({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Sd.ZodArray,...lu(t)});function Yu(e){if(e instanceof Xu){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=md.create(Yu(r))}return new Xu({...e._def,shape:()=>t})}else if(e instanceof Ju)return new Ju({...e._def,type:Yu(e.element)});else if(e instanceof md)return md.create(Yu(e.unwrap()));else if(e instanceof hd)return hd.create(Yu(e.unwrap()));else if(e instanceof nd)return nd.create(e.items.map(e=>Yu(e)));else return e}var Xu=class e extends uu{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=Gl.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==k.object){let t=this._getOrReturnCtx(e);return j(t,{code:A.invalid_type,expected:k.object,received:t.parsedType}),M}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ku&&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 su(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Ku){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&&(j(n,{code:A.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 su(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=>$l.mergeObjectSync(t,e)):$l.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return ou.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:ou.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:Sd.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 Gl.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 Gl.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Yu(this)}partial(t){let n={};for(let e of Gl.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 Gl.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof md;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return ld(Gl.objectKeys(this.shape))}};Xu.create=(e,t)=>new Xu({shape:()=>e,unknownKeys:`strip`,catchall:Ku.create(),typeName:Sd.ZodObject,...lu(t)}),Xu.strictCreate=(e,t)=>new Xu({shape:()=>e,unknownKeys:`strict`,catchall:Ku.create(),typeName:Sd.ZodObject,...lu(t)}),Xu.lazycreate=(e,t)=>new Xu({shape:e,unknownKeys:`strip`,catchall:Ku.create(),typeName:Sd.ZodObject,...lu(t)});var Zu=class extends uu{_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 Jl(e.ctx.common.issues));return j(t,{code:A.invalid_union,unionErrors:n}),M}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 Jl(e));return j(t,{code:A.invalid_union,unionErrors:i}),M}}get options(){return this._def.options}};Zu.create=(e,t)=>new Zu({options:e,typeName:Sd.ZodUnion,...lu(t)});var Qu=e=>e instanceof sd?Qu(e.schema):e instanceof pd?Qu(e.innerType()):e instanceof cd?[e.value]:e instanceof ud?e.options:e instanceof dd?Gl.objectValues(e.enum):e instanceof gd?Qu(e._def.innerType):e instanceof Hu?[void 0]:e instanceof Uu?[null]:e instanceof md?[void 0,...Qu(e.unwrap())]:e instanceof hd?[null,...Qu(e.unwrap())]:e instanceof yd||e instanceof xd?Qu(e.unwrap()):e instanceof _d?Qu(e._def.innerType):[],$u=class e extends uu{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.object)return j(t,{code:A.invalid_type,expected:k.object,received:t.parsedType}),M;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}):(j(t,{code:A.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),M)}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=Qu(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:Sd.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...lu(r)})}};function ed(e,t){let n=ql(e),r=ql(t);if(e===t)return{valid:!0,data:e};if(n===k.object&&r===k.object){let n=Gl.objectKeys(t),r=Gl.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=ed(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===k.array&&r===k.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=ed(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===k.date&&r===k.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var td=class extends uu{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(nu(e)||nu(r))return M;let i=ed(e.value,r.value);return i.valid?((ru(e)||ru(r))&&t.dirty(),{status:t.value,value:i.data}):(j(n,{code:A.invalid_intersection_types}),M)};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}))}};td.create=(e,t,n)=>new td({left:e,right:t,typeName:Sd.ZodIntersection,...lu(n)});var nd=class e extends uu{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==k.array)return j(n,{code:A.invalid_type,expected:k.array,received:n.parsedType}),M;if(n.data.length<this._def.items.length)return j(n,{code:A.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),M;!this._def.rest&&n.data.length>this._def.items.length&&(j(n,{code:A.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 su(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>$l.mergeArray(t,e)):$l.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};nd.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new nd({items:e,typeName:Sd.ZodTuple,rest:null,...lu(t)})};var rd=class e extends uu{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!==k.object)return j(n,{code:A.invalid_type,expected:k.object,received:n.parsedType}),M;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new su(n,e,n.path,e)),value:a._parse(new su(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?$l.mergeObjectAsync(t,r):$l.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof uu?new e({keyType:t,valueType:n,typeName:Sd.ZodRecord,...lu(r)}):new e({keyType:Fu.create(),valueType:t,typeName:Sd.ZodRecord,...lu(n)})}},id=class extends uu{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!==k.map)return j(n,{code:A.invalid_type,expected:k.map,received:n.parsedType}),M;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new su(n,e,n.path,[a,`key`])),value:i._parse(new su(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 M;(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 M;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};id.create=(e,t,n)=>new id({valueType:t,keyType:e,typeName:Sd.ZodMap,...lu(n)});var ad=class e extends uu{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==k.set)return j(n,{code:A.invalid_type,expected:k.set,received:n.parsedType}),M;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(j(n,{code:A.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&&(j(n,{code:A.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 M;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 su(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:ou.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:ou.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};ad.create=(e,t)=>new ad({valueType:e,minSize:null,maxSize:null,typeName:Sd.ZodSet,...lu(t)});var od=class e extends uu{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.function)return j(t,{code:A.invalid_type,expected:k.function,received:t.parsedType}),M;function n(e,n){return Ql({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Zl(),Yl].filter(e=>!!e),issueData:{code:A.invalid_arguments,argumentsError:n}})}function r(e,n){return Ql({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Zl(),Yl].filter(e=>!!e),issueData:{code:A.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof fd){let e=this;return tu(async function(...t){let o=new Jl([]),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 tu(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Jl([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Jl([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:nd.create(t).rest(Gu.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||nd.create([]).rest(Gu.create()),returns:n||Gu.create(),typeName:Sd.ZodFunction,...lu(r)})}},sd=class extends uu{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})}};sd.create=(e,t)=>new sd({getter:e,typeName:Sd.ZodLazy,...lu(t)});var cd=class extends uu{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return j(t,{received:t.data,code:A.invalid_literal,expected:this._def.value}),M}return{status:`valid`,value:e.data}}get value(){return this._def.value}};cd.create=(e,t)=>new cd({value:e,typeName:Sd.ZodLiteral,...lu(t)});function ld(e,t){return new ud({values:e,typeName:Sd.ZodEnum,...lu(t)})}var ud=class e extends uu{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return j(t,{expected:Gl.joinValues(n),received:t.parsedType,code:A.invalid_type}),M}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return j(t,{received:t.data,code:A.invalid_enum_value,options:n}),M}return tu(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})}};ud.create=ld;var dd=class extends uu{_parse(e){let t=Gl.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==k.string&&n.parsedType!==k.number){let e=Gl.objectValues(t);return j(n,{expected:Gl.joinValues(e),received:n.parsedType,code:A.invalid_type}),M}if(this._cache||=new Set(Gl.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=Gl.objectValues(t);return j(n,{received:n.data,code:A.invalid_enum_value,options:e}),M}return tu(e.data)}get enum(){return this._def.values}};dd.create=(e,t)=>new dd({values:e,typeName:Sd.ZodNativeEnum,...lu(t)});var fd=class extends uu{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==k.promise&&t.common.async===!1?(j(t,{code:A.invalid_type,expected:k.promise,received:t.parsedType}),M):tu((t.parsedType===k.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};fd.create=(e,t)=>new fd({type:e,typeName:Sd.ZodPromise,...lu(t)});var pd=class extends uu{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Sd.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=>{j(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 M;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?M:r.status===`dirty`||t.value===`dirty`?eu(r.value):r});{if(t.value===`aborted`)return M;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?M:r.status===`dirty`||t.value===`dirty`?eu(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`?M:(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`?M:(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(!iu(e))return M;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=>iu(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):M);Gl.assertNever(r)}};pd.create=(e,t,n)=>new pd({schema:e,typeName:Sd.ZodEffects,effect:t,...lu(n)}),pd.createWithPreprocess=(e,t,n)=>new pd({schema:t,effect:{type:`preprocess`,transform:e},typeName:Sd.ZodEffects,...lu(n)});var md=class extends uu{_parse(e){return this._getType(e)===k.undefined?tu(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};md.create=(e,t)=>new md({innerType:e,typeName:Sd.ZodOptional,...lu(t)});var hd=class extends uu{_parse(e){return this._getType(e)===k.null?tu(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};hd.create=(e,t)=>new hd({innerType:e,typeName:Sd.ZodNullable,...lu(t)});var gd=class extends uu{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===k.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};gd.create=(e,t)=>new gd({innerType:e,typeName:Sd.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...lu(t)});var _d=class extends uu{_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 au(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Jl(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Jl(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};_d.create=(e,t)=>new _d({innerType:e,typeName:Sd.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...lu(t)});var vd=class extends uu{_parse(e){if(this._getType(e)!==k.nan){let t=this._getOrReturnCtx(e);return j(t,{code:A.invalid_type,expected:k.nan,received:t.parsedType}),M}return{status:`valid`,value:e.data}}};vd.create=e=>new vd({typeName:Sd.ZodNaN,...lu(e)});var yd=class extends uu{_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}},bd=class e extends uu{_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`?M:e.status===`dirty`?(t.dirty(),eu(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`?M: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:Sd.ZodPipeline})}},xd=class extends uu{_parse(e){let t=this._def.innerType._parse(e),n=e=>(iu(e)&&(e.value=Object.freeze(e.value)),e);return au(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};xd.create=(e,t)=>new xd({innerType:e,typeName:Sd.ZodReadonly,...lu(t)}),Xu.lazycreate;var Sd;(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`})(Sd||={});var N=Fu.create,Cd=Lu.create;vd.create,Ru.create;var wd=zu.create;Bu.create,Vu.create,Hu.create,Uu.create;var Td=Wu.create,Ed=Gu.create;Ku.create,qu.create;var Dd=Ju.create,Od=Xu.create;Xu.strictCreate;var kd=Zu.create,Ad=$u.create;td.create,nd.create;var jd=rd.create;id.create,ad.create,od.create,sd.create;var Md=cd.create,Nd=ud.create,Pd=dd.create;fd.create,pd.create,md.create,hd.create,pd.createWithPreprocess,bd.create;var Fd=Od({name:N(),arguments:N()}),Id=Od({id:N(),type:Md(`function`),function:Fd,encryptedValue:N().optional()}),Ld=Od({id:N(),role:N(),content:N().optional(),name:N().optional(),encryptedValue:N().optional()}),Rd=Od({type:Md(`text`),text:N()}),zd=Ad(`type`,[Od({type:Md(`data`),value:N(),mimeType:N()}),Od({type:Md(`url`),value:N(),mimeType:N().optional()})]),Bd=Od({type:Md(`image`),source:zd,metadata:Ed().optional()}),Vd=Od({type:Md(`audio`),source:zd,metadata:Ed().optional()}),Hd=Od({type:Md(`video`),source:zd,metadata:Ed().optional()}),Ud=Od({type:Md(`document`),source:zd,metadata:Ed().optional()}),Wd=Od({type:Md(`binary`),mimeType:N(),id:N().optional(),url:N().optional(),data:N().optional(),filename:N().optional()}),Gd=(e,t)=>{!e.id&&!e.url&&!e.data&&t.addIssue({code:A.custom,message:`BinaryInputContent requires at least one of id, url, or data.`,path:[`id`]})};Wd.superRefine((e,t)=>{Gd(e,t)});var Kd=Ad(`type`,[Rd,Bd,Vd,Hd,Ud,Wd]).superRefine((e,t)=>{e.type===`binary`&&Gd(e,t)}),qd=Ad(`role`,[Ld.extend({role:Md(`developer`),content:N()}),Ld.extend({role:Md(`system`),content:N()}),Ld.extend({role:Md(`assistant`),content:N().optional(),toolCalls:Dd(Id).optional()}),Ld.extend({role:Md(`user`),content:kd([N(),Dd(Kd)])}),Od({id:N(),content:N(),role:Md(`tool`),toolCallId:N(),error:N().optional(),encryptedValue:N().optional()}),Od({id:N(),role:Md(`activity`),activityType:N(),content:jd(Td())}),Od({id:N(),role:Md(`reasoning`),content:N(),encryptedValue:N().optional()})]);kd([Md(`developer`),Md(`system`),Md(`assistant`),Md(`user`),Md(`tool`),Md(`activity`),Md(`reasoning`)]);var Jd=Od({description:N(),value:N()}),Yd=Od({name:N(),description:N(),parameters:Td(),metadata:jd(Td()).optional()}),Xd=Od({id:N(),reason:N(),message:N().optional(),toolCallId:N().optional(),responseSchema:jd(Td()).optional(),expiresAt:N().optional(),metadata:jd(Td()).optional()}),Zd=Od({interruptId:N(),status:Nd([`resolved`,`cancelled`]),payload:Td().optional()}),Qd=Od({threadId:N(),runId:N(),parentRunId:N().optional(),state:Td(),messages:Dd(qd),tools:Dd(Yd),context:Dd(Jd),forwardedProps:Td(),resume:Dd(Zd).optional()}),$d=Td(),ef=class extends Error{constructor(e){super(e)}},tf=class extends ef{constructor(){super(`Connect not implemented. This method is not supported by the current agent.`)}},nf=Od({name:N(),description:N().optional()}),rf=Od({name:N().optional(),type:N().optional(),description:N().optional(),version:N().optional(),provider:N().optional(),documentationUrl:N().optional(),metadata:jd(Ed()).optional()}),af=Od({streaming:wd().optional(),websocket:wd().optional(),httpBinary:wd().optional(),pushNotifications:wd().optional(),resumable:wd().optional()}),of=Od({supported:wd().optional(),items:Dd(Yd).optional(),parallelCalls:wd().optional(),clientProvided:wd().optional()}),sf=Od({structuredOutput:wd().optional(),supportedMimeTypes:Dd(N()).optional()}),cf=Od({snapshots:wd().optional(),deltas:wd().optional(),memory:wd().optional(),persistentState:wd().optional()}),lf=Od({supported:wd().optional(),delegation:wd().optional(),handoffs:wd().optional(),subAgents:Dd(nf).optional()}),uf=Od({supported:wd().optional(),streaming:wd().optional(),encrypted:wd().optional()}),df=Od({image:wd().optional(),audio:wd().optional(),video:wd().optional(),pdf:wd().optional(),file:wd().optional()}),ff=Od({image:wd().optional(),audio:wd().optional()}),pf=Od({input:df.optional(),output:ff.optional()}),mf=Od({codeExecution:wd().optional(),sandboxed:wd().optional(),maxIterations:Cd().optional(),maxExecutionTime:Cd().optional()}),hf=Od({supported:wd().optional(),approvals:wd().optional(),interventions:wd().optional(),feedback:wd().optional(),interrupts:wd().optional(),approveWithEdits:wd().optional()});Od({identity:rf.optional(),transport:af.optional(),tools:of.optional(),output:sf.optional(),state:cf.optional(),multiAgent:lf.optional(),reasoning:uf.optional(),multimodal:pf.optional(),execution:mf.optional(),humanInTheLoop:hf.optional(),custom:jd(Ed()).optional()});var gf=kd([Md(`developer`),Md(`system`),Md(`assistant`),Md(`user`)]),P=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}({}),_f=Od({type:Pd(P),timestamp:Cd().optional(),rawEvent:Td().optional()}).passthrough(),vf=_f.extend({type:Md(P.TEXT_MESSAGE_START),messageId:N(),role:gf.default(`assistant`),name:N().optional()}),yf=_f.extend({type:Md(P.TEXT_MESSAGE_CONTENT),messageId:N(),delta:N()}),bf=_f.extend({type:Md(P.TEXT_MESSAGE_END),messageId:N()}),xf=_f.extend({type:Md(P.TEXT_MESSAGE_CHUNK),messageId:N().optional(),role:gf.optional(),delta:N().optional(),name:N().optional()}),Sf=_f.extend({type:Md(P.THINKING_TEXT_MESSAGE_START)}),Cf=yf.omit({messageId:!0,type:!0}).extend({type:Md(P.THINKING_TEXT_MESSAGE_CONTENT)}),wf=_f.extend({type:Md(P.THINKING_TEXT_MESSAGE_END)}),Tf=_f.extend({type:Md(P.TOOL_CALL_START),toolCallId:N(),toolCallName:N(),parentMessageId:N().optional()}),Ef=_f.extend({type:Md(P.TOOL_CALL_ARGS),toolCallId:N(),delta:N()}),Df=_f.extend({type:Md(P.TOOL_CALL_END),toolCallId:N()}),Of=_f.extend({messageId:N(),type:Md(P.TOOL_CALL_RESULT),toolCallId:N(),content:N(),role:Md(`tool`).optional()}),kf=_f.extend({type:Md(P.TOOL_CALL_CHUNK),toolCallId:N().optional(),toolCallName:N().optional(),parentMessageId:N().optional(),delta:N().optional()}),Af=_f.extend({type:Md(P.THINKING_START),title:N().optional()}),jf=_f.extend({type:Md(P.THINKING_END)}),Mf=_f.extend({type:Md(P.STATE_SNAPSHOT),snapshot:$d}),Nf=_f.extend({type:Md(P.STATE_DELTA),delta:Dd(Td())}),Pf=_f.extend({type:Md(P.MESSAGES_SNAPSHOT),messages:Dd(qd)}),Ff=_f.extend({type:Md(P.ACTIVITY_SNAPSHOT),messageId:N(),activityType:N(),content:jd(Td()),replace:wd().optional().default(!0)}),If=_f.extend({type:Md(P.ACTIVITY_DELTA),messageId:N(),activityType:N(),patch:Dd(Td())}),Lf=_f.extend({type:Md(P.RAW),event:Td(),source:N().optional()}),Rf=_f.extend({type:Md(P.CUSTOM),name:N(),value:Td()}),zf=_f.extend({type:Md(P.RUN_STARTED),threadId:N(),runId:N(),parentRunId:N().optional(),input:Qd.optional()}),Bf=Ad(`type`,[Od({type:Md(`success`)}).strict(),Od({type:Md(`interrupt`),interrupts:Dd(Xd).min(1)}).strict()]),Vf=_f.extend({type:Md(P.RUN_FINISHED),threadId:N(),runId:N(),result:Td().optional(),outcome:Bf.nullable().optional().transform(e=>e??void 0)}),Hf=_f.extend({type:Md(P.RUN_ERROR),message:N(),code:N().optional()}),Uf=_f.extend({type:Md(P.STEP_STARTED),stepName:N()}),Wf=_f.extend({type:Md(P.STEP_FINISHED),stepName:N()}),Gf=kd([Md(`tool-call`),Md(`message`)]),Kf=Ad(`type`,[vf,yf,bf,xf,Af,jf,Sf,Cf,wf,Tf,Ef,Df,kf,Of,Mf,Nf,Pf,Ff,If,Lf,Rf,zf,Vf,Hf,Uf,Wf,_f.extend({type:Md(P.REASONING_START),messageId:N()}),_f.extend({type:Md(P.REASONING_MESSAGE_START),messageId:N(),role:Md(`reasoning`)}),_f.extend({type:Md(P.REASONING_MESSAGE_CONTENT),messageId:N(),delta:N()}),_f.extend({type:Md(P.REASONING_MESSAGE_END),messageId:N()}),_f.extend({type:Md(P.REASONING_MESSAGE_CHUNK),messageId:N().optional(),delta:N().optional()}),_f.extend({type:Md(P.REASONING_END),messageId:N()}),_f.extend({type:Md(P.REASONING_ENCRYPTED_VALUE),subtype:Gf,entityId:N(),encryptedValue:N()})]),qf=(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)}})(),Jf=Object.prototype.hasOwnProperty;function Yf(e,t){return Jf.call(e,t)}function Xf(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)Yf(e,i)&&r.push(i);return r}function Zf(e){switch(typeof e){case`object`:return JSON.parse(JSON.stringify(e));case`undefined`:return null;default:return e}}function Qf(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 $f(e){return e.indexOf(`/`)===-1&&e.indexOf(`~`)===-1?e:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function ep(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function tp(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t<n;t++)if(tp(e[t]))return!0}else if(typeof e==`object`){for(var r=Xf(e),i=r.length,a=0;a<i;a++)if(tp(e[r[a]]))return!0}}return!1}function np(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(`
|
|
78
|
-
`)}var rp=function(e){qf(t,e);function t(t,n,r,i,a){var o=this.constructor,s=e.call(this,np(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=np(t,{name:n,index:r,operation:i,tree:a}),s}return t}(Error),ip=s({JsonPatchError:()=>ap,_areEquals:()=>hp,applyOperation:()=>up,applyPatch:()=>dp,applyReducer:()=>fp,deepClone:()=>op,getValueByPointer:()=>lp,validate:()=>mp,validator:()=>pp}),ap=rp,op=Zf,sp={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=lp(n,this.path);r&&=Zf(r);var i=up(n,{op:`remove`,path:this.from}).removed;return up(n,{op:`add`,path:this.path,value:i}),{newDocument:n,removed:r}},copy:function(e,t,n){var r=lp(n,this.from);return up(n,{op:`add`,path:this.path,value:Zf(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:hp(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},cp={add:function(e,t,n){return Qf(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:sp.move,copy:sp.copy,test:sp.test,_get:sp._get};function lp(e,t){if(t==``)return e;var n={op:`_get`,path:t};return up(e,n),n.value}function up(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):pp(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=lp(e,t.from),t.op===`move`&&(o.removed=e),o;if(t.op===`test`){if(o.test=hp(e,t.value),o.test===!1)throw new ap(`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 ap("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,a,t,e);else return o}else{r||(e=Zf(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:pp;;){if(f=s[l],f&&f.indexOf(`~`)!=-1&&(f=ep(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&&!Qf(f))throw new ap(`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 Qf(f)&&(f=~~f);if(l>=u){if(n&&t.op===`add`&&f>c.length)throw new ap(`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=cp[t.op].call(t,c,f,e);if(o.test===!1)throw new ap(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}}else if(l>=u){var o=sp[t.op].call(t,c,f,e);if(o.test===!1)throw new ap(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}if(c=c[f],n&&l<u&&(!c||typeof c!=`object`))throw new ap(`Cannot perform operation at the desired path`,`OPERATION_PATH_UNRESOLVABLE`,a,t,e)}}}function dp(e,t,n,r,i){if(r===void 0&&(r=!0),i===void 0&&(i=!0),n&&!Array.isArray(t))throw new ap(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);r||(e=Zf(e));for(var a=Array(t.length),o=0,s=t.length;o<s;o++)a[o]=up(e,t[o],n,!0,i,o),e=a[o].newDocument;return a.newDocument=e,a}function fp(e,t,n){var r=up(e,t);if(r.test===!1)throw new ap(`Test operation failed`,`TEST_OPERATION_FAILED`,n,t,e);return r.newDocument}function pp(e,t,n,r){if(typeof e!=`object`||!e||Array.isArray(e))throw new ap(`Operation is not an object`,`OPERATION_NOT_AN_OBJECT`,t,e,n);if(!sp[e.op])throw new ap("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 ap("Operation `path` property is not a string",`OPERATION_PATH_INVALID`,t,e,n);if(e.path.indexOf(`/`)!==0&&e.path.length>0)throw new ap('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 ap("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 ap("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`)&&tp(e.value))throw new ap("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 ap("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 ap(`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=mp([{op:`_get`,path:e.from,value:void 0}],n);if(o&&o.name===`OPERATION_PATH_UNRESOLVABLE`)throw new ap(`Cannot perform the operation from a path that does not exist`,`OPERATION_FROM_UNRESOLVABLE`,t,e,n)}}}function mp(e,t,n){try{if(!Array.isArray(e))throw new ap(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);if(t)dp(Zf(t),Zf(e),n||!0);else{n||=pp;for(var r=0;r<e.length;r++)n(e[r],r,t,void 0)}}catch(e){if(e instanceof ap)return e;throw e}}function hp(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(!hp(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],!hp(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}var gp=s({compare:()=>Dp,generate:()=>Tp,observe:()=>wp,unobserve:()=>Cp}),_p=new WeakMap,vp=function(){function e(e){this.observers=new Map,this.obj=e}return e}(),yp=function(){function e(e,t){this.callback=e,this.observer=t}return e}();function bp(e){return _p.get(e)}function xp(e,t){return e.observers.get(t)}function Sp(e,t){e.observers.delete(t.callback)}function Cp(e,t){t.unobserve()}function wp(e,t){var n=[],r,i=bp(e);if(!i)i=new vp(e),_p.set(e,i);else{var a=xp(i,t);r=a&&a.observer}if(r)return r;if(r={},i.value=Zf(e),t){r.callback=t,r.next=null;var o=function(){Tp(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(){Tp(r),clearTimeout(r.next),Sp(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 yp(t,r)),r}function Tp(e,t){t===void 0&&(t=!1);var n=_p.get(e.object);Ep(n.value,e.object,e.patches,``,t),e.patches.length&&dp(n.value,e.patches);var r=e.patches;return r.length>0&&(e.patches=[],e.callback&&e.callback(r)),r}function Ep(e,t,n,r,i){if(t!==e){typeof t.toJSON==`function`&&(t=t.toJSON());for(var a=Xf(t),o=Xf(e),s=!1,c=o.length-1;c>=0;c--){var l=o[c],u=e[l];if(Yf(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)?Ep(u,d,n,r+`/`+$f(l),i):u!==d&&(i&&n.push({op:`test`,path:r+`/`+$f(l),value:Zf(u)}),n.push({op:`replace`,path:r+`/`+$f(l),value:Zf(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&n.push({op:`test`,path:r+`/`+$f(l),value:Zf(u)}),n.push({op:`remove`,path:r+`/`+$f(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];!Yf(e,l)&&t[l]!==void 0&&n.push({op:`add`,path:r+`/`+$f(l),value:Zf(t[l])})}}}function Dp(e,t,n){n===void 0&&(n=!1);var r=[];return Ep(e,t,r,``,n),r}var Op=Object.assign({},ip,gp,{JsonPatchError:rp,deepClone:Zf,escapePathComponent:$f,unescapePathComponent:ep}),kp=function(e,t){return kp=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])},kp(e,t)};function Ap(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);kp(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var jp=function(){return jp=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},jp.apply(this,arguments)};function Mp(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 Np(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 Pp(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 Fp(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 Ip(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 Lp(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 Rp(e){return this instanceof Rp?(this.v=e,this):new Rp(e)}function zp(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 Rp?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 Bp(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Fp==`function`?Fp(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 Vp(e){return typeof e==`function`}function Hp(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 Up=Hp(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
79
|
-
`+t.map(function(e,t){return t+1+`) `+e.toString()}).join(`
|
|
80
|
-
`):``,this.name=`UnsubscriptionError`,this.errors=t}});function Wp(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Gp=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=Fp(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(Vp(c))try{c()}catch(e){i=e instanceof Up?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var u=Fp(l),d=u.next();!d.done;d=u.next()){var f=d.value;try{Jp(f)}catch(e){i??=[],e instanceof Up?i=Lp(Lp([],Ip(i)),Ip(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 Up(i)}},e.prototype.add=function(t){if(t&&t!==this)if(this.closed)Jp(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)&&Wp(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&Wp(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e}(),Kp=Gp.EMPTY;function qp(e){return e instanceof Gp||e&&`closed`in e&&Vp(e.remove)&&Vp(e.add)&&Vp(e.unsubscribe)}function Jp(e){Vp(e)?e():e.unsubscribe()}var Yp={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Xp={setTimeout:function(e,t){var n=[...arguments].slice(2),r=Xp.delegate;return r?.setTimeout?r.setTimeout.apply(r,Lp([e,t],Ip(n))):setTimeout.apply(void 0,Lp([e,t],Ip(n)))},clearTimeout:function(e){return(Xp.delegate?.clearTimeout||clearTimeout)(e)},delegate:void 0};function Zp(e){Xp.setTimeout(function(){var t=Yp.onUnhandledError;if(t)t(e);else throw e})}function Qp(){}var $p=(function(){return nm(`C`,void 0,void 0)})();function em(e){return nm(`E`,void 0,e)}function tm(e){return nm(`N`,e,void 0)}function nm(e,t,n){return{kind:e,value:t,error:n}}var rm=null;function im(e){if(Yp.useDeprecatedSynchronousErrorHandling){var t=!rm;if(t&&(rm={errorThrown:!1,error:null}),e(),t){var n=rm,r=n.errorThrown,i=n.error;if(rm=null,r)throw i}}else e()}function am(e){Yp.useDeprecatedSynchronousErrorHandling&&rm&&(rm.errorThrown=!0,rm.error=e)}var om=function(e){Ap(t,e);function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,qp(t)&&t.add(n)):n.destination=nee,n}return t.create=function(e,t,n){return new cm(e,t,n)},t.prototype.next=function(e){this.isStopped?dm(tm(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?dm(em(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?dm($p,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}(Gp),eee=Function.prototype.bind;function sm(e,t){return eee.call(e,t)}var tee=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){lm(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){lm(e)}else lm(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){lm(e)}},e}(),cm=function(e){Ap(t,e);function t(t,n,r){var i=e.call(this)||this,a;if(Vp(t)||!t)a={next:t??void 0,error:n??void 0,complete:r??void 0};else{var o;i&&Yp.useDeprecatedNextContext?(o=Object.create(t),o.unsubscribe=function(){return i.unsubscribe()},a={next:t.next&&sm(t.next,o),error:t.error&&sm(t.error,o),complete:t.complete&&sm(t.complete,o)}):a=t}return i.destination=new tee(a),i}return t}(om);function lm(e){Yp.useDeprecatedSynchronousErrorHandling?am(e):Zp(e)}function um(e){throw e}function dm(e,t){var n=Yp.onStoppedNotification;n&&Xp.setTimeout(function(){return n(e,t)})}var nee={closed:!0,next:Qp,error:um,complete:Qp},fm=(function(){return typeof Symbol==`function`&&Symbol.observable||`@@observable`})();function pm(e){return e}function mm(){return hm([...arguments])}function hm(e){return e.length===0?pm:e.length===1?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)}}var gm=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=iee(e)?e:new cm(e,t,n);return im(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=_m(t),new t(function(t,r){var i=new cm({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[fm]=function(){return this},e.prototype.pipe=function(){return hm([...arguments])(this)},e.prototype.toPromise=function(e){var t=this;return e=_m(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 _m(e){return e??Yp.Promise??Promise}function ree(e){return e&&Vp(e.next)&&Vp(e.error)&&Vp(e.complete)}function iee(e){return e&&e instanceof om||ree(e)&&qp(e)}function vm(e){return Vp(e?.lift)}function ym(e){return function(t){if(vm(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 bm(e,t,n,r,i){return new xm(e,t,n,r,i)}var xm=function(e){Ap(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}(om),Sm=Hp(function(e){return function(){e(this),this.name=`ObjectUnsubscribedError`,this.message=`object unsubscribed`}}),Cm=function(e){Ap(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 wm(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new Sm},t.prototype.next=function(e){var t=this;im(function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||=Array.from(t.observers);try{for(var i=Fp(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;im(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;im(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?Kp:(this.currentObservers=null,a.push(e),new Gp(function(){t.currentObservers=null,Wp(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 gm;return e.source=this,e},t.create=function(e,t){return new wm(e,t)},t}(gm),wm=function(e){Ap(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)??Kp},t}(Cm),Tm={now:function(){return(Tm.delegate||Date).now()},delegate:void 0},Em=function(e){Ap(t,e);function t(t,n,r){t===void 0&&(t=1/0),n===void 0&&(n=1/0),r===void 0&&(r=Tm);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}(Cm),Dm=new gm(function(e){return e.complete()});function Om(e){return e&&Vp(e.schedule)}function km(e){return e[e.length-1]}function Am(e){return Om(km(e))?e.pop():void 0}var jm=(function(e){return e&&typeof e.length==`number`&&typeof e!=`function`});function Mm(e){return Vp(e?.then)}function Nm(e){return Vp(e[fm])}function Pm(e){return Symbol.asyncIterator&&Vp(e?.[Symbol.asyncIterator])}function Fm(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 Im(){return typeof Symbol!=`function`||!Symbol.iterator?`@@iterator`:Symbol.iterator}var Lm=Im();function Rm(e){return Vp(e?.[Lm])}function zm(e){return zp(this,arguments,function(){var t,n,r,i;return Pp(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,Rp(t.read())];case 3:return n=a.sent(),r=n.value,i=n.done,i?[4,Rp(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,Rp(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 Bm(e){return Vp(e?.getReader)}function Vm(e){if(e instanceof gm)return e;if(e!=null){if(Nm(e))return Hm(e);if(jm(e))return Um(e);if(Mm(e))return Wm(e);if(Pm(e))return Km(e);if(Rm(e))return Gm(e);if(Bm(e))return qm(e)}throw Fm(e)}function Hm(e){return new gm(function(t){var n=e[fm]();if(Vp(n.subscribe))return n.subscribe(t);throw TypeError(`Provided object does not correctly implement Symbol.observable`)})}function Um(e){return new gm(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function Wm(e){return new gm(function(t){e.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,Zp)})}function Gm(e){return new gm(function(t){var n,r;try{for(var i=Fp(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 Km(e){return new gm(function(t){Jm(e,t).catch(function(e){return t.error(e)})})}function qm(e){return Km(zm(e))}function Jm(e,t){var n,r,i,a;return Np(this,void 0,void 0,function(){var o,s;return Pp(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=Bp(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 Ym(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 Xm(e,t){return t===void 0&&(t=0),ym(function(n,r){n.subscribe(bm(r,function(n){return Ym(r,e,function(){return r.next(n)},t)},function(){return Ym(r,e,function(){return r.complete()},t)},function(n){return Ym(r,e,function(){return r.error(n)},t)}))})}function Zm(e,t){return t===void 0&&(t=0),ym(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Qm(e,t){return Vm(e).pipe(Zm(t),Xm(t))}function $m(e,t){return Vm(e).pipe(Zm(t),Xm(t))}function eh(e,t){return new gm(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function th(e,t){return new gm(function(n){var r;return Ym(n,t,function(){r=e[Lm](),Ym(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 Vp(r?.return)&&r.return()}})}function nh(e,t){if(!e)throw Error(`Iterable cannot be null`);return new gm(function(n){Ym(n,t,function(){var r=e[Symbol.asyncIterator]();Ym(n,t,function(){r.next().then(function(e){e.done?n.complete():n.next(e.value)})},0,!0)})})}function rh(e,t){return nh(zm(e),t)}function ih(e,t){if(e!=null){if(Nm(e))return Qm(e,t);if(jm(e))return eh(e,t);if(Mm(e))return $m(e,t);if(Pm(e))return nh(e,t);if(Rm(e))return th(e,t);if(Bm(e))return rh(e,t)}throw Fm(e)}function ah(e,t){return t?ih(e,t):Vm(e)}function oh(){var e=[...arguments];return ah(e,Am(e))}function sh(e,t){var n=Vp(e)?e:function(){return e},r=function(e){return e.error(n())};return new gm(t?function(e){return t.schedule(r,0,e)}:r)}var ch=Hp(function(e){return function(){e(this),this.name=`EmptyError`,this.message=`no elements in sequence`}});function lh(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 ch)}})})}function uh(e,t){return ym(function(n,r){var i=0;n.subscribe(bm(r,function(n){r.next(e.call(t,n,i++))}))})}function aee(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;Vm(n(e,u++)).subscribe(bm(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?Ym(t,o,function(){return m(e)}):m(e)};c.length&&l<r;)e();f()}catch(e){t.error(e)}}))};return e.subscribe(bm(t,p,function(){d=!0,f()})),function(){s?.()}}function dh(e,t,n){return n===void 0&&(n=1/0),Vp(t)?dh(function(n,r){return uh(function(e,i){return t(n,e,r,i)})(Vm(e(n,r)))},n):(typeof t==`number`&&(n=t),ym(function(t,r){return aee(t,r,e,n)}))}function oee(e){return e===void 0&&(e=1/0),dh(pm,e)}function fh(e){return new gm(function(t){Vm(e()).subscribe(t)})}function ph(e){return ym(function(t,n){var r=null,i=!1,a;r=t.subscribe(bm(n,void 0,void 0,function(o){a=Vm(e(o,ph(e)(t))),r?(r.unsubscribe(),r=null,a.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,a.subscribe(n))})}function mh(e,t){return Vp(t)?dh(e,t,1):dh(e,1)}function see(e){return ym(function(t,n){var r=!1;t.subscribe(bm(n,function(e){r=!0,n.next(e)},function(){r||n.next(e),n.complete()}))})}function hh(e){return ym(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function gh(e,t){return ym(function(n,r){var i=null,a=0,o=!1,s=function(){return o&&!i&&r.complete()};n.subscribe(bm(r,function(n){i?.unsubscribe();var o=0,c=a++;Vm(e(n,c)).subscribe(i=bm(r,function(e){return r.next(t?t(n,e,c,o++):e)},function(){i=null,s()}))},function(){o=!0,s()}))})}function _h(e){return ym(function(t,n){Vm(e).subscribe(bm(n,function(){return n.complete()},Qp)),!n.closed&&t.subscribe(n)})}function vh(e,t,n){var r=Vp(e)||t||n?{next:e,error:t,complete:n}:e;return r?ym(function(e,t){var n;(n=r.subscribe)==null||n.call(r);var i=!0;e.subscribe(bm(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)}))}):pm}function yh(e){return` \r
|
|
81
|
-
`.indexOf(e)>=0}function bh(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():yh(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`:yh(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 xh(){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 Sh(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 Ch=4294967296;function wh(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>=Ch&&(i+=r/Ch|0,r%=Ch)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?kh(r,i):Oh(r,i)}function Th(e,t){let n=Oh(e,t),r=n.hi&2147483648;r&&(n=kh(n.lo,n.hi));let i=Eh(n.lo,n.hi);return r?`-`+i:i}function Eh(e,t){if({lo:e,hi:t}=Dh(e,t),t<=2097151)return String(Ch*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()+Ah(o)+Ah(a)}function Dh(e,t){return{lo:e>>>0,hi:t>>>0}}function Oh(e,t){return{lo:e|0,hi:t|0}}function kh(e,t){return t=~t,e?e=~e+1:t+=1,Oh(e,t)}var Ah=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function jh(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 Mh(){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 Nh=Ph();function Ph(){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()),Fh(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),Ih(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),Fh(e),wh(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),Ih(e),wh(e)},dec(e,t){return Th(e,t)},uDec(e,t){return Eh(e,t)}}}function Fh(e){if(!/^-?[0-9]+$/.test(e))throw Error(`invalid int64: `+e)}function Ih(e){if(!/^[0-9]+$/.test(e))throw Error(`invalid uint64: `+e)}var Lh=Symbol.for(`@bufbuild/protobuf/text-encoding`);function Rh(){if(globalThis[Lh]==null){let e=new globalThis.TextEncoder,t=new globalThis.TextDecoder,n;globalThis[Lh]={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[Lh]}var zh;(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`})(zh||={});var Bh=class{constructor(e=Rh().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(Hh(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return Vh(e),jh(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){Uh(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){Hh(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Vh(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Vh(e),e=(e<<1^e>>31)>>>0,jh(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=Nh.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=Nh.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=Nh.enc(e);return Sh(t.lo,t.hi,this.buf),this}sint64(e){let t=Nh.enc(e),n=t.hi>>31;return Sh(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=Nh.uEnc(e);return Sh(t.lo,t.hi,this.buf),this}},F=class{constructor(e,t=Rh().decodeUtf8){this.decodeUtf8=t,this.varint64=xh,this.uint32=Mh,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 zh.Varint:for(;this.buf[this.pos++]&128;);break;case zh.Bit64:this.pos+=4;case zh.Bit32:this.pos+=4;break;case zh.LengthDelimited:let r=this.uint32();this.pos+=r;break;case zh.StartGroup:if(n<=0)throw Error(`maximum recursion depth reached`);for(;;){let[e,r]=this.tag();if(r===zh.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 Nh.dec(...this.varint64())}uint64(){return Nh.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,Nh.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 Nh.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Nh.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 Vh(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 Hh(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 Uh(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 cee=function(e){return e[e.NULL_VALUE=0]=`NULL_VALUE`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function Wh(){return{fields:{}}}var Gh={encode(e,t=new Bh){return Object.entries(e.fields).forEach(([e,n])=>{n!==void 0&&qh.encode({key:e,value:n},t.uint32(10).fork()).join()}),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Wh();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:{if(e!==10)break;let t=qh.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 Gh.fromPartial(e??{})},fromPartial(e){let t=Wh();return t.fields=Object.entries(e.fields??{}).reduce((e,[t,n])=>(n!==void 0&&(e[t]=n),e),{}),t},wrap(e){let t=Wh();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 Kh(){return{key:``,value:void 0}}var qh={encode(e,t=new Bh){return e.key!==``&&t.uint32(10).string(e.key),e.value!==void 0&&Yh.encode(Yh.wrap(e.value),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Kh();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=Yh.unwrap(Yh.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return qh.fromPartial(e??{})},fromPartial(e){let t=Kh();return t.key=e.key??``,t.value=e.value??void 0,t}};function Jh(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var Yh={encode(e,t=new Bh){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&&Gh.encode(Gh.wrap(e.structValue),t.uint32(42).fork()).join(),e.listValue!==void 0&&Zh.encode(Zh.wrap(e.listValue),t.uint32(50).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Jh();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=Gh.unwrap(Gh.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.listValue=Zh.unwrap(Zh.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Yh.fromPartial(e??{})},fromPartial(e){let t=Jh();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=Jh();if(e===null)t.nullValue=cee.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 Xh(){return{values:[]}}var Zh={encode(e,t=new Bh){for(let n of e.values)Yh.encode(Yh.wrap(n),t.uint32(10).fork()).join();return t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Xh();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.values.push(Yh.unwrap(Yh.decode(n,n.uint32())));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Zh.fromPartial(e??{})},fromPartial(e){let t=Xh();return t.values=e.values?.map(e=>e)||[],t},wrap(e){let t=Xh();return t.values=e??[],t},unwrap(e){return e?.hasOwnProperty(`values`)&&globalThis.Array.isArray(e.values)?e.values:e}},lee=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 Qh(){return{op:0,path:``,from:void 0,value:void 0}}var $h={encode(e,t=new Bh){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&&Yh.encode(Yh.wrap(e.value),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Qh();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=Yh.unwrap(Yh.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return $h.fromPartial(e??{})},fromPartial(e){let t=Qh();return t.op=e.op??0,t.path=e.path??``,t.from=e.from??void 0,t.value=e.value??void 0,t}};function eg(){return{id:``,type:``,function:void 0}}var tg={encode(e,t=new Bh){return e.id!==``&&t.uint32(10).string(e.id),e.type!==``&&t.uint32(18).string(e.type),e.function!==void 0&&rg.encode(e.function,t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=eg();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=rg.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return tg.fromPartial(e??{})},fromPartial(e){let t=eg();return t.id=e.id??``,t.type=e.type??``,t.function=e.function!==void 0&&e.function!==null?rg.fromPartial(e.function):void 0,t}};function ng(){return{name:``,arguments:``}}var rg={encode(e,t=new Bh){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 F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=ng();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 rg.fromPartial(e??{})},fromPartial(e){let t=ng();return t.name=e.name??``,t.arguments=e.arguments??``,t}};function ig(){return{value:``,mimeType:``}}var ag={encode(e,t=new Bh){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 F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=ig();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 ag.fromPartial(e??{})},fromPartial(e){let t=ig();return t.value=e.value??``,t.mimeType=e.mimeType??``,t}};function og(){return{value:``,mimeType:void 0}}var sg={encode(e,t=new Bh){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 F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=og();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 sg.fromPartial(e??{})},fromPartial(e){let t=og();return t.value=e.value??``,t.mimeType=e.mimeType??void 0,t}};function cg(){return{data:void 0,url:void 0}}var lg={encode(e,t=new Bh){return e.data!==void 0&&ag.encode(e.data,t.uint32(10).fork()).join(),e.url!==void 0&&sg.encode(e.url,t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=cg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.data=ag.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.url=sg.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return lg.fromPartial(e??{})},fromPartial(e){let t=cg();return t.data=e.data!==void 0&&e.data!==null?ag.fromPartial(e.data):void 0,t.url=e.url!==void 0&&e.url!==null?sg.fromPartial(e.url):void 0,t}};function ug(){return{text:``}}var dg={encode(e,t=new Bh){return e.text!==``&&t.uint32(10).string(e.text),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=ug();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 dg.fromPartial(e??{})},fromPartial(e){let t=ug();return t.text=e.text??``,t}};function fg(){return{source:void 0,metadata:void 0}}var pg={encode(e,t=new Bh){return e.source!==void 0&&lg.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&Yh.encode(Yh.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=fg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=Yh.unwrap(Yh.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return pg.fromPartial(e??{})},fromPartial(e){let t=fg();return t.source=e.source!==void 0&&e.source!==null?lg.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function mg(){return{source:void 0,metadata:void 0}}var hg={encode(e,t=new Bh){return e.source!==void 0&&lg.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&Yh.encode(Yh.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=mg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=Yh.unwrap(Yh.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return hg.fromPartial(e??{})},fromPartial(e){let t=mg();return t.source=e.source!==void 0&&e.source!==null?lg.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function gg(){return{source:void 0,metadata:void 0}}var _g={encode(e,t=new Bh){return e.source!==void 0&&lg.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&Yh.encode(Yh.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=gg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=Yh.unwrap(Yh.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return _g.fromPartial(e??{})},fromPartial(e){let t=gg();return t.source=e.source!==void 0&&e.source!==null?lg.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function vg(){return{source:void 0,metadata:void 0}}var yg={encode(e,t=new Bh){return e.source!==void 0&&lg.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&Yh.encode(Yh.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=vg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=lg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=Yh.unwrap(Yh.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return yg.fromPartial(e??{})},fromPartial(e){let t=vg();return t.source=e.source!==void 0&&e.source!==null?lg.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function bg(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var xg={encode(e,t=new Bh){return e.text!==void 0&&dg.encode(e.text,t.uint32(10).fork()).join(),e.image!==void 0&&pg.encode(e.image,t.uint32(18).fork()).join(),e.audio!==void 0&&hg.encode(e.audio,t.uint32(26).fork()).join(),e.video!==void 0&&_g.encode(e.video,t.uint32(34).fork()).join(),e.document!==void 0&&yg.encode(e.document,t.uint32(42).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=bg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.text=dg.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.image=pg.decode(n,n.uint32());continue;case 3:if(e!==26)break;i.audio=hg.decode(n,n.uint32());continue;case 4:if(e!==34)break;i.video=_g.decode(n,n.uint32());continue;case 5:if(e!==42)break;i.document=yg.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return xg.fromPartial(e??{})},fromPartial(e){let t=bg();return t.text=e.text!==void 0&&e.text!==null?dg.fromPartial(e.text):void 0,t.image=e.image!==void 0&&e.image!==null?pg.fromPartial(e.image):void 0,t.audio=e.audio!==void 0&&e.audio!==null?hg.fromPartial(e.audio):void 0,t.video=e.video!==void 0&&e.video!==null?_g.fromPartial(e.video):void 0,t.document=e.document!==void 0&&e.document!==null?yg.fromPartial(e.document):void 0,t}};function Sg(){return{id:``,role:``,content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var Cg={encode(e,t=new Bh){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)tg.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)xg.encode(n,t.uint32(66).fork()).join();return t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Sg();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(tg.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(xg.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Cg.fromPartial(e??{})},fromPartial(e){let t=Sg();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=>tg.fromPartial(e))||[],t.toolCallId=e.toolCallId??void 0,t.error=e.error??void 0,t.contentParts=e.contentParts?.map(e=>xg.fromPartial(e))||[],t}};function wg(){return{id:``,reason:``,message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var Tg={encode(e,t=new Bh){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&&Yh.encode(Yh.wrap(e.responseSchema),t.uint32(42).fork()).join(),e.expiresAt!==void 0&&t.uint32(50).string(e.expiresAt),e.metadata!==void 0&&Yh.encode(Yh.wrap(e.metadata),t.uint32(58).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=wg();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=Yh.unwrap(Yh.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.expiresAt=n.string();continue;case 7:if(e!==58)break;i.metadata=Yh.unwrap(Yh.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Tg.fromPartial(e??{})},fromPartial(e){let t=wg();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}},Eg=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 Dg(){return{type:0,timestamp:void 0,rawEvent:void 0}}var Og={encode(e,t=new Bh){return e.type!==0&&t.uint32(8).int32(e.type),e.timestamp!==void 0&&t.uint32(16).int64(e.timestamp),e.rawEvent!==void 0&&Yh.encode(Yh.wrap(e.rawEvent),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Dg();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=p_(n.int64());continue;case 3:if(e!==26)break;i.rawEvent=Yh.unwrap(Yh.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Og.fromPartial(e??{})},fromPartial(e){let t=Dg();return t.type=e.type??0,t.timestamp=e.timestamp??void 0,t.rawEvent=e.rawEvent??void 0,t}};function kg(){return{baseEvent:void 0,messageId:``,role:void 0,name:void 0}}var Ag={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.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 F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=kg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.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 Ag.fromPartial(e??{})},fromPartial(e){let t=kg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.role=e.role??void 0,t.name=e.name??void 0,t}};function jg(){return{baseEvent:void 0,messageId:``,delta:``}}var Mg={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.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 F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=jg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.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 Mg.fromPartial(e??{})},fromPartial(e){let t=jg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.delta=e.delta??``,t}};function Ng(){return{baseEvent:void 0,messageId:``}}var Pg={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Ng();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.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 Pg.fromPartial(e??{})},fromPartial(e){let t=Ng();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t}};function Fg(){return{baseEvent:void 0,toolCallId:``,toolCallName:``,parentMessageId:void 0}}var Ig={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.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 F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Fg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.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 Ig.fromPartial(e??{})},fromPartial(e){let t=Fg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.toolCallName=e.toolCallName??``,t.parentMessageId=e.parentMessageId??void 0,t}};function Lg(){return{baseEvent:void 0,toolCallId:``,delta:``}}var Rg={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.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 F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Lg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.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 Rg.fromPartial(e??{})},fromPartial(e){let t=Lg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.delta=e.delta??``,t}};function zg(){return{baseEvent:void 0,toolCallId:``}}var Bg={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=zg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.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 Bg.fromPartial(e??{})},fromPartial(e){let t=zg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t}};function Vg(){return{baseEvent:void 0,snapshot:void 0}}var Hg={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.encode(e.baseEvent,t.uint32(10).fork()).join(),e.snapshot!==void 0&&Yh.encode(Yh.wrap(e.snapshot),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Vg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.snapshot=Yh.unwrap(Yh.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Hg.fromPartial(e??{})},fromPartial(e){let t=Vg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.snapshot=e.snapshot??void 0,t}};function Ug(){return{baseEvent:void 0,delta:[]}}var Wg={encode(e,t=new Bh){e.baseEvent!==void 0&&Og.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.delta)$h.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Ug();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.delta.push($h.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Wg.fromPartial(e??{})},fromPartial(e){let t=Ug();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.delta=e.delta?.map(e=>$h.fromPartial(e))||[],t}};function Gg(){return{baseEvent:void 0,messages:[]}}var Kg={encode(e,t=new Bh){e.baseEvent!==void 0&&Og.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.messages)Cg.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Gg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messages.push(Cg.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Kg.fromPartial(e??{})},fromPartial(e){let t=Gg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.messages=e.messages?.map(e=>Cg.fromPartial(e))||[],t}};function qg(){return{baseEvent:void 0,event:void 0,source:void 0}}var Jg={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.encode(e.baseEvent,t.uint32(10).fork()).join(),e.event!==void 0&&Yh.encode(Yh.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 F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=qg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.event=Yh.unwrap(Yh.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 Jg.fromPartial(e??{})},fromPartial(e){let t=qg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.event=e.event??void 0,t.source=e.source??void 0,t}};function Yg(){return{baseEvent:void 0,name:``,value:void 0}}var Xg={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.encode(e.baseEvent,t.uint32(10).fork()).join(),e.name!==``&&t.uint32(18).string(e.name),e.value!==void 0&&Yh.encode(Yh.wrap(e.value),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Yg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.name=n.string();continue;case 3:if(e!==26)break;i.value=Yh.unwrap(Yh.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Xg.fromPartial(e??{})},fromPartial(e){let t=Yg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.name=e.name??``,t.value=e.value??void 0,t}};function Zg(){return{baseEvent:void 0,threadId:``,runId:``}}var Qg={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.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 F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=Zg();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.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 Qg.fromPartial(e??{})},fromPartial(e){let t=Zg();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??``,t.runId=e.runId??``,t}};function $g(){return{baseEvent:void 0,threadId:``,runId:``,result:void 0,outcome:``,interrupts:[]}}var e_={encode(e,t=new Bh){e.baseEvent!==void 0&&Og.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&&Yh.encode(Yh.wrap(e.result),t.uint32(34).fork()).join(),e.outcome!==``&&t.uint32(42).string(e.outcome);for(let n of e.interrupts)Tg.encode(n,t.uint32(50).fork()).join();return t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=$g();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.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=Yh.unwrap(Yh.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(Tg.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return e_.fromPartial(e??{})},fromPartial(e){let t=$g();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.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=>Tg.fromPartial(e))||[],t}};function t_(){return{baseEvent:void 0,code:void 0,message:``}}var n_={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.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 F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=t_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.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 n_.fromPartial(e??{})},fromPartial(e){let t=t_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.code=e.code??void 0,t.message=e.message??``,t}};function r_(){return{baseEvent:void 0,stepName:``}}var i_={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==``&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=r_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.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 i_.fromPartial(e??{})},fromPartial(e){let t=r_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??``,t}};function a_(){return{baseEvent:void 0,stepName:``}}var o_={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==``&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=a_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.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 o_.fromPartial(e??{})},fromPartial(e){let t=a_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??``,t}};function s_(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var c_={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.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 F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=s_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=Og.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 c_.fromPartial(e??{})},fromPartial(e){let t=s_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.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 l_(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var u_={encode(e,t=new Bh){return e.baseEvent!==void 0&&Og.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 F?e:new F(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=Og.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 u_.fromPartial(e??{})},fromPartial(e){let t=l_();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Og.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 d_(){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 f_={encode(e,t=new Bh){return e.textMessageStart!==void 0&&Ag.encode(e.textMessageStart,t.uint32(10).fork()).join(),e.textMessageContent!==void 0&&Mg.encode(e.textMessageContent,t.uint32(18).fork()).join(),e.textMessageEnd!==void 0&&Pg.encode(e.textMessageEnd,t.uint32(26).fork()).join(),e.toolCallStart!==void 0&&Ig.encode(e.toolCallStart,t.uint32(34).fork()).join(),e.toolCallArgs!==void 0&&Rg.encode(e.toolCallArgs,t.uint32(42).fork()).join(),e.toolCallEnd!==void 0&&Bg.encode(e.toolCallEnd,t.uint32(50).fork()).join(),e.stateSnapshot!==void 0&&Hg.encode(e.stateSnapshot,t.uint32(58).fork()).join(),e.stateDelta!==void 0&&Wg.encode(e.stateDelta,t.uint32(66).fork()).join(),e.messagesSnapshot!==void 0&&Kg.encode(e.messagesSnapshot,t.uint32(74).fork()).join(),e.raw!==void 0&&Jg.encode(e.raw,t.uint32(82).fork()).join(),e.custom!==void 0&&Xg.encode(e.custom,t.uint32(90).fork()).join(),e.runStarted!==void 0&&Qg.encode(e.runStarted,t.uint32(98).fork()).join(),e.runFinished!==void 0&&e_.encode(e.runFinished,t.uint32(106).fork()).join(),e.runError!==void 0&&n_.encode(e.runError,t.uint32(114).fork()).join(),e.stepStarted!==void 0&&i_.encode(e.stepStarted,t.uint32(122).fork()).join(),e.stepFinished!==void 0&&o_.encode(e.stepFinished,t.uint32(130).fork()).join(),e.textMessageChunk!==void 0&&c_.encode(e.textMessageChunk,t.uint32(138).fork()).join(),e.toolCallChunk!==void 0&&u_.encode(e.toolCallChunk,t.uint32(146).fork()).join(),t},decode(e,t){let n=e instanceof F?e:new F(e),r=t===void 0?n.len:n.pos+t,i=d_();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.textMessageStart=Ag.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.textMessageContent=Mg.decode(n,n.uint32());continue;case 3:if(e!==26)break;i.textMessageEnd=Pg.decode(n,n.uint32());continue;case 4:if(e!==34)break;i.toolCallStart=Ig.decode(n,n.uint32());continue;case 5:if(e!==42)break;i.toolCallArgs=Rg.decode(n,n.uint32());continue;case 6:if(e!==50)break;i.toolCallEnd=Bg.decode(n,n.uint32());continue;case 7:if(e!==58)break;i.stateSnapshot=Hg.decode(n,n.uint32());continue;case 8:if(e!==66)break;i.stateDelta=Wg.decode(n,n.uint32());continue;case 9:if(e!==74)break;i.messagesSnapshot=Kg.decode(n,n.uint32());continue;case 10:if(e!==82)break;i.raw=Jg.decode(n,n.uint32());continue;case 11:if(e!==90)break;i.custom=Xg.decode(n,n.uint32());continue;case 12:if(e!==98)break;i.runStarted=Qg.decode(n,n.uint32());continue;case 13:if(e!==106)break;i.runFinished=e_.decode(n,n.uint32());continue;case 14:if(e!==114)break;i.runError=n_.decode(n,n.uint32());continue;case 15:if(e!==122)break;i.stepStarted=i_.decode(n,n.uint32());continue;case 16:if(e!==130)break;i.stepFinished=o_.decode(n,n.uint32());continue;case 17:if(e!==138)break;i.textMessageChunk=c_.decode(n,n.uint32());continue;case 18:if(e!==146)break;i.toolCallChunk=u_.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return f_.fromPartial(e??{})},fromPartial(e){let t=d_();return t.textMessageStart=e.textMessageStart!==void 0&&e.textMessageStart!==null?Ag.fromPartial(e.textMessageStart):void 0,t.textMessageContent=e.textMessageContent!==void 0&&e.textMessageContent!==null?Mg.fromPartial(e.textMessageContent):void 0,t.textMessageEnd=e.textMessageEnd!==void 0&&e.textMessageEnd!==null?Pg.fromPartial(e.textMessageEnd):void 0,t.toolCallStart=e.toolCallStart!==void 0&&e.toolCallStart!==null?Ig.fromPartial(e.toolCallStart):void 0,t.toolCallArgs=e.toolCallArgs!==void 0&&e.toolCallArgs!==null?Rg.fromPartial(e.toolCallArgs):void 0,t.toolCallEnd=e.toolCallEnd!==void 0&&e.toolCallEnd!==null?Bg.fromPartial(e.toolCallEnd):void 0,t.stateSnapshot=e.stateSnapshot!==void 0&&e.stateSnapshot!==null?Hg.fromPartial(e.stateSnapshot):void 0,t.stateDelta=e.stateDelta!==void 0&&e.stateDelta!==null?Wg.fromPartial(e.stateDelta):void 0,t.messagesSnapshot=e.messagesSnapshot!==void 0&&e.messagesSnapshot!==null?Kg.fromPartial(e.messagesSnapshot):void 0,t.raw=e.raw!==void 0&&e.raw!==null?Jg.fromPartial(e.raw):void 0,t.custom=e.custom!==void 0&&e.custom!==null?Xg.fromPartial(e.custom):void 0,t.runStarted=e.runStarted!==void 0&&e.runStarted!==null?Qg.fromPartial(e.runStarted):void 0,t.runFinished=e.runFinished!==void 0&&e.runFinished!==null?e_.fromPartial(e.runFinished):void 0,t.runError=e.runError!==void 0&&e.runError!==null?n_.fromPartial(e.runError):void 0,t.stepStarted=e.stepStarted!==void 0&&e.stepStarted!==null?i_.fromPartial(e.stepStarted):void 0,t.stepFinished=e.stepFinished!==void 0&&e.stepFinished!==null?o_.fromPartial(e.stepFinished):void 0,t.textMessageChunk=e.textMessageChunk!==void 0&&e.textMessageChunk!==null?c_.fromPartial(e.textMessageChunk):void 0,t.toolCallChunk=e.toolCallChunk!==void 0&&e.toolCallChunk!==null?u_.fromPartial(e.toolCallChunk):void 0,t}};function p_(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 m_=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}}},h_=e=>{if(!(!e||typeof e!=`object`)){if(e.text)return{type:`text`,text:e.text.text};if(e.image)return{type:`image`,source:m_(e.image.source),metadata:e.image.metadata};if(e.audio)return{type:`audio`,source:m_(e.audio.source),metadata:e.audio.metadata};if(e.video)return{type:`video`,source:m_(e.video.source),metadata:e.video.metadata};if(e.document)return{type:`document`,source:m_(e.document.source),metadata:e.document.metadata}}};function g_(e){let t=f_.decode(e),n=Object.values(t).find(e=>e!==void 0);if(!n)throw Error(`Invalid event`);if(n.type=Eg[n.baseEvent.type],n.timestamp=n.baseEvent.timestamp,n.rawEvent=n.baseEvent.rawEvent,delete n.baseEvent,n.type===P.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=>h_(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===P.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===P.STATE_DELTA)for(let e of n.delta)e.op=lee[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]}),Kf.parse(n)}var __;(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})(__||={});var v_;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(v_||={});var y_=__.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),b_=e=>{switch(typeof e){case`undefined`:return y_.undefined;case`string`:return y_.string;case`number`:return Number.isNaN(e)?y_.nan:y_.number;case`boolean`:return y_.boolean;case`function`:return y_.function;case`bigint`:return y_.bigint;case`symbol`:return y_.symbol;case`object`:return Array.isArray(e)?y_.array:e===null?y_.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?y_.promise:typeof Map<`u`&&e instanceof Map?y_.map:typeof Set<`u`&&e instanceof Set?y_.set:typeof Date<`u`&&e instanceof Date?y_.date:y_.object;default:return y_.unknown}},I=__.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`]),x_=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,__.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()}};x_.create=e=>new x_(e);var S_=(e,t)=>{let n;switch(e.code){case I.invalid_type:n=e.received===y_.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case I.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,__.jsonStringifyReplacer)}`;break;case I.unrecognized_keys:n=`Unrecognized key(s) in object: ${__.joinValues(e.keys,`, `)}`;break;case I.invalid_union:n=`Invalid input`;break;case I.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${__.joinValues(e.options)}`;break;case I.invalid_enum_value:n=`Invalid enum value. Expected ${__.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}"`:__.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,__.assertNever(e)}return{message:n}},uee=S_;function C_(){return uee}var w_=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=C_(),r=w_({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===S_?void 0:S_].filter(e=>!!e)});e.common.issues.push(r)}var T_=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 E_;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 E_;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}}},E_=Object.freeze({status:`aborted`}),D_=e=>({status:`dirty`,value:e}),O_=e=>({status:`valid`,value:e}),k_=e=>e.status===`aborted`,A_=e=>e.status===`dirty`,j_=e=>e.status===`valid`,M_=e=>typeof Promise<`u`&&e instanceof Promise,N_;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(N_||={});var P_=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}},F_=(e,t)=>{if(j_(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 x_(e.common.issues);return this._error=t,this._error}}};function I_(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 L_=class{get description(){return this._def.description}_getType(e){return b_(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:b_(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T_,ctx:{common:e.parent.common,data:e.data,parsedType:b_(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(M_(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:b_(e)};return F_(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:b_(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return j_(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=>j_(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:b_(e)},r=this._parse({data:e,path:n.path,parent:n});return F_(n,await(M_(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 Bv({schema:this,typeName:Yv.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 Vv.create(this,this._def)}nullable(){return Hv.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return xv.create(this)}promise(){return zv.create(this,this._def)}or(e){return wv.create([this,e],this._def)}and(e){return Ov.create(this,e,this._def)}transform(e){return new Bv({...I_(this._def),schema:this,typeName:Yv.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Uv({...I_(this._def),innerType:this,defaultValue:t,typeName:Yv.ZodDefault})}brand(){return new Kv({typeName:Yv.ZodBranded,type:this,...I_(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Wv({...I_(this._def),innerType:this,catchValue:t,typeName:Yv.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return qv.create(this,e)}readonly(){return Jv.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},R_=/^c[^\s-]{8,}$/i,z_=/^[0-9a-z]+$/,B_=/^[0-9A-HJKMNP-TV-Z]{26}$/i,V_=/^[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,H_=/^[a-z0-9_-]{21}$/i,U_=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,W_=/^[-+]?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)?)??$/,G_=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,K_=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,q_,J_=/^(?:(?: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])$/,Y_=/^(?:(?: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])$/,X_=/^(([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]))$/,Z_=/^(([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])$/,Q_=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$_=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ev=`((\\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])))`,tv=RegExp(`^${ev}$`);function nv(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 rv(e){return RegExp(`^${nv(e)}$`)}function iv(e){let t=`${ev}T${nv(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function av(e,t){return!!((t===`v4`||!t)&&J_.test(e)||(t===`v6`||!t)&&X_.test(e))}function ov(e,t){if(!U_.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 sv(e,t){return!!((t===`v4`||!t)&&Y_.test(e)||(t===`v6`||!t)&&Z_.test(e))}var cv=class e extends L_{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y_.string){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:y_.string,received:t.parsedType}),E_}let t=new T_,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`)G_.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`)q_||=new RegExp(K_,`u`),q_.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`)V_.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`)H_.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`)R_.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`)z_.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`)B_.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`?iv(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`?tv.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?rv(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`?W_.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`duration`,code:I.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?av(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`?ov(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`?sv(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`?Q_.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`base64`,code:I.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?$_.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`base64url`,code:I.invalid_string,message:r.message}),t.dirty()):__.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,...N_.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...N_.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...N_.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...N_.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...N_.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...N_.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...N_.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...N_.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...N_.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...N_.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...N_.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...N_.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...N_.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...N_.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,...N_.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,...N_.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...N_.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...N_.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...N_.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...N_.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...N_.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...N_.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...N_.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...N_.errToObj(t)})}nonempty(e){return this.min(1,N_.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}};cv.create=e=>new cv({checks:[],typeName:Yv.ZodString,coerce:e?.coerce??!1,...I_(e)});function lv(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 uv=class e extends L_{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)!==y_.number){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:y_.number,received:t.parsedType}),E_}let t,n=new T_;for(let r of this._def.checks)r.kind===`int`?__.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`?lv(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()):__.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,N_.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,N_.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,N_.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,N_.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:N_.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:N_.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:N_.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:N_.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:N_.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:N_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:N_.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:N_.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:N_.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:N_.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`&&__.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)}};uv.create=e=>new uv({checks:[],typeName:Yv.ZodNumber,coerce:e?.coerce||!1,...I_(e)});var dv=class e extends L_{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)!==y_.bigint)return this._getInvalidInput(e);let t,n=new T_;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()):__.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:y_.bigint,received:t.parsedType}),E_}gte(e,t){return this.setLimit(`min`,e,!0,N_.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,N_.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,N_.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,N_.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:N_.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:N_.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:N_.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:N_.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:N_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:N_.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}};dv.create=e=>new dv({checks:[],typeName:Yv.ZodBigInt,coerce:e?.coerce??!1,...I_(e)});var fv=class extends L_{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y_.boolean){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:y_.boolean,received:t.parsedType}),E_}return O_(e.data)}};fv.create=e=>new fv({typeName:Yv.ZodBoolean,coerce:e?.coerce||!1,...I_(e)});var pv=class e extends L_{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y_.date){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:y_.date,received:t.parsedType}),E_}if(Number.isNaN(e.data.getTime()))return L(this._getOrReturnCtx(e),{code:I.invalid_date}),E_;let t=new T_,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()):__.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:N_.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:N_.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)}};pv.create=e=>new pv({checks:[],coerce:e?.coerce||!1,typeName:Yv.ZodDate,...I_(e)});var mv=class extends L_{_parse(e){if(this._getType(e)!==y_.symbol){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:y_.symbol,received:t.parsedType}),E_}return O_(e.data)}};mv.create=e=>new mv({typeName:Yv.ZodSymbol,...I_(e)});var hv=class extends L_{_parse(e){if(this._getType(e)!==y_.undefined){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:y_.undefined,received:t.parsedType}),E_}return O_(e.data)}};hv.create=e=>new hv({typeName:Yv.ZodUndefined,...I_(e)});var gv=class extends L_{_parse(e){if(this._getType(e)!==y_.null){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:y_.null,received:t.parsedType}),E_}return O_(e.data)}};gv.create=e=>new gv({typeName:Yv.ZodNull,...I_(e)});var _v=class extends L_{constructor(){super(...arguments),this._any=!0}_parse(e){return O_(e.data)}};_v.create=e=>new _v({typeName:Yv.ZodAny,...I_(e)});var vv=class extends L_{constructor(){super(...arguments),this._unknown=!0}_parse(e){return O_(e.data)}};vv.create=e=>new vv({typeName:Yv.ZodUnknown,...I_(e)});var yv=class extends L_{_parse(e){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:y_.never,received:t.parsedType}),E_}};yv.create=e=>new yv({typeName:Yv.ZodNever,...I_(e)});var bv=class extends L_{_parse(e){if(this._getType(e)!==y_.undefined){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:y_.void,received:t.parsedType}),E_}return O_(e.data)}};bv.create=e=>new bv({typeName:Yv.ZodVoid,...I_(e)});var xv=class e extends L_{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==y_.array)return L(t,{code:I.invalid_type,expected:y_.array,received:t.parsedType}),E_;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 P_(t,e,t.path,n)))).then(e=>T_.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new P_(t,e,t.path,n)));return T_.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:N_.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:N_.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:N_.toString(n)}})}nonempty(e){return this.min(1,e)}};xv.create=(e,t)=>new xv({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Yv.ZodArray,...I_(t)});function Sv(e){if(e instanceof Cv){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Vv.create(Sv(r))}return new Cv({...e._def,shape:()=>t})}else if(e instanceof xv)return new xv({...e._def,type:Sv(e.element)});else if(e instanceof Vv)return Vv.create(Sv(e.unwrap()));else if(e instanceof Hv)return Hv.create(Sv(e.unwrap()));else if(e instanceof kv)return kv.create(e.items.map(e=>Sv(e)));else return e}var Cv=class e extends L_{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=__.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==y_.object){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:y_.object,received:t.parsedType}),E_}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof yv&&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 P_(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof yv){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 P_(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=>T_.mergeObjectSync(t,e)):T_.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return N_.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:N_.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:Yv.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 __.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 __.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Sv(this)}partial(t){let n={};for(let e of __.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 __.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Vv;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Iv(__.objectKeys(this.shape))}};Cv.create=(e,t)=>new Cv({shape:()=>e,unknownKeys:`strip`,catchall:yv.create(),typeName:Yv.ZodObject,...I_(t)}),Cv.strictCreate=(e,t)=>new Cv({shape:()=>e,unknownKeys:`strict`,catchall:yv.create(),typeName:Yv.ZodObject,...I_(t)}),Cv.lazycreate=(e,t)=>new Cv({shape:e,unknownKeys:`strip`,catchall:yv.create(),typeName:Yv.ZodObject,...I_(t)});var wv=class extends L_{_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 x_(e.ctx.common.issues));return L(t,{code:I.invalid_union,unionErrors:n}),E_}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 x_(e));return L(t,{code:I.invalid_union,unionErrors:i}),E_}}get options(){return this._def.options}};wv.create=(e,t)=>new wv({options:e,typeName:Yv.ZodUnion,...I_(t)});var Tv=e=>e instanceof Pv?Tv(e.schema):e instanceof Bv?Tv(e.innerType()):e instanceof Fv?[e.value]:e instanceof Lv?e.options:e instanceof Rv?__.objectValues(e.enum):e instanceof Uv?Tv(e._def.innerType):e instanceof hv?[void 0]:e instanceof gv?[null]:e instanceof Vv?[void 0,...Tv(e.unwrap())]:e instanceof Hv?[null,...Tv(e.unwrap())]:e instanceof Kv||e instanceof Jv?Tv(e.unwrap()):e instanceof Wv?Tv(e._def.innerType):[],Ev=class e extends L_{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==y_.object)return L(t,{code:I.invalid_type,expected:y_.object,received:t.parsedType}),E_;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]}),E_)}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=Tv(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:Yv.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...I_(r)})}};function Dv(e,t){let n=b_(e),r=b_(t);if(e===t)return{valid:!0,data:e};if(n===y_.object&&r===y_.object){let n=__.objectKeys(t),r=__.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Dv(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===y_.array&&r===y_.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=Dv(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===y_.date&&r===y_.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Ov=class extends L_{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(k_(e)||k_(r))return E_;let i=Dv(e.value,r.value);return i.valid?((A_(e)||A_(r))&&t.dirty(),{status:t.value,value:i.data}):(L(n,{code:I.invalid_intersection_types}),E_)};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}))}};Ov.create=(e,t,n)=>new Ov({left:e,right:t,typeName:Yv.ZodIntersection,...I_(n)});var kv=class e extends L_{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y_.array)return L(n,{code:I.invalid_type,expected:y_.array,received:n.parsedType}),E_;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`}),E_;!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 P_(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>T_.mergeArray(t,e)):T_.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};kv.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new kv({items:e,typeName:Yv.ZodTuple,rest:null,...I_(t)})};var Av=class e extends L_{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!==y_.object)return L(n,{code:I.invalid_type,expected:y_.object,received:n.parsedType}),E_;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new P_(n,e,n.path,e)),value:a._parse(new P_(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?T_.mergeObjectAsync(t,r):T_.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof L_?new e({keyType:t,valueType:n,typeName:Yv.ZodRecord,...I_(r)}):new e({keyType:cv.create(),valueType:t,typeName:Yv.ZodRecord,...I_(n)})}},jv=class extends L_{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!==y_.map)return L(n,{code:I.invalid_type,expected:y_.map,received:n.parsedType}),E_;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new P_(n,e,n.path,[a,`key`])),value:i._parse(new P_(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 E_;(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 E_;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};jv.create=(e,t,n)=>new jv({valueType:t,keyType:e,typeName:Yv.ZodMap,...I_(n)});var Mv=class e extends L_{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y_.set)return L(n,{code:I.invalid_type,expected:y_.set,received:n.parsedType}),E_;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 E_;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 P_(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:N_.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:N_.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Mv.create=(e,t)=>new Mv({valueType:e,minSize:null,maxSize:null,typeName:Yv.ZodSet,...I_(t)});var Nv=class e extends L_{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==y_.function)return L(t,{code:I.invalid_type,expected:y_.function,received:t.parsedType}),E_;function n(e,n){return w_({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,C_(),S_].filter(e=>!!e),issueData:{code:I.invalid_arguments,argumentsError:n}})}function r(e,n){return w_({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,C_(),S_].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 zv){let e=this;return O_(async function(...t){let o=new x_([]),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 O_(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new x_([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new x_([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:kv.create(t).rest(vv.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||kv.create([]).rest(vv.create()),returns:n||vv.create(),typeName:Yv.ZodFunction,...I_(r)})}},Pv=class extends L_{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})}};Pv.create=(e,t)=>new Pv({getter:e,typeName:Yv.ZodLazy,...I_(t)});var Fv=class extends L_{_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}),E_}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Fv.create=(e,t)=>new Fv({value:e,typeName:Yv.ZodLiteral,...I_(t)});function Iv(e,t){return new Lv({values:e,typeName:Yv.ZodEnum,...I_(t)})}var Lv=class e extends L_{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return L(t,{expected:__.joinValues(n),received:t.parsedType,code:I.invalid_type}),E_}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}),E_}return O_(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})}};Lv.create=Iv;var Rv=class extends L_{_parse(e){let t=__.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==y_.string&&n.parsedType!==y_.number){let e=__.objectValues(t);return L(n,{expected:__.joinValues(e),received:n.parsedType,code:I.invalid_type}),E_}if(this._cache||=new Set(__.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=__.objectValues(t);return L(n,{received:n.data,code:I.invalid_enum_value,options:e}),E_}return O_(e.data)}get enum(){return this._def.values}};Rv.create=(e,t)=>new Rv({values:e,typeName:Yv.ZodNativeEnum,...I_(t)});var zv=class extends L_{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==y_.promise&&t.common.async===!1?(L(t,{code:I.invalid_type,expected:y_.promise,received:t.parsedType}),E_):O_((t.parsedType===y_.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};zv.create=(e,t)=>new zv({type:e,typeName:Yv.ZodPromise,...I_(t)});var Bv=class extends L_{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Yv.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 E_;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?E_:r.status===`dirty`||t.value===`dirty`?D_(r.value):r});{if(t.value===`aborted`)return E_;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?E_:r.status===`dirty`||t.value===`dirty`?D_(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`?E_:(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`?E_:(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(!j_(e))return E_;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=>j_(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):E_);__.assertNever(r)}};Bv.create=(e,t,n)=>new Bv({schema:e,typeName:Yv.ZodEffects,effect:t,...I_(n)}),Bv.createWithPreprocess=(e,t,n)=>new Bv({schema:t,effect:{type:`preprocess`,transform:e},typeName:Yv.ZodEffects,...I_(n)});var Vv=class extends L_{_parse(e){return this._getType(e)===y_.undefined?O_(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Vv.create=(e,t)=>new Vv({innerType:e,typeName:Yv.ZodOptional,...I_(t)});var Hv=class extends L_{_parse(e){return this._getType(e)===y_.null?O_(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Hv.create=(e,t)=>new Hv({innerType:e,typeName:Yv.ZodNullable,...I_(t)});var Uv=class extends L_{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===y_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Uv.create=(e,t)=>new Uv({innerType:e,typeName:Yv.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...I_(t)});var Wv=class extends L_{_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 M_(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new x_(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new x_(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Wv.create=(e,t)=>new Wv({innerType:e,typeName:Yv.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...I_(t)});var Gv=class extends L_{_parse(e){if(this._getType(e)!==y_.nan){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:y_.nan,received:t.parsedType}),E_}return{status:`valid`,value:e.data}}};Gv.create=e=>new Gv({typeName:Yv.ZodNaN,...I_(e)});var Kv=class extends L_{_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}},qv=class e extends L_{_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`?E_:e.status===`dirty`?(t.dirty(),D_(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`?E_: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:Yv.ZodPipeline})}},Jv=class extends L_{_parse(e){let t=this._def.innerType._parse(e),n=e=>(j_(e)&&(e.value=Object.freeze(e.value)),e);return M_(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Jv.create=(e,t)=>new Jv({innerType:e,typeName:Yv.ZodReadonly,...I_(t)}),Cv.lazycreate;var Yv;(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`})(Yv||={});var Xv=cv.create;uv.create,Gv.create,dv.create;var Zv=fv.create;pv.create,mv.create,hv.create,gv.create;var Qv=_v.create;vv.create,yv.create,bv.create,xv.create;var $v=Cv.create;Cv.strictCreate,wv.create;var ey=Ev.create;Ov.create,kv.create,Av.create,jv.create,Mv.create,Nv.create,Pv.create;var ty=Fv.create,ny=Lv.create;Rv.create,zv.create,Bv.create,Vv.create,Hv.create,Bv.createWithPreprocess,qv.create;var ry=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,iy=e=>{if(typeof e!=`string`)throw TypeError(`Invalid argument expected string`);let t=e.match(ry);if(!t)throw Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},ay=e=>e===`*`||e===`x`||e===`X`,oy=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},sy=(e,t)=>typeof e==typeof t?[e,t]:[String(e),String(t)],cy=(e,t)=>{if(ay(e)||ay(t))return 0;let[n,r]=sy(oy(e),oy(t));return n>r?1:n<r?-1:0},ly=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let r=cy(e[n]||`0`,t[n]||`0`);if(r!==0)return r}return 0},uy=(e,t)=>{let n=iy(e),r=iy(t),i=n.pop(),a=r.pop(),o=ly(n,r);return o===0?i&&a?ly(i.split(`.`),a.split(`.`)):i||a?i?-1:1:0:o},dy=e=>{if(typeof structuredClone==`function`)return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return Array.isArray(e)?[...e]:{...e}}};function fy(){return Wl()}function py(e){if(Object.freeze(e),typeof e==`object`&&e)for(let t of Object.values(e))typeof t==`object`&&t&&!Object.isFrozen(t)&&py(t);return e}var my=512*1024;function hy(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 gy(e,t,n,r){let i=typeof process<`u`&&!0,a=i&&!!{}.VITEST_WORKER_ID,o=i&&!!{}.VITEST_WORKER_ID,s=o&&!hy(t,n,my),c=s?dy(t):t,l=s?dy(n):n,u=!1,d=!1,f;for(let t of e)try{s&&(py(c),py(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=dy(e.messages),u=!0,n=!0),e.state!==void 0&&e.state!==l&&(l=dy(e.state),d=!0,n=!0),s&&n&&hy(c,l,my)&&(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)?dy(c):c}:{},...d?{state:Object.isFrozen(l)?dy(l):l}:{},...f===void 0?{}:{stopPropagation:f}}}function _y(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 vy(e){if(e instanceof yy)return e;if(e===!0)return new yy(_y(!0))}var yy=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 by(e){return e.enabled?new yy(e):void 0}function xy(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 Sy=(e,t,n,r,i)=>{let a=vy(i),o=dy(n.messages),s=dy(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=dy(c);return c={},e.messages!==void 0||e.state!==void 0?oh(e):Dm};return t.pipe(mh(async t=>{let i=await gy(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 P.TEXT_MESSAGE_START:{let i=await gy(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 P.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 gy(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 P.TEXT_MESSAGE_END:{let{messageId:i}=t,a=o.find(e=>e.id===i);return a?(l(await gy(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 P.TOOL_CALL_START:{let i=await gy(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=xy(o,r,e);i.toolCalls??=[],i.toolCalls.push({id:e,type:`function`,function:{name:n,arguments:``}}),l({messages:o})}return u()}case P.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 gy(r,o,s,(r,i,a)=>{let o=d.function.arguments,s=d.function.name,c={};try{c=bh(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 P.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 gy(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 P.TOOL_CALL_RESULT:{let i=await gy(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 P.STATE_SNAPSHOT:{let i=await gy(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 P.STATE_DELTA:{let i=await gy(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=Op.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 P.MESSAGES_SNAPSHOT:{let i=await gy(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 P.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 gy(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:dy(i.content)},c;a===-1?(o.push(t),c=t):d?f&&(o[a]={...d,activityType:i.activityType,content:dy(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 P.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 gy(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=dy(d.content??{}),t=Op.applyPatch(e,i.patch??[],!0,!1).newDocument;o[a]={...d,content:dy(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 P.RAW:return l(await gy(r,o,s,(r,i,a)=>r.onRawEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case P.CUSTOM:return l(await gy(r,o,s,(r,i,a)=>r.onCustomEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case P.RUN_STARTED:{let i=await gy(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 P.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 gy(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 P.RUN_ERROR:return l(await gy(r,o,s,(r,i,a)=>r.onRunErrorEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case P.STEP_STARTED:return l(await gy(r,o,s,(r,i,a)=>r.onStepStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case P.STEP_FINISHED:return l(await gy(r,o,s,(r,i,a)=>r.onStepFinishedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case P.TEXT_MESSAGE_CHUNK:throw Error(`TEXT_MESSAGE_CHUNK must be tranformed before being applied`);case P.TOOL_CALL_CHUNK:throw Error(`TOOL_CALL_CHUNK must be tranformed before being applied`);case P.THINKING_START:return u();case P.THINKING_END:return u();case P.THINKING_TEXT_MESSAGE_START:return u();case P.THINKING_TEXT_MESSAGE_CONTENT:return u();case P.THINKING_TEXT_MESSAGE_END:return u();case P.REASONING_START:return l(await gy(r,o,s,(r,i,a)=>r.onReasoningStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case P.REASONING_MESSAGE_START:{let i=await gy(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 P.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 gy(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 P.REASONING_MESSAGE_END:{let{messageId:i}=t,a=o.find(e=>e.id===i);return a?(l(await gy(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 P.REASONING_MESSAGE_CHUNK:throw Error(`REASONING_MESSAGE_CHUNK must be transformed before being applied`);case P.REASONING_END:return l(await gy(r,o,s,(r,i,a)=>r.onReasoningEndEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case P.REASONING_ENCRYPTED_VALUE:{let{subtype:i,entityId:a,encryptedValue:d}=t,f=await gy(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()}),oee(),r.length>0?see({}):e=>e)},Cy=e=>t=>{let n=vy(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(dh(e=>{let t=e.type;if(n?.event(`VERIFY`,`Event:`,e,{type:e.type}),o)return sh(()=>new ef(`Cannot send event type '${t}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(a&&t!==P.RUN_ERROR&&t!==P.RUN_STARTED)return sh(()=>new ef(`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!==P.RUN_STARTED&&t!==P.RUN_ERROR)return sh(()=>new ef(`First event must be 'RUN_STARTED'`))}else if(t===P.RUN_STARTED){if(d&&!a)return sh(()=>new ef(`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 P.TEXT_MESSAGE_START:{let t=e.messageId;return r.has(t)?sh(()=>new ef(`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),oh(e))}case P.TEXT_MESSAGE_CONTENT:{let t=e.messageId;return r.has(t)?oh(e):sh(()=>new ef(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${t}'. Start a text message with 'TEXT_MESSAGE_START' first.`))}case P.TEXT_MESSAGE_END:{let t=e.messageId;return r.has(t)?(r.delete(t),oh(e)):sh(()=>new ef(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${t}'. A 'TEXT_MESSAGE_START' event must be sent first.`))}case P.TOOL_CALL_START:{let t=e.toolCallId;return i.has(t)?sh(()=>new ef(`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),oh(e))}case P.TOOL_CALL_ARGS:{let t=e.toolCallId;return i.has(t)?oh(e):sh(()=>new ef(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${t}'. Start a tool call with 'TOOL_CALL_START' first.`))}case P.TOOL_CALL_END:{let t=e.toolCallId;return i.has(t)?(i.delete(t),oh(e)):sh(()=>new ef(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${t}'. A 'TOOL_CALL_START' event must be sent first.`))}case P.STEP_STARTED:{let t=e.stepName;return c.has(t)?sh(()=>new ef(`Step "${t}" is already active for 'STEP_STARTED'`)):(c.set(t,!0),oh(e))}case P.STEP_FINISHED:{let t=e.stepName;return c.has(t)?(c.delete(t),oh(e)):sh(()=>new ef(`Cannot send 'STEP_FINISHED' for step "${t}" that was not started`))}case P.RUN_STARTED:return d=!0,oh(e);case P.RUN_FINISHED:if(c.size>0){let e=Array.from(c.keys()).join(`, `);return sh(()=>new ef(`Cannot send 'RUN_FINISHED' while steps are still active: ${e}`))}if(r.size>0){let e=Array.from(r.keys()).join(`, `);return sh(()=>new ef(`Cannot send 'RUN_FINISHED' while text messages are still active: ${e}`))}if(i.size>0){let e=Array.from(i.keys()).join(`, `);return sh(()=>new ef(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${e}`))}return a=!0,oh(e);case P.RUN_ERROR:return o=!0,oh(e);case P.CUSTOM:return oh(e);case P.THINKING_TEXT_MESSAGE_START:return l?u?sh(()=>new ef(`Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.`)):(u=!0,oh(e)):sh(()=>new ef(`Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first.`));case P.THINKING_TEXT_MESSAGE_CONTENT:return u?oh(e):sh(()=>new ef(`Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first.`));case P.THINKING_TEXT_MESSAGE_END:return u?(u=!1,oh(e)):sh(()=>new ef(`Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first.`));case P.THINKING_START:return l?sh(()=>new ef(`Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.`)):(l=!0,oh(e));case P.THINKING_END:return l?(l=!1,oh(e)):sh(()=>new ef(`Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first.`));default:return oh(e)}}))},wy=function(e){return e.HEADERS=`headers`,e.DATA=`data`,e}({}),Ty=e=>fh(()=>ah(e())).pipe(gh(e=>{if(!e.ok){let t=e.headers.get(`content-type`)||``;return ah(e.text()).pipe(dh(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,sh(()=>i)}))}let t={type:wy.HEADERS,status:e.status,headers:e.headers},n=e.body?.getReader();return n?new gm(e=>(e.next(t),(async()=>{try{for(;;){let{done:t,value:r}=await n.read();if(t)break;let i={type:wy.DATA,data:r};e.next(i)}e.complete()}catch(t){e.error(t)}})(),()=>{n.cancel().catch(e=>{if(e?.name!==`AbortError`)throw e})})):sh(()=>Error(`Failed to getReader() from response`))})),Ey=(e,t)=>{let n=vy(t),r=new Cm,i=new TextDecoder(`utf-8`,{fatal:!1}),a=``;e.subscribe({next:e=>{if(e.type!==wy.HEADERS&&e.type===wy.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(`
|
|
82
|
-
`),i=[];for(let e of t)e.startsWith(`data:`)&&i.push(e.slice(5).replace(/^ /,``));if(i.length>0)try{let e=i.join(`
|
|
83
|
-
`),t=JSON.parse(e);n?.event(`SSE`,`Event received:`,t,{type:t.type}),r.next(t)}catch(e){r.error(e)}}return r.asObservable()},Dy=e=>{let t=new Cm,n=new Uint8Array;e.subscribe({next:e=>{if(e.type!==wy.HEADERS&&e.type===wy.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=g_(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()},Oy=(e,t)=>{let n=vy(t),r=new Cm,i=new Em,a=!1;return e.subscribe({next:e=>{if(i.next(e),e.type===wy.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`?Dy(i).subscribe({next:e=>r.next(e),error:e=>r.error(e),complete:()=>r.complete()}):Ey(i,n).subscribe({next:e=>{try{let t=Kf.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:P.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()},ky=ny([`TextMessageStart`,`TextMessageContent`,`TextMessageEnd`,`ActionExecutionStart`,`ActionExecutionArgs`,`ActionExecutionEnd`,`ActionExecutionResult`,`AgentStateMessage`,`MetaEvent`,`RunStarted`,`RunFinished`,`RunError`,`NodeStarted`,`NodeFinished`]),Ay=ny([`LangGraphInterruptEvent`,`PredictState`,`Exit`]);ey(`type`,[$v({type:ty(ky.enum.TextMessageStart),messageId:Xv(),parentMessageId:Xv().optional(),role:Xv().optional()}),$v({type:ty(ky.enum.TextMessageContent),messageId:Xv(),content:Xv()}),$v({type:ty(ky.enum.TextMessageEnd),messageId:Xv()}),$v({type:ty(ky.enum.ActionExecutionStart),actionExecutionId:Xv(),actionName:Xv(),parentMessageId:Xv().optional()}),$v({type:ty(ky.enum.ActionExecutionArgs),actionExecutionId:Xv(),args:Xv()}),$v({type:ty(ky.enum.ActionExecutionEnd),actionExecutionId:Xv()}),$v({type:ty(ky.enum.ActionExecutionResult),actionName:Xv(),actionExecutionId:Xv(),result:Xv()}),$v({type:ty(ky.enum.AgentStateMessage),threadId:Xv(),agentName:Xv(),nodeName:Xv(),runId:Xv(),active:Zv(),role:Xv(),state:Xv(),running:Zv()}),$v({type:ty(ky.enum.MetaEvent),name:Ay,value:Qv()}),$v({type:ty(ky.enum.RunError),message:Xv(),code:Xv().optional()})]),$v({id:Xv(),role:Xv(),content:Xv(),parentMessageId:Xv().optional()}),$v({id:Xv(),name:Xv(),arguments:Qv(),parentMessageId:Xv().optional()}),$v({id:Xv(),result:Qv(),actionExecutionId:Xv(),actionName:Xv()});var jy=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(`
|
|
84
|
-
`)},My=(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(dh(r=>{switch(r.type){case P.TEXT_MESSAGE_START:{let e=r;return[{type:ky.enum.TextMessageStart,messageId:e.messageId,role:e.role}]}case P.TEXT_MESSAGE_CONTENT:{let e=r;return[{type:ky.enum.TextMessageContent,messageId:e.messageId,content:e.delta}]}case P.TEXT_MESSAGE_END:{let e=r;return[{type:ky.enum.TextMessageEnd,messageId:e.messageId}]}case P.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:ky.enum.ActionExecutionStart,actionExecutionId:e.toolCallId,actionName:e.toolCallName,parentMessageId:e.parentMessageId}]}case P.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(bh(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:ky.enum.ActionExecutionArgs,actionExecutionId:c.toolCallId,args:c.delta},...p?[{type:ky.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]:[]]}case P.TOOL_CALL_END:{let e=r;return[{type:ky.enum.ActionExecutionEnd,actionExecutionId:e.toolCallId}]}case P.TOOL_CALL_RESULT:{let e=r;return[{type:ky.enum.ActionExecutionResult,actionExecutionId:e.toolCallId,result:e.content,actionName:d[e.toolCallId]||`unknown`}]}case P.RAW:return[];case P.CUSTOM:{let e=r;switch(e.name){case`Exit`:a=!1;break;case`PredictState`:l=e.value;break}return[{type:ky.enum.MetaEvent,name:e.name,value:e.value}]}case P.STATE_SNAPSHOT:return f(r.snapshot),[{type:ky.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}];case P.STATE_DELTA:{let c=r,l=Op.applyPatch(i,c.delta,!0,!1);return l?(f(l.newDocument),[{type:ky.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]):[]}case P.MESSAGES_SNAPSHOT:return c=r.messages,[{type:ky.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...c?{messages:c}:{}}),active:!0}];case P.RUN_STARTED:return[];case P.RUN_FINISHED:return c&&(i.messages=c),Object.keys(i).length===0?[]:[{type:ky.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...c?{messages:Ny(c)}:{}}),active:!1}];case P.RUN_ERROR:{let e=r;return[{type:ky.enum.RunError,message:e.message,code:e.code}]}case P.STEP_STARTED:return s=r.stepName,u=[],l=null,[{type:ky.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!0}];case P.STEP_FINISHED:return u=[],l=null,[{type:ky.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!1}];default:return[]}}))};function Ny(e){let t=[];for(let n of e)if(n.role===`assistant`||n.role===`user`||n.role===`system`){let e=jy(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 Py=e=>t=>{let n=vy(e),r,i,a,o,s=()=>{if(!r||o!==`text`)throw Error(`No text message to close`);let e={type:P.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:P.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:P.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(dh(e=>{switch(e.type){case P.TEXT_MESSAGE_START:case P.TEXT_MESSAGE_CONTENT:case P.TEXT_MESSAGE_END:case P.TOOL_CALL_START:case P.TOOL_CALL_ARGS:case P.TOOL_CALL_END:case P.TOOL_CALL_RESULT:case P.STATE_SNAPSHOT:case P.STATE_DELTA:case P.MESSAGES_SNAPSHOT:case P.CUSTOM:case P.RUN_STARTED:case P.RUN_FINISHED:case P.RUN_ERROR:case P.STEP_STARTED:case P.STEP_FINISHED:case P.THINKING_START:case P.THINKING_END:case P.THINKING_TEXT_MESSAGE_START:case P.THINKING_TEXT_MESSAGE_CONTENT:case P.THINKING_TEXT_MESSAGE_END:case P.REASONING_START:case P.REASONING_MESSAGE_START:case P.REASONING_MESSAGE_CONTENT:case P.REASONING_MESSAGE_END:case P.REASONING_END:return[...u(),e];case P.RAW:case P.ACTIVITY_SNAPSHOT:case P.ACTIVITY_DELTA:case P.REASONING_ENCRYPTED_VALUE:return[e];case P.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:P.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:P.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 P.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:P.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:P.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 P.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:P.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:P.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,[]}),hh(()=>{u()}))};function Fy(e,t=new Date){return e.expiresAt===void 0?!1:new Date(e.expiresAt)<=t}function Iy(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 Ly=class{runNext(e,t){return t.run(e).pipe(Py(!1))}runNextWithState(e,t){let n=dy(e.messages||[]),r=dy(e.state||{}),i=new Em;return Sy(e,i,t,[]).subscribe(e=>{e.messages!==void 0&&(n=e.messages),e.state!==void 0&&(r=e.state)}),this.runNext(e,t).pipe(mh(async e=>(i.next(e),await new Promise(e=>setTimeout(e,0)),{event:e,messages:dy(n),state:dy(r)})))}},Ry=class extends Ly{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function zy(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 By=class extends Ly{run(e,t){let{parentRunId:n,...r}=e,i={...r,messages:r.messages.map(zy)};return this.runNext(i,t)}},Vy=`THINKING_START`,Hy=`THINKING_END`,Uy=`THINKING_TEXT_MESSAGE_START`,Wy=`THINKING_TEXT_MESSAGE_CONTENT`,Gy=`THINKING_TEXT_MESSAGE_END`,Ky=class extends Ly{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(uh(e=>this.transformEvent(e)))}transformEvent(e){switch(e.type){case Vy:{this.currentReasoningId=fy();let{title:t,...n}=e;return this.warnAboutTransformation(Vy,P.REASONING_START),{...n,type:P.REASONING_START,messageId:this.currentReasoningId}}case Uy:return this.currentMessageId=fy(),this.warnAboutTransformation(Uy,P.REASONING_MESSAGE_START),{...e,type:P.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:`assistant`};case Wy:{let{delta:t,...n}=e;return this.warnAboutTransformation(Wy,P.REASONING_MESSAGE_CONTENT),{...n,type:P.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??fy(),delta:t}}case Gy:{let t=this.currentMessageId??fy();return this.warnAboutTransformation(Gy,P.REASONING_MESSAGE_END),{...e,type:P.REASONING_MESSAGE_END,messageId:t}}case Hy:{let t=this.currentReasoningId??fy();return this.warnAboutTransformation(Hy,P.REASONING_END),{...e,type:P.REASONING_END,messageId:t}}default:return e}}};function qy(e){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:`document`}function Jy(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`binary`&&`mimeType`in e&&typeof e.mimeType==`string`}function Yy(e){let t=qy(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 Xy(e){let t=e.content;if(!Array.isArray(t))return e;let n=t.map(e=>Jy(e)?Yy(e):e);return{...e,content:n}}var Zy=class extends Ly{run(e,t){let n={...e,messages:e.messages.map(Xy)};return this.runNext(n,t)}},Qy=`0.0.57`,$y=class{get maxVersion(){return Qy}get debug(){return this._debug}set debug(e){this._debug=_y(e),this._debugLogger=by(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(e){typeof e==`boolean`?this._debugLogger=e?by(_y(!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??Wl(),this.messages=dy(r??[]),this.state=dy(i??{}),this._debug=_y(a),this._debugLogger=by(this._debug),uy(this.maxVersion,`0.0.39`)<=0&&this.middlewares.unshift(new By),uy(this.maxVersion,`0.0.45`)<=0&&this.middlewares.unshift(new Ky),uy(this.maxVersion,`0.0.47`)<=0&&this.middlewares.unshift(new Zy)}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 Ry(e):e);return this.middlewares.push(...t),this}async runAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??Wl();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 Cm;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await lh(mm(()=>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),Py(this.debugLogger),Cy(this.debugLogger),e=>e.pipe(_h(this.activeRunDetach$)),e=>this.apply(n,e,a),e=>this.processApplyEvents(n,e,a),ph(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))),hh(()=>{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}))(oh(null)));let s=dy(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}connect(e){throw new tf}async connectAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??Wl();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 Cm;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await lh(mm(()=>fh(()=>this.connect(n)),Py(this.debugLogger),Cy(this.debugLogger),e=>e.pipe(_h(this.activeRunDetach$)),e=>this.apply(n,e,a),e=>this.processApplyEvents(n,e,a),ph(e=>(this.isRunning=!1,e instanceof tf?Dm:this.onError(n,e,a))),hh(()=>{this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(oh(null)),{defaultValue:void 0});let s=dy(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 Sy(e,t,this,n,this.debugLogger)}processApplyEvents(e,t,n){return t.pipe(vh(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=dy(this.messages).filter(e=>e.role!==`activity`);return{threadId:this.threadId,runId:e?.runId||Wl(),tools:dy(e?.tools??[]),context:dy(e?.context??[]),forwardedProps:dy(e?.forwardedProps??{}),state:dy(this.state),messages:t,...e?.resume===void 0?{}:{resume:dy(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 ef(`Thread has ${n.length} pending interrupt(s) not addressed by resume: ${n.join(`, `)}`);for(let e of this.pendingInterrupts)if(Fy(e))throw new ef(`Interrupt ${e.id} expired at ${e.expiresAt}`)}let n=await gy(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 ah(gy(n,this.messages,this.state,(n,r,i)=>n.onRunFailed?.({error:t,messages:r,state:i,agent:this,input:e}))).pipe(uh(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 gy(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=dy(this.messages),e.state=dy(this.state),e._debug=this._debug,e._debugLogger=this._debugLogger,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e.pendingInterrupts=dy(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=dy(e),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(e){this.state=dy(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??Wl();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(Py(this.debugLogger),Cy(this.debugLogger),My(this.threadId,t.runId,this.agentId),e=>e.pipe(uh(e=>(this.debugLogger?.event(`LEGACY`,`Event:`,e,{type:e.type}),e))))}},eb=class extends $y{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=dy(e.headers??{}),this.fetch=e.fetch??((e,t)=>fetch(e,t))}run(e){return Oy(Ty(()=>this.fetch(this.url,this.requestInit(e))),this.debugLogger)}clone(){let e=super.clone();e.url=this.url,e.headers=dy(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}},tb;(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})(tb||={});var nb;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(nb||={});var rb=tb.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),ib=e=>{switch(typeof e){case`undefined`:return rb.undefined;case`string`:return rb.string;case`number`:return Number.isNaN(e)?rb.nan:rb.number;case`boolean`:return rb.boolean;case`function`:return rb.function;case`bigint`:return rb.bigint;case`symbol`:return rb.symbol;case`object`:return Array.isArray(e)?rb.array:e===null?rb.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?rb.promise:typeof Map<`u`&&e instanceof Map?rb.map:typeof Set<`u`&&e instanceof Set?rb.set:typeof Date<`u`&&e instanceof Date?rb.date:rb.object;default:return rb.unknown}},R=tb.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`]),ab=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,tb.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()}};ab.create=e=>new ab(e);var ob=(e,t)=>{let n;switch(e.code){case R.invalid_type:n=e.received===rb.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case R.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,tb.jsonStringifyReplacer)}`;break;case R.unrecognized_keys:n=`Unrecognized key(s) in object: ${tb.joinValues(e.keys,`, `)}`;break;case R.invalid_union:n=`Invalid input`;break;case R.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${tb.joinValues(e.options)}`;break;case R.invalid_enum_value:n=`Invalid enum value. Expected ${tb.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}"`:tb.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,tb.assertNever(e)}return{message:n}},sb=ob;function cb(){return sb}var lb=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=cb(),r=lb({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ob?void 0:ob].filter(e=>!!e)});e.common.issues.push(r)}var ub=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 db;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 db;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}}},db=Object.freeze({status:`aborted`}),fb=e=>({status:`dirty`,value:e}),pb=e=>({status:`valid`,value:e}),mb=e=>e.status===`aborted`,hb=e=>e.status===`dirty`,gb=e=>e.status===`valid`,_b=e=>typeof Promise<`u`&&e instanceof Promise,vb;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(vb||={});var yb=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}},bb=(e,t)=>{if(gb(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 ab(e.common.issues);return this._error=t,this._error}}};function xb(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 Sb=class{get description(){return this._def.description}_getType(e){return ib(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ib(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ub,ctx:{common:e.parent.common,data:e.data,parsedType:ib(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(_b(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:ib(e)};return bb(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:ib(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return gb(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=>gb(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:ib(e)},r=this._parse({data:e,path:n.path,parent:n});return bb(n,await(_b(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 gx({schema:this,typeName:Tx.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 _x.create(this,this._def)}nullable(){return vx.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Zb.create(this)}promise(){return hx.create(this,this._def)}or(e){return ex.create([this,e],this._def)}and(e){return ix.create(this,e,this._def)}transform(e){return new gx({...xb(this._def),schema:this,typeName:Tx.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new yx({...xb(this._def),innerType:this,defaultValue:t,typeName:Tx.ZodDefault})}brand(){return new Sx({typeName:Tx.ZodBranded,type:this,...xb(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new bx({...xb(this._def),innerType:this,catchValue:t,typeName:Tx.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Cx.create(this,e)}readonly(){return wx.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Cb=/^c[^\s-]{8,}$/i,wb=/^[0-9a-z]+$/,Tb=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Eb=/^[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,Db=/^[a-z0-9_-]{21}$/i,Ob=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,kb=/^[-+]?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)?)??$/,Ab=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jb=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,Mb,Nb=/^(?:(?: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])$/,Pb=/^(?:(?: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])$/,Fb=/^(([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]))$/,Ib=/^(([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])$/,dee=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,fee=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Lb=`((\\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])))`,pee=RegExp(`^${Lb}$`);function Rb(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 mee(e){return RegExp(`^${Rb(e)}$`)}function hee(e){let t=`${Lb}T${Rb(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function gee(e,t){return!!((t===`v4`||!t)&&Nb.test(e)||(t===`v6`||!t)&&Fb.test(e))}function _ee(e,t){if(!Ob.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 vee(e,t){return!!((t===`v4`||!t)&&Pb.test(e)||(t===`v6`||!t)&&Ib.test(e))}var zb=class e extends Sb{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==rb.string){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:rb.string,received:t.parsedType}),db}let t=new ub,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`)Ab.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`)Mb||=new RegExp(jb,`u`),Mb.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`)Eb.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`)Db.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`)Cb.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`)wb.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`)Tb.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`?hee(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`?pee.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:R.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?mee(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`?kb.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`duration`,code:R.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?gee(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`?_ee(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`?vee(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`?dee.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`base64`,code:R.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?fee.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:`base64url`,code:R.invalid_string,message:r.message}),t.dirty()):tb.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,...vb.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...vb.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...vb.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...vb.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...vb.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...vb.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...vb.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...vb.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...vb.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...vb.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...vb.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...vb.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...vb.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...vb.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,...vb.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,...vb.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...vb.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...vb.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...vb.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...vb.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...vb.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...vb.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...vb.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...vb.errToObj(t)})}nonempty(e){return this.min(1,vb.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}};zb.create=e=>new zb({checks:[],typeName:Tx.ZodString,coerce:e?.coerce??!1,...xb(e)});function yee(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 Bb=class e extends Sb{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)!==rb.number){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:rb.number,received:t.parsedType}),db}let t,n=new ub;for(let r of this._def.checks)r.kind===`int`?tb.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`?yee(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()):tb.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,vb.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,vb.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,vb.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,vb.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:vb.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:vb.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:vb.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:vb.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:vb.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:vb.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:vb.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:vb.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:vb.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:vb.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`&&tb.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)}};Bb.create=e=>new Bb({checks:[],typeName:Tx.ZodNumber,coerce:e?.coerce||!1,...xb(e)});var Vb=class e extends Sb{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)!==rb.bigint)return this._getInvalidInput(e);let t,n=new ub;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()):tb.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:rb.bigint,received:t.parsedType}),db}gte(e,t){return this.setLimit(`min`,e,!0,vb.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,vb.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,vb.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,vb.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:vb.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:vb.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:vb.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:vb.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:vb.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:vb.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}};Vb.create=e=>new Vb({checks:[],typeName:Tx.ZodBigInt,coerce:e?.coerce??!1,...xb(e)});var Hb=class extends Sb{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==rb.boolean){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:rb.boolean,received:t.parsedType}),db}return pb(e.data)}};Hb.create=e=>new Hb({typeName:Tx.ZodBoolean,coerce:e?.coerce||!1,...xb(e)});var Ub=class e extends Sb{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==rb.date){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:rb.date,received:t.parsedType}),db}if(Number.isNaN(e.data.getTime()))return z(this._getOrReturnCtx(e),{code:R.invalid_date}),db;let t=new ub,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()):tb.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:vb.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:vb.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)}};Ub.create=e=>new Ub({checks:[],coerce:e?.coerce||!1,typeName:Tx.ZodDate,...xb(e)});var Wb=class extends Sb{_parse(e){if(this._getType(e)!==rb.symbol){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:rb.symbol,received:t.parsedType}),db}return pb(e.data)}};Wb.create=e=>new Wb({typeName:Tx.ZodSymbol,...xb(e)});var Gb=class extends Sb{_parse(e){if(this._getType(e)!==rb.undefined){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:rb.undefined,received:t.parsedType}),db}return pb(e.data)}};Gb.create=e=>new Gb({typeName:Tx.ZodUndefined,...xb(e)});var Kb=class extends Sb{_parse(e){if(this._getType(e)!==rb.null){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:rb.null,received:t.parsedType}),db}return pb(e.data)}};Kb.create=e=>new Kb({typeName:Tx.ZodNull,...xb(e)});var qb=class extends Sb{constructor(){super(...arguments),this._any=!0}_parse(e){return pb(e.data)}};qb.create=e=>new qb({typeName:Tx.ZodAny,...xb(e)});var Jb=class extends Sb{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pb(e.data)}};Jb.create=e=>new Jb({typeName:Tx.ZodUnknown,...xb(e)});var Yb=class extends Sb{_parse(e){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:rb.never,received:t.parsedType}),db}};Yb.create=e=>new Yb({typeName:Tx.ZodNever,...xb(e)});var Xb=class extends Sb{_parse(e){if(this._getType(e)!==rb.undefined){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:rb.void,received:t.parsedType}),db}return pb(e.data)}};Xb.create=e=>new Xb({typeName:Tx.ZodVoid,...xb(e)});var Zb=class e extends Sb{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==rb.array)return z(t,{code:R.invalid_type,expected:rb.array,received:t.parsedType}),db;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 yb(t,e,t.path,n)))).then(e=>ub.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new yb(t,e,t.path,n)));return ub.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:vb.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:vb.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:vb.toString(n)}})}nonempty(e){return this.min(1,e)}};Zb.create=(e,t)=>new Zb({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Tx.ZodArray,...xb(t)});function Qb(e){if(e instanceof $b){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=_x.create(Qb(r))}return new $b({...e._def,shape:()=>t})}else if(e instanceof Zb)return new Zb({...e._def,type:Qb(e.element)});else if(e instanceof _x)return _x.create(Qb(e.unwrap()));else if(e instanceof vx)return vx.create(Qb(e.unwrap()));else if(e instanceof ax)return ax.create(e.items.map(e=>Qb(e)));else return e}var $b=class e extends Sb{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=tb.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==rb.object){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:rb.object,received:t.parsedType}),db}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Yb&&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 yb(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Yb){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 yb(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=>ub.mergeObjectSync(t,e)):ub.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return vb.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:vb.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:Tx.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 tb.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 tb.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Qb(this)}partial(t){let n={};for(let e of tb.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 tb.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof _x;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return fx(tb.objectKeys(this.shape))}};$b.create=(e,t)=>new $b({shape:()=>e,unknownKeys:`strip`,catchall:Yb.create(),typeName:Tx.ZodObject,...xb(t)}),$b.strictCreate=(e,t)=>new $b({shape:()=>e,unknownKeys:`strict`,catchall:Yb.create(),typeName:Tx.ZodObject,...xb(t)}),$b.lazycreate=(e,t)=>new $b({shape:e,unknownKeys:`strip`,catchall:Yb.create(),typeName:Tx.ZodObject,...xb(t)});var ex=class extends Sb{_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 ab(e.ctx.common.issues));return z(t,{code:R.invalid_union,unionErrors:n}),db}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 ab(e));return z(t,{code:R.invalid_union,unionErrors:i}),db}}get options(){return this._def.options}};ex.create=(e,t)=>new ex({options:e,typeName:Tx.ZodUnion,...xb(t)});var tx=e=>e instanceof ux?tx(e.schema):e instanceof gx?tx(e.innerType()):e instanceof dx?[e.value]:e instanceof px?e.options:e instanceof mx?tb.objectValues(e.enum):e instanceof yx?tx(e._def.innerType):e instanceof Gb?[void 0]:e instanceof Kb?[null]:e instanceof _x?[void 0,...tx(e.unwrap())]:e instanceof vx?[null,...tx(e.unwrap())]:e instanceof Sx||e instanceof wx?tx(e.unwrap()):e instanceof bx?tx(e._def.innerType):[],nx=class e extends Sb{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==rb.object)return z(t,{code:R.invalid_type,expected:rb.object,received:t.parsedType}),db;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]}),db)}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=tx(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:Tx.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...xb(r)})}};function rx(e,t){let n=ib(e),r=ib(t);if(e===t)return{valid:!0,data:e};if(n===rb.object&&r===rb.object){let n=tb.objectKeys(t),r=tb.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=rx(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===rb.array&&r===rb.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=rx(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===rb.date&&r===rb.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var ix=class extends Sb{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(mb(e)||mb(r))return db;let i=rx(e.value,r.value);return i.valid?((hb(e)||hb(r))&&t.dirty(),{status:t.value,value:i.data}):(z(n,{code:R.invalid_intersection_types}),db)};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}))}};ix.create=(e,t,n)=>new ix({left:e,right:t,typeName:Tx.ZodIntersection,...xb(n)});var ax=class e extends Sb{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==rb.array)return z(n,{code:R.invalid_type,expected:rb.array,received:n.parsedType}),db;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`}),db;!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 yb(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>ub.mergeArray(t,e)):ub.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};ax.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new ax({items:e,typeName:Tx.ZodTuple,rest:null,...xb(t)})};var ox=class e extends Sb{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!==rb.object)return z(n,{code:R.invalid_type,expected:rb.object,received:n.parsedType}),db;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new yb(n,e,n.path,e)),value:a._parse(new yb(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?ub.mergeObjectAsync(t,r):ub.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Sb?new e({keyType:t,valueType:n,typeName:Tx.ZodRecord,...xb(r)}):new e({keyType:zb.create(),valueType:t,typeName:Tx.ZodRecord,...xb(n)})}},sx=class extends Sb{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!==rb.map)return z(n,{code:R.invalid_type,expected:rb.map,received:n.parsedType}),db;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new yb(n,e,n.path,[a,`key`])),value:i._parse(new yb(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 db;(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 db;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};sx.create=(e,t,n)=>new sx({valueType:t,keyType:e,typeName:Tx.ZodMap,...xb(n)});var cx=class e extends Sb{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==rb.set)return z(n,{code:R.invalid_type,expected:rb.set,received:n.parsedType}),db;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 db;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 yb(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:vb.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:vb.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};cx.create=(e,t)=>new cx({valueType:e,minSize:null,maxSize:null,typeName:Tx.ZodSet,...xb(t)});var lx=class e extends Sb{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==rb.function)return z(t,{code:R.invalid_type,expected:rb.function,received:t.parsedType}),db;function n(e,n){return lb({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cb(),ob].filter(e=>!!e),issueData:{code:R.invalid_arguments,argumentsError:n}})}function r(e,n){return lb({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cb(),ob].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 hx){let e=this;return pb(async function(...t){let o=new ab([]),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 pb(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new ab([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new ab([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:ax.create(t).rest(Jb.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||ax.create([]).rest(Jb.create()),returns:n||Jb.create(),typeName:Tx.ZodFunction,...xb(r)})}},ux=class extends Sb{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})}};ux.create=(e,t)=>new ux({getter:e,typeName:Tx.ZodLazy,...xb(t)});var dx=class extends Sb{_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}),db}return{status:`valid`,value:e.data}}get value(){return this._def.value}};dx.create=(e,t)=>new dx({value:e,typeName:Tx.ZodLiteral,...xb(t)});function fx(e,t){return new px({values:e,typeName:Tx.ZodEnum,...xb(t)})}var px=class e extends Sb{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return z(t,{expected:tb.joinValues(n),received:t.parsedType,code:R.invalid_type}),db}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}),db}return pb(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})}};px.create=fx;var mx=class extends Sb{_parse(e){let t=tb.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==rb.string&&n.parsedType!==rb.number){let e=tb.objectValues(t);return z(n,{expected:tb.joinValues(e),received:n.parsedType,code:R.invalid_type}),db}if(this._cache||=new Set(tb.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=tb.objectValues(t);return z(n,{received:n.data,code:R.invalid_enum_value,options:e}),db}return pb(e.data)}get enum(){return this._def.values}};mx.create=(e,t)=>new mx({values:e,typeName:Tx.ZodNativeEnum,...xb(t)});var hx=class extends Sb{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==rb.promise&&t.common.async===!1?(z(t,{code:R.invalid_type,expected:rb.promise,received:t.parsedType}),db):pb((t.parsedType===rb.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};hx.create=(e,t)=>new hx({type:e,typeName:Tx.ZodPromise,...xb(t)});var gx=class extends Sb{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Tx.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 db;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?db:r.status===`dirty`||t.value===`dirty`?fb(r.value):r});{if(t.value===`aborted`)return db;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?db:r.status===`dirty`||t.value===`dirty`?fb(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`?db:(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`?db:(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(!gb(e))return db;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=>gb(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):db);tb.assertNever(r)}};gx.create=(e,t,n)=>new gx({schema:e,typeName:Tx.ZodEffects,effect:t,...xb(n)}),gx.createWithPreprocess=(e,t,n)=>new gx({schema:t,effect:{type:`preprocess`,transform:e},typeName:Tx.ZodEffects,...xb(n)});var _x=class extends Sb{_parse(e){return this._getType(e)===rb.undefined?pb(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};_x.create=(e,t)=>new _x({innerType:e,typeName:Tx.ZodOptional,...xb(t)});var vx=class extends Sb{_parse(e){return this._getType(e)===rb.null?pb(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vx.create=(e,t)=>new vx({innerType:e,typeName:Tx.ZodNullable,...xb(t)});var yx=class extends Sb{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===rb.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};yx.create=(e,t)=>new yx({innerType:e,typeName:Tx.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...xb(t)});var bx=class extends Sb{_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 _b(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new ab(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new ab(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};bx.create=(e,t)=>new bx({innerType:e,typeName:Tx.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...xb(t)});var xx=class extends Sb{_parse(e){if(this._getType(e)!==rb.nan){let t=this._getOrReturnCtx(e);return z(t,{code:R.invalid_type,expected:rb.nan,received:t.parsedType}),db}return{status:`valid`,value:e.data}}};xx.create=e=>new xx({typeName:Tx.ZodNaN,...xb(e)});var Sx=class extends Sb{_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}},Cx=class e extends Sb{_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`?db:e.status===`dirty`?(t.dirty(),fb(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`?db: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:Tx.ZodPipeline})}},wx=class extends Sb{_parse(e){let t=this._def.innerType._parse(e),n=e=>(gb(e)&&(e.value=Object.freeze(e.value)),e);return _b(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};wx.create=(e,t)=>new wx({innerType:e,typeName:Tx.ZodReadonly,...xb(t)}),$b.lazycreate;var Tx;(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`})(Tx||={});var Ex=zb.create,Dx=Bb.create;xx.create,Vb.create;var Ox=Hb.create;Ub.create,Wb.create,Gb.create,Kb.create;var kx=qb.create;Jb.create,Yb.create,Xb.create;var Ax=Zb.create,jx=$b.create;$b.strictCreate;var Mx=ex.create;nx.create,ix.create,ax.create;var Nx=ox.create;sx.create,cx.create,lx.create,ux.create;var Px=dx.create,Fx=px.create;mx.create,hx.create,gx.create,_x.create,vx.create;var Ix=gx.createWithPreprocess;Cx.create;var Lx={string:(e=>zb.create({...e,coerce:!0})),number:(e=>Bb.create({...e,coerce:!0})),boolean:(e=>Hb.create({...e,coerce:!0})),bigint:(e=>Vb.create({...e,coerce:!0})),date:(e=>Ub.create({...e,coerce:!0}))},Rx=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)}},zx=class extends Rx{constructor(e,t){super(e,`VALIDATION_ERROR`),this.details=t}},Bx=class extends Rx{constructor(e,t){super(e,`DATA_ERROR`),this.path=t}},Vx=class extends Rx{constructor(e,t,n){super(e,`EXPRESSION_ERROR`),this.expression=t,this.details=n}},Hx=class extends Rx{constructor(e){super(e,`STATE_ERROR`)}};function Ux(e){return e&&typeof e==`object`&&`value`in e&&`peek`in e}function Wx(e,t){return{name:e.name,returnType:e.returnType,schema:e.schema,execute:t}}var Gx=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 Vx(`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 ab?new Vx(`Validation failed for function '${e}': ${t.message}`,e,t.errors??t.issues):t}}}},Kx=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()}},qx=Symbol.for(`preact-signals`);function Jx(){if(eS>1)eS--;else{var e,t=!1;for((function(){var e=iS;for(iS=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}})();$x!==void 0;){var n=$x;for($x=void 0,tS++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&lS(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(tS=0,eS--,t)throw e}}function Yx(e){if(eS>0)return e();rS=++nS,eS++;try{return e()}finally{Jx()}}var Xx,Zx=void 0;function Qx(e){var t=Zx,n=Xx;Zx=void 0,Xx=void 0;try{return e()}finally{Zx=t,Xx=n}}var $x=void 0,eS=0,tS=0,nS=0,rS=0,iS=void 0,aS=0;function oS(e){if(Zx!==void 0){var t=e.n;if(t===void 0||t.t!==Zx)return t={i:0,S:e,p:Zx.s,n:void 0,t:Zx,e:void 0,x:void 0,r:t},Zx.s!==void 0&&(Zx.s.n=t),Zx.s=t,e.n=t,32&Zx.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=Zx.s,t.n=void 0,Zx.s.n=t,Zx.s=t),t}}function sS(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}sS.prototype.brand=qx,sS.prototype.h=function(){return!0},sS.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?Qx(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},sS.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&&Qx(function(){var e;(e=t.Z)==null||e.call(t)}))}},sS.prototype.subscribe=function(e){var t=this;return vS(function(){var n=t.value;Qx(function(){return e(n)})},{name:`sub`})},sS.prototype.valueOf=function(){return this.value},sS.prototype.toString=function(){return this.value+``},sS.prototype.toJSON=function(){return this.value},sS.prototype.peek=function(){var e=this;return Qx(function(){return e.value})},Object.defineProperty(sS.prototype,"value",{get:function(){var e=oS(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(tS>100)throw Error(`Cycle detected`);(function(e){eS!==0&&tS===0&&e.l!==rS&&(e.l=rS,iS={S:e,v:e.v,i:e.i,o:iS})})(this),this.v=e,this.i++,aS++,eS++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Jx()}}}});function cS(e,t){return new sS(e,t)}function lS(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 uS(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 dS(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 fS(e,t){sS.call(this,void 0,t),this.x=e,this.s=void 0,this.g=aS-1,this.f=4}fS.prototype=new sS,fS.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===aS))return!0;if(this.g=aS,this.f|=1,this.i>0&&!lS(this))return this.f&=-2,!0;var e=Zx;try{uS(this),Zx=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 Zx=e,dS(this),this.f&=-2,!0},fS.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)}sS.prototype.S.call(this,e)},fS.prototype.U=function(e){if(this.t!==void 0&&(sS.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)}},fS.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(fS.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=oS(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function pS(e,t){return new fS(e,t)}function mS(e){var t=e.m;if(e.m=void 0,typeof t==`function`){eS++;var n=Zx;Zx=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,hS(e),t}finally{Zx=n,Jx()}}}function hS(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,mS(e)}function gS(e){if(Zx!==this)throw Error(`Out-of-order effect`);dS(this),Zx=e,this.f&=-2,8&this.f&&hS(this),Jx()}function _S(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Xx&&Xx.push(this)}_S.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()}},_S.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,mS(this),uS(this),eS++;var e=Zx;return Zx=this,gS.bind(this,e)},_S.prototype.N=function(){2&this.f||(this.f|=2,this.u=$x,$x=this)},_S.prototype.d=function(){this.f|=8,1&this.f||hS(this)},_S.prototype.dispose=function(){this.d()};function vS(e,t){var n=new _S(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}function yS(e){return/^\d+$/.test(e)}var bS=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,cS(this.get(t))),this.signals.get(t)}set(e,t){if(e==null)throw new Bx(`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)&&!yS(a))throw new Bx(`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 Bx(`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]=yS(e)?[]:{}}i=i[a]}if(Array.isArray(i)&&!yS(r))throw new Bx(`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 Bx(`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=vS(()=>{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);Yx(()=>{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(){Yx(()=>{for(let e of this.signals.keys())this.updateSignal(e)})}isDescendant(e,t){return t===`/`||t===``?e!==`/`:e.startsWith(t+`/`)}},xS=class{constructor(){this.components=new Map,this._onCreated=new Kx,this._onDeleted=new Kx,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 Hx(`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()}},SS=jx({name:Ex().describe(`The name of the action, taken from the component's action.event.name property.`),surfaceId:Ex().describe(`The id of the surface where the event originated.`),sourceComponentId:Ex().describe(`The id of the component that triggered the event.`),timestamp:Ex().datetime().describe(`An ISO 8601 timestamp of when the event occurred.`),context:Nx(kx()).describe(`A JSON object containing the key-value pairs from the component's action.event.context, after resolving all data bindings.`)}).strict(),CS=Mx([jx({code:Px(`VALIDATION_FAILED`),surfaceId:Ex().describe(`The id of the surface where the error occurred.`),path:Ex().describe(`The JSON pointer to the field that failed validation (e.g. '/components/0/text').`),message:Ex().describe(`A short one or two sentence description of why validation failed.`)}).strict(),jx({code:Ex().refine(e=>e!==`VALIDATION_FAILED`),message:Ex().describe(`A short one or two sentence description of why the error occurred.`),surfaceId:Ex().describe(`The id of the surface where the error occurred.`)}).passthrough()]);jx({version:Px(`v0.9`)}).and(Mx([jx({action:SS}),jx({error:CS})])),jx({version:Px(`v0.9`),surfaces:Nx(jx({}).passthrough()).describe(`A map of surface IDs to their current data models.`)}).strict();var wS=class{constructor(e,t,n={},r=!1){this.id=e,this.catalog=t,this.theme=n,this.sendDataModel=r,this._onAction=new Kx,this._onError=new Kx,this.onAction=this._onAction,this.onError=this._onError,this.dataModel=new bS({}),this.componentsModel=new xS}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=SS.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()}},TS=class{constructor(){this.surfaces=new Map,this.surfaceUnsubscribers=new Map,this._onSurfaceCreated=new Kx,this._onSurfaceDeleted=new Kx,this._onAction=new Kx,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()}},ES=class{constructor(e,t,n){this.id=e,this.type=t,this._onUpdated=new Kx,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}}},DS=Symbol(`Let zodToJsonSchema decide on which parser to use`),OS={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`},kS=e=>typeof e==`string`?{...OS,name:e}:{...OS,...e},AS=e=>{let t=kS(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 jS(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function MS(e,t,n,r,i){e[t]=n,jS(e,t,r,i)}var NS=(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(`/`)},PS;(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})(PS||={});var FS;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(FS||={});var IS=PS.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),LS=e=>{switch(typeof e){case`undefined`:return IS.undefined;case`string`:return IS.string;case`number`:return Number.isNaN(e)?IS.nan:IS.number;case`boolean`:return IS.boolean;case`function`:return IS.function;case`bigint`:return IS.bigint;case`symbol`:return IS.symbol;case`object`:return Array.isArray(e)?IS.array:e===null?IS.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?IS.promise:typeof Map<`u`&&e instanceof Map?IS.map:typeof Set<`u`&&e instanceof Set?IS.set:typeof Date<`u`&&e instanceof Date?IS.date:IS.object;default:return IS.unknown}},B=PS.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`]),RS=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,PS.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()}};RS.create=e=>new RS(e);var zS=(e,t)=>{let n;switch(e.code){case B.invalid_type:n=e.received===IS.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case B.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,PS.jsonStringifyReplacer)}`;break;case B.unrecognized_keys:n=`Unrecognized key(s) in object: ${PS.joinValues(e.keys,`, `)}`;break;case B.invalid_union:n=`Invalid input`;break;case B.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${PS.joinValues(e.options)}`;break;case B.invalid_enum_value:n=`Invalid enum value. Expected ${PS.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}"`:PS.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,PS.assertNever(e)}return{message:n}},BS=zS;function VS(){return BS}var HS=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=VS(),r=HS({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===zS?void 0:zS].filter(e=>!!e)});e.common.issues.push(r)}var US=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 WS;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 WS;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}}},WS=Object.freeze({status:`aborted`}),GS=e=>({status:`dirty`,value:e}),KS=e=>({status:`valid`,value:e}),qS=e=>e.status===`aborted`,JS=e=>e.status===`dirty`,YS=e=>e.status===`valid`,XS=e=>typeof Promise<`u`&&e instanceof Promise,ZS;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(ZS||={});var QS=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}},$S=(e,t)=>{if(YS(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 RS(e.common.issues);return this._error=t,this._error}}};function eC(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 tC=class{get description(){return this._def.description}_getType(e){return LS(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:LS(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new US,ctx:{common:e.parent.common,data:e.data,parsedType:LS(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(XS(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:LS(e)};return $S(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:LS(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return YS(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=>YS(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:LS(e)},r=this._parse({data:e,path:n.path,parent:n});return $S(n,await(XS(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 RC({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 zC.create(this,this._def)}nullable(){return BC.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return yC.create(this)}promise(){return LC.create(this,this._def)}or(e){return SC.create([this,e],this._def)}and(e){return EC.create(this,e,this._def)}transform(e){return new RC({...eC(this._def),schema:this,typeName:H.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new VC({...eC(this._def),innerType:this,defaultValue:t,typeName:H.ZodDefault})}brand(){return new WC({typeName:H.ZodBranded,type:this,...eC(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new HC({...eC(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 GC.create(this,e)}readonly(){return KC.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},nC=/^c[^\s-]{8,}$/i,rC=/^[0-9a-z]+$/,bee=/^[0-9A-HJKMNP-TV-Z]{26}$/i,xee=/^[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,See=/^[a-z0-9_-]{21}$/i,Cee=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,wee=/^[-+]?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)?)??$/,Tee=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Eee=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,iC,Dee=/^(?:(?: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])$/,Oee=/^(?:(?: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])$/,kee=/^(([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]))$/,Aee=/^(([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])$/,jee=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Mee=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,aC=`((\\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])))`,Nee=RegExp(`^${aC}$`);function oC(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 Pee(e){return RegExp(`^${oC(e)}$`)}function Fee(e){let t=`${aC}T${oC(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Iee(e,t){return!!((t===`v4`||!t)&&Dee.test(e)||(t===`v6`||!t)&&kee.test(e))}function Lee(e,t){if(!Cee.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 Ree(e,t){return!!((t===`v4`||!t)&&Oee.test(e)||(t===`v6`||!t)&&Aee.test(e))}var sC=class e extends tC{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==IS.string){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:IS.string,received:t.parsedType}),WS}let t=new US,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`)Tee.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`)iC||=new RegExp(Eee,`u`),iC.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`)xee.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`)See.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`)nC.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`)rC.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`)bee.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`?Fee(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`?Nee.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{code:B.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Pee(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`?wee.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`duration`,code:B.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Iee(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`?Lee(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`?Ree(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`?jee.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`base64`,code:B.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Mee.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:`base64url`,code:B.invalid_string,message:r.message}),t.dirty()):PS.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,...ZS.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...ZS.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...ZS.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...ZS.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...ZS.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...ZS.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...ZS.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...ZS.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...ZS.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...ZS.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...ZS.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...ZS.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...ZS.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...ZS.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,...ZS.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,...ZS.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...ZS.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...ZS.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...ZS.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...ZS.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...ZS.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...ZS.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...ZS.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...ZS.errToObj(t)})}nonempty(e){return this.min(1,ZS.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}};sC.create=e=>new sC({checks:[],typeName:H.ZodString,coerce:e?.coerce??!1,...eC(e)});function zee(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 cC=class e extends tC{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)!==IS.number){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:IS.number,received:t.parsedType}),WS}let t,n=new US;for(let r of this._def.checks)r.kind===`int`?PS.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`?zee(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()):PS.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,ZS.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,ZS.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,ZS.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,ZS.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ZS.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:ZS.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:ZS.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:ZS.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:ZS.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:ZS.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:ZS.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:ZS.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:ZS.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:ZS.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`&&PS.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)}};cC.create=e=>new cC({checks:[],typeName:H.ZodNumber,coerce:e?.coerce||!1,...eC(e)});var lC=class e extends tC{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)!==IS.bigint)return this._getInvalidInput(e);let t,n=new US;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()):PS.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:IS.bigint,received:t.parsedType}),WS}gte(e,t){return this.setLimit(`min`,e,!0,ZS.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,ZS.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,ZS.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,ZS.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ZS.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:ZS.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:ZS.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:ZS.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:ZS.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:ZS.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}};lC.create=e=>new lC({checks:[],typeName:H.ZodBigInt,coerce:e?.coerce??!1,...eC(e)});var uC=class extends tC{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==IS.boolean){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:IS.boolean,received:t.parsedType}),WS}return KS(e.data)}};uC.create=e=>new uC({typeName:H.ZodBoolean,coerce:e?.coerce||!1,...eC(e)});var dC=class e extends tC{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==IS.date){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:IS.date,received:t.parsedType}),WS}if(Number.isNaN(e.data.getTime()))return V(this._getOrReturnCtx(e),{code:B.invalid_date}),WS;let t=new US,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()):PS.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:ZS.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:ZS.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)}};dC.create=e=>new dC({checks:[],coerce:e?.coerce||!1,typeName:H.ZodDate,...eC(e)});var fC=class extends tC{_parse(e){if(this._getType(e)!==IS.symbol){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:IS.symbol,received:t.parsedType}),WS}return KS(e.data)}};fC.create=e=>new fC({typeName:H.ZodSymbol,...eC(e)});var pC=class extends tC{_parse(e){if(this._getType(e)!==IS.undefined){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:IS.undefined,received:t.parsedType}),WS}return KS(e.data)}};pC.create=e=>new pC({typeName:H.ZodUndefined,...eC(e)});var mC=class extends tC{_parse(e){if(this._getType(e)!==IS.null){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:IS.null,received:t.parsedType}),WS}return KS(e.data)}};mC.create=e=>new mC({typeName:H.ZodNull,...eC(e)});var hC=class extends tC{constructor(){super(...arguments),this._any=!0}_parse(e){return KS(e.data)}};hC.create=e=>new hC({typeName:H.ZodAny,...eC(e)});var gC=class extends tC{constructor(){super(...arguments),this._unknown=!0}_parse(e){return KS(e.data)}};gC.create=e=>new gC({typeName:H.ZodUnknown,...eC(e)});var _C=class extends tC{_parse(e){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:IS.never,received:t.parsedType}),WS}};_C.create=e=>new _C({typeName:H.ZodNever,...eC(e)});var vC=class extends tC{_parse(e){if(this._getType(e)!==IS.undefined){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:IS.void,received:t.parsedType}),WS}return KS(e.data)}};vC.create=e=>new vC({typeName:H.ZodVoid,...eC(e)});var yC=class e extends tC{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==IS.array)return V(t,{code:B.invalid_type,expected:IS.array,received:t.parsedType}),WS;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 QS(t,e,t.path,n)))).then(e=>US.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new QS(t,e,t.path,n)));return US.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:ZS.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:ZS.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:ZS.toString(n)}})}nonempty(e){return this.min(1,e)}};yC.create=(e,t)=>new yC({type:e,minLength:null,maxLength:null,exactLength:null,typeName:H.ZodArray,...eC(t)});function bC(e){if(e instanceof xC){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=zC.create(bC(r))}return new xC({...e._def,shape:()=>t})}else if(e instanceof yC)return new yC({...e._def,type:bC(e.element)});else if(e instanceof zC)return zC.create(bC(e.unwrap()));else if(e instanceof BC)return BC.create(bC(e.unwrap()));else if(e instanceof DC)return DC.create(e.items.map(e=>bC(e)));else return e}var xC=class e extends tC{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=PS.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==IS.object){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:IS.object,received:t.parsedType}),WS}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof _C&&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 QS(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof _C){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 QS(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=>US.mergeObjectSync(t,e)):US.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return ZS.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:ZS.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 PS.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 PS.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return bC(this)}partial(t){let n={};for(let e of PS.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 PS.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof zC;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return PC(PS.objectKeys(this.shape))}};xC.create=(e,t)=>new xC({shape:()=>e,unknownKeys:`strip`,catchall:_C.create(),typeName:H.ZodObject,...eC(t)}),xC.strictCreate=(e,t)=>new xC({shape:()=>e,unknownKeys:`strict`,catchall:_C.create(),typeName:H.ZodObject,...eC(t)}),xC.lazycreate=(e,t)=>new xC({shape:e,unknownKeys:`strip`,catchall:_C.create(),typeName:H.ZodObject,...eC(t)});var SC=class extends tC{_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 RS(e.ctx.common.issues));return V(t,{code:B.invalid_union,unionErrors:n}),WS}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 RS(e));return V(t,{code:B.invalid_union,unionErrors:i}),WS}}get options(){return this._def.options}};SC.create=(e,t)=>new SC({options:e,typeName:H.ZodUnion,...eC(t)});var CC=e=>e instanceof MC?CC(e.schema):e instanceof RC?CC(e.innerType()):e instanceof NC?[e.value]:e instanceof FC?e.options:e instanceof IC?PS.objectValues(e.enum):e instanceof VC?CC(e._def.innerType):e instanceof pC?[void 0]:e instanceof mC?[null]:e instanceof zC?[void 0,...CC(e.unwrap())]:e instanceof BC?[null,...CC(e.unwrap())]:e instanceof WC||e instanceof KC?CC(e.unwrap()):e instanceof HC?CC(e._def.innerType):[],wC=class e extends tC{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==IS.object)return V(t,{code:B.invalid_type,expected:IS.object,received:t.parsedType}),WS;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]}),WS)}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=CC(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,...eC(r)})}};function TC(e,t){let n=LS(e),r=LS(t);if(e===t)return{valid:!0,data:e};if(n===IS.object&&r===IS.object){let n=PS.objectKeys(t),r=PS.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=TC(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===IS.array&&r===IS.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=TC(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===IS.date&&r===IS.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var EC=class extends tC{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(qS(e)||qS(r))return WS;let i=TC(e.value,r.value);return i.valid?((JS(e)||JS(r))&&t.dirty(),{status:t.value,value:i.data}):(V(n,{code:B.invalid_intersection_types}),WS)};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}))}};EC.create=(e,t,n)=>new EC({left:e,right:t,typeName:H.ZodIntersection,...eC(n)});var DC=class e extends tC{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==IS.array)return V(n,{code:B.invalid_type,expected:IS.array,received:n.parsedType}),WS;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`}),WS;!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 QS(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>US.mergeArray(t,e)):US.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};DC.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new DC({items:e,typeName:H.ZodTuple,rest:null,...eC(t)})};var OC=class e extends tC{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!==IS.object)return V(n,{code:B.invalid_type,expected:IS.object,received:n.parsedType}),WS;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new QS(n,e,n.path,e)),value:a._parse(new QS(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?US.mergeObjectAsync(t,r):US.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof tC?new e({keyType:t,valueType:n,typeName:H.ZodRecord,...eC(r)}):new e({keyType:sC.create(),valueType:t,typeName:H.ZodRecord,...eC(n)})}},kC=class extends tC{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!==IS.map)return V(n,{code:B.invalid_type,expected:IS.map,received:n.parsedType}),WS;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new QS(n,e,n.path,[a,`key`])),value:i._parse(new QS(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 WS;(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 WS;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};kC.create=(e,t,n)=>new kC({valueType:t,keyType:e,typeName:H.ZodMap,...eC(n)});var AC=class e extends tC{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==IS.set)return V(n,{code:B.invalid_type,expected:IS.set,received:n.parsedType}),WS;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 WS;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 QS(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:ZS.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:ZS.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};AC.create=(e,t)=>new AC({valueType:e,minSize:null,maxSize:null,typeName:H.ZodSet,...eC(t)});var jC=class e extends tC{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==IS.function)return V(t,{code:B.invalid_type,expected:IS.function,received:t.parsedType}),WS;function n(e,n){return HS({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,VS(),zS].filter(e=>!!e),issueData:{code:B.invalid_arguments,argumentsError:n}})}function r(e,n){return HS({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,VS(),zS].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 LC){let e=this;return KS(async function(...t){let o=new RS([]),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 KS(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new RS([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new RS([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:DC.create(t).rest(gC.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||DC.create([]).rest(gC.create()),returns:n||gC.create(),typeName:H.ZodFunction,...eC(r)})}},MC=class extends tC{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})}};MC.create=(e,t)=>new MC({getter:e,typeName:H.ZodLazy,...eC(t)});var NC=class extends tC{_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}),WS}return{status:`valid`,value:e.data}}get value(){return this._def.value}};NC.create=(e,t)=>new NC({value:e,typeName:H.ZodLiteral,...eC(t)});function PC(e,t){return new FC({values:e,typeName:H.ZodEnum,...eC(t)})}var FC=class e extends tC{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return V(t,{expected:PS.joinValues(n),received:t.parsedType,code:B.invalid_type}),WS}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}),WS}return KS(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})}};FC.create=PC;var IC=class extends tC{_parse(e){let t=PS.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==IS.string&&n.parsedType!==IS.number){let e=PS.objectValues(t);return V(n,{expected:PS.joinValues(e),received:n.parsedType,code:B.invalid_type}),WS}if(this._cache||=new Set(PS.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=PS.objectValues(t);return V(n,{received:n.data,code:B.invalid_enum_value,options:e}),WS}return KS(e.data)}get enum(){return this._def.values}};IC.create=(e,t)=>new IC({values:e,typeName:H.ZodNativeEnum,...eC(t)});var LC=class extends tC{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==IS.promise&&t.common.async===!1?(V(t,{code:B.invalid_type,expected:IS.promise,received:t.parsedType}),WS):KS((t.parsedType===IS.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};LC.create=(e,t)=>new LC({type:e,typeName:H.ZodPromise,...eC(t)});var RC=class extends tC{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 WS;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?WS:r.status===`dirty`||t.value===`dirty`?GS(r.value):r});{if(t.value===`aborted`)return WS;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?WS:r.status===`dirty`||t.value===`dirty`?GS(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`?WS:(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`?WS:(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(!YS(e))return WS;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=>YS(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):WS);PS.assertNever(r)}};RC.create=(e,t,n)=>new RC({schema:e,typeName:H.ZodEffects,effect:t,...eC(n)}),RC.createWithPreprocess=(e,t,n)=>new RC({schema:t,effect:{type:`preprocess`,transform:e},typeName:H.ZodEffects,...eC(n)});var zC=class extends tC{_parse(e){return this._getType(e)===IS.undefined?KS(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};zC.create=(e,t)=>new zC({innerType:e,typeName:H.ZodOptional,...eC(t)});var BC=class extends tC{_parse(e){return this._getType(e)===IS.null?KS(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};BC.create=(e,t)=>new BC({innerType:e,typeName:H.ZodNullable,...eC(t)});var VC=class extends tC{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===IS.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};VC.create=(e,t)=>new VC({innerType:e,typeName:H.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...eC(t)});var HC=class extends tC{_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 XS(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new RS(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new RS(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};HC.create=(e,t)=>new HC({innerType:e,typeName:H.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...eC(t)});var UC=class extends tC{_parse(e){if(this._getType(e)!==IS.nan){let t=this._getOrReturnCtx(e);return V(t,{code:B.invalid_type,expected:IS.nan,received:t.parsedType}),WS}return{status:`valid`,value:e.data}}};UC.create=e=>new UC({typeName:H.ZodNaN,...eC(e)});var WC=class extends tC{_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}},GC=class e extends tC{_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`?WS:e.status===`dirty`?(t.dirty(),GS(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`?WS: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})}},KC=class extends tC{_parse(e){let t=this._def.innerType._parse(e),n=e=>(YS(e)&&(e.value=Object.freeze(e.value)),e);return XS(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};KC.create=(e,t)=>new KC({innerType:e,typeName:H.ZodReadonly,...eC(t)}),xC.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||={}),sC.create,cC.create,UC.create,lC.create,uC.create,dC.create,fC.create,pC.create,mC.create,hC.create,gC.create,_C.create,vC.create,yC.create,xC.create,xC.strictCreate,SC.create,wC.create,EC.create,DC.create,OC.create,kC.create,AC.create,jC.create,MC.create,NC.create,FC.create,IC.create,LC.create,RC.create,zC.create,BC.create,RC.createWithPreprocess,GC.create;function qC(e){if(e.target!==`openAi`)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy===`relative`?NS(t,e.currentPath):t.join(`/`)}}function JC(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==H.ZodAny&&(n.items=Rw(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&MS(n,`minItems`,e.minLength.value,e.minLength.message,t),e.maxLength&&MS(n,`maxItems`,e.maxLength.value,e.maxLength.message,t),e.exactLength&&(MS(n,`minItems`,e.exactLength.value,e.exactLength.message,t),MS(n,`maxItems`,e.exactLength.value,e.exactLength.message,t)),n}function YC(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?MS(n,`minimum`,r.value,r.message,t):MS(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),MS(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?MS(n,`maximum`,r.value,r.message,t):MS(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),MS(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:MS(n,`multipleOf`,r.value,r.message,t);break}return n}function XC(){return{type:`boolean`}}function ZC(e,t){return Rw(e.type._def,t)}var QC=(e,t)=>Rw(e.innerType._def,t);function $C(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>$C(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 ew(e,t)}}var ew=(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`:MS(n,`minimum`,r.value,r.message,t);break;case`max`:MS(n,`maximum`,r.value,r.message,t);break}return n};function tw(e,t){return{...Rw(e.innerType._def,t),default:e.defaultValue()}}function nw(e,t){return t.effectStrategy===`input`?Rw(e.schema._def,t):qC(t)}function rw(e){return{type:`string`,enum:Array.from(e.values)}}var iw=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function aw(e,t){let n=[Rw(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),Rw(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(iw(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 ow(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 sw=void 0,cw={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:()=>(sw===void 0&&(sw=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),sw),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 lw(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:MS(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t);break;case`max`:MS(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`:pw(n,`email`,r.message,t);break;case`format:idn-email`:pw(n,`idn-email`,r.message,t);break;case`pattern:zod`:mw(n,cw.email,r.message,t);break}break;case`url`:pw(n,`uri`,r.message,t);break;case`uuid`:pw(n,`uuid`,r.message,t);break;case`regex`:mw(n,r.regex,r.message,t);break;case`cuid`:mw(n,cw.cuid,r.message,t);break;case`cuid2`:mw(n,cw.cuid2,r.message,t);break;case`startsWith`:mw(n,RegExp(`^${uw(r.value,t)}`),r.message,t);break;case`endsWith`:mw(n,RegExp(`${uw(r.value,t)}$`),r.message,t);break;case`datetime`:pw(n,`date-time`,r.message,t);break;case`date`:pw(n,`date`,r.message,t);break;case`time`:pw(n,`time`,r.message,t);break;case`duration`:pw(n,`duration`,r.message,t);break;case`length`:MS(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t),MS(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`includes`:mw(n,RegExp(uw(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&pw(n,`ipv4`,r.message,t),r.version!==`v4`&&pw(n,`ipv6`,r.message,t);break;case`base64url`:mw(n,cw.base64url,r.message,t);break;case`jwt`:mw(n,cw.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&mw(n,cw.ipv4Cidr,r.message,t),r.version!==`v4`&&mw(n,cw.ipv6Cidr,r.message,t);break;case`emoji`:mw(n,cw.emoji(),r.message,t);break;case`ulid`:mw(n,cw.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:pw(n,`binary`,r.message,t);break;case`contentEncoding:base64`:MS(n,`contentEncoding`,`base64`,r.message,t);break;case`pattern:zod`:mw(n,cw.base64,r.message,t);break}break;case`nanoid`:mw(n,cw.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:(e=>{})(r)}return n}function uw(e,t){return t.patternStrategy===`escape`?fw(e):e}var dw=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function fw(e){let t=``;for(let n=0;n<e.length;n++)dw.has(e[n])||(t+=`\\`),t+=e[n];return t}function pw(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}}})):MS(e,`format`,t,n,r)}function mw(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:hw(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):MS(e,`pattern`,hw(t,r),n,r)}function hw(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
|
|
85
|
-
]))`;continue}else if(r[e]===`$`){i+=`($|(?=[\r
|
|
86
|
-
]))`;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 gw(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]:Rw(e.valueType._def,{...t,currentPath:[...t.currentPath,`properties`,r]})??qC(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:`object`,additionalProperties:Rw(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}=lw(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}=ZC(e.keyType._def,t);return{...n,propertyNames:i}}return n}function _w(e,t){return t.mapStrategy===`record`?gw(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[Rw(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||qC(t),Rw(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||qC(t)],minItems:2,maxItems:2}}}function vw(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 yw(e){return e.target===`openAi`?void 0:{not:qC({...e,currentPath:[...e.currentPath,`not`]})}}function bw(e){return e.target===`openApi3`?{enum:[`null`],nullable:!0}:{type:`null`}}var xw={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function Sw(e,t){if(t.target===`openApi3`)return Cw(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in xw&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=xw[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 Cw(e,t)}var Cw=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>Rw(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 ww(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:xw[e.innerType._def.typeName],nullable:!0}:{type:[xw[e.innerType._def.typeName],`null`]};if(t.target===`openApi3`){let n=Rw(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&`$ref`in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let n=Rw(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function Tw(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`,jS(n,`type`,r.message,t);break;case`min`:t.target===`jsonSchema7`?r.inclusive?MS(n,`minimum`,r.value,r.message,t):MS(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),MS(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?MS(n,`maximum`,r.value,r.message,t):MS(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),MS(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:MS(n,`multipleOf`,r.value,r.message,t);break}return n}function Ew(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=Ow(o);s&&n&&(o._def.typeName===`ZodOptional`&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let c=Rw(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=Dw(e,t);return o!==void 0&&(r.additionalProperties=o),r}function Dw(e,t){if(e.catchall._def.typeName!==`ZodNever`)return Rw(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 Ow(e){try{return e.isOptional()}catch{return!0}}var kw=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return Rw(e.innerType._def,t);let n=Rw(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:qC(t)},n]}:qC(t)},Aw=(e,t)=>{if(t.pipeStrategy===`input`)return Rw(e.in._def,t);if(t.pipeStrategy===`output`)return Rw(e.out._def,t);let n=Rw(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,Rw(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function jw(e,t){return Rw(e.type._def,t)}function Mw(e,t){let n={type:`array`,uniqueItems:!0,items:Rw(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&MS(n,`minItems`,e.minSize.value,e.minSize.message,t),e.maxSize&&MS(n,`maxItems`,e.maxSize.value,e.maxSize.message,t),n}function Nw(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>Rw(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:Rw(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>Rw(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Pw(e){return{not:qC(e)}}function Fw(e){return qC(e)}var Iw=(e,t)=>Rw(e.innerType._def,t),Lw=(e,t,n)=>{switch(t){case H.ZodString:return lw(e,n);case H.ZodNumber:return Tw(e,n);case H.ZodObject:return Ew(e,n);case H.ZodBigInt:return YC(e,n);case H.ZodBoolean:return XC();case H.ZodDate:return $C(e,n);case H.ZodUndefined:return Pw(n);case H.ZodNull:return bw(n);case H.ZodArray:return JC(e,n);case H.ZodUnion:case H.ZodDiscriminatedUnion:return Sw(e,n);case H.ZodIntersection:return aw(e,n);case H.ZodTuple:return Nw(e,n);case H.ZodRecord:return gw(e,n);case H.ZodLiteral:return ow(e,n);case H.ZodEnum:return rw(e);case H.ZodNativeEnum:return vw(e);case H.ZodNullable:return ww(e,n);case H.ZodOptional:return kw(e,n);case H.ZodMap:return _w(e,n);case H.ZodSet:return Mw(e,n);case H.ZodLazy:return()=>e.getter()._def;case H.ZodPromise:return jw(e,n);case H.ZodNaN:case H.ZodNever:return yw(n);case H.ZodEffects:return nw(e,n);case H.ZodAny:return qC(n);case H.ZodUnknown:return Fw(n);case H.ZodDefault:return tw(e,n);case H.ZodBranded:return ZC(e,n);case H.ZodReadonly:return Iw(e,n);case H.ZodCatch:return QC(e,n);case H.ZodPipeline:return Aw(e,n);case H.ZodFunction:case H.ZodVoid:case H.ZodSymbol:return;default:return(e=>void 0)(t)}};function Rw(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==DS)return i}if(r&&!n){let e=zw(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=Lw(e,e.typeName,t),o=typeof a==`function`?Rw(a(),t):a;if(o&&Bw(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var zw=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:NS(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`),qC(t)):t.$refStrategy===`seen`?qC(t):void 0}},Bw=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),Vw=(e,t)=>{let n=AS(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:Rw(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??qC(n)}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=Rw(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??qC(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},Hw=class{constructor(e,t){this.catalogs=e,this.actionHandler=t,this.model=new TS,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=Vw(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=Vw(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=Vw(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 zx(`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 Hx(`Catalog not found: ${n}`);if(this.model.getSurface(t))throw new Hx(`Surface ${t} already exists.`);let o=new wS(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 Hx(`Surface not found for message: ${t.surfaceId}`);for(let e of t.components){let{id:t,component:r,...i}=e;if(!t)throw new zx(`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 ES(t,r,i);n.componentsModel.addComponent(e)}else a.properties=i;else{if(!r)throw new zx(`Cannot create component ${t} without a type.`);let e=new ES(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 Hx(`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}`}},Uw=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:Ux(i)?i.peek():i}return e}subscribeDynamicValue(e,t){let n=this.resolveSignal(e),r=!0,i=n.peek(),a=vS(()=>{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 cS(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 sS?n:cS(n);return r.unsubscribe=()=>e.abort(),r}let r=Object.keys(n),i=cS(void 0),a,o,s=pS(()=>{let e={};for(let t=0;t<r.length;t++)e[r[t]]=n[r[t]].value;return e}),c=vS(()=>{try{let e=s.value;a&&a.abort(),o&&=(o(),void 0),a=new AbortController;let n=this.evaluateFunctionReactive(t.call,e,a.signal);Ux(n)?o=vS(()=>{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 cS(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 ab){let n=new Vx(`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 Vx?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}`}},Ww=class{constructor(e,t,n=`/`){let r=e.componentsModel.get(t);if(!r)throw new Hx(`Component not found: ${t}`);this.componentModel=r,this.surfaceComponents=e.componentsModel,this.dataContext=new Uw(e,n),this._actionDispatcher=t=>e.dispatchAction(t,this.componentModel.id)}dispatchAction(e){return this._actionDispatcher(e)}};function Gw(e){return Kw(e)}function Kw(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:Kw(n._def.type)};if(n._def.typeName===`ZodObject`){let e={},t=n._def.shape();for(let[n,r]of Object.entries(t))e[n]=Kw(r,n);return{type:`OBJECT`,shape:e}}return{type:`STATIC`}}var qw=class{constructor(e,t){this.dataListeners=[],this.propsListeners=[],this.currentProps={},this.isConnected=!1,this.context=e,this.behaviorTree=Gw(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}},Jw=jx({path:Ex().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.`),Yw=jx({call:Ex().describe(`The name of the function to call.`),args:Nx(kx()).describe(`Arguments passed to the function.`),returnType:Fx([`string`,`number`,`boolean`,`array`,`object`,`any`,`void`]).default(`boolean`)}).describe(`REF:common_types.json#/$defs/FunctionCall|Invokes a named function on the client.`),Xw=Mx([Ox(),Jw,Yw]).describe(`REF:common_types.json#/$defs/DynamicBoolean|A boolean value that can be a literal, a path, or a function call returning a boolean.`),Zw=Mx([Ex(),Jw,Yw]).describe(`REF:common_types.json#/$defs/DynamicString|Represents a string`),Qw=Mx([Dx(),Jw,Yw]).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.`),$w=Mx([Ax(Ex()),Jw,Yw]).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.`),eT=Mx([Ex(),Dx(),Ox(),Ax(kx()),Jw,Yw]).describe(`REF:common_types.json#/$defs/DynamicValue|A value that can be a literal, a path, or a function call returning any type.`),tT=Ex().describe(`REF:common_types.json#/$defs/ComponentId|The unique identifier for a component.`),nT=Mx([Ax(tT).describe(`A static list of child component IDs.`),jx({componentId:tT,path:Ex().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`),rT=Mx([jx({event:jx({name:Ex(),context:Nx(eT).optional()})}).describe(`Triggers a server-side event.`),jx({functionCall:Yw}).describe(`Executes a local client-side function.`)]).describe(`REF:common_types.json#/$defs/Action`),iT=jx({condition:Xw,message:Ex().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.`),aT=jx({checks:Ax(iT).optional().describe(`A list of checks to perform.`)}).describe(`REF:common_types.json#/$defs/Checkable|Properties for components that support client-side checks.`),oT=jx({label:Zw.optional().describe(`REF:common_types.json#/$defs/DynamicString|A short string used by assistive technologies to convey the purpose of an element.`),description:Zw.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.`),sT={ComponentId:tT,ChildList:nT,DataBinding:Jw,DynamicValue:eT,DynamicString:Zw,DynamicNumber:Qw,DynamicBoolean:Xw,DynamicStringList:$w,FunctionCall:Yw,CheckRule:iT,Checkable:aT,Action:rT,AccessibilityAttributes:oT,AnyComponent:jx({component:Ex().describe(`The type name of the component.`),id:tT.optional(),weight:Dx().optional()}).passthrough().describe(`A generic A2UI component definition.`)},cT=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})),lT=o(((e,t)=>{t.exports=cT()})),U=lT();function uT(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 qw(t,e.schema)):i.current=new qw(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 dT=`16px`,fT=`1px solid #ccc`,pT=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`}},mT=e=>{switch(e){case`start`:return`flex-start`;case`center`:return`center`;case`end`:return`flex-end`;case`stretch`:return`stretch`;default:return`stretch`}},hT=()=>({margin:`8px`,boxSizing:`border-box`}),gT=()=>({margin:`8px`,padding:dT,border:fT,borderRadius:`8px`,boxSizing:`border-box`}),_T=class e{static{this.MAX_DEPTH=10}parse(t,n=0){if(n>e.MAX_DEPTH)throw new Vx(`Max recursion depth reached in parse`);if(!t||!t.includes("${"))return[t];let r=[],i=new vT(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 Vx(`Unclosed interpolation: missing '}'`);return e.input.substring(t,e.pos-1)}parseExpression(e,t=0){if(e=e.trim(),!e)return``;let n=new vT(e),r=this.parseExpressionInternal(n,t);if(!n.isAtEnd())throw new Vx(`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 Vx(`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 Vx(`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+=`
|
|
87
|
-
`: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`}},vT=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()}},yT=365.2425,bT=6048e5,xT=864e5,ST=3600*24;ST*7,ST*yT/12*3;var CT=Symbol.for(`constructDateFrom`);function wT(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&CT in e?e[CT](t):e instanceof Date?new e.constructor(t):new Date(t)}function TT(e,t){return wT(t||e,e)}var ET={};function DT(){return ET}function OT(e,t){let n=DT(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=TT(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 kT(e,t){return OT(e,{...t,weekStartsOn:1})}function AT(e,t){let n=TT(e,t?.in),r=n.getFullYear(),i=wT(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=kT(i),o=wT(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=kT(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function jT(e){let t=TT(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 MT(e,...t){let n=wT.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function NT(e,t){let n=TT(e,t?.in);return n.setHours(0,0,0,0),n}function PT(e,t,n){let[r,i]=MT(n?.in,e,t),a=NT(r),o=NT(i),s=+a-jT(a),c=+o-jT(o);return Math.round((s-c)/xT)}function FT(e,t){let n=AT(e,t),r=wT(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),kT(r)}function IT(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function LT(e){return!(!IT(e)&&typeof e!=`number`||isNaN(+TT(e)))}function RT(e,t){let n=TT(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}var zT={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`}},BT=(e,t,n)=>{let r,i=zT[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 VT(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var HT={date:VT({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:VT({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:VT({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},UT={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},WT=(e,t,n,r)=>UT[e];function GT(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 KT={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:GT({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:GT({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:GT({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:GT({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:GT({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 qT(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)?YT(s,e=>e.test(o)):JT(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 JT(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function YT(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function XT(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 ZT={code:`en-US`,formatDistance:BT,formatLong:HT,formatRelative:WT,localize:KT,match:{ordinalNumber:XT({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:qT({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:qT({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:qT({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:qT({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:qT({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 QT(e,t){let n=TT(e,t?.in);return PT(n,RT(n))+1}function $T(e,t){let n=TT(e,t?.in),r=kT(n)-+FT(n);return Math.round(r/bT)+1}function eE(e,t){let n=TT(e,t?.in),r=n.getFullYear(),i=DT(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=wT(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=OT(o,t),c=wT(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=OT(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function tE(e,t){let n=DT(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=eE(e,t),a=wT(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),OT(a,t)}function nE(e,t){let n=TT(e,t?.in),r=OT(n,t)-+tE(n,t);return Math.round(r/bT)+1}function rE(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var iE={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return rE(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):rE(n+1,2)},d(e,t){return rE(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 rE(e.getHours()%12||12,t.length)},H(e,t){return rE(e.getHours(),t.length)},m(e,t){return rE(e.getMinutes(),t.length)},s(e,t){return rE(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return rE(Math.trunc(r*10**(n-3)),t.length)}},aE={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},oE={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 iE.y(e,t)},Y:function(e,t,n,r){let i=eE(e,r),a=i>0?i:1-i;return t===`YY`?rE(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):rE(a,t.length)},R:function(e,t){return rE(AT(e),t.length)},u:function(e,t){return rE(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 rE(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 rE(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 iE.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 rE(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=nE(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):rE(i,t.length)},I:function(e,t,n){let r=$T(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):rE(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):iE.d(e,t)},D:function(e,t,n){let r=QT(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):rE(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 rE(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 rE(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 rE(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?aE.noon:r===0?aE.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?aE.evening:r>=12?aE.afternoon:r>=4?aE.morning:aE.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 iE.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):iE.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):rE(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):rE(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):iE.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):iE.s(e,t)},S:function(e,t){return iE.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return cE(r);case`XXXX`:case`XX`:return lE(r);default:return lE(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return cE(r);case`xxxx`:case`xx`:return lE(r);default:return lE(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+sE(r,`:`);default:return`GMT`+lE(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+sE(r,`:`);default:return`GMT`+lE(r,`:`)}},t:function(e,t,n){return rE(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return rE(+e,t.length)}};function sE(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+rE(a,2)}function cE(e,t){return e%60==0?(e>0?`-`:`+`)+rE(Math.abs(e)/60,2):lE(e,t)}function lE(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=rE(Math.trunc(r/60),2),a=rE(r%60,2);return n+i+t+a}var uE=(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`})}},dE=(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`})}},fE={p:dE,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return uE(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}}`,uE(r,t)).replace(`{{time}}`,dE(i,t))}},pE=/^D+$/,mE=/^Y+$/,hE=[`D`,`DD`,`YY`,`YYYY`];function gE(e){return pE.test(e)}function _E(e){return mE.test(e)}function vE(e,t,n){let r=yE(e,t,n);if(console.warn(r),hE.includes(e))throw RangeError(r)}function yE(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 bE=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,xE=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,SE=/^'([^]*?)'?$/,CE=/''/g,wE=/[a-zA-Z]/;function TE(e,t,n){let r=DT(),i=n?.locale??r.locale??ZT,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=TT(e,n?.in);if(!LT(s))throw RangeError(`Invalid time value`);let c=t.match(xE).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=fE[t];return n(e,i.formatLong)}return e}).join(``).match(bE).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:EE(e)};if(oE[t])return{isToken:!0,value:e};if(t.match(wE))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&&_E(a)||!n?.useAdditionalDayOfYearTokens&&gE(a))&&vE(a,t,String(e));let o=oE[a[0]];return o(s,a,i.localize,l)}).join(``)}function EE(e){let t=e.match(SE);return t?t[1].replace(CE,`'`):e}var DE={name:`add`,returnType:`number`,schema:jx({a:Ix(e=>e===null?void 0:e,Lx.number()),b:Ix(e=>e===null?void 0:e,Lx.number())})},OE={name:`subtract`,returnType:`number`,schema:jx({a:Ix(e=>e===null?void 0:e,Lx.number()),b:Ix(e=>e===null?void 0:e,Lx.number())})},kE={name:`multiply`,returnType:`number`,schema:jx({a:Ix(e=>e===null?void 0:e,Lx.number()),b:Ix(e=>e===null?void 0:e,Lx.number())})},AE={name:`divide`,returnType:`number`,schema:jx({a:Ix(e=>e===null?void 0:e,Lx.number()),b:Ix(e=>e===null?void 0:e,Lx.number())})},jE={name:`equals`,returnType:`boolean`,schema:jx({a:kx().refine(e=>e!==void 0,`Required`),b:kx().refine(e=>e!==void 0,`Required`)})},ME={name:`not_equals`,returnType:`boolean`,schema:jx({a:kx().refine(e=>e!==void 0,`Required`),b:kx().refine(e=>e!==void 0,`Required`)})},NE={name:`greater_than`,returnType:`boolean`,schema:jx({a:Ix(e=>e===null?void 0:e,Lx.number()),b:Ix(e=>e===null?void 0:e,Lx.number())})},PE={name:`less_than`,returnType:`boolean`,schema:jx({a:Ix(e=>e===null?void 0:e,Lx.number()),b:Ix(e=>e===null?void 0:e,Lx.number())})},FE={name:`and`,returnType:`boolean`,schema:jx({values:Ax(kx()).min(2)})},IE={name:`or`,returnType:`boolean`,schema:jx({values:Ax(kx()).min(2)})},LE={name:`not`,returnType:`boolean`,schema:jx({value:kx().refine(e=>e!==void 0,`Required`)})},RE={name:`contains`,returnType:`boolean`,schema:jx({string:Ix(e=>e===void 0?void 0:String(e),Ex()),substring:Ix(e=>e===void 0?void 0:String(e),Ex())})},zE={name:`starts_with`,returnType:`boolean`,schema:jx({string:Ix(e=>e===void 0?void 0:String(e),Ex()),prefix:Ix(e=>e===void 0?void 0:String(e),Ex())})},BE={name:`ends_with`,returnType:`boolean`,schema:jx({string:Ix(e=>e===void 0?void 0:String(e),Ex()),suffix:Ix(e=>e===void 0?void 0:String(e),Ex())})},VE={name:`required`,returnType:`boolean`,schema:jx({value:kx().refine(e=>e!==void 0,`Required`)})},HE={name:`regex`,returnType:`boolean`,schema:jx({value:Ix(e=>e===void 0?void 0:String(e),Ex()),pattern:Ix(e=>e===void 0?void 0:String(e),Ex())})},UE={name:`length`,returnType:`boolean`,schema:jx({value:kx().refine(e=>e!==void 0,`Required`),min:Lx.number().optional(),max:Lx.number().optional()}).refine(e=>e.min!==void 0||e.max!==void 0,{message:`Must provide either 'min' or 'max'`})},WE={name:`numeric`,returnType:`boolean`,schema:jx({value:Lx.number(),min:Lx.number().optional(),max:Lx.number().optional()}).refine(e=>e.min!==void 0||e.max!==void 0,{message:`Must provide either 'min' or 'max'`})},GE={name:`email`,returnType:`boolean`,schema:jx({value:Ix(e=>e===void 0?void 0:String(e),Ex())})},KE={name:`formatString`,returnType:`any`,schema:jx({value:Lx.string()})},qE={name:`formatNumber`,returnType:`string`,schema:jx({value:Lx.number(),decimals:Lx.number().optional(),grouping:Ox().default(!0)})},JE={name:`formatCurrency`,returnType:`string`,schema:jx({value:Lx.number(),currency:Lx.string(),decimals:Lx.number().optional(),grouping:Ox().default(!0)})},YE={name:`formatDate`,returnType:`string`,schema:jx({value:kx().refine(e=>e!==void 0,`Required`),format:Lx.string()})},XE={name:`pluralize`,returnType:`string`,schema:jx({value:Lx.number(),zero:Lx.string().optional(),one:Lx.string().optional(),two:Lx.string().optional(),few:Lx.string().optional(),many:Lx.string().optional(),other:Lx.string()}).passthrough()},ZE={name:`openUrl`,returnType:`void`,schema:jx({url:Ix(e=>e===void 0?void 0:String(e),Ex())})},QE=[Wx(DE,e=>e.a+e.b),Wx(OE,e=>e.a-e.b),Wx(kE,e=>e.a*e.b),Wx(AE,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}),Wx(jE,e=>e.a===e.b),Wx(ME,e=>e.a!==e.b),Wx(NE,e=>e.a>e.b),Wx(PE,e=>e.a<e.b),Wx(FE,e=>e.values.every(e=>!!e)),Wx(IE,e=>e.values.some(e=>!!e)),Wx(LE,e=>!e.value),Wx(RE,e=>e.string.includes(e.substring)),Wx(zE,e=>e.string.startsWith(e.prefix)),Wx(BE,e=>e.string.endsWith(e.suffix)),Wx(VE,e=>{let t=e.value;return!(t==null||typeof t==`string`&&t===``||Array.isArray(t)&&t.length===0)}),Wx(HE,e=>{try{return new RegExp(e.pattern).test(e.value)}catch(t){throw new Vx(`Invalid regex pattern: ${e.pattern}`,`regex`,t)}}),Wx(UE,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)}),Wx(WE,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)),Wx(GE,e=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(e.value)),Wx(KE,(e,t)=>{let n=e.value,r=new _T().parse(n);if(r.length===0)return``;let i=r.map(e=>typeof e!=`object`||!e||Array.isArray(e)?e:t.resolveSignal(e));return pS(()=>i.map(e=>Ux(e)?e.value:e).join(``))}),Wx(qE,e=>isNaN(e.value)?``:new Intl.NumberFormat(`en-US`,{minimumFractionDigits:e.decimals,maximumFractionDigits:e.decimals,useGrouping:e.grouping}).format(e.value)),Wx(JE,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)}}),Wx(YE,e=>{if(!e.value)return``;let t=new Date(e.value);if(isNaN(t.getTime()))return``;try{return e.format===`ISO`?t.toISOString():TE(t,e.format)}catch(e){return console.warn(`Error formatting date:`,e),t.toISOString()}}),Wx(XE,e=>{let t=new Intl.PluralRules(`en-US`).select(e.value);return String(e[t]||e.other||``)}),Wx(ZE,e=>{e.url&&typeof window<`u`&&window.open&&window.open(e.url,`_blank`)})],$E={accessibility:oT.optional(),weight:Dx().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()},eD={name:`Text`,schema:jx({...$E,text:Zw.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:Fx([`h1`,`h2`,`h3`,`h4`,`h5`,`caption`,`body`]).default(`body`).describe(`A hint for the base text style.`).optional()}).strict()},tD={name:`Image`,schema:jx({...$E,url:Zw.describe(`The URL of the image to display.`),description:Zw.describe(`The accessibility description of the image.`).optional(),fit:Fx([`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:Fx([`icon`,`avatar`,`smallFeature`,`mediumFeature`,`largeFeature`,`header`]).default(`mediumFeature`).describe(`A hint for the image size and style.`).optional()}).strict()},nD=`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(`.`),rD={name:`Icon`,schema:jx({...$E,name:Mx([Fx(nD),jx({path:Ex()}).strict()]).describe(`The name of the icon to display.`)}).strict()},iD={name:`Video`,schema:jx({...$E,url:Zw.describe(`The URL of the video to display.`)}).strict()},aD={name:`AudioPlayer`,schema:jx({...$E,url:Zw.describe(`The URL of the audio to be played.`),description:Zw.describe(`A description of the audio, such as a title or summary.`).optional()}).strict()},oD={name:`Row`,schema:jx({...$E,children:nT.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:Fx([`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:Fx([`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.`)},sD={name:`Column`,schema:jx({...$E,children:nT.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:Fx([`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:Fx([`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.`)},cD={name:`List`,schema:jx({...$E,children:nT.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:Fx([`vertical`,`horizontal`]).default(`vertical`).describe(`The direction in which the list items are laid out.`).optional(),align:Fx([`start`,`center`,`end`,`stretch`]).default(`stretch`).describe(`Defines the alignment of children along the cross axis.`).optional()}).strict()},lD={name:`Card`,schema:jx({...$E,child:tT.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()},uD={name:`Tabs`,schema:jx({...$E,tabs:Ax(jx({title:Zw.describe(`The tab title.`),child:tT.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()},dD={name:`Modal`,schema:jx({...$E,trigger:tT.describe(`The ID of the component that opens the modal when interacted with (e.g., a button). Do NOT define the component inline.`),content:tT.describe(`The ID of the component to be displayed inside the modal. Do NOT define the component inline.`)}).strict()},fD={name:`Divider`,schema:jx({...$E,axis:Fx([`horizontal`,`vertical`]).default(`horizontal`).describe(`The orientation of the divider.`).optional()}).strict()},pD={name:`Button`,schema:jx({...$E,child:tT.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:Fx([`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:rT,checks:aT.shape.checks}).strict()},mD={name:`TextField`,schema:jx({...$E,label:Zw.describe(`The text label for the input field.`),value:Zw.describe(`The value of the text field.`).optional(),variant:Fx([`longText`,`number`,`shortText`,`obscured`]).default(`shortText`).describe(`The type of input field to display.`).optional(),validationRegexp:Ex().describe(`A regular expression used for client-side validation of the input.`).optional(),checks:aT.shape.checks}).strict()},hD={name:`CheckBox`,schema:jx({...$E,label:Zw.describe(`The text to display next to the checkbox.`),value:Xw.describe(`The current state of the checkbox (true for checked, false for unchecked).`),checks:aT.shape.checks}).strict()},gD={name:`ChoicePicker`,schema:jx({...$E,label:Zw.describe(`The label for the group of options.`).optional(),variant:Fx([`multipleSelection`,`mutuallyExclusive`]).default(`mutuallyExclusive`).describe(`A hint for how the choice picker should be displayed and behave.`).optional(),options:Ax(jx({label:Zw.describe(`The text to display for this option.`),value:Ex().describe(`The stable value associated with this option.`)}).strict()).describe(`The list of available options to choose from.`),value:$w.describe(`The list of currently selected values. This should be bound to a string array in the data model.`),displayStyle:Fx([`checkbox`,`chips`]).default(`checkbox`).describe(`The display style of the component.`).optional(),filterable:Ox().default(!1).describe(`If true, displays a search input to filter the options.`).optional(),checks:aT.shape.checks}).strict().describe(`A component that allows selecting one or more options from a list.`)},_D={name:`Slider`,schema:jx({...$E,label:Zw.describe(`The label for the slider.`).optional(),min:Dx().default(0).describe(`The minimum value of the slider.`).optional(),max:Dx().describe(`The maximum value of the slider.`),value:Qw.describe(`The current value of the slider.`),checks:aT.shape.checks}).strict()},vD={name:`DateTimeInput`,schema:jx({...$E,value:Zw.describe(`The selected date and/or time value in ISO 8601 format. If not yet set, initialize with an empty string.`),enableDate:Ox().default(!1).describe(`If true, allows the user to select a date.`).optional(),enableTime:Ox().default(!1).describe(`If true, allows the user to select a time.`).optional(),min:Mx([Zw,Ex().date(),Ex().time(),Ex().datetime()]).describe(`The minimum allowed date/time in ISO 8601 format.`).optional(),max:Mx([Zw,Ex().date(),Ex().time(),Ex().datetime()]).describe(`The maximum allowed date/time in ISO 8601 format.`).optional(),label:Zw.describe(`The text label for the input field.`).optional(),checks:aT.shape.checks}).strict()},yD=uT(eD,({props:e})=>{let t=e.text??``,n={...hT(),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})}}),bD=uT(tD,({props:e})=>{let t=e=>e===`scaleDown`?`scale-down`:e||`fill`,n={...hT(),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})}),xD=uT(rD,({props:e})=>{let t=typeof e.name==`string`?e.name:e.name?.path;return(0,U.jsx)(`span`,{className:`material-symbols-outlined`,style:{...hT(),fontSize:`24px`,width:`24px`,height:`24px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`},children:t})}),SD=uT(iD,({props:e})=>{let t={...hT(),width:`100%`,aspectRatio:`16/9`};return(0,U.jsx)(`video`,{src:e.url,controls:!0,style:t})}),CD=uT(aD,({props:e})=>{let t={...hT(),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})]})}),wD=({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,TD=new Gx(`https://a2ui.org/specification/v0_9/basic_catalog.json`,[yD,bD,xD,SD,CD,uT(oD,({props:e,buildChild:t,context:n})=>(0,U.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:pT(e.justify),alignItems:mT(e.align),width:`100%`,margin:0,padding:0},children:(0,U.jsx)(wD,{childList:e.children,buildChild:t,context:n})})),uT(sD,({props:e,buildChild:t,context:n})=>(0,U.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:pT(e.justify),alignItems:mT(e.align),width:`100%`,margin:0,padding:0},children:(0,U.jsx)(wD,{childList:e.children,buildChild:t,context:n})})),uT(cD,({props:e,buildChild:t,context:n})=>{let r=e.direction===`horizontal`;return(0,U.jsx)(`div`,{style:{display:`flex`,flexDirection:r?`row`:`column`,alignItems:mT(e.align),overflowX:r?`auto`:`hidden`,overflowY:r?`hidden`:`auto`,width:`100%`,margin:0,padding:0},children:(0,U.jsx)(wD,{childList:e.children,buildChild:t,context:n})})}),uT(lD,({props:e,buildChild:t})=>(0,U.jsx)(`div`,{style:{...gT(),backgroundColor:`#fff`,boxShadow:`0 2px 4px rgba(0,0,0,0.1)`,width:`100%`},children:e.child?t(e.child):null})),uT(uD,({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})]})}),uT(fD,({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})}),uT(dD,({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})]})})]})}),uT(pD,({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})),uT(mD,({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:fT,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`:fT},value:e.value||``,onChange:t}):(0,U.jsx)(`input`,{id:a,type:r,style:{...i,border:o?`1px solid red`:fT},value:e.value||``,onChange:t}),o&&(0,U.jsx)(`span`,{style:{fontSize:`12px`,color:`red`},children:e.validationErrors[0]})]})}),uT(hD,({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]})]})}),uT(gD,({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)`:fT,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)})})]})}),uT(_D,({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`}})]})}),uT(vD,({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:fT,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})]})})],QE),ED=(0,b.createContext)(void 0);function DD({theme:e,children:t}){return(0,U.jsx)(ED.Provider,{value:e??{},children:t})}var OD=(0,b.memo)(({surface:e,id:t,basePath:n,compImpl:r,componentModel:i})=>{let a=r.render,o=(0,b.useMemo)(()=>new Ww(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)(kD,{surface:e,id:t,basePath:r},`${t}-${r}`)},[e,o.dataContext.path])})});OD.displayName=`ResolvedChild`;var kD=(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)(OD,{surface:e,id:t,basePath:n,componentModel:i,compImpl:a}):(0,U.jsxs)(`div`,{style:{color:`red`},children:[`Unknown component: `,i.type]})});kD.displayName=`DeferredChild`;var AD=({surface:e})=>(0,U.jsx)(kD,{surface:e,id:`root`,basePath:`/`}),jD;(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})(jD||={});var MD;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(MD||={});var ND=jD.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),PD=e=>{switch(typeof e){case`undefined`:return ND.undefined;case`string`:return ND.string;case`number`:return Number.isNaN(e)?ND.nan:ND.number;case`boolean`:return ND.boolean;case`function`:return ND.function;case`bigint`:return ND.bigint;case`symbol`:return ND.symbol;case`object`:return Array.isArray(e)?ND.array:e===null?ND.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?ND.promise:typeof Map<`u`&&e instanceof Map?ND.map:typeof Set<`u`&&e instanceof Set?ND.set:typeof Date<`u`&&e instanceof Date?ND.date:ND.object;default:return ND.unknown}},W=jD.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`]),FD=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,jD.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()}};FD.create=e=>new FD(e);var ID=(e,t)=>{let n;switch(e.code){case W.invalid_type:n=e.received===ND.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case W.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,jD.jsonStringifyReplacer)}`;break;case W.unrecognized_keys:n=`Unrecognized key(s) in object: ${jD.joinValues(e.keys,`, `)}`;break;case W.invalid_union:n=`Invalid input`;break;case W.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${jD.joinValues(e.options)}`;break;case W.invalid_enum_value:n=`Invalid enum value. Expected ${jD.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}"`:jD.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,jD.assertNever(e)}return{message:n}},LD=ID;function RD(){return LD}var zD=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=RD(),r=zD({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ID?void 0:ID].filter(e=>!!e)});e.common.issues.push(r)}var BD=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 VD;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 VD;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}}},VD=Object.freeze({status:`aborted`}),HD=e=>({status:`dirty`,value:e}),UD=e=>({status:`valid`,value:e}),WD=e=>e.status===`aborted`,GD=e=>e.status===`dirty`,KD=e=>e.status===`valid`,qD=e=>typeof Promise<`u`&&e instanceof Promise,JD;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(JD||={});var YD=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}},XD=(e,t)=>{if(KD(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 FD(e.common.issues);return this._error=t,this._error}}};function ZD(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 QD=class{get description(){return this._def.description}_getType(e){return PD(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:PD(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new BD,ctx:{common:e.parent.common,data:e.data,parsedType:PD(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(qD(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:PD(e)};return XD(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:PD(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return KD(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=>KD(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:PD(e)},r=this._parse({data:e,path:n.path,parent:n});return XD(n,await(qD(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 QO({schema:this,typeName:sk.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 $O.create(this,this._def)}nullable(){return ek.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return IO.create(this)}promise(){return ZO.create(this,this._def)}or(e){return zO.create([this,e],this._def)}and(e){return HO.create(this,e,this._def)}transform(e){return new QO({...ZD(this._def),schema:this,typeName:sk.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new tk({...ZD(this._def),innerType:this,defaultValue:t,typeName:sk.ZodDefault})}brand(){return new ik({typeName:sk.ZodBranded,type:this,...ZD(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new nk({...ZD(this._def),innerType:this,catchValue:t,typeName:sk.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ak.create(this,e)}readonly(){return ok.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},$D=/^c[^\s-]{8,}$/i,eO=/^[0-9a-z]+$/,tO=/^[0-9A-HJKMNP-TV-Z]{26}$/i,nO=/^[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,rO=/^[a-z0-9_-]{21}$/i,iO=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,aO=/^[-+]?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)?)??$/,oO=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,sO=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,cO,lO=/^(?:(?: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])$/,uO=/^(?:(?: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])$/,dO=/^(([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]))$/,fO=/^(([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])$/,pO=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,mO=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,hO=`((\\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])))`,gO=RegExp(`^${hO}$`);function _O(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 vO(e){return RegExp(`^${_O(e)}$`)}function yO(e){let t=`${hO}T${_O(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function bO(e,t){return!!((t===`v4`||!t)&&lO.test(e)||(t===`v6`||!t)&&dO.test(e))}function xO(e,t){if(!iO.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 SO(e,t){return!!((t===`v4`||!t)&&uO.test(e)||(t===`v6`||!t)&&fO.test(e))}var CO=class e extends QD{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ND.string){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:ND.string,received:t.parsedType}),VD}let t=new BD,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`)oO.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`)cO||=new RegExp(sO,`u`),cO.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`)nO.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`)rO.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`)$D.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`)eO.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`)tO.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`?yO(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`?gO.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:W.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?vO(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`?aO.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`duration`,code:W.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?bO(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`?xO(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`?SO(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`?pO.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`base64`,code:W.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?mO.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:`base64url`,code:W.invalid_string,message:r.message}),t.dirty()):jD.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,...JD.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...JD.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...JD.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...JD.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...JD.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...JD.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...JD.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...JD.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...JD.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...JD.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...JD.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...JD.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...JD.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...JD.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,...JD.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,...JD.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...JD.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...JD.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...JD.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...JD.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...JD.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...JD.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...JD.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...JD.errToObj(t)})}nonempty(e){return this.min(1,JD.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}};CO.create=e=>new CO({checks:[],typeName:sk.ZodString,coerce:e?.coerce??!1,...ZD(e)});function wO(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 TO=class e extends QD{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)!==ND.number){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:ND.number,received:t.parsedType}),VD}let t,n=new BD;for(let r of this._def.checks)r.kind===`int`?jD.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`?wO(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()):jD.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,JD.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,JD.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,JD.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,JD.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:JD.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:JD.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:JD.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:JD.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:JD.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:JD.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:JD.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:JD.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:JD.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:JD.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`&&jD.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)}};TO.create=e=>new TO({checks:[],typeName:sk.ZodNumber,coerce:e?.coerce||!1,...ZD(e)});var EO=class e extends QD{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)!==ND.bigint)return this._getInvalidInput(e);let t,n=new BD;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()):jD.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:ND.bigint,received:t.parsedType}),VD}gte(e,t){return this.setLimit(`min`,e,!0,JD.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,JD.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,JD.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,JD.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:JD.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:JD.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:JD.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:JD.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:JD.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:JD.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}};EO.create=e=>new EO({checks:[],typeName:sk.ZodBigInt,coerce:e?.coerce??!1,...ZD(e)});var DO=class extends QD{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ND.boolean){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:ND.boolean,received:t.parsedType}),VD}return UD(e.data)}};DO.create=e=>new DO({typeName:sk.ZodBoolean,coerce:e?.coerce||!1,...ZD(e)});var OO=class e extends QD{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ND.date){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:ND.date,received:t.parsedType}),VD}if(Number.isNaN(e.data.getTime()))return G(this._getOrReturnCtx(e),{code:W.invalid_date}),VD;let t=new BD,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()):jD.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:JD.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:JD.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)}};OO.create=e=>new OO({checks:[],coerce:e?.coerce||!1,typeName:sk.ZodDate,...ZD(e)});var kO=class extends QD{_parse(e){if(this._getType(e)!==ND.symbol){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:ND.symbol,received:t.parsedType}),VD}return UD(e.data)}};kO.create=e=>new kO({typeName:sk.ZodSymbol,...ZD(e)});var AO=class extends QD{_parse(e){if(this._getType(e)!==ND.undefined){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:ND.undefined,received:t.parsedType}),VD}return UD(e.data)}};AO.create=e=>new AO({typeName:sk.ZodUndefined,...ZD(e)});var jO=class extends QD{_parse(e){if(this._getType(e)!==ND.null){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:ND.null,received:t.parsedType}),VD}return UD(e.data)}};jO.create=e=>new jO({typeName:sk.ZodNull,...ZD(e)});var MO=class extends QD{constructor(){super(...arguments),this._any=!0}_parse(e){return UD(e.data)}};MO.create=e=>new MO({typeName:sk.ZodAny,...ZD(e)});var NO=class extends QD{constructor(){super(...arguments),this._unknown=!0}_parse(e){return UD(e.data)}};NO.create=e=>new NO({typeName:sk.ZodUnknown,...ZD(e)});var PO=class extends QD{_parse(e){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:ND.never,received:t.parsedType}),VD}};PO.create=e=>new PO({typeName:sk.ZodNever,...ZD(e)});var FO=class extends QD{_parse(e){if(this._getType(e)!==ND.undefined){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:ND.void,received:t.parsedType}),VD}return UD(e.data)}};FO.create=e=>new FO({typeName:sk.ZodVoid,...ZD(e)});var IO=class e extends QD{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==ND.array)return G(t,{code:W.invalid_type,expected:ND.array,received:t.parsedType}),VD;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 YD(t,e,t.path,n)))).then(e=>BD.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new YD(t,e,t.path,n)));return BD.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:JD.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:JD.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:JD.toString(n)}})}nonempty(e){return this.min(1,e)}};IO.create=(e,t)=>new IO({type:e,minLength:null,maxLength:null,exactLength:null,typeName:sk.ZodArray,...ZD(t)});function LO(e){if(e instanceof RO){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=$O.create(LO(r))}return new RO({...e._def,shape:()=>t})}else if(e instanceof IO)return new IO({...e._def,type:LO(e.element)});else if(e instanceof $O)return $O.create(LO(e.unwrap()));else if(e instanceof ek)return ek.create(LO(e.unwrap()));else if(e instanceof UO)return UO.create(e.items.map(e=>LO(e)));else return e}var RO=class e extends QD{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=jD.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==ND.object){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:ND.object,received:t.parsedType}),VD}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof PO&&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 YD(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof PO){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 YD(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=>BD.mergeObjectSync(t,e)):BD.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return JD.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:JD.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:sk.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 jD.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 jD.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return LO(this)}partial(t){let n={};for(let e of jD.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 jD.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof $O;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return JO(jD.objectKeys(this.shape))}};RO.create=(e,t)=>new RO({shape:()=>e,unknownKeys:`strip`,catchall:PO.create(),typeName:sk.ZodObject,...ZD(t)}),RO.strictCreate=(e,t)=>new RO({shape:()=>e,unknownKeys:`strict`,catchall:PO.create(),typeName:sk.ZodObject,...ZD(t)}),RO.lazycreate=(e,t)=>new RO({shape:e,unknownKeys:`strip`,catchall:PO.create(),typeName:sk.ZodObject,...ZD(t)});var zO=class extends QD{_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 FD(e.ctx.common.issues));return G(t,{code:W.invalid_union,unionErrors:n}),VD}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 FD(e));return G(t,{code:W.invalid_union,unionErrors:i}),VD}}get options(){return this._def.options}};zO.create=(e,t)=>new zO({options:e,typeName:sk.ZodUnion,...ZD(t)});var BO=e=>e instanceof KO?BO(e.schema):e instanceof QO?BO(e.innerType()):e instanceof qO?[e.value]:e instanceof YO?e.options:e instanceof XO?jD.objectValues(e.enum):e instanceof tk?BO(e._def.innerType):e instanceof AO?[void 0]:e instanceof jO?[null]:e instanceof $O?[void 0,...BO(e.unwrap())]:e instanceof ek?[null,...BO(e.unwrap())]:e instanceof ik||e instanceof ok?BO(e.unwrap()):e instanceof nk?BO(e._def.innerType):[],Bee=class e extends QD{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==ND.object)return G(t,{code:W.invalid_type,expected:ND.object,received:t.parsedType}),VD;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]}),VD)}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=BO(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:sk.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...ZD(r)})}};function VO(e,t){let n=PD(e),r=PD(t);if(e===t)return{valid:!0,data:e};if(n===ND.object&&r===ND.object){let n=jD.objectKeys(t),r=jD.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=VO(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===ND.array&&r===ND.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=VO(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===ND.date&&r===ND.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var HO=class extends QD{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(WD(e)||WD(r))return VD;let i=VO(e.value,r.value);return i.valid?((GD(e)||GD(r))&&t.dirty(),{status:t.value,value:i.data}):(G(n,{code:W.invalid_intersection_types}),VD)};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}))}};HO.create=(e,t,n)=>new HO({left:e,right:t,typeName:sk.ZodIntersection,...ZD(n)});var UO=class e extends QD{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ND.array)return G(n,{code:W.invalid_type,expected:ND.array,received:n.parsedType}),VD;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`}),VD;!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 YD(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>BD.mergeArray(t,e)):BD.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};UO.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new UO({items:e,typeName:sk.ZodTuple,rest:null,...ZD(t)})};var Vee=class e extends QD{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!==ND.object)return G(n,{code:W.invalid_type,expected:ND.object,received:n.parsedType}),VD;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new YD(n,e,n.path,e)),value:a._parse(new YD(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?BD.mergeObjectAsync(t,r):BD.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof QD?new e({keyType:t,valueType:n,typeName:sk.ZodRecord,...ZD(r)}):new e({keyType:CO.create(),valueType:t,typeName:sk.ZodRecord,...ZD(n)})}},WO=class extends QD{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!==ND.map)return G(n,{code:W.invalid_type,expected:ND.map,received:n.parsedType}),VD;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new YD(n,e,n.path,[a,`key`])),value:i._parse(new YD(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 VD;(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 VD;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};WO.create=(e,t,n)=>new WO({valueType:t,keyType:e,typeName:sk.ZodMap,...ZD(n)});var GO=class e extends QD{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ND.set)return G(n,{code:W.invalid_type,expected:ND.set,received:n.parsedType}),VD;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 VD;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 YD(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:JD.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:JD.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};GO.create=(e,t)=>new GO({valueType:e,minSize:null,maxSize:null,typeName:sk.ZodSet,...ZD(t)});var Hee=class e extends QD{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==ND.function)return G(t,{code:W.invalid_type,expected:ND.function,received:t.parsedType}),VD;function n(e,n){return zD({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,RD(),ID].filter(e=>!!e),issueData:{code:W.invalid_arguments,argumentsError:n}})}function r(e,n){return zD({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,RD(),ID].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 ZO){let e=this;return UD(async function(...t){let o=new FD([]),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 UD(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new FD([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new FD([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:UO.create(t).rest(NO.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||UO.create([]).rest(NO.create()),returns:n||NO.create(),typeName:sk.ZodFunction,...ZD(r)})}},KO=class extends QD{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})}};KO.create=(e,t)=>new KO({getter:e,typeName:sk.ZodLazy,...ZD(t)});var qO=class extends QD{_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}),VD}return{status:`valid`,value:e.data}}get value(){return this._def.value}};qO.create=(e,t)=>new qO({value:e,typeName:sk.ZodLiteral,...ZD(t)});function JO(e,t){return new YO({values:e,typeName:sk.ZodEnum,...ZD(t)})}var YO=class e extends QD{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return G(t,{expected:jD.joinValues(n),received:t.parsedType,code:W.invalid_type}),VD}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}),VD}return UD(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})}};YO.create=JO;var XO=class extends QD{_parse(e){let t=jD.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ND.string&&n.parsedType!==ND.number){let e=jD.objectValues(t);return G(n,{expected:jD.joinValues(e),received:n.parsedType,code:W.invalid_type}),VD}if(this._cache||=new Set(jD.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=jD.objectValues(t);return G(n,{received:n.data,code:W.invalid_enum_value,options:e}),VD}return UD(e.data)}get enum(){return this._def.values}};XO.create=(e,t)=>new XO({values:e,typeName:sk.ZodNativeEnum,...ZD(t)});var ZO=class extends QD{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==ND.promise&&t.common.async===!1?(G(t,{code:W.invalid_type,expected:ND.promise,received:t.parsedType}),VD):UD((t.parsedType===ND.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ZO.create=(e,t)=>new ZO({type:e,typeName:sk.ZodPromise,...ZD(t)});var QO=class extends QD{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===sk.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 VD;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?VD:r.status===`dirty`||t.value===`dirty`?HD(r.value):r});{if(t.value===`aborted`)return VD;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?VD:r.status===`dirty`||t.value===`dirty`?HD(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`?VD:(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`?VD:(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(!KD(e))return VD;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=>KD(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):VD);jD.assertNever(r)}};QO.create=(e,t,n)=>new QO({schema:e,typeName:sk.ZodEffects,effect:t,...ZD(n)}),QO.createWithPreprocess=(e,t,n)=>new QO({schema:t,effect:{type:`preprocess`,transform:e},typeName:sk.ZodEffects,...ZD(n)});var $O=class extends QD{_parse(e){return this._getType(e)===ND.undefined?UD(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$O.create=(e,t)=>new $O({innerType:e,typeName:sk.ZodOptional,...ZD(t)});var ek=class extends QD{_parse(e){return this._getType(e)===ND.null?UD(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ek.create=(e,t)=>new ek({innerType:e,typeName:sk.ZodNullable,...ZD(t)});var tk=class extends QD{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===ND.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};tk.create=(e,t)=>new tk({innerType:e,typeName:sk.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...ZD(t)});var nk=class extends QD{_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 qD(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new FD(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new FD(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};nk.create=(e,t)=>new nk({innerType:e,typeName:sk.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...ZD(t)});var rk=class extends QD{_parse(e){if(this._getType(e)!==ND.nan){let t=this._getOrReturnCtx(e);return G(t,{code:W.invalid_type,expected:ND.nan,received:t.parsedType}),VD}return{status:`valid`,value:e.data}}};rk.create=e=>new rk({typeName:sk.ZodNaN,...ZD(e)});var ik=class extends QD{_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}},ak=class e extends QD{_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`?VD:e.status===`dirty`?(t.dirty(),HD(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`?VD: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:sk.ZodPipeline})}},ok=class extends QD{_parse(e){let t=this._def.innerType._parse(e),n=e=>(KD(e)&&(e.value=Object.freeze(e.value)),e);return qD(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};ok.create=(e,t)=>new ok({innerType:e,typeName:sk.ZodReadonly,...ZD(t)}),RO.lazycreate;var sk;(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`})(sk||={});var Uee=CO.create;TO.create,rk.create,EO.create,DO.create,OO.create,kO.create,AO.create,jO.create,MO.create;var Wee=NO.create;PO.create,FO.create,IO.create;var ck=RO.create;RO.strictCreate,zO.create,Bee.create,HO.create,UO.create,Vee.create,WO.create,GO.create,Hee.create,KO.create,qO.create;var lk=YO.create;XO.create,ZO.create,QO.create,$O.create,ek.create,QO.createWithPreprocess,ak.create;var Gee=uT({name:`Text`,schema:ck({text:sT.DynamicString,variant:lk([`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})}}),Kee=uT({name:`Button`,schema:ck({child:sT.ComponentId,action:sT.Action,variant:lk([`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})),uk=({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,qee=ck({children:sT.ChildList,justify:lk([`center`,`end`,`spaceAround`,`spaceBetween`,`spaceEvenly`,`start`,`stretch`]).optional(),align:lk([`start`,`center`,`end`,`stretch`]).optional()}),Jee=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`}},Yee=e=>{switch(e){case`start`:return`flex-start`;case`center`:return`center`;case`end`:return`flex-end`;case`stretch`:return`stretch`;default:return`stretch`}},Xee=uT({name:`Row`,schema:qee},({props:e,buildChild:t})=>(0,U.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:Jee(e.justify),alignItems:Yee(e.align)},children:(0,U.jsx)(uk,{childList:e.children,buildChild:t})})),Zee=ck({children:sT.ChildList,justify:lk([`start`,`center`,`end`,`spaceBetween`,`spaceAround`,`spaceEvenly`,`stretch`]).optional(),align:lk([`center`,`end`,`start`,`stretch`]).optional()}),Qee=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`}},$ee=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 Gx(`https://a2ui.org/specification/v0_9/catalogs/minimal/minimal_catalog.json`,[Gee,Kee,Xee,uT({name:`Column`,schema:Zee},({props:e,buildChild:t})=>(0,U.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:Qee(e.justify),alignItems:$ee(e.align),gap:`8px`},children:(0,U.jsx)(uk,{childList:e.children,buildChild:t})})),uT({name:`TextField`,schema:ck({label:sT.DynamicString,value:sT.DynamicString,variant:lk([`longText`,`number`,`shortText`,`obscured`]).optional(),validationRegexp:Uee().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})]})})],[Wx({name:`capitalize`,returnType:`string`,schema:ck({value:Wee()})},e=>{let t=e.value;return typeof t==`string`?t.toUpperCase():t})]);var dk=(0,b.createContext)(null),fk=(0,b.createContext)(null);function ete({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 Hw([n??TD],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)(dk.Provider,{value:f,children:(0,U.jsx)(fk.Provider,{value:p,children:(0,U.jsx)(DD,{theme:t,children:r})})})}function tte(){let e=(0,b.useContext)(dk);if(!e)throw Error(`useA2UIActions must be used within an A2UIProvider`);return e}function nte(){let e=(0,b.useContext)(fk);if(!e)throw Error(`useA2UIState must be used within an A2UIProvider`);return e}function pk(){let e=tte(),t=nte();return{processMessages:e.processMessages,getSurface:e.getSurface,clearSurfaces:e.clearSurfaces,version:t.version}}function mk(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=mk(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function hk(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=mk(e))&&(r&&(r+=` `),r+=t);return r}function rte(...e){return hk(e)}var ite=(0,b.memo)(function(){return(0,U.jsx)(`div`,{className:`a2ui-loading`,style:{padding:`16px`,opacity:.5},children:`Loading...`})}),ate=(0,b.memo)(function({surfaceId:e,className:t,fallback:n=null,loadingFallback:r}){let{getSurface:i,version:a}=pk(),o=i(e);if(!o)return(0,U.jsx)(U.Fragment,{children:n});let s=r??(0,U.jsx)(ite,{});return(0,U.jsx)(`div`,{className:rte(`a2ui-surface`,t),"data-surface-id":e,"data-version":a,children:(0,U.jsx)(b.Suspense,{fallback:s,children:(0,U.jsx)(AD,{surface:o})})})}),gk=`https://a2ui.org/specification/v0_9/basic_catalog.json`,_k=`A2UI Component Schema — available components for generating UI surfaces. Use these component names and properties when creating A2UI operations.`;function vk(e){for(let t of TD.components.keys())if(!e.components.has(t))return!1;return!0}function yk(e){let t=[];for(let n of e.components.keys())TD.components.has(n)||t.push(n);return t}function bk(e){let t=e??TD,n=[];if(n.push(`Available A2UI catalog:`),t.id===gk)return n.push(`- ${t.id} (basic catalog)`),n.join(`
|
|
88
|
-
`);let r=vk(t),i=yk(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=Vw(r.schema);n.push(` - ${e}:`),n.push(` ${JSON.stringify(i,null,2).split(`
|
|
89
|
-
`).join(`
|
|
90
|
-
`)}`)}return n.join(`
|
|
91
|
-
`)}var xk=TD,Sk={description:_k,value:bk(xk)};function Ck(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 wk(e){return String(e.type||``).toUpperCase()}function Tk(e,t){return String(e.messageId||t)}function Ek(e,t){return String(e.runId||t)}function Dk(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Ok(e){if(Array.isArray(e))return Ck(e.filter(e=>!!(e&&typeof e==`object`)));if(e&&typeof e==`object`){let t=e.a2ui_operations;return Array.isArray(t)?Ck(t.filter(e=>!!(e&&typeof e==`object`))):[e]}return[]}function kk(e){return e==null||e===``?``:typeof e==`string`?e:JSON.stringify(e,null,2)}var Ak=class{agent;onEvent;tools=new Map;runMessageIds=new Map;pendingByRun=new Map;activeRunId=``;constructor(e){this.agent=new eb({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=Iy(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:[Sk],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=wk(e),r=Ek(e,t),i=Tk(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=Dk(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:Ok(t.content??e)})}else if(n===`RUN_FINISHED`){let e=Dk(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=Dk(e.metadata),n=e.toolCallId?this.tools.get(e.toolCallId):void 0,i=String(t.tool_name||t.toolName||n?.name||e.reason||`人工确认`),a=kk(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}}},jk=new Set([`completed`,`failed`,`error`,`cancelled`,`canceled`,`aborted`,`interrupted`,`resume_failed`]);function Mk(e){if(e.EventType!==`run_status`)return null;let t=String(e.Content?.status||``).trim().toLowerCase();return jk.has(t)?t:null}function Nk(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 Pk(){let e=globalThis.crypto;return e&&typeof e.randomUUID==`function`?`run_${e.randomUUID()}`:`run_${Date.now()}_${Math.random().toString(16).slice(2)}`}var Fk={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`]},Ik=class{_stage=`idle`;listeners=new Set;abortController=null;activeCompactionId=null;activeSessionId=null;aguiClient=null;aguiThreadSessionId=null;api;controlStateValue={phase:`idle`};lastControlCommand=null;config={agentId:`default-agent`,apiFormats:[`responses`],agentFramework:``,selectedModel:``,thinkingMode:`auto`};constructor(e){this.api=e}get stage(){return this._stage}get controlState(){return this.controlStateValue}async submitControl(e){this.lastControlCommand=e;let t;try{t=Kc(await this.api.submitControl(e))}catch(e){if(e instanceof Uc)return this.controlStateValue={phase:`contract_mismatch`,error:null,receipt:null},this.emit({type:`system_message`,content:`【系统提示】控制指令响应不符合 agent-kernel/v1 合同,已停止变更本地状态。`}),this.controlStateValue;throw e}return this.controlStateValue=this.controlStateFor(t,e),t.status===`accepted`||t.status===`duplicate`?this.emit({type:`activity`,phase:`指令已入队,等待运行时处理`,status:`waiting`,countEvent:!1}):t.status===`queue_full`?this.emit({type:`system_message`,content:`【系统提示】指令队列已满,可点击重试;重试将复用同一幂等键。`}):t.status===`unsupported`?this.emit({type:`system_message`,content:`【系统提示】运行时不支持该操作:${t.error?.message||``}`}):t.status===`persistence_uncertain`?this.emit({type:`system_message`,content:`【系统提示】指令提交结果待确认,正在查询状态…`}):t.status===`rejected`&&this.emit({type:`system_message`,content:`【系统提示】指令被拒绝:${t.error?.message||``}`}),this.controlStateValue}controlStateFor(e,t){switch(e.status){case`accepted`:case`duplicate`:return{phase:`queued`,receipt:e,error:null};case`queue_full`:return{phase:`retryable`,retryKey:t.idempotency_key,receipt:e,error:e.error};case`unsupported`:return{phase:`unsupported`,receipt:e,error:e.error};case`persistence_uncertain`:return{phase:`confirming`,retryKey:t.idempotency_key,receipt:e,error:e.error};default:return{phase:`rejected`,receipt:e,error:e.error}}}async retryControl(){let e=this.lastControlCommand;if(!e||this.controlStateValue.phase!==`retryable`&&this.controlStateValue.phase!==`confirming`)return this.controlStateValue;if(this.controlStateValue.phase===`confirming`)try{await this.api.getAgentStatus()}catch(e){console.warn(`[RunEngine] status query after persistence_uncertain failed:`,e)}return this.submitControl(e)}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 Ak({url:t.Endpoint,agentId:this.config.agentId,threadId:e,onEvent:e=>this.emit(e)}),this.aguiThreadSessionId=e),this.aguiClient)}setStage(e){let t=Fk[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{n||=await this.createSession(e),n||=`default-session-${Date.now()}`,this.activeSessionId=n;let r=await this.uploadFiles(e,t);this.setStage(`connecting`),this.emit({type:`activity`,phase:`连接运行时`,status:`connecting`,countEvent:!1});let i=t?`responses`:Cl({agentFramework:this.config.agentFramework,apiFormats:this.config.apiFormats}),a=gl(i),o=a.createState(),s=Pk();D.getState().setCurrentRunId(s),D.getState().setActiveInvocationId(s),D.getState().setLastSeqId(0);let c=this.config.hostedChatTransport,l=!t&&!e.executionMode&&e.attachments.length===0&&c?.Protocol===`ag-ui`?this.getAguiClient(n):null;if(l&&c){this.setStage(`streaming`),this.emit({type:`activity`,phase:`等待 AG-UI 输出`,status:`waiting`,countEvent:!1});let t=await l.run(e.text,s,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 u=this.buildRequestBody(n,i,t,e,r,s),d=await this.api.runAgent(u,{signal:this.abortController?.signal});this.setStage(`streaming`),this.emit({type:`activity`,phase:`等待首个输出`,status:`waiting`,countEvent:!1});let f=`msg-${Date.now()}`,p=await Fl(d),m;if(m=p.receipt?await this.consumeKernelRunEvents(n,s,p.receipt,f):await this.consumeStream(p.stream,a,o,f,s),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 Ht&&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}=yl(a);a=s;for(let e of o){if(!e.trim())continue;let n=vl(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=Mk(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=Pk();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=gl(`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=Pk();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} 读取失败,原因: ${bl(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} 上传失败,原因: ${bl(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=this.buildExecutionMetadata(r),s={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:Rt(Lt(this.config.thinkingMode)),Metadata:{agentengine:{tool_approval_mode:this.config.permissionMode||`risk`,...o}}};if(n)s.ResponsesInput=r.responsesInput,s.PreviousResponseId=r.previousResponseId;else{let e=[{type:`input_text`,text:r.text.trim()}];e.push(...i),t===`responses`&&(s.ResponsesInput=[{role:`user`,content:e}]),s.Messages=[{role:`user`,content:e}]}return s}buildExecutionMetadata(e){let t=e.executionMode;if(!t)return{};let n=this.config.runtimeCapabilityMatrix?.[t];if(!n?.supported||n.mode===`unavailable`)return{};if(t===`plan`)return{collaboration_mode:`plan`};if(t===`goal`){let t=e.text.trim();return t?{collaboration_mode:`default`,goal_objective:t}:{}}return{}}async consumeKernelRunEvents(e,t,n,r){if(n.status===`rejected`||n.status===`unsupported`)return this.setStage(`error`),this.emit({type:`error`,error:Error(n.error?.message||`运行提交被拒绝(${n.status})`)}),{terminalStatus:`failed`};if(n.status===`queue_full`)return this.setStage(`error`),this.emit({type:`rate_limited`,message:`运行队列已满,请稍后重试`}),{terminalStatus:`failed`};n.status===`persistence_uncertain`&&this.emit({type:`system_message`,content:`提交结果未知,正在从事件流确认运行状态…`}),this.emit({type:`assistant_message_created`,messageId:r,invocationId:t}),this.emit({type:`activity`,phase:`已提交运行,订阅事件流`,status:`running`,countEvent:!1});let i=new Pl(e),a,o=0;for(;a===void 0&&o<6;)try{let t=D.getState().lastSeqId||0,n=await this.api.subscribeSessionEvents(e,t,{signal:this.abortController?.signal});o=0;let r=n.getReader(),s=new TextDecoder,c=``;for(;a===void 0;){let{value:t,done:n}=await r.read();if(n)break;c+=s.decode(t,{stream:!0});let o=yl(c);c=o.remainder;for(let t of o.chunks)if(t.trim())for(let n of vl(t)){let t=n.data;if(!t||typeof t!=`object`)continue;let r=i.translate(t),o=Number(t.seq);if(Number.isFinite(o)&&o>0&&D.getState().setLastSeqId(o),r&&(this.emit({type:`stream_event`,event:r,sessionId:e}),r.EventType===`run_status`)){let e=String(r.Content?.status||``).toLowerCase();e!==`interrupted`&&jk.has(e)&&(a=e)}}}a===void 0&&await new Promise(e=>setTimeout(e,3e3))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return{terminalStatus:`cancelled`};if(o+=1,o>=6)break;await new Promise(e=>setTimeout(e,800*o))}return a===void 0&&(a=`interrupted`),{terminalStatus:a}}async consumeStream(e,t,n,r,i){let a=e.getReader(),o=new TextDecoder,s=``,c=!1;try{for(;;){let{value:e,done:l}=await a.read();if(l)break;c||(c=!0,this.emit({type:`assistant_message_created`,messageId:r,invocationId:i})),s+=o.decode(e,{stream:!0});let{chunks:u,remainder:d}=yl(s);s=d;for(let e of u){if(!e.trim())continue;if(this.isCompactionChunk(e)){let t=vl(e);for(let e of t)e.eventName.startsWith(`response.compaction`)&&this.upsertCompactionMessage({...e.data,phase:e.eventName.split(`.`).pop()});continue}let i=vl(e),o=!1,s;for(let e of i){if(e.eventName===`__done__`){o=!0;continue}let i=Nk(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(_l(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(()=>{}),{terminalStatus:s}}}}catch(e){if(!(e instanceof DOMException&&e.name===`AbortError`))throw e}return{}}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:e.name||`人工确认`,args:e.args||``,message:e.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)}},Lk=0;function Rk(e){return Lk+=1,`${e}-${Lk}`}function zk(e){return e.map(e=>e.type===`thinking`&&e.status===`streaming`?{...e,status:`done`}:e)}function Bk(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:Rk(`thinking`),type:`thinking`,content:t,status:`streaming`}]}function Vk(e,t){let n=[...zk(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:Rk(`text`),type:`text`,content:t,status:`streaming`}]}function Hk(e,t){let n=zk(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:Rk(`text`),type:`text`,content:t,status:`done`}]}function Uk(e,t,n){let r=[...zk(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:Rk(`tool`),type:`tool`,toolName:t,args:n.args??``,output:n.output,status:n.status??`running`,extra:n.extra}]}function Wk(e){return zk(e??[])}function Gk(e){let t=[];if(e.reasoning&&e.reasoning.trim()&&t.push({id:Rk(`thinking`),type:`thinking`,content:e.reasoning,status:`done`}),e.tools)for(let n of Object.values(e.tools))t.push({id:Rk(`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:Rk(`text`),type:`text`,content:e.content,status:`done`}),t}var Kk=new Set([`resolved`,`cancelled`,`expired`]);function qk(e){return Kk.has(e)}function Jk(e,t){return`interaction:${e}:revision-${t}`}function Yk(e,t){let n=t.approved;if(typeof n==`boolean`)return n?`已同意`:`已拒绝`;let r=Object.keys(t);return r.length===0?e===`approve`?`已同意`:e===`reject`?`已拒绝`:e===`cancel`?`已取消`:`已提交`:`${e}(${r.slice(0,3).map(e=>{let n=t[e];return`${e}=${typeof n==`string`?n.length>24?`${n.slice(0,24)}…`:n:typeof n==`object`&&n?`[object]`:String(n)}`}).join(`, `)})`}var Xk=class{records=new Map;listeners=new Set;key(e,t){return`${e}${t}`}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}emit(e){for(let t of this.listeners)t(e)}get(e,t){return this.records.get(this.key(e,t))||null}listPending(e){return this.listAll(e).filter(e=>e.status===`pending`)}listAll(e){return this.all().filter(t=>t.sessionId===e)}all(){return[...this.records.values()].sort((e,t)=>String(e.createdAt).localeCompare(String(t.createdAt)))}upsert(e){let t=this.get(e.sessionId,e.interactionId),n,r;return t?qk(t.status)&&!qk(e.status)||e.revision<t.revision||e.revision===t.revision&&qk(t.status)&&!qk(e.status)||t.status===`resolving`&&!qk(e.status)?(n=t,r={type:`interaction_updated`,interaction:n}):qk(e.status)?(n={...t,...e,title:t.title||e.title,kind:t.kind||e.kind,message:t.message||e.message,requestSchema:t.requestSchema??e.requestSchema,presentation:t.presentation??e.presentation,actor:e.actor??t.actor,outcome:e.outcome??t.outcome,resolvedAt:e.resolvedAt??t.resolvedAt,responseSummary:e.responseSummary??t.responseSummary},r={type:`interaction_resolved`,interaction:n}):(n={...t,...e},r={type:`interaction_updated`,interaction:n}):(n=e,r={type:`interaction_requested`,interaction:n}),this.records.set(this.key(n.sessionId,n.interactionId),n),this.emit(r),r}markResolving(e,t){let n=this.get(e,t);!n||n.status!==`pending`||(this.records.set(this.key(e,t),{...n,status:`resolving`}),this.emit({type:`interaction_updated`,interaction:this.get(e,t)}))}resolveLocally(e,t,n){let r=this.get(e,t);if(!r)return;let i={...r,...n,resolvedAt:n.resolvedAt??r.resolvedAt??new Date().toISOString(),revision:n.revision??r.revision};this.records.set(this.key(e,t),i),this.emit({type:`interaction_resolved`,interaction:i})}recordIdempotencyKey(e,t,n){let r=this.get(e,t);if(!r)return;let i={...r,extensions:{...r.extensions,idempotency_key:n}};this.records.set(this.key(e,t),i),this.emit({type:`interaction_updated`,interaction:i})}markFailed(e,t,n){let r=this.get(e,t);if(!r||r.status!==`resolving`)return;let i={...r,status:`failed`,extensions:{...r.extensions,submit_error:n}};this.records.set(this.key(e,t),i),this.emit({type:`interaction_updated`,interaction:i})}revertToPending(e,t){let n=this.get(e,t);if(!n||n.status!==`resolving`)return;let r={...n,status:`pending`};this.records.set(this.key(e,t),r),this.emit({type:`interaction_updated`,interaction:r})}remove(e,t){let n=this.key(e,t);this.records.has(n)&&(this.records.delete(n),this.emit({type:`interaction_removed`,interactionId:t}))}clearSession(e){for(let t of this.listAll(e))this.remove(e,t.interactionId)}},Zk={approve:`approved`,reject:`rejected`,submit:`submitted`,cancel:`cancelled`};function Qk(e,t){return{schema_version:1,command_id:`local-${t}`,status:e,message_id:null,run_id:null,accepted_seq:null,error:null,extensions:{}}}var $k=class{store;deps;inFlight=new Map;constructor(e){this.deps=e,this.store=e.store||new Xk}listPending(e){return this.store.listPending(e)}setInteractionV1Enabled(e){this.deps.interactionV1Enabled=e}subscribe(e){return this.store.subscribe(e)}ingest(e){this.store.upsert(e)}ingestHistory(e){for(let t of e)this.store.upsert(t);for(let[e]of this.inFlight){let t=this.findByInteractionId(e);t&&t.status!==`pending`&&t.status!==`resolving`&&this.inFlight.delete(e)}}findByInteractionId(e){return this.store.all().find(t=>t.interactionId===e)||null}async respond(e){let t=this.findByInteractionId(e.interactionId);if(!t)return Qk(`rejected`,e.interactionId);if(t.status===`resolved`||t.status===`cancelled`||t.status===`expired`||t.status===`resolving`)return Qk(`duplicate`,e.interactionId);let n=e.idempotencyKey||Jk(e.interactionId,e.expectedRevision),r=this.inFlight.get(e.interactionId);if(r)return Qk(r===n?`duplicate`:`rejected`,e.interactionId);this.inFlight.set(e.interactionId,n),this.store.markResolving(t.sessionId,e.interactionId);let i=this.deps.interactionV1Enabled||t.source===`interaction_v1`;try{if(!i&&t.source===`responses`&&this.deps.legacyResponsesApproval)return this.deps.legacyResponsesApproval(e.interactionId,e.action===`approve`),this.resolveLocal(t,e,n),Qk(`accepted`,e.interactionId);if(!i&&t.source===`agui`&&this.deps.legacyAguiResume)return this.deps.legacyAguiResume(String(t.extensions.interrupt_id||e.interactionId),e.action===`cancel`?`cancelled`:`resolved`,e.response)?(this.resolveLocal(t,e,n),Qk(`accepted`,e.interactionId)):(this.store.revertToPending(t.sessionId,e.interactionId),Qk(`rejected`,e.interactionId));let r=Kc(await this.deps.submitInteraction({AgentId:this.deps.agentId,SessionId:t.sessionId,RunId:t.runId||``,InteractionId:e.interactionId,ExpectedRevision:e.expectedRevision,Action:e.action,Response:e.response,IdempotencyKey:n}));return r.status===`accepted`||r.status===`duplicate`?this.store.recordIdempotencyKey(t.sessionId,e.interactionId,n):r.status===`queue_full`?this.store.revertToPending(t.sessionId,e.interactionId):this.store.markFailed(t.sessionId,e.interactionId,{code:r.error?.code??String(r.status),message:r.error?.message??`提交未通过(${r.status})`,retryable:r.error?.retryable??!1}),r}finally{this.inFlight.delete(e.interactionId)}}resolveLocal(e,t,n){let r=t.action===`cancel`?`cancelled`:`resolved`;this.store.resolveLocally(e.sessionId,t.interactionId,{status:r,outcome:Zk[t.action],actor:`user`,responseSummary:Yk(t.action,t.response),revision:t.expectedRevision});let i=this.store.get(e.sessionId,t.interactionId);i&&this.store.upsert({...i,extensions:{...i.extensions,idempotency_key:n}})}},eA=new Set([`approval`,`structured_input`,`plan_review`,`custom`]),tA=new Set([`pending`,`resolving`,`failed`,`resolved`,`cancelled`,`expired`]),nA=new Set([`approved`,`rejected`,`submitted`,`cancelled`,`expired`]);function rA(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function iA(e){return typeof e==`string`&&e.length>0?e:null}function aA(e){let t=String(e.kind||`approval`),n=String(e.status||`pending`),r=String(e.outcome||``),i=rA(e.presentation),a=i?rA(i.a2ui):null;return{interactionId:e.interactionId,sessionId:e.sessionId,runId:iA(e.runId),kind:eA.has(t)?t:`custom`,title:typeof e.title==`string`&&e.title?e.title:`人工确认`,message:typeof e.message==`string`&&e.message?e.message:`本次运行需要人工处理后才能继续。`,requestSchema:rA(e.requestSchema),presentation:a?{a2ui:{wireVersion:String(a.wire_version??a.wireVersion??``),catalogDigest:String(a.catalog_digest??a.catalogDigest??``),messages:Array.isArray(a.messages)?a.messages.filter(e=>typeof e==`object`):[]}}:null,status:tA.has(n)?n:`pending`,revision:Number.isFinite(Number(e.revision))&&Number(e.revision)>0?Number(e.revision):1,createdAt:iA(e.createdAt)||new Date().toISOString(),expiresAt:iA(e.expiresAt),resolvedAt:iA(e.resolvedAt),actor:iA(e.actor),outcome:nA.has(r)?r:null,responseSummary:iA(e.responseSummary),source:e.source,extensions:e.extensions||{}}}var oA=new Set([`interaction.requested`,`interaction_requested`,`ksadk.interaction/v1.requested`,`InteractionRequested`]),sA=new Set([`interaction.resolved`,`interaction_resolved`,`ksadk.interaction/v1.resolved`,`InteractionResolved`,`interaction.cancelled`,`interaction.cancel`,`interaction.expired`]);function cA(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function lA(e,t){let n=cA(e);if(!n)return null;let r=String(n.event_type||n.EventType||``).trim();if(!r)return null;let i=cA(n.payload??n.Content)||{},a=cA(i.interaction)||cA(i.Interaction)||cA(i.interaction_request)||i,o=String(a.interaction_id||a.InteractionId||i.interaction_id||i.InteractionId||``);if(!o)return null;let s=String(n.session_id||a.session_id||t||``);if(!s)return null;if(oA.has(r))return aA({interactionId:o,sessionId:s,runId:a.run_id??n.run_id,kind:a.kind??`approval`,title:a.title,message:a.message??a.description,requestSchema:a.request_schema??a.RequestSchema,presentation:a.presentation,status:`pending`,revision:a.revision??1,createdAt:a.created_at??n.timestamp,expiresAt:a.expires_at,source:`interaction_v1`,extensions:a.extensions});if(sA.has(r)){let e=r===`interaction.cancelled`||r===`interaction.cancel`?`cancelled`:r===`interaction.expired`?`expired`:`resolved`,t=String(i.outcome??a.outcome??a.status??``).toLowerCase(),c=String(i.action??a.action??``).toLowerCase(),l=t;l||=c===`approve`?`approved`:c===`reject`?`rejected`:c===`submit`?`submitted`:c===`cancel`||e===`cancelled`?`cancelled`:e===`expired`?`expired`:`submitted`;let u=e===`resolved`?`resolved`:e;return aA({interactionId:o,sessionId:s,runId:a.run_id??n.run_id,kind:a.kind,title:a.title,message:a.message,requestSchema:a.request_schema,presentation:a.presentation,status:u,revision:a.revision,createdAt:a.created_at??n.timestamp,expiresAt:a.expires_at,resolvedAt:i.resolved_at??a.resolved_at??n.timestamp,actor:i.actor??a.actor??n.actor_ref,outcome:l,responseSummary:i.response_summary??a.response_summary??(c?`${c}`:void 0),source:`interaction_v1`,extensions:a.extensions})}return null}function uA(e){return!e.approvalRequestId||!e.sessionId?null:aA({interactionId:e.approvalRequestId,sessionId:e.sessionId,runId:e.runId??null,kind:`approval`,title:e.name?`审批:${e.name}`:`人工确认`,message:e.message||`本次运行需要人工审批后才能继续。`,requestSchema:e.requestSchema??null,status:`pending`,revision:1,source:`responses`,extensions:e.approvalLevel?{approval_level:e.approvalLevel}:{}})}function dA(e){return!e.interruptId||!e.sessionId?null:aA({interactionId:e.interruptId,sessionId:e.sessionId,runId:e.runId??null,kind:`approval`,title:e.name?`确认:${e.name}`:`人工确认`,message:e.message||`本次运行需要人工确认后才能继续。`,requestSchema:e.requestSchema??null,status:`pending`,revision:1,source:`agui`,extensions:{interrupt_id:e.interruptId,...e.toolCallId?{tool_call_id:e.toolCallId}:{},...e.reason?{reason:e.reason}:{}}})}function fA(e){let t=typeof e==`object`&&e?e.components:null,n=Array.isArray(t)?t:[],r=[];for(let e of n)typeof e==`object`&&e&&typeof e.id==`string`&&r.push(e.id);return r.sort()}function pA(e){let t=fA(e).join(`|`),n=2166136261,r=16777619;for(let e=0;e<t.length;e+=1){let i=t.charCodeAt(e);n=(n^i)>>>0,n=Math.imul(n,16777619)>>>0,r=r+Math.imul(i+e,2246822507)>>>0}return`fnv1a-${n.toString(16)}-${r.toString(16)}`}function mA(e,t){if(!e)return hA(null);if(e.wireVersion!==`0.9.1`||!e.messages||e.messages.length===0)return hA(e);if(e.catalogDigest){let n=pA(t);if(e.catalogDigest!==n)return`json-schema-form`}return`a2ui`}function hA(e){return e&&gA(e)?`json-schema-form`:`basic-controls`}function gA(e){return e.messages.some(e=>{let t=e.inputSchema??e.input_schema??e.schema;return typeof t==`object`&&!!t})}var _A=new Xk;function vA(e,t){let n=lA(e,t);return n&&_A.upsert(n),n}function yA(e){let t=e.sessionId||``;if(!t||!e.approvalRequestId)return null;let n=e.protocol===`ag-ui`?dA({interruptId:e.approvalRequestId,sessionId:t,name:e.name,message:e.message,reason:e.approvalLevel}):uA({approvalRequestId:e.approvalRequestId,sessionId:t,name:e.name,message:e.message,approvalLevel:e.approvalLevel});return n&&_A.upsert(n),n}var bA=[],xA=[];function SA(e){return typeof e==`string`?e.trim():``}function CA(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:void 0}function wA(e){return typeof e==`string`||typeof e==`number`?e:void 0}function TA(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function EA(e){return e!==null}function DA(e){return e!==null}function OA(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 kA(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 AA(e){return OA(e)[0]?.runId||``}function jA(e){let t=AA(e);return t?e.filter(e=>e.runId===t):[]}function MA(e){let t=TA(e);if(!t)return null;let n=TA(t.Metadata??t.metadata),r=TA(t.Content??t.content),i=SA(t.CheckpointId??t.checkpointId??t.checkpoint_id??n?.checkpoint_id??n?.checkpointId??r?.checkpoint_id??r?.checkpointId),a=SA(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:SA(t.SessionId??t.sessionId??t.session_id)||void 0,invocationId:SA(t.InvocationId??t.invocationId??t.invocation_id)||void 0,seqId:CA(t.SeqId??t.seqId??t.seq_id),timestamp:wA(t.Timestamp??t.timestamp??t.CreatedAt??t.createdAt),framework:SA(t.Framework??t.framework??n?.framework??r?.framework)||void 0,frameworkRef:TA(t.FrameworkRef??t.frameworkRef??t.framework_ref??n?.framework_ref??n?.frameworkRef),phase:SA(t.Phase??t.phase??n?.phase??r?.phase)||void 0,stage:SA(t.Stage??t.stage??n?.stage??n?.title)||void 0,summary:SA(t.Summary??t.summary??n?.summary??n?.description)||void 0,nextAction:SA(t.NextAction??t.nextAction??t.next_action??n?.nextAction??n?.next_action)||void 0,status:SA(t.Status??t.status??n?.status??r?.status)||void 0,metadata:n}}function NA(e){let t=TA(e);if(!t)return null;let n=SA(t.ReceiptId??t.receiptId??t.receipt_id),r=SA(t.IdempotencyKey??t.idempotencyKey??t.idempotency_key),i=SA(t.ToolName??t.toolName??t.tool_name);return!n||!r||!i?null:{receiptId:n,idempotencyKey:r,toolName:i,toolCallId:SA(t.ToolCallId??t.toolCallId??t.tool_call_id)||void 0,runId:SA(t.RunId??t.runId??t.run_id)||void 0,checkpointId:SA(t.CheckpointId??t.checkpointId??t.checkpoint_id)||void 0,sessionId:SA(t.SessionId??t.sessionId??t.session_id)||void 0,invocationId:SA(t.InvocationId??t.invocationId??t.invocation_id)||void 0,seqId:CA(t.SeqId??t.seqId??t.seq_id),timestamp:wA(t.Timestamp??t.timestamp??t.CreatedAt??t.createdAt),status:SA(t.Status??t.status)||void 0,replayed:!!(t.Replayed??t.replayed),metadata:TA(t.Metadata??t.metadata)}}var PA=S()((e,t)=>({checkpointsBySessionId:{},toolReceiptsBySessionId:{},setSessionCheckpoints:(t,n)=>e(e=>({checkpointsBySessionId:{...e.checkpointsBySessionId,[t]:OA(jA(n.map(MA).filter(EA).map(e=>({...e,sessionId:e.sessionId||t}))))}})),upsertSessionCheckpoint:(t,n)=>{let r=MA(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=jA([...i.values()]);return{checkpointsBySessionId:{...e.checkpointsBySessionId,[t]:OA(a)}}})},getSessionCheckpoints:e=>{let n=String(e||``);return n&&t().checkpointsBySessionId[n]||bA},setSessionToolReceipts:(t,n)=>e(e=>({toolReceiptsBySessionId:{...e.toolReceiptsBySessionId,[t]:kA(n.map(NA).filter(DA).map(e=>({...e,sessionId:e.sessionId||t})))}})),getSessionToolReceipts:e=>{let n=String(e||``);return n&&t().toolReceiptsBySessionId[n]||xA},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 FA(e){return String(e||``).replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}function IA(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,`
|
|
92
|
-
`).replace(/\\"/g,`"`);try{let e=JSON.parse(t);if(typeof e!=`string`)return LA(e);t=e.trim()}catch{return FA(t).replace(/\\n/g,`
|
|
93
|
-
`).replace(/\\"/g,`"`)}}return t}function LA(e){return typeof e==`string`?IA(e):Array.isArray(e)?e.map(e=>LA(e)):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,LA(t)]))}function RA(e){return typeof e==`string`?IA(e):LA(e)}function zA(e){return e===!1?!0:typeof e==`string`?e.trim().toLowerCase()===`false`:!1}function BA(e){return e===!0?!0:typeof e==`string`?e.trim().toLowerCase()===`true`:!1}function VA(e){return e==null||e===!1?!1:typeof e==`string`?e.trim().length>0:typeof e==`object`?Object.keys(e).length>0:!0}function HA(e){return String(e?.status||``).trim().toLowerCase()===`accepted_not_extracted`}function UA(e,t=0){if(!e||t>4)return!1;if(typeof e==`string`){let n=IA(e);return n!==e&&UA(n,t+1)}if(Array.isArray(e))return e.some(e=>UA(e,t+1));if(typeof e!=`object`||HA(e))return!1;if(zA(e.ok)||zA(e.success))return!0;let n=BA(e.ok)||BA(e.success),r=String(e.status||``).trim().toLowerCase();return!n&&[`error`,`failed`,`failure`].includes(r)||!n&&(VA(e.error_type)||VA(e.error_message)||VA(e.error))?!0:Object.values(e).some(e=>UA(e,t+1))}function WA(e){return e==null||e===``?!1:UA(RA(e))}function GA(e){if(e==null||e===``)return``;let t=RA(e);return typeof t==`string`?t:JSON.stringify(t,null,2)}var KA=new Set([`completed`,`failed`,`error`,`cancelled`,`canceled`,`aborted`,`interrupted`,`resume_failed`]),qA=new Set([`tool_call`,`tool_result`,`stage_tool_call`,`stage_tool_result`]),JA={"run.started":`in_progress`,"run.progress":`in_progress`,"run.interrupted":`interrupted`,"run.completed":`completed`,"run.failed":`failed`,"run.canceled":`cancelled`};function YA(e){let t=e?.Content?.payload;return t&&typeof t==`object`?t:{}}function XA(e,t){let n=String(e||``),r=String(t||``);return n?!r||n.endsWith(r)?n:r.startsWith(n)?r:`${n}${r}`:r}function ZA(e){let t=String(e?.EventType||``),n=YA(e);return JA[t]?{...e,EventType:`run_status`,Content:{status:String(n.status||JA[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 QA(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:XA(t?.text,YA(r).text)});continue}t.push(ZA(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)=>dj(e)-dj(t))}function $A(e){let t=String(e?.EventType||``).trim(),n=YA(e);return String(e?.Content?.status||n.status||JA[t]||``).trim().toLowerCase()}function ej(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 tj(e){let t=String(e||``).trim();return t?`/agentengine/api/v1/AttachmentContent?FileUri=${encodeURIComponent(t)}`:``}function nj(e){return String(e||``).match(/^data:([^;,]+)/)?.[1]||``}function rj(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 ij(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:tj(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||nj(t)||`image/*`});continue}if(e?.type===`input_file`&&e.fileData){let t=String(e.fileData.fileUri||``).trim();i({name:e.fileData.displayName||`attachment`,url:tj(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:tj(t),type:e.mime_type||`application/octet-stream`,fileUri:t};!n.url&&!n.fileUri&&Array.from(r.values()).some(e=>e.name===n.name&&rj(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 aj(e){let t=e?.Metadata?.responses_output;if(!Array.isArray(t))return{};let n=Zc(),r=ll({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:WA(e.output)?`error`:`completed`})}return{...i?{reasoning:i}:{},...Object.keys(a).length>0?{tools:a}:{}}}function oj(e,t,n){return t===`running`?e===`prompt_too_long`?`检测到上下文过长,正在自动压缩历史后重试`:`正在自动压缩上下文`:n?e===`prompt_too_long`?`上下文过长,系统已自动压缩历史并重试`:`系统已自动压缩较早的对话上下文`:t===`failed`?`自动压缩上下文未完成`:e===`prompt_too_long`?`已完成上下文压缩,并继续当前回复`:`已完成上下文压缩`}function sj(e,t){return[e,t.content||``,t.reasoning||``].join(`\0`)}function cj(e){return e?.Metadata?.responses_mirror===!0||String(e?.Metadata?.responses_mirror||``).trim().toLowerCase()===`true`}function lj(e){if(e?.EventType!==`user_message`)return``;let t=ij(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 uj(e){return e?.EventType===`assistant_stream_snapshot`}function dj(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 fj(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function pj(e){let t=String(e?.EventType||``);if(!qA.has(t))return null;let n=String(e.Metadata?.tool_name||e.Metadata?.name||e.Metadata?.function_name||ej(e.Content?.parts)||`tool`).trim()||`tool`,r={name:n,args:``,status:`running`},i=t===`tool_result`||t===`stage_tool_result`?(()=>{let t=fj(e.Metadata?.tool_output??e.Metadata?.output??e.Metadata?.result??ej(e.Content?.parts));return{...r,output:t,status:WA(t)?`error`:`completed`}})():{...r,args:fj(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 mj(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 hj(e={},t=``){let n=String(t||``).trim().toLowerCase(),r=n===`completed`?`completed`:KA.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 gj(e,t){return{...e,reasoning:_j(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 _j(e=``,t=``){let n=String(e||``),r=String(t||``);return n?!r||n.endsWith(r)?n:r.startsWith(n)?r:`${n}${r}`:r}function vj(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:oj(e.trigger,e.status,e.historical)}}function yj(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=ij(e);return vj({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=ij(e).text||ej(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(qA.has(t))return pj(e);if(t!==`user_message`&&t!==`assistant_message`&&t!==`assistant_stream_snapshot`)return null;let n=ij(e),r=t===`assistant_message`?aj(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 bj(e=[]){let t=new Map,n=new Map,r=new Set,i=new Set,a=new Set,o=new Set,s=QA(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`||cj(e)){if(e?.EventType===`assistant_message`){let t=String(e.InvocationId||``).trim();t&&u.add(t)}if(uj(e)){let t=String(e.InvocationId||``).trim();if(t){let n=d.get(t);(!n||dj(e)>=dj(n))&&d.set(t,e)}}continue}let t=lj(e);t&&l.add(t)}let f=c.filter(e=>{if(uj(e)){let t=String(e.InvocationId||``).trim();return t?u.has(t)?!1:d.get(t)===e:!0}if(e?.EventType!==`user_message`||!cj(e))return!0;let t=lj(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]=gj(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:hj(r.tools,t.get(n))}):{}};for(let e of f){if(e.EventType===`run_status`)continue;let t=yj(e);if(!t)continue;let n=String(e.InvocationId||``).trim();if(n&&(t.invocationId=n),qA.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:mj(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=sj(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:_j(h.reasoning,t.reasoning)}),h=null;continue}if(v(),r){let n=String(e.InvocationId||``).trim(),r=sj(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:hj(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 xj(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 Sj(e){return KA.has($A(e))}function Cj(e,t){let n=String(e||``),r=String(t||``);return!n||!r||n.endsWith(r)?n||r:r.startsWith(n)?r:`${n}${r}`}function wj(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 Tj(e,t,n){let r=bj(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=Cj(a?.content,r.content),s=Cj(a?.reasoning,r.reasoning),c=wj(a?.tools,r.tools),l={...a,...r,id:a?.id||r.id||`${n}:assistant`,invocationId:n,content:o,reasoning:s,tools:c,blocks:Gk({content:o,reasoning:s,tools:c})};return i<0?[...e,l]:e.map((e,t)=>t===i?l:e)}var Ej=new Set([`completed`]),Dj=new Set([`failed`,`error`,`cancelled`,`canceled`,`aborted`,`incomplete`]),Oj=new Map;function kj(e,t){an.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 Aj(e){let t=String(e||``).trim().toLowerCase(),n=Ej.has(t)?`completed`:Dj.has(t)?`error`:null;n&&an.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 jj(e){let t=!!(e.sessionId&&Ze.getState().currentSessionId!==e.sessionId);if(t&&![`activity`,`stage_changed`,`stream_ended`,`error`,`rate_limited`,`terminal`].includes(e.type))return;let n=an.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`:kj(e.messageId,e.invocationId);break;case`text_delta`:kj(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>t.id===e.messageId?{...t,content:t.content+e.delta,blocks:Vk(t.blocks,e.delta)}:t));break;case`text_final`:kj(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>t.id===e.messageId?{...t,content:e.text,blocks:Hk(t.blocks,e.text)}:t));break;case`reasoning_delta`:kj(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>t.id===e.messageId?{...t,reasoning:(t.reasoning||``)+e.delta,blocks:Bk(t.blocks,e.delta)}:t));break;case`tool_upsert`:kj(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:Uk(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`:kj(e.messageId),r(e.sessionId),n.patchMessages(t=>t.map(t=>{if(t.id!==e.messageId)return t;let n=WA(e.output)?`error`:`completed`;return{...t,blocks:Uk(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`:kj(e.messageId),yA({approvalRequestId:e.approvalRequestId,protocol:e.protocol,name:e.name,message:e.message,args:e.args,approvalLevel:e.approvalLevel,sessionId:e.sessionId}),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:Uk(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=vj({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||an.getState().patchMessages(e=>e.map(e=>e.role!==`model`||!e.blocks?.some(e=>e.status===`streaming`)?e:{...e,blocks:Wk(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||Aj(e.status);break;case`stream_event`:{let t=e.sessionId||e.event.SessionId;vA(e.event,t||void 0);let 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=xj(Oj.get(n)||[],[e.event]);Oj.set(n,i),an.getState().patchMessages(e=>Tj(e,i,r)),Sj(e.event)&&Oj.delete(n)}e.event.EventType===`run_checkpoint`&&t&&PA.getState().upsertSessionCheckpoint(t,e.event);{let n=$A(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}`;an.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}`;an.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}`;an.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}`;an.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}`;an.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 Mj(){Oj.clear()}function Nj(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:p.Thinking?c:`auto`,permissionMode:l,runtimeCapabilityMatrix:p.RuntimeCapabilityMatrix,hostedChatTransport:Se(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 Ik(e.api),m(i),i.subscribe(jj),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),C.getState().setQueuedDrafts(t=>[...t,e])},[d]),_=(0,b.useCallback)(e=>{let i=u.current,a=h(i);if(a.stage!==`idle`)return!1;Mj(),C.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)&&an.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,executionMode:e.executionMode,sessionId:i,onSessionCreated:e=>{Ze.getState().upsertSessions([{SessionId:e,UpdatedAt:new Date().toISOString()}]),u.current=e,kt(r,e),Ze.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){C.getState().setQueuedDrafts([]);return}C.getState().setQueuedDrafts(e=>e.slice(1)),queueMicrotask(()=>{_(e)||(d.current.unshift(e),C.getState().setQueuedDrafts(t=>[e,...t]))})}},[d,_]);let v=(0,b.useCallback)(async(e,t,n,r,i)=>{let a={text:e,attachments:t,responsesInput:n,previousResponseId:r,executionMode:i};if(h(u.current).stage!==`idle`&&D.getState().isSessionStreaming(u.current)){n===void 0&&g({text:e,attachments:t,executionMode:i});return}!_(a)&&n===void 0&&g({text:e,attachments:t,executionMode:i})},[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;Mj(),C.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)(()=>{Mj()},[]);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 Pj(e){return String(e||``).trim()}function Fj(e){let t=Pj(e).toLowerCase();return t===`up`||t===`down`?t:``}function Ij(e){if(!e||typeof e!=`object`)return null;let t=Fj(e.Rating||e.rating);return t?{agentId:Pj(e.AgentId||e.agentId),sessionId:Pj(e.SessionId||e.sessionId),responseId:Pj(e.ResponseId||e.responseId),eventId:Pj(e.EventId||e.eventId),rating:t,comment:String(e.Comment??e.comment??``),traceId:Pj(e.TraceId||e.traceId),rootSpanId:Pj(e.RootSpanId||e.rootSpanId),updatedAt:Pj(e.UpdatedAt||e.updatedAt)}:null}function Lj(e,t,n){return!!(e?.role===`model`&&Pj(e.responseId)&&!(t&&n))}function Rj({agentId:e,sessionId:t,message:n}){let r=Pj(n?.responseId);if(!r)throw Error(`Message missing response id`);return{AgentId:Pj(e),SessionId:Pj(t),ResponseId:r}}function zj({agentId:e,sessionId:t,message:n,rating:r,comment:i=``}){let a=Fj(r);if(!a)throw Error(`Feedback rating must be up or down`);return{...Rj({agentId:e,sessionId:t,message:n}),Rating:a,Comment:String(i||``),TraceId:Pj(n?.traceId),RootSpanId:Pj(n?.rootSpanId)}}function Bj(e,{messageId:t,rating:n,comment:r=``}){let i=e.find(e=>e.id===t),a=i?.feedback?{...i.feedback}:null,o=Fj(n);return{nextMessages:e.map(e=>e.id===t?{...e,feedback:{...e.feedback||{},responseId:Pj(e.responseId),eventId:Pj(e.eventId),rating:o,comment:String(r||``),pending:!0,error:``}}:e),previousFeedback:a}}function Vj(e,{messageId:t,feedback:n}){let r=Ij(n)||n;return e.map(e=>e.id===t?{...e,feedback:r?{...r,pending:!1,error:``}:void 0}:e)}function Hj(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 Uj(e,{messageId:t}){return e.map(e=>{if(e.id!==t)return e;let{feedback:n,...r}=e;return r})}function Wj(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;an.getState().patchMessages(t=>{let n=Bj(t,{messageId:e.message.id,rating:e.rating,comment:e.comment||``});return r=n.previousFeedback,n.nextMessages});try{let r=Ij((await i.upsertResponseFeedback(zj({agentId:t,sessionId:n,message:e.message,rating:e.rating,comment:e.comment||``})))?.Feedback);r&&an.getState().patchMessages(t=>Vj(t,{messageId:e.message.id,feedback:r}))}catch(t){console.error(`Failed to submit response feedback:`,t),an.getState().patchMessages(t=>Hj(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;an.getState().patchMessages(t=>Uj(t,{messageId:e.id}));try{await i.deleteResponseFeedback(Rj({agentId:t,sessionId:n,message:e}))}catch(t){console.error(`Failed to delete response feedback:`,t),an.getState().patchMessages(t=>Hj(t,{messageId:e.id,previousFeedback:r}))}},[t,n,i]),respondToApproval:(0,b.useCallback)(e=>{!e.approvalRequestId||r||(an.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])}}function Gj(e){let[t]=(0,b.useState)(()=>new $k({agentId:e.agentId,store:_A,submitInteraction:t=>e.api.submitInteraction({...t,AgentId:e.getAgentId?.()??t.AgentId}),interactionV1Enabled:e.interactionV1Enabled,legacyResponsesApproval:e.legacyResponsesApproval,legacyAguiResume:e.legacyAguiResume}));(0,b.useEffect)(()=>{t.setInteractionV1Enabled(e.interactionV1Enabled)},[t,e.interactionV1Enabled]);let[n,r]=(0,b.useState)(0);return(0,b.useEffect)(()=>_A.subscribe(()=>r(e=>e+1)),[]),{client:t,pending:(0,b.useMemo)(()=>e.currentSessionId?_A.listAll(e.currentSessionId).filter(e=>e.status===`pending`||e.status===`resolving`||e.status===`failed`):[],[n,e.currentSessionId]),records:(0,b.useMemo)(()=>e.currentSessionId?_A.listAll(e.currentSessionId):[],[n,e.currentSessionId]),respond:(0,b.useCallback)(e=>t.respond(e),[t]),localCatalog:xk}}var Kj={running:`running`,completed:`completed`,failed:`error`,paused:`paused`,approved:`completed`,denied:`completed`},qj={paused:`pending`,approved:`approved`,denied:`rejected`};function Jj(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 Yj(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 Xj(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=Kj[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=qj[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 Zj(e){if(Array.isArray(e))return e.map(e=>({name:e.name||``,url:e.url||``,type:e.mime||``,fileUri:e.file_uri}))}function Qj(e){return e==null?``:typeof e==`string`?e:JSON.stringify(e)}function $j(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=Kj[String(e?.Status||`completed`).toLowerCase()]??`completed`;return[{id:`history-tool-${r}`,type:`tool`,toolName:String(e?.Name||`tool`),args:Qj(e?.Args),...e?.Result===void 0?{}:{output:Qj(e.Result)},status:i,...e?.ToolCallId?{extra:{previousResponseId:String(e.ToolCallId)}}:{}}]})}function eM(e){let t=e.Role===`assistant`?`model`:e.Role||`user`,n=e.ToolEvents?.length?Xj(e.ToolEvents):void 0,r=Zj(e.Attachments),i=$j(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:Yj(e.Content),timestamp:Jj(e.Timestamp),eventType:t===`user`?`user_message`:`assistant_message`,reasoning:a,tools:n,attachments:r};return t===`model`&&(o.blocks=i??Gk({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 tM(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:Jj(e.Timestamp),aguiActivity:{surfaceId:r,messages:Ck(a)}}]:[]}):[]}function nM(e){return e.flatMap(e=>[eM(e),...tM(e)])}var rM=class extends Error{seq;constructor(e){super(`Session event seq ${e} was received twice with conflicting content`),this.name=`SessionEventConflictError`,this.seq=e}};function iM(e){return Array.isArray(e)?`[${e.map(iM).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,t])=>`${JSON.stringify(e)}:${iM(t)}`).join(`,`)}}`:JSON.stringify(e)??`null`}var aM=new Set([`runtime`]),oM=class{eventsBySeq=new Map;lastSeqValue=0;accept(e){let t=Xc(e);if(!t.ok)throw t.error;let n=t.value,r=this.eventsBySeq.get(n.seq);if(r){if(iM(r)!==iM(n))throw new rM(n.seq);return}this.eventsBySeq.set(n.seq,n),this.lastSeqValue=Math.max(this.lastSeqValue,n.seq)}get lastSeq(){return this.lastSeqValue}reconnectAfterSeq(){return this.lastSeqValue}displayableEvents(){return[...this.eventsBySeq.values()].filter(e=>aM.has(e.family)).sort((e,t)=>e.seq-t.seq)}};function sM(){return new oM}var cM=500,lM=30,uM=50,dM=1800*1e3;function fM(e){return new Promise(t=>{if(e.aborted){t();return}let n=globalThis.setTimeout(t,cM);e.addEventListener(`abort`,()=>{globalThis.clearTimeout(n),t()},{once:!0})})}var pM=new Set([`in_progress`,`running`,`resuming`,`starting`]);function mM(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()+dM&&Date.now()-n<=dM}function hM(e){let t=$A(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 gM(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)(sM()),d=(0,b.useRef)(0),f=(0,b.useRef)(new Map),p=(0,b.useRef)(null),m=(0,b.useRef)(null),h=(0,b.useCallback)(async(e,t,r)=>{let i=r.filter(e=>Lj(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?Ij(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&&an.getState().patchMessages(e=>e.map(e=>o.has(e.id)?{...e,feedback:o.get(e.id)}:e))},[n]),g=(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,d=``;for(;!i&&o();){let{value:t,done:n}=await c.read();if(n)break;d+=l.decode(t,{stream:!0});let s=yl(d);d=s.remainder;for(let t of s.chunks)if(t.trim()){for(let n of vl(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;if(typeof t.seq==`number`){try{u.current.accept(t)}catch(e){console.error(`[SessionLifecycle] session event cursor conflict:`,e)}a=Math.max(a,u.current.reconnectAfterSeq()),jj({type:`stream_event`,sessionId:e.sessionId,event:t}),i||=Sj(t),r||=i;let n=hM(t);n&&D.getState().updateActivity({sessionId:e.sessionId,status:n.status,phase:n.phase,detail:e.invocationId,countEvent:!1});continue}let s=Number(t.SeqId||0);Number.isFinite(s)&&(a=Math.max(a,s)),jj({type:`stream_event`,sessionId:e.sessionId,event:t}),i||=Sj(t),r||=i;let c=hM(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 fM(t.signal)}i&&o()&&jj({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&&p.current?.(e.sessionId),m.current?.(c.current,e.sessionId))}},[n]),_=(0,b.useCallback)(async e=>{let t=s.current,o=++d.current;t&&t!==e&&(an.getState().setMessages([]),Ze.getState().clearSessionMessageHistory(e),PA.getState().setSessionCheckpoints(e,[]),PA.getState().setSessionToolReceipts(e,[]),D.getState().setCurrentRunId(``),D.getState().clearActivity()),s.current=e;let u=()=>s.current===e&&d.current===o;Ze.getState().setCurrentSessionId(e),Ze.getState().setSessionInitialMessageHistoryLoading(e,!0),i(),l.current?.abort(),r&&C.getState().setMobileSidebarOpen(!1);try{let t=await n.listSessionMessages(e,{limit:uM,includeReasoning:!0,includeToolEvents:!0,includeAttachments:!0});if(!u())return;let r=nM(t.Messages);an.getState().setMessages(r),Ze.getState().setSessionMessageHistory(e,{nextCursor:t.NextCursor,hasMore:t.HasMore}),h(c.current,e,r);let i=t.LatestSeqId||0;try{let t=await n.listSessionEvents(e,{limit:50});if(u())for(let n of t.Events||[])vA(n,e)}catch(e){console.warn(`[SessionLifecycle] interaction history replay failed:`,e)}let o=Ce.getState().capabilities||a;if(o.RunLifecycle.Enabled&&o.RunLifecycle.Checkpoints?(n.listSessionCheckpoints({agentId:c.current,sessionId:e}).then(t=>{u()&&PA.getState().setSessionCheckpoints(e,t.Checkpoints||[])}).catch(t=>{u()&&(console.warn(`[SessionLifecycle] checkpoint load failed:`,t),PA.getState().setSessionCheckpoints(e,[]))}),n.listToolReceipts({agentId:c.current,sessionId:e}).then(t=>{u()&&PA.getState().setSessionToolReceipts(e,t.ToolReceipts||[])}).catch(t=>{u()&&(console.warn(`[SessionLifecycle] tool receipt load failed:`,t),PA.getState().setSessionToolReceipts(e,[]))})):PA.getState().clearSessionCheckpoints(e),o.RunLifecycle.Enabled&&o.RunLifecycle.Resume)try{let t=await n.getSession(e);if(!u())return;let r=String(t.ActiveRunStatus||``).toLowerCase();t.ActiveInvocationId&&(pM.has(r)||r===``&&mM(t))&&g({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{u()&&Ze.getState().setSessionInitialMessageHistoryLoading(e,!1)}},[n,r,h,i,g,a]),v=(0,b.useCallback)(async(e=`default-agent`,t=null)=>{try{let r=Ze.getState();r.sessionsAgentId&&r.sessionsAgentId!==e&&r.resetSessionPagination(e),Ze.getState().setLoadingSessions(!0);let i=await n.listSessions(e,{page:1,pageSize:lM});Ze.getState().upsertSessions(i.Sessions||[],{agentId:e,total:Number(i.Total??i.Sessions?.length??0),page:Number(i.Page??1),pageSize:Number(i.PageSize??lM),replace:!0});let a=Ze.getState().sessions,c=s.current,u=At(a,c||t||Ot(e));u&&u!==c?_(u):!u&&c&&(d.current+=1,l.current?.abort(),o?.(),s.current=null,Ze.getState().setCurrentSessionId(null),an.getState().setMessages([]),Ze.getState().clearSessionMessageHistory(),PA.getState().clearSessionCheckpoints(),D.getState().setCurrentRunId(``),D.getState().clearActivity())}catch(e){if(e instanceof Ut)return;console.error(`Failed to fetch sessions:`,e)}finally{Ze.getState().setLoadingSessions(!1)}},[n,o,_]),y=(0,b.useCallback)(async()=>{let e=Ze.getState();if(e.isLoadingSessions||!e.hasMoreSessions)return;let t=We({total:e.sessionsTotal,pageSize:e.sessionsPageSize||lM,loadedPages:e.loadedPages});if(!t)return;let r=e.sessionsPageSize||lM,i=e.sessionsAgentId||c.current||`default-agent`;try{Ze.getState().setLoadingSessions(!0);let a=await n.listSessions(i,{page:t,pageSize:r});Ze.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 Ut)return;console.error(`Failed to load more sessions:`,e)}finally{Ze.getState().setLoadingSessions(!1)}},[n]);(0,b.useEffect)(()=>{p.current=_},[_]),(0,b.useEffect)(()=>{m.current=v},[v]);let x=(0,b.useCallback)(async()=>{try{d.current+=1,l.current?.abort();let e=(await n.createSession(t)).SessionId;e&&(Ze.getState().upsertSessions([{SessionId:e,UpdatedAt:new Date().toISOString()}]),s.current=e,Ze.getState().setCurrentSessionId(e),an.getState().setMessages([]),Ze.getState().clearSessionMessageHistory(e),PA.getState().setSessionCheckpoints(e,[]),PA.getState().setSessionToolReceipts(e,[]),D.getState().setCurrentRunId(``),D.getState().clearActivity(),r&&(C.getState().setMobileSidebarOpen(!1),C.getState().setMobileActionsOpen(!1)),v(t,e))}catch(e){if(e instanceof Ut)return;console.error(`Failed to create session:`,e)}},[t,n,v,r]),ee=(0,b.useCallback)(async e=>{try{if((await n.deleteSession(e)).Deleted===!1){C.getState().pushToast(`会话暂未删除,云端运行时仍在同步,请稍后重试。`,`error`),v(t,s.current??void 0);return}Ze.getState().removeSession(e),Ze.getState().clearSessionMessageHistory(e),s.current===e&&(d.current+=1,l.current?.abort(),o?.(),s.current=null,an.getState().setMessages([]),PA.getState().clearSessionCheckpoints(e),Ze.getState().setCurrentSessionId(null),D.getState().setCurrentRunId(``),D.getState().clearActivity(),v(t))}catch(e){if(e instanceof Ut)return;console.error(`Failed to delete session`,e),C.getState().pushToast(`删除会话失败,请稍后重试。`,`error`)}},[t,n,o,v]);return{fetchSessions:v,loadMoreSessions:y,loadSession:_,loadOlderSessionMessages:(0,b.useCallback)(async e=>{let t=Ze.getState().messageHistory[e];if(!t||!t.hasMore||t.nextCursor===null||t.isLoadingOlder)return;let r=d.current,i=Symbol(e);f.current.set(e,i);try{Ze.getState().setSessionMessageHistoryLoading(e,!0);let a=await n.listSessionMessages(e,{beforeSeqId:t.nextCursor,limit:uM,includeReasoning:!0,includeToolEvents:!0,includeAttachments:!0});if(s.current!==e||d.current!==r||f.current.get(e)!==i)return;let o=nM(a.Messages),l=new Set(o.map(e=>e.id)),u=[...o,...an.getState().messages.filter(e=>!l.has(e.id))];an.getState().setMessages(u),Ze.getState().setSessionMessageHistory(e,{nextCursor:a.NextCursor,hasMore:a.HasMore}),h(c.current,e,o)}catch(e){e instanceof Ut||console.error(`Failed to load older session messages:`,e)}finally{f.current.get(e)===i&&(f.current.delete(e),Ze.getState().setSessionMessageHistoryLoading(e,!1))}},[n,h]),createNewSession:x,deleteSession:ee,currentSessionIdRef:s,agentIdRef:c,runSubscriptionAbortRef:l}}var _M=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),vM=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),yM=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),bM=e=>{let t=yM(e);return t.charAt(0).toUpperCase()+t.slice(1)},xM={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`},SM=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},CM=(0,b.createContext)({}),wM=()=>(0,b.useContext)(CM),TM=(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=``}=wM()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,b.createElement)(`svg`,{ref:c,...xM,width:t??l??xM.width,height:t??l??xM.height,stroke:e??f,strokeWidth:m,className:_M(`lucide`,p,i),...!a&&!SM(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,b.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),EM=(e,t)=>{let n=(0,b.forwardRef)(({className:n,...r},i)=>(0,b.createElement)(TM,{ref:i,iconNode:t,className:_M(`lucide-${vM(bM(e))}`,`lucide-${e}`,n),...r}));return n.displayName=bM(e),n},DM=EM(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),OM=EM(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),kM=EM(`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`}]]),AM=EM(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),jM=EM(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),MM=EM(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),NM=EM(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),PM=EM(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),FM=EM(`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`}]]),IM=EM(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),LM=EM(`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`}]]),RM=EM(`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`}]]),zM=EM(`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`}]]),BM=EM(`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`}]]),VM=EM(`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`}]]),HM=EM(`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`}]]),UM=EM(`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`}]]),WM=EM(`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`}]]),GM=EM(`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`}]]),KM=EM(`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`}]]),qM=EM(`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`}]]),JM=EM(`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`}]]),YM=EM(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),XM=EM(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),ZM=EM(`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`}]]),QM=EM(`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`}]]),$M=EM(`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`}]]),eN=EM(`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`}]]),tN=EM(`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`}]]),nN=EM(`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`}]]),rN=EM(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),iN=EM(`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`}]]),aN=EM(`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`}]]),oN=EM(`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`}]]),sN=EM(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),cN=EM(`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`}]]),lN=EM(`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`}]]),uN=EM(`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`}]]),dN=EM(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),fN=EM(`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`}]]),pN=EM(`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`}]]),mN=EM(`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`}]]),hN=EM(`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`}]]),gN=EM(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),_N=EM(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),vN=EM(`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`}]]),yN=EM(`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`}]]),bN=EM(`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`}]]),xN=EM(`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`}]]),SN=EM(`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`}]]),CN=EM(`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`}]]),wN=EM(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),TN=EM(`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`}]]),EN=(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},DN=(e,t)=>({classGroupId:e,validator:t}),ON=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),kN=`-`,AN=[],jN=`arbitrary..`,MN=e=>{let t=FN(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return PN(e);let n=e.split(kN);return NN(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?EN(i,t):t:i||AN}return n[e]||AN}}},NN=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=NN(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(kN):e.slice(t).join(kN),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},PN=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?jN+r:void 0})(),FN=e=>{let{theme:t,classGroups:n}=e;return IN(n,t)},IN=(e,t)=>{let n=ON();for(let r in e){let i=e[r];LN(i,n,r,t)}return n},LN=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];RN(i,t,n,r)}},RN=(e,t,n,r)=>{if(typeof e==`string`){zN(e,t,n);return}if(typeof e==`function`){BN(e,t,n,r);return}VN(e,t,n,r)},zN=(e,t,n)=>{let r=e===``?t:HN(t,e);r.classGroupId=n},BN=(e,t,n,r)=>{if(UN(e)){LN(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(DN(n,e))},VN=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];LN(o,HN(t,a),n,r)}},HN=(e,t)=>{let n=e,r=t.split(kN),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=ON(),n.nextPart.set(t,i)),n=i}return n},UN=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,WN=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)}}},GN=`!`,KN=`:`,qN=[],JN=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),YN=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===KN){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(GN)?(c=s.slice(0,-1),l=!0):s.startsWith(GN)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return JN(t,l,c,u)};if(t){let e=t+KN,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):JN(qN,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},XN=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}},ZN=e=>({cache:WN(e.cacheSize),parseClassName:YN(e),sortModifiers:XN(e),...MN(e)}),QN=/\s+/,$N=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(QN),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+GN: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},eP=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=tP(n))&&(i&&(i+=` `),i+=r);return i},tP=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=tP(e[r]))&&(n&&(n+=` `),n+=t);return n},nP=(e,...t)=>{let n,r,i,a,o=o=>(n=ZN(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=$N(e,n);return i(e,a),a};return a=o,(...e)=>a(eP(...e))},rP=[],iP=e=>{let t=t=>t[e]||rP;return t.isThemeGetter=!0,t},aP=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,oP=/^\((?:(\w[\w-]*):)?(.+)\)$/i,sP=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,cP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,lP=/\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$/,uP=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,dP=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,fP=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,pP=e=>sP.test(e),mP=e=>!!e&&!Number.isNaN(Number(e)),hP=e=>!!e&&Number.isInteger(Number(e)),gP=e=>e.endsWith(`%`)&&mP(e.slice(0,-1)),_P=e=>cP.test(e),vP=()=>!0,yP=e=>lP.test(e)&&!uP.test(e),bP=()=>!1,xP=e=>dP.test(e),SP=e=>fP.test(e),CP=e=>!TP(e)&&!NP(e),wP=e=>VP(e,GP,bP),TP=e=>aP.test(e),EP=e=>VP(e,KP,yP),DP=e=>VP(e,qP,mP),OP=e=>VP(e,YP,vP),kP=e=>VP(e,JP,bP),AP=e=>VP(e,UP,bP),jP=e=>VP(e,WP,SP),MP=e=>VP(e,XP,xP),NP=e=>oP.test(e),PP=e=>HP(e,KP),FP=e=>HP(e,JP),IP=e=>HP(e,UP),LP=e=>HP(e,GP),RP=e=>HP(e,WP),zP=e=>HP(e,XP,!0),BP=e=>HP(e,YP,!0),VP=(e,t,n)=>{let r=aP.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},HP=(e,t,n=!1)=>{let r=oP.exec(e);return r?r[1]?t(r[1]):n:!1},UP=e=>e===`position`||e===`percentage`,WP=e=>e===`image`||e===`url`,GP=e=>e===`length`||e===`size`||e===`bg-size`,KP=e=>e===`length`,qP=e=>e===`number`,JP=e=>e===`family-name`,YP=e=>e===`number`||e===`weight`,XP=e=>e===`shadow`,ZP=nP(()=>{let e=iP(`color`),t=iP(`font`),n=iP(`text`),r=iP(`font-weight`),i=iP(`tracking`),a=iP(`leading`),o=iP(`breakpoint`),s=iP(`container`),c=iP(`spacing`),l=iP(`radius`),u=iP(`shadow`),d=iP(`inset-shadow`),f=iP(`text-shadow`),p=iP(`drop-shadow`),m=iP(`blur`),h=iP(`perspective`),g=iP(`aspect`),_=iP(`ease`),v=iP(`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(),NP,TP],ee=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],te=()=>[`auto`,`contain`,`none`],S=()=>[NP,TP,c],ne=()=>[pP,`full`,`auto`,...S()],re=()=>[hP,`none`,`subgrid`,NP,TP],C=()=>[`auto`,{span:[`full`,hP,NP,TP]},hP,NP,TP],w=()=>[hP,`auto`,NP,TP],ie=()=>[`auto`,`min`,`max`,`fr`,NP,TP],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=()=>[pP,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...S()],le=()=>[pP,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...S()],ue=()=>[pP,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...S()],T=()=>[e,NP,TP],E=()=>[...b(),IP,AP,{position:[NP,TP]}],de=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],fe=()=>[`auto`,`cover`,`contain`,LP,wP,{size:[NP,TP]}],pe=()=>[gP,PP,EP],me=()=>[``,`none`,`full`,l,NP,TP],he=()=>[``,mP,PP,EP],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=()=>[mP,gP,IP,AP],ye=()=>[``,`none`,m,NP,TP],be=()=>[`none`,mP,NP,TP],xe=()=>[`none`,mP,NP,TP],Se=()=>[mP,NP,TP],Ce=()=>[pP,`full`,...S()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[_P],breakpoint:[_P],color:[vP],container:[_P],"drop-shadow":[_P],ease:[`in`,`out`,`in-out`],font:[CP],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[_P],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[_P],shadow:[_P],spacing:[`px`,mP],text:[_P],"text-shadow":[_P],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,pP,TP,NP,g]}],container:[`container`],columns:[{columns:[mP,TP,NP,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:ne()}],"inset-x":[{"inset-x":ne()}],"inset-y":[{"inset-y":ne()}],start:[{"inset-s":ne(),start:ne()}],end:[{"inset-e":ne(),end:ne()}],"inset-bs":[{"inset-bs":ne()}],"inset-be":[{"inset-be":ne()}],top:[{top:ne()}],right:[{right:ne()}],bottom:[{bottom:ne()}],left:[{left:ne()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[hP,`auto`,NP,TP]}],basis:[{basis:[pP,`full`,`auto`,s,...S()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[mP,pP,`auto`,`initial`,`none`,TP]}],grow:[{grow:[``,mP,NP,TP]}],shrink:[{shrink:[``,mP,NP,TP]}],order:[{order:[hP,`first`,`last`,`none`,NP,TP]}],"grid-cols":[{"grid-cols":re()}],"col-start-end":[{col:C()}],"col-start":[{"col-start":w()}],"col-end":[{"col-end":w()}],"grid-rows":[{"grid-rows":re()}],"row-start-end":[{row:C()}],"row-start":[{"row-start":w()}],"row-end":[{"row-end":w()}],"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,PP,EP]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,BP,OP]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,gP,TP]}],"font-family":[{font:[FP,kP,t]}],"font-features":[{"font-features":[TP]}],"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,NP,TP]}],"line-clamp":[{"line-clamp":[mP,`none`,NP,DP]}],leading:[{leading:[a,...S()]}],"list-image":[{"list-image":[`none`,NP,TP]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,NP,TP]}],"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:[mP,`from-font`,`auto`,NP,EP]}],"text-decoration-color":[{decoration:T()}],"underline-offset":[{"underline-offset":[mP,`auto`,NP,TP]}],"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`,NP,TP]}],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`,NP,TP]}],"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`]},hP,NP,TP],radial:[``,NP,TP],conic:[hP,NP,TP]},RP,jP]}],"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":[mP,NP,TP]}],"outline-w":[{outline:[``,mP,PP,EP]}],"outline-color":[{outline:T()}],shadow:[{shadow:[``,`none`,u,zP,MP]}],"shadow-color":[{shadow:T()}],"inset-shadow":[{"inset-shadow":[`none`,d,zP,MP]}],"inset-shadow-color":[{"inset-shadow":T()}],"ring-w":[{ring:he()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:T()}],"ring-offset-w":[{"ring-offset":[mP,EP]}],"ring-offset-color":[{"ring-offset":T()}],"inset-ring-w":[{"inset-ring":he()}],"inset-ring-color":[{"inset-ring":T()}],"text-shadow":[{"text-shadow":[`none`,f,zP,MP]}],"text-shadow-color":[{"text-shadow":T()}],opacity:[{opacity:[mP,NP,TP]}],"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":[mP]}],"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":[NP,TP]}],"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":[mP]}],"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`,NP,TP]}],filter:[{filter:[``,`none`,NP,TP]}],blur:[{blur:ye()}],brightness:[{brightness:[mP,NP,TP]}],contrast:[{contrast:[mP,NP,TP]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,zP,MP]}],"drop-shadow-color":[{"drop-shadow":T()}],grayscale:[{grayscale:[``,mP,NP,TP]}],"hue-rotate":[{"hue-rotate":[mP,NP,TP]}],invert:[{invert:[``,mP,NP,TP]}],saturate:[{saturate:[mP,NP,TP]}],sepia:[{sepia:[``,mP,NP,TP]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,NP,TP]}],"backdrop-blur":[{"backdrop-blur":ye()}],"backdrop-brightness":[{"backdrop-brightness":[mP,NP,TP]}],"backdrop-contrast":[{"backdrop-contrast":[mP,NP,TP]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,mP,NP,TP]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[mP,NP,TP]}],"backdrop-invert":[{"backdrop-invert":[``,mP,NP,TP]}],"backdrop-opacity":[{"backdrop-opacity":[mP,NP,TP]}],"backdrop-saturate":[{"backdrop-saturate":[mP,NP,TP]}],"backdrop-sepia":[{"backdrop-sepia":[``,mP,NP,TP]}],"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`,NP,TP]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[mP,`initial`,NP,TP]}],ease:[{ease:[`linear`,`initial`,_,NP,TP]}],delay:[{delay:[mP,NP,TP]}],animate:[{animate:[`none`,v,NP,TP]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,NP,TP]}],"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:[NP,TP,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:Ce()}],"translate-x":[{"translate-x":Ce()}],"translate-y":[{"translate-y":Ce()}],"translate-z":[{"translate-z":Ce()}],"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`,NP,TP]}],"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`,NP,TP]}],fill:[{fill:[`none`,...T()]}],"stroke-w":[{stroke:[mP,PP,EP,DP]}],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 K(...e){return ZP(hk(e))}var QP=new Set([`in_progress`,`running`,`resuming`,`starting`,`streaming`,`queued`,`pending`,`accepted`]),$P=new Set([`failed`,`error`,`resume_failed`,`interrupted`,`cancelled`,`canceled`,`aborted`,`expired`]),eF=300*1e3;function tF(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 nF(e){return String(e||``).trim().toLowerCase()}function rF(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 iF(e){return[e?.Title,e?.Summary,e?.FirstPrompt,e?.LastPrompt,e?.SessionId,e?.Model?.display_name,e?.Model?.id].map(nF).join(` `)}function aF(e,t={}){if(!QP.has(nF(e?.ActiveRunStatus)))return!1;let n=tF(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):eF;return r-n<=i}function oF(e=[],t=``,n={}){let r=nF(t),i=new Set(Array.isArray(n.pinnedSessionIds)?n.pinnedSessionIds:[]);return(Array.isArray(e)?e:[]).filter(e=>e?.SessionId).filter(e=>!r||iF(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=+!!aF(e,n),s=+!!aF(t,n);return o===s?tF(t)-tF(e):s-o})}function sF(e,t={}){let n=aF(e,t),r=$P.has(nF(e?.ActiveRunStatus));return{running:n,failed:r,label:n||r?``:rF(e?.UpdatedAt??e?.updated_at)}}function cF({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)(()=>oF(e,f,{pinnedSessionIds:c}),[e,c,f]),h=(0,b.useMemo)(()=>new Set(c),[c]);return(0,U.jsxs)(`div`,{className:K(`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)(QM,{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)(dN,{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=sF(e),o=h.has(e.SessionId),c=t===e.SessionId;return(0,U.jsxs)(`div`,{className:K(`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/[0.035] text-sidebar-text`:`cursor-pointer text-sidebar-text-secondary hover:bg-sidebar-hover hover:text-sidebar-text`),children:[(0,U.jsxs)(`button`,{type:`button`,"aria-current":c?`page`:void 0,className:`flex min-w-0 flex-1 items-center gap-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-primary/60`,onClick:()=>r(e.SessionId),children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:s(e)}),n.running?(0,U.jsx)(`span`,{"aria-label":`运行中`,className:`h-1.5 w-1.5 flex-shrink-0 animate-spin rounded-full border border-primary border-t-transparent`}):n.failed?(0,U.jsx)(`span`,{"aria-label":`运行失败`,title:`运行失败`,className:`h-1.5 w-1.5 flex-shrink-0 rounded-full bg-rose-500/75`}):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:`absolute right-1 top-1/2 flex -translate-y-1/2 items-center justify-end gap-0.5 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:t=>a(e.SessionId,t),className:K(`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)(aN,{className:`h-3.5 w-3.5`}):(0,U.jsx)(oN,{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)(bN,{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)(XM,{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 lF(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function uF(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function dF(...e){return t=>{let n=!1,r=e.map(e=>{let r=uF(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():uF(e[t],null)}}}}function fF(...e){return b.useCallback(dF(...e),e)}function pF(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 mF(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,hF(i,...t)]}function hF(...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 gF=globalThis?.document?b.useLayoutEffect:()=>{},_F=b.useId||(()=>void 0),vF=0;function yF(e){let[t,n]=b.useState(_F());return gF(()=>{e||n(e=>e??String(vF++))},[e]),e||(t?`radix-${t}`:``)}var bF=b.useInsertionEffect||gF;function xF({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=SF({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=CF(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function SF({defaultProp:e,onChange:t}){let[n,r]=b.useState(e),i=b.useRef(n),a=b.useRef(t);return bF(()=>{a.current=t},[t]),b.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function CF(e){return typeof e==`function`}function wF(e){let t=TF(e),n=b.forwardRef((e,n)=>{let{children:r,...i}=e,a=b.Children.toArray(r),o=a.find(DF);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 TF(e){let t=b.forwardRef((e,t)=>{let{children:n,...r}=e;if(b.isValidElement(n)){let e=kF(n),i=OF(r,n.props);return n.type!==b.Fragment&&(i.ref=t?dF(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 EF=Symbol(`radix.slottable`);function DF(e){return b.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===EF}function OF(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 kF(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 AF=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=wF(`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 jF(e,t){e&&xl.flushSync(()=>e.dispatchEvent(t))}function MF(e){let t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>(...e)=>t.current?.(...e),[])}function NF(e,t=globalThis?.document){let n=MF(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 PF=`DismissableLayer`,FF=`dismissableLayer.update`,IF=`dismissableLayer.pointerDownOutside`,LF=`dismissableLayer.focusOutside`,RF,zF=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),BF=b.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=b.useContext(zF),[u,d]=b.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=b.useState({}),m=fF(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=UF(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!x||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),te=WF(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return NF(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&&(RF=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),GF(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=RF)}},[u,f,n,l]),b.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),GF())},[u,l]),b.useEffect(()=>{let e=()=>p({});return document.addEventListener(FF,e),()=>document.removeEventListener(FF,e)},[]),(0,U.jsx)(AF.div,{...c,ref:m,style:{pointerEvents:y?x?`auto`:`none`:void 0,...e.style},onFocusCapture:lF(e.onFocusCapture,te.onFocusCapture),onBlurCapture:lF(e.onBlurCapture,te.onBlurCapture),onPointerDownCapture:lF(e.onPointerDownCapture,ee.onPointerDownCapture)})});BF.displayName=PF;var VF=`DismissableLayerBranch`,HF=b.forwardRef((e,t)=>{let n=b.useContext(zF),r=b.useRef(null),i=fF(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)(AF.div,{...e,ref:i})});HF.displayName=VF;function UF(e,t=globalThis?.document){let n=MF(e),r=b.useRef(!1),i=b.useRef(()=>{});return b.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){KF(IF,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 WF(e,t=globalThis?.document){let n=MF(e),r=b.useRef(!1);return b.useEffect(()=>{let e=e=>{e.target&&!r.current&&KF(LF,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 GF(){let e=new CustomEvent(FF);document.dispatchEvent(e)}function KF(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?jF(i,a):i.dispatchEvent(a)}var qF=`focusScope.autoFocusOnMount`,JF=`focusScope.autoFocusOnUnmount`,YF={bubbles:!1,cancelable:!0},XF=`FocusScope`,ZF=b.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=b.useState(null),l=MF(i),u=MF(a),d=b.useRef(null),f=fF(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:iI(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||iI(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&iI(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){aI.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(qF,YF);s.addEventListener(qF,l),s.dispatchEvent(t),t.defaultPrevented||(QF(cI(eI(s)),{select:!0}),document.activeElement===e&&iI(s))}return()=>{s.removeEventListener(qF,l),setTimeout(()=>{let t=new CustomEvent(JF,YF);s.addEventListener(JF,u),s.dispatchEvent(t),t.defaultPrevented||iI(e??document.body,{select:!0}),s.removeEventListener(JF,u),aI.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]=$F(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&iI(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&iI(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,U.jsx)(AF.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});ZF.displayName=XF;function QF(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(iI(r,{select:t}),document.activeElement!==n)return}function $F(e){let t=eI(e);return[tI(t,e),tI(t.reverse(),e)]}function eI(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 tI(e,t){for(let n of e)if(!nI(n,{upTo:t}))return n}function nI(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 rI(e){return e instanceof HTMLInputElement&&`select`in e}function iI(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&rI(e)&&t&&e.select()}}var aI=oI();function oI(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=sI(e,t),e.unshift(t)},remove(t){e=sI(e,t),e[0]?.resume()}}}function sI(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function cI(e){return e.filter(e=>e.tagName!==`A`)}var lI=`Portal`,uI=b.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=b.useState(!1);gF(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?xl.createPortal((0,U.jsx)(AF.div,{...r,ref:t}),o):null});uI.displayName=lI;function dI(e,t){return b.useReducer((e,n)=>t[e][n]??e,e)}var fI=e=>{let{present:t,children:n}=e,r=pI(t),i=typeof n==`function`?n({present:r.isPresent}):b.Children.only(n),a=fF(r.ref,hI(i));return typeof n==`function`||r.isPresent?b.cloneElement(i,{ref:a}):null};fI.displayName=`Presence`;function pI(e){let[t,n]=b.useState(),r=b.useRef(null),i=b.useRef(e),a=b.useRef(`none`),[o,s]=dI(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return b.useEffect(()=>{let e=mI(r.current);a.current=o===`mounted`?e:`none`},[o]),gF(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=mI(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),gF(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=mI(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=mI(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 mI(e){return e?.animationName||`none`}function hI(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 gI=0;function _I(){b.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??vI()),document.body.insertAdjacentElement(`beforeend`,e[1]??vI()),gI++,()=>{gI===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),gI--}},[])}function vI(){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 yI=`right-scroll-bar-position`,bI=`width-before-scroll-bar`,xI=`with-scroll-bars-hidden`,SI=`--removed-body-scroll-bar-size`;function CI(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function wI(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 TI=typeof window<`u`?b.useLayoutEffect:b.useEffect,EI=new WeakMap;function DI(e,t){var n=wI(t||null,function(t){return e.forEach(function(e){return CI(e,t)})});return TI(function(){var t=EI.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||CI(e,null)}),i.forEach(function(e){r.has(e)||CI(e,a)})}EI.set(n,e)},[e]),n}function OI(e){return e}function kI(e,t){t===void 0&&(t=OI);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 AI(e){e===void 0&&(e={});var t=kI(null);return t.options=jp({async:!0,ssr:!1},e),t}var jI=function(e){var t=e.sideCar,n=Mp(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,jp({},n))};jI.isSideCarExport=!0;function MI(e,t){return e.useMedium(t),jI}var NI=AI(),PI=function(){},FI=b.forwardRef(function(e,t){var n=b.useRef(null),r=b.useState({onScrollCapture:PI,onWheelCapture:PI,onTouchMoveCapture:PI}),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=Mp(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),ee=f,te=DI([n,t]),S=jp(jp({},x),i);return b.createElement(b.Fragment,null,u&&b.createElement(ee,{sideCar:NI,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),jp(jp({},S),{ref:te})):b.createElement(v,jp({},S,{className:c,ref:te}),s))});FI.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},FI.classNames={fullWidth:bI,zeroRight:yI};var II,LI=function(){if(II)return II;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function RI(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=LI();return t&&e.setAttribute(`nonce`,t),e}function zI(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function BI(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var VI=function(){var e=0,t=null;return{add:function(n){e==0&&(t=RI())&&(zI(t,n),BI(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},HI=function(){var e=VI();return function(t,n){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},UI=function(){var e=HI();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},WI={left:0,top:0,right:0,gap:0},GI=function(e){return parseInt(e||``,10)||0},KI=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[GI(n),GI(r),GI(i)]},qI=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return WI;var t=KI(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])}},JI=UI(),YI=`data-scroll-locked`,XI=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
94
|
-
.${xI} {
|
|
95
|
-
overflow: hidden ${r};
|
|
96
|
-
padding-right: ${s}px ${r};
|
|
97
|
-
}
|
|
98
|
-
body[${YI}] {
|
|
99
|
-
overflow: hidden ${r};
|
|
100
|
-
overscroll-behavior: contain;
|
|
101
|
-
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
102
|
-
padding-left: ${i}px;
|
|
103
|
-
padding-top: ${a}px;
|
|
104
|
-
padding-right: ${o}px;
|
|
105
|
-
margin-left:0;
|
|
106
|
-
margin-top:0;
|
|
107
|
-
margin-right: ${s}px ${r};
|
|
108
|
-
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.${yI} {
|
|
112
|
-
right: ${s}px ${r};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.${bI} {
|
|
116
|
-
margin-right: ${s}px ${r};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.${yI} .${yI} {
|
|
120
|
-
right: 0 ${r};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.${bI} .${bI} {
|
|
124
|
-
margin-right: 0 ${r};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
body[${YI}] {
|
|
128
|
-
${SI}: ${s}px;
|
|
129
|
-
}
|
|
130
|
-
`},ZI=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},QI=function(){b.useEffect(function(){return document.body.setAttribute(YI,(ZI()+1).toString()),function(){var e=ZI()-1;e<=0?document.body.removeAttribute(YI):document.body.setAttribute(YI,e.toString())}},[])},$I=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;QI();var a=b.useMemo(function(){return qI(i)},[i]);return b.createElement(JI,{styles:XI(a,!t,i,n?``:`!important`)})},eL=!1;if(typeof window<`u`)try{var tL=Object.defineProperty({},"passive",{get:function(){return eL=!0,!0}});window.addEventListener(`test`,tL,tL),window.removeEventListener(`test`,tL,tL)}catch{eL=!1}var nL=eL?{passive:!1}:!1,rL=function(e){return e.tagName===`TEXTAREA`},iL=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!rL(e)&&n[t]===`visible`)},aL=function(e){return iL(e,`overflowY`)},oL=function(e){return iL(e,`overflowX`)},sL=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),uL(e,r)){var i=dL(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},cL=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},lL=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},uL=function(e,t){return e===`v`?aL(t):oL(t)},dL=function(e,t){return e===`v`?cL(t):lL(t)},fL=function(e,t){return e===`h`&&t===`rtl`?-1:1},pL=function(e,t,n,r,i){var a=fL(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=dL(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&uL(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},mL=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},hL=function(e){return[e.deltaX,e.deltaY]},gL=function(e){return e&&`current`in e?e.current:e},_L=function(e,t){return e[0]===t[0]&&e[1]===t[1]},vL=function(e){return`
|
|
131
|
-
.block-interactivity-${e} {pointer-events: none;}
|
|
132
|
-
.allow-interactivity-${e} {pointer-events: all;}
|
|
133
|
-
`},yL=0,bL=[];function xL(e){var t=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),i=b.useState(yL++)[0],a=b.useState(UI)[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=Lp([e.lockRef.current],(e.shards||[]).map(gL),!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=mL(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=sL(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=sL(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 pL(h,t,e,h===`h`?s:c,!0)},[]),c=b.useCallback(function(e){var n=e;if(!(!bL.length||bL[bL.length-1]!==a)){var r=`deltaY`in n?hL(n):mL(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&_L(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(gL).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:SL(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=mL(e),r.current=void 0},[]),d=b.useCallback(function(t){l(t.type,hL(t),t.target,s(t,e.lockRef.current))},[]),f=b.useCallback(function(t){l(t.type,mL(t),t.target,s(t,e.lockRef.current))},[]);b.useEffect(function(){return bL.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,nL),document.addEventListener(`touchmove`,c,nL),document.addEventListener(`touchstart`,u,nL),function(){bL=bL.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,nL),document.removeEventListener(`touchmove`,c,nL),document.removeEventListener(`touchstart`,u,nL)}},[]);var p=e.removeScrollBar,m=e.inert;return b.createElement(b.Fragment,null,m?b.createElement(a,{styles:vL(i)}):null,p?b.createElement($I,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function SL(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var CL=MI(NI,xL),wL=b.forwardRef(function(e,t){return b.createElement(FI,jp({},e,{ref:t,sideCar:CL}))});wL.classNames=FI.classNames;var TL=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},EL=new WeakMap,DL=new WeakMap,OL={},kL=0,AL=function(e){return e&&(e.host||AL(e.parentNode))},jL=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=AL(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})},ML=function(e,t,n,r){var i=jL(t,Array.isArray(e)?e:[e]);OL[n]||(OL[n]=new WeakMap);var a=OL[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=(EL.get(e)||0)+1,l=(a.get(e)||0)+1;EL.set(e,c),a.set(e,l),o.push(e),c===1&&i&&DL.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(),kL++,function(){o.forEach(function(e){var t=EL.get(e)-1,i=a.get(e)-1;EL.set(e,t),a.set(e,i),t||(DL.has(e)||e.removeAttribute(r),DL.delete(e)),i||e.removeAttribute(n)}),kL--,kL||(EL=new WeakMap,EL=new WeakMap,DL=new WeakMap,OL={})}},NL=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||TL(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),ML(r,i,n,`aria-hidden`)):function(){return null}};function PL(e){let t=FL(e),n=b.forwardRef((e,n)=>{let{children:r,...i}=e,a=b.Children.toArray(r),o=a.find(LL);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 FL(e){let t=b.forwardRef((e,t)=>{let{children:n,...r}=e;if(b.isValidElement(n)){let e=zL(n),i=RL(r,n.props);return n.type!==b.Fragment&&(i.ref=t?dF(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 IL=Symbol(`radix.slottable`);function LL(e){return b.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===IL}function RL(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 zL(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 BL=`Dialog`,[VL,ote]=mF(BL),[HL,UL]=VL(BL),WL=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]=xF({prop:r,defaultProp:i??!1,onChange:a,caller:BL});return(0,U.jsx)(HL,{scope:t,triggerRef:s,contentRef:c,contentId:yF(),titleId:yF(),descriptionId:yF(),open:l,onOpenChange:u,onOpenToggle:b.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};WL.displayName=BL;var GL=`DialogTrigger`,KL=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=UL(GL,n),a=fF(t,i.triggerRef);return(0,U.jsx)(AF.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":fR(i.open),...r,ref:a,onClick:lF(e.onClick,i.onOpenToggle)})});KL.displayName=GL;var qL=`DialogPortal`,[JL,YL]=VL(qL,{forceMount:void 0}),XL=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=UL(qL,t);return(0,U.jsx)(JL,{scope:t,forceMount:n,children:b.Children.map(r,e=>(0,U.jsx)(fI,{present:n||a.open,children:(0,U.jsx)(uI,{asChild:!0,container:i,children:e})}))})};XL.displayName=qL;var ZL=`DialogOverlay`,QL=b.forwardRef((e,t)=>{let n=YL(ZL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=UL(ZL,e.__scopeDialog);return a.modal?(0,U.jsx)(fI,{present:r||a.open,children:(0,U.jsx)(eR,{...i,ref:t})}):null});QL.displayName=ZL;var $L=PL(`DialogOverlay.RemoveScroll`),eR=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=UL(ZL,n);return(0,U.jsx)(wL,{as:$L,allowPinchZoom:!0,shards:[i.contentRef],children:(0,U.jsx)(AF.div,{"data-state":fR(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),tR=`DialogContent`,nR=b.forwardRef((e,t)=>{let n=YL(tR,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=UL(tR,e.__scopeDialog);return(0,U.jsx)(fI,{present:r||a.open,children:a.modal?(0,U.jsx)(rR,{...i,ref:t}):(0,U.jsx)(iR,{...i,ref:t})})});nR.displayName=tR;var rR=b.forwardRef((e,t)=>{let n=UL(tR,e.__scopeDialog),r=b.useRef(null),i=fF(t,n.contentRef,r);return b.useEffect(()=>{let e=r.current;if(e)return NL(e)},[]),(0,U.jsx)(aR,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:lF(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:lF(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:lF(e.onFocusOutside,e=>e.preventDefault())})}),iR=b.forwardRef((e,t)=>{let n=UL(tR,e.__scopeDialog),r=b.useRef(!1),i=b.useRef(!1);return(0,U.jsx)(aR,{...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()}})}),aR=b.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=UL(tR,n),c=b.useRef(null),l=fF(t,c);return _I(),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ZF,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,U.jsx)(BF,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":fR(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hR,{titleId:s.titleId}),(0,U.jsx)(_R,{contentRef:c,descriptionId:s.descriptionId})]})]})}),oR=`DialogTitle`,sR=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=UL(oR,n);return(0,U.jsx)(AF.h2,{id:i.titleId,...r,ref:t})});sR.displayName=oR;var cR=`DialogDescription`,lR=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=UL(cR,n);return(0,U.jsx)(AF.p,{id:i.descriptionId,...r,ref:t})});lR.displayName=cR;var uR=`DialogClose`,dR=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=UL(uR,n);return(0,U.jsx)(AF.button,{type:`button`,...r,ref:t,onClick:lF(e.onClick,()=>i.onOpenChange(!1))})});dR.displayName=uR;function fR(e){return e?`open`:`closed`}var pR=`DialogTitleWarning`,[ste,mR]=pF(pR,{contentName:tR,titleName:oR,docsSlug:`dialog`}),hR=({titleId:e})=>{let t=mR(pR),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
134
|
-
|
|
135
|
-
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
136
|
-
|
|
137
|
-
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},gR=`DialogDescriptionWarning`,_R=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${mR(gR).contentName}}.`;return b.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},vR=WL,yR=XL,bR=QL,xR=nR,SR=sR,CR=lR,wR=dR,TR=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,ER=hk,DR=(e,t)=>n=>{if(t?.variants==null)return ER(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=TR(t)||TR(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 ER(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)},OR=vR,kR=yR,AR=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(bR,{className:K(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t,ref:n}));AR.displayName=bR.displayName;var jR=DR(`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`}}),MR=b.forwardRef(({side:e=`right`,className:t,children:n,showOverlay:r=!0,showCloseButton:i=!0,...a},o)=>(0,U.jsxs)(kR,{children:[r?(0,U.jsx)(AR,{}):null,(0,U.jsxs)(xR,{ref:o,className:K(jR({side:e}),t),...a,children:[n,i?(0,U.jsxs)(wR,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,U.jsx)(wN,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]}):null]})]}));MR.displayName=xR.displayName;var NR=({className:e,...t})=>(0,U.jsx)(`div`,{className:K(`flex flex-col space-y-2 text-center sm:text-left`,e),...t});NR.displayName=`SheetHeader`;var PR=({className:e,...t})=>(0,U.jsx)(`div`,{className:K(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});PR.displayName=`SheetFooter`;var FR=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(SR,{ref:n,className:K(`text-lg font-semibold text-foreground`,e),...t}));FR.displayName=SR.displayName;var IR=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(CR,{ref:n,className:K(`text-sm text-muted-foreground`,e),...t}));IR.displayName=CR.displayName;function LR(e){return String(e.Title||``).trim()||String(e.FirstPrompt||``).trim()||String(e.LastPrompt||``).trim()||String(e.Summary||``).trim()||`新对话`}function RR({uiCapabilities:e,createNewSession:t,deleteSession:n,loadSession:r,loadMoreSessions:i}){let a=Ze(e=>e.sessions),o=Ze(e=>e.currentSessionId),s=Ze(e=>e.pinnedSessionIds),c=Ze(e=>e.isLoadingSessions),l=Ze(e=>e.hasMoreSessions),u=C(e=>e.sidebarOpen),d=C(e=>e.mobileSidebarOpen),{isMobile:f}=Vt(),p=xe(e),{desktopSidebarVisible:m}=tt({isMobile:f,desktopSidebarOpen:u,mobileSidebarOpen:d});return p?f?(0,U.jsx)(OR,{open:d,onOpenChange:e=>C.getState().setMobileSidebarOpen(e),children:(0,U.jsxs)(MR,{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)(FR,{className:`sr-only`,children:`历史记录`}),(0,U.jsx)(IR,{className:`sr-only`,children:`查看和切换历史对话。`}),(0,U.jsx)(cF,{sessions:a,currentSessionId:o,onCreateNewSession:t,onSelectSession:r,onDeleteSession:(e,t)=>{t.stopPropagation(),n(e)},onTogglePinSession:(e,t)=>{t.stopPropagation(),Ze.getState().togglePinnedSession(e)},onLoadMoreSessions:i,sessionTitle:LR,pinnedSessionIds:s,hasMoreSessions:l,isLoadingSessions:c})]})}):(0,U.jsx)(`aside`,{className:K(`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)(cF,{sessions:a,currentSessionId:o,onCreateNewSession:t,onSelectSession:r,onDeleteSession:(e,t)=>{t.stopPropagation(),n(e)},onTogglePinSession:(e,t)=>{t.stopPropagation(),Ze.getState().togglePinnedSession(e)},onLoadMoreSessions:i,sessionTitle:LR,pinnedSessionIds:s,hasMoreSessions:l,isLoadingSessions:c})}):null}function zR(){}function BR(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 VR(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var HR=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,UR=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,WR={};function GR(e,t){return((t||WR).jsx?UR:HR).test(e)}var KR=/[ \t\n\f\r]/g;function qR(e){return typeof e==`object`?e.type===`text`?JR(e.value):!1:JR(e)}function JR(e){return e.replace(KR,``)===``}var YR=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};YR.prototype.normal={},YR.prototype.property={},YR.prototype.space=void 0;function XR(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new YR(n,r,t)}function ZR(e){return e.toLowerCase()}var QR=class{constructor(e,t){this.attribute=t,this.property=e}};QR.prototype.attribute=``,QR.prototype.booleanish=!1,QR.prototype.boolean=!1,QR.prototype.commaOrSpaceSeparated=!1,QR.prototype.commaSeparated=!1,QR.prototype.defined=!1,QR.prototype.mustUseProperty=!1,QR.prototype.number=!1,QR.prototype.overloadedBoolean=!1,QR.prototype.property=``,QR.prototype.spaceSeparated=!1,QR.prototype.space=void 0;var $R=s({boolean:()=>tz,booleanish:()=>nz,commaOrSpaceSeparated:()=>oz,commaSeparated:()=>az,number:()=>q,overloadedBoolean:()=>rz,spaceSeparated:()=>iz}),ez=0,tz=sz(),nz=sz(),rz=sz(),q=sz(),iz=sz(),az=sz(),oz=sz();function sz(){return 2**++ez}var cz=Object.keys($R),lz=class extends QR{constructor(e,t,n,r){let i=-1;if(super(e,t),uz(this,`space`,r),typeof n==`number`)for(;++i<cz.length;){let e=cz[i];uz(this,cz[i],(n&$R[e])===$R[e])}}};lz.prototype.defined=!0;function uz(e,t,n){n&&(e[t]=n)}function dz(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new lz(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[ZR(r)]=r,n[ZR(a.attribute)]=r}return new YR(t,n,e.space)}var fz=dz({properties:{ariaActiveDescendant:null,ariaAtomic:nz,ariaAutoComplete:null,ariaBusy:nz,ariaChecked:nz,ariaColCount:q,ariaColIndex:q,ariaColSpan:q,ariaControls:iz,ariaCurrent:null,ariaDescribedBy:iz,ariaDetails:null,ariaDisabled:nz,ariaDropEffect:iz,ariaErrorMessage:null,ariaExpanded:nz,ariaFlowTo:iz,ariaGrabbed:nz,ariaHasPopup:null,ariaHidden:nz,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:iz,ariaLevel:q,ariaLive:null,ariaModal:nz,ariaMultiLine:nz,ariaMultiSelectable:nz,ariaOrientation:null,ariaOwns:iz,ariaPlaceholder:null,ariaPosInSet:q,ariaPressed:nz,ariaReadOnly:nz,ariaRelevant:null,ariaRequired:nz,ariaRoleDescription:iz,ariaRowCount:q,ariaRowIndex:q,ariaRowSpan:q,ariaSelected:nz,ariaSetSize:q,ariaSort:null,ariaValueMax:q,ariaValueMin:q,ariaValueNow:q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function pz(e,t){return t in e?e[t]:t}function mz(e,t){return pz(e,t.toLowerCase())}var hz=dz({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:az,acceptCharset:iz,accessKey:iz,action:null,allow:null,allowFullScreen:tz,allowPaymentRequest:tz,allowUserMedia:tz,alt:null,as:null,async:tz,autoCapitalize:null,autoComplete:iz,autoFocus:tz,autoPlay:tz,blocking:iz,capture:null,charSet:null,checked:tz,cite:null,className:iz,cols:q,colSpan:null,content:null,contentEditable:nz,controls:tz,controlsList:iz,coords:q|az,crossOrigin:null,data:null,dateTime:null,decoding:null,default:tz,defer:tz,dir:null,dirName:null,disabled:tz,download:rz,draggable:nz,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:tz,formTarget:null,headers:iz,height:q,hidden:rz,high:q,href:null,hrefLang:null,htmlFor:iz,httpEquiv:iz,id:null,imageSizes:null,imageSrcSet:null,inert:tz,inputMode:null,integrity:null,is:null,isMap:tz,itemId:null,itemProp:iz,itemRef:iz,itemScope:tz,itemType:iz,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:tz,low:q,manifest:null,max:null,maxLength:q,media:null,method:null,min:null,minLength:q,multiple:tz,muted:tz,name:null,nonce:null,noModule:tz,noValidate:tz,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:tz,optimum:q,pattern:null,ping:iz,placeholder:null,playsInline:tz,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:tz,referrerPolicy:null,rel:iz,required:tz,reversed:tz,rows:q,rowSpan:q,sandbox:iz,scope:null,scoped:tz,seamless:tz,selected:tz,shadowRootClonable:tz,shadowRootDelegatesFocus:tz,shadowRootMode:null,shape:null,size:q,sizes:null,slot:null,span:q,spellCheck:nz,src:null,srcDoc:null,srcLang:null,srcSet:null,start:q,step:null,style:null,tabIndex:q,target:null,title:null,translate:null,type:null,typeMustMatch:tz,useMap:null,value:nz,width:q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:iz,axis:null,background:null,bgColor:null,border:q,borderColor:null,bottomMargin:q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:tz,declare:tz,event:null,face:null,frame:null,frameBorder:null,hSpace:q,leftMargin:q,link:null,longDesc:null,lowSrc:null,marginHeight:q,marginWidth:q,noResize:tz,noHref:tz,noShade:tz,noWrap:tz,object:null,profile:null,prompt:null,rev:null,rightMargin:q,rules:null,scheme:null,scrolling:nz,standby:null,summary:null,text:null,topMargin:q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:tz,disableRemotePlayback:tz,prefix:null,property:null,results:q,security:null,unselectable:null},space:`html`,transform:mz}),gz=dz({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:oz,accentHeight:q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:q,amplitude:q,arabicForm:null,ascent:q,attributeName:null,attributeType:null,azimuth:q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:q,by:null,calcMode:null,capHeight:q,className:iz,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:q,diffuseConstant:q,direction:null,display:null,dur:null,divisor:q,dominantBaseline:null,download:tz,dx:null,dy:null,edgeMode:null,editable:null,elevation:q,enableBackground:null,end:null,event:null,exponent:q,externalResourcesRequired:null,fill:null,fillOpacity:q,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:az,g2:az,glyphName:az,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:q,horizOriginX:q,horizOriginY:q,id:null,ideographic:q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:q,k:q,k1:q,k2:q,k3:q,k4:q,kernelMatrix:oz,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:q,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:q,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:q,overlineThickness:q,paintOrder:null,panose1:null,path:null,pathLength:q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:iz,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:q,pointsAtY:q,pointsAtZ:q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:oz,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:oz,rev:oz,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:oz,requiredFeatures:oz,requiredFonts:oz,requiredFormats:oz,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:q,specularExponent:q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:q,strikethroughThickness:q,string:null,stroke:null,strokeDashArray:oz,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:q,strokeOpacity:q,strokeWidth:null,style:null,surfaceScale:q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:oz,tabIndex:q,tableValues:null,target:null,targetX:q,targetY:q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:oz,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:q,underlineThickness:q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:q,values:null,vAlphabetic:q,vMathematical:q,vectorEffect:null,vHanging:q,vIdeographic:q,version:null,vertAdvY:q,vertOriginX:q,vertOriginY:q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:pz}),_z=dz({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()}}),vz=dz({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:mz}),yz=dz({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),bz={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`},xz=/[A-Z]/g,Sz=/-[a-z]/g,Cz=/^data[-\w.:]+$/i;function wz(e,t){let n=ZR(t),r=t,i=QR;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Cz.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Sz,Ez);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Sz.test(e)){let n=e.replace(xz,Tz);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=lz}return new i(r,t)}function Tz(e){return`-`+e.toLowerCase()}function Ez(e){return e.charAt(1).toUpperCase()}var Dz=XR([fz,hz,_z,vz,yz],`html`),Oz=XR([fz,gz,_z,vz,yz],`svg`);function kz(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Az(e){return e.join(` `).trim()}var jz=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=`
|
|
138
|
-
`,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=ne();)t!==!1&&e.push(t);return e}function ne(){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 re(){var e=y(),t=ee(a);if(t){if(ne(),!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 C(){var e=[];S(e);for(var t;t=re();)t!==!1&&(e.push(t),S(e));return e}return te(),C()}function _(e){return e?e.replace(l,p):p}t.exports=g})),Mz=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(jz());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}})),Nz=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))}})),Pz=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Mz()),r=Nz();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})),Fz=Lz(`end`),Iz=Lz(`start`);function Lz(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 Rz(e){let t=Iz(e),n=Fz(e);if(t&&n)return{start:t,end:n}}function zz(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Vz(e.position):`start`in e||`end`in e?Vz(e):`line`in e||`column`in e?Bz(e):``}function Bz(e){return Hz(e&&e.line)+`:`+Hz(e&&e.column)}function Vz(e){return Bz(e&&e.start)+`-`+Bz(e&&e.end)}function Hz(e){return e&&typeof e==`number`?e:1}var Uz=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=zz(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}};Uz.prototype.file=``,Uz.prototype.name=``,Uz.prototype.reason=``,Uz.prototype.message=``,Uz.prototype.stack=``,Uz.prototype.column=void 0,Uz.prototype.line=void 0,Uz.prototype.ancestors=void 0,Uz.prototype.cause=void 0,Uz.prototype.fatal=void 0,Uz.prototype.place=void 0,Uz.prototype.ruleId=void 0,Uz.prototype.source=void 0;var cte=l(Pz(),1),Wz={}.hasOwnProperty,lte=new Map,ute=/[A-Z]/g,dte=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),fte=new Set([`td`,`th`]);function pte(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=xte(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=bte(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`?Oz:Dz,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Gz(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Gz(e,t,n){if(t.type===`element`)return mte(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return hte(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return _te(e,t,n);if(t.type===`mdxjsEsm`)return gte(e,t);if(t.type===`root`)return vte(e,t,n);if(t.type===`text`)return yte(e,t)}function mte(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Oz,e.schema=i),e.ancestors.push(t);let a=Yz(e,t.tagName,!1),o=Ste(e,t),s=Jz(e,t);return dte.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!qR(e):!0})),Kz(e,o,a,t),qz(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function hte(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)}Xz(e,t.position)}function gte(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Xz(e,t.position)}function _te(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Oz,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Yz(e,t.name,!0),o=Cte(e,t),s=Jz(e,t);return Kz(e,o,a,t),qz(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function vte(e,t,n){let r={};return qz(r,Jz(e,t)),e.create(t,e.Fragment,r,n)}function yte(e,t){return t.value}function Kz(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function qz(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function bte(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 xte(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=Iz(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 Ste(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Wz.call(t.properties,i)){let a=wte(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&fte.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 Cte(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 Xz(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 Xz(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function Jz(e,t){let n=[],r=-1,i=e.passKeys?new Map:lte;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=Gz(e,a,o);s!==void 0&&n.push(s)}return n}function wte(e,t,n){let r=wz(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?VR(n):Az(n)),r.property===`style`){let t=typeof n==`object`?n:Tte(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Ete(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?bz[r.property]||r.property:r.attribute,n]}}function Tte(e,t){try{return(0,cte.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Uz("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 Yz(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=GR(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=GR(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Wz.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Xz(e)}function Xz(e,t){let n=new Uz("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 Ete(e){let t={},n;for(n in e)Wz.call(e,n)&&(t[Dte(n)]=e[n]);return t}function Dte(e){let t=e.replace(ute,Ote);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Ote(e){return`-`+e.toLowerCase()}var Zz={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`]},kte={};function Qz(e,t){let n=t||kte;return $z(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function $z(e,t,n){if(Ate(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 eB(e.children,t,n)}return Array.isArray(e)?eB(e,t,n):``}function eB(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=$z(e[i],t,n);return r.join(``)}function Ate(e){return!!(e&&typeof e==`object`)}var tB=document.createElement(`i`);function nB(e){let t=`&`+e+`;`;tB.innerHTML=t;let n=tB.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function rB(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 iB(e,t){return e.length>0?(rB(e,e.length,0,t),e):t}var aB={}.hasOwnProperty;function oB(e){let t={},n=-1;for(;++n<e.length;)jte(t,e[n]);return t}function jte(e,t){let n;for(n in t){let r=(aB.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){aB.call(r,a)||(r[a]=[]);let e=i[a];Mte(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Mte(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);rB(e,0,0,r)}function sB(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 cB(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var lB=vB(/[A-Za-z]/),uB=vB(/[\dA-Za-z]/),Nte=vB(/[#-'*+\--9=?A-Z^-~]/);function dB(e){return e!==null&&(e<32||e===127)}var fB=vB(/\d/),Pte=vB(/[\dA-Fa-f]/),Fte=vB(/[!-/:-@[-`{-~]/);function pB(e){return e!==null&&e<-2}function mB(e){return e!==null&&(e<0||e===32)}function hB(e){return e===-2||e===-1||e===32}var gB=vB(/\p{P}|\p{S}/u),_B=vB(/\s/);function vB(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function yB(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&uB(e.charCodeAt(n+1))&&uB(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 bB(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return hB(r)?(e.enter(n),s(r)):t(r)}function s(r){return hB(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Ite={tokenize:Lte};function Lte(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`),bB(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 pB(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Rte={tokenize:zte},xB={tokenize:Bte};function zte(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 rB(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(xB,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(xB,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 pB(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++;rB(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 Bte(e,t,n){return bB(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function SB(e){if(e===null||mB(e)||_B(e))return 1;if(gB(e))return 2}function CB(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 wB={name:`attention`,resolveAll:Vte,tokenize:Hte};function Vte(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};TB(d,-c),TB(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=iB(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=iB(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=iB(l,CB(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=iB(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=iB(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,rB(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 Hte(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=SB(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=SB(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 TB(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Ute={name:`autolink`,tokenize:Wte};function Wte(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 lB(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||uB(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||uB(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||dB(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Nte(t)?(e.consume(t),l):n(t)}function u(e){return uB(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||uB(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var EB={partial:!0,tokenize:Gte};function Gte(e,t,n){return r;function r(t){return hB(t)?bB(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||pB(e)?t(e):n(e)}}var DB={continuation:{tokenize:qte},exit:Jte,name:`blockQuote`,tokenize:Kte};function Kte(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 hB(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function qte(e,t,n){let r=this;return i;function i(t){return hB(t)?bB(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(DB,t,n)(r)}}function Jte(e){e.exit(`blockQuote`)}var OB={name:`characterEscape`,tokenize:Yte};function Yte(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 Fte(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var kB={name:`characterReference`,tokenize:Xte};function Xte(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=uB,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=Pte,u):(e.enter(`characterReferenceValue`),a=7,o=fB,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===uB&&!nB(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 AB={partial:!0,tokenize:Qte},jB={concrete:!0,name:`codeFenced`,tokenize:Zte};function Zte(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`),hB(t)?bB(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||pB(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(AB,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||pB(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):hB(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),bB(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||pB(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||pB(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&&hB(t)?bB(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||pB(t)?e.check(AB,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||pB(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`),hB(t)?bB(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`),hB(t)?bB(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||pB(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function Qte(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 MB={name:`codeIndented`,tokenize:ene},$te={partial:!0,tokenize:tne};function ene(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),bB(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):pB(t)?e.attempt($te,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||pB(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function tne(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):pB(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):bB(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):pB(e)?i(e):n(e)}}var nne={name:`codeText`,previous:ine,resolve:rne,tokenize:ane};function rne(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 ine(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function ane(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)):pB(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||pB(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 one=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&&NB(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),NB(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),NB(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);NB(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);NB(this.left,t.reverse())}}};function NB(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 PB(e){let t={},n=-1,r,i,a,o,s,c,l,u=new one(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,sne(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 rB(e,0,1/0,u.slice(0)),!l}function sne(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 cne={resolve:une,tokenize:dne},lne={partial:!0,tokenize:fne};function une(e){return PB(e),e}function dne(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):pB(t)?e.check(lne,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 fne(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),bB(e,a,`linePrefix`)}function a(i){if(i===null||pB(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 FB(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||dB(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||pB(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||mB(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||dB(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 IB(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):pB(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||pB(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!hB(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function LB(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):pB(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),bB(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||pB(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 RB(e,t){let n;return r;function r(i){return pB(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):hB(i)?bB(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var pne={name:`definition`,tokenize:hne},mne={partial:!0,tokenize:gne};function hne(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return IB.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=cB(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 mB(t)?RB(e,l)(t):l(t)}function l(t){return FB(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(mne,d,d)(t)}function d(t){return hB(t)?bB(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||pB(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function gne(e,t,n){return r;function r(t){return mB(t)?RB(e,i)(t):n(t)}function i(t){return LB(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return hB(t)?bB(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||pB(e)?t(e):n(e)}}var _ne={name:`hardBreakEscape`,tokenize:vne};function vne(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return pB(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var yne={name:`headingAtx`,resolve:bne,tokenize:xne};function bne(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`},rB(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function xne(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||mB(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||pB(n)?(e.exit(`atxHeading`),t(n)):hB(n)?bB(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||mB(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Sne=`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(`.`),zB=[`pre`,`script`,`style`,`textarea`],Cne={concrete:!0,name:`htmlFlow`,resolveTo:Ene,tokenize:Dne},wne={partial:!0,tokenize:kne},Tne={partial:!0,tokenize:One};function Ene(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 Dne(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):lB(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):lB(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:w:m):n(i)}function h(t){return lB(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||mB(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&zB.includes(l)?(i=1,r.interrupt?t(s):w(s)):Sne.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):w(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||uB(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:w):n(i)}function v(t){return hB(t)?(e.consume(t),v):re(t)}function y(t){return t===47?(e.consume(t),re):t===58||t===95||lB(t)?(e.consume(t),b):hB(t)?(e.consume(t),y):re(t)}function b(t){return t===45||t===46||t===58||t===95||uB(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),ee):hB(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):hB(t)?(e.consume(t),ee):S(t)}function te(t){return t===c?(e.consume(t),c=null,ne):t===null||pB(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||mB(t)?x(t):(e.consume(t),S)}function ne(e){return e===47||e===62||hB(e)?y(e):n(e)}function re(t){return t===62?(e.consume(t),C):n(t)}function C(t){return t===null||pB(t)?w(t):hB(t)?(e.consume(t),C):n(t)}function w(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):pB(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(wne,de,ie)(t)):t===null||pB(t)?(e.exit(`htmlFlowData`),ie(t)):(e.consume(t),w)}function ie(t){return e.check(Tne,ae,de)(t)}function ae(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),oe}function oe(t){return t===null||pB(t)?ie(t):(e.enter(`htmlFlowData`),w(t))}function se(t){return t===45?(e.consume(t),T):w(t)}function ce(t){return t===47?(e.consume(t),o=``,le):w(t)}function le(t){if(t===62){let n=o.toLowerCase();return zB.includes(n)?(e.consume(t),E):w(t)}return lB(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),le):w(t)}function ue(t){return t===93?(e.consume(t),T):w(t)}function T(t){return t===62?(e.consume(t),E):t===45&&i===2?(e.consume(t),T):w(t)}function E(t){return t===null||pB(t)?(e.exit(`htmlFlowData`),de(t)):(e.consume(t),E)}function de(n){return e.exit(`htmlFlow`),t(n)}}function One(e,t,n){let r=this;return i;function i(t){return pB(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 kne(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(EB,t,n)}}var Ane={name:`htmlText`,tokenize:jne};function jne(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):lB(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):lB(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):pB(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):pB(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):pB(t)?(o=v,ce(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):pB(t)?(o=y,ce(t)):(e.consume(t),y)}function b(e){return e===62?se(e):y(e)}function x(t){return lB(t)?(e.consume(t),ee):n(t)}function ee(t){return t===45||uB(t)?(e.consume(t),ee):te(t)}function te(t){return pB(t)?(o=te,ce(t)):hB(t)?(e.consume(t),te):se(t)}function S(t){return t===45||uB(t)?(e.consume(t),S):t===47||t===62||mB(t)?ne(t):n(t)}function ne(t){return t===47?(e.consume(t),se):t===58||t===95||lB(t)?(e.consume(t),re):pB(t)?(o=ne,ce(t)):hB(t)?(e.consume(t),ne):se(t)}function re(t){return t===45||t===46||t===58||t===95||uB(t)?(e.consume(t),re):C(t)}function C(t){return t===61?(e.consume(t),w):pB(t)?(o=C,ce(t)):hB(t)?(e.consume(t),C):ne(t)}function w(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,ie):pB(t)?(o=w,ce(t)):hB(t)?(e.consume(t),w):(e.consume(t),ae)}function ie(t){return t===i?(e.consume(t),i=void 0,oe):t===null?n(t):pB(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||mB(t)?ne(t):(e.consume(t),ae)}function oe(e){return e===47||e===62||mB(e)?ne(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 hB(t)?bB(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 BB={name:`labelEnd`,resolveAll:Fne,resolveTo:Ine,tokenize:Lne},Mne={tokenize:Rne},Nne={tokenize:zne},Pne={tokenize:Bne};function Fne(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&&rB(e,0,e.length,n),e}function Ine(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=iB(s,e.slice(a+1,a+r+3)),s=iB(s,[[`enter`,u,t]]),s=iB(s,CB(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=iB(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=iB(s,e.slice(o+1)),s=iB(s,[[`exit`,c,t]]),rB(e,a,e.length,s),e}function Lne(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(cB(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(Mne,u,o?u:d)(t):t===91?e.attempt(Nne,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Pne,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function Rne(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 mB(t)?RB(e,a)(t):a(t)}function a(t){return t===41?u(t):FB(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return mB(t)?RB(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?LB(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return mB(t)?RB(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 zne(e,t,n){let r=this;return i;function i(t){return IB.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(cB(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Bne(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 Vne={name:`labelStartImage`,resolveAll:BB.resolveAll,tokenize:Hne};function Hne(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 Une={name:`labelStartLink`,resolveAll:BB.resolveAll,tokenize:Wne};function Wne(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 VB={name:`lineEnding`,tokenize:Gne};function Gne(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),bB(e,t,`linePrefix`)}}var HB={name:`thematicBreak`,tokenize:Kne};function Kne(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||pB(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),hB(t)?bB(e,s,`whitespace`)(t):s(t))}}var UB={continuation:{tokenize:Xne},exit:Qne,name:`list`,tokenize:Yne},qne={partial:!0,tokenize:$ne},Jne={partial:!0,tokenize:Zne};function Yne(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:fB(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(HB,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 fB(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(EB,r.interrupt?n:u,e.attempt(qne,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return hB(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 Xne(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(EB,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,bB(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!hB(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(Jne,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,bB(e,e.attempt(UB,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function Zne(e,t,n){let r=this;return bB(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 Qne(e){e.exit(this.containerState.type)}function $ne(e,t,n){let r=this;return bB(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!hB(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var WB={name:`setextUnderline`,resolveTo:ere,tokenize:tre};function ere(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 tre(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`),hB(t)?bB(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||pB(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var nre={tokenize:rre};function rre(e){let t=this,n=e.attempt(EB,r,e.attempt(this.parser.constructs.flowInitial,i,bB(e,e.attempt(this.parser.constructs.flow,i,e.attempt(cne,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 ire={resolveAll:KB()},are=GB(`string`),ore=GB(`text`);function GB(e){return{resolveAll:KB(e===`text`?sre: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 KB(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 sre(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 cre=s({attentionMarkers:()=>gre,contentInitial:()=>ure,disable:()=>_re,document:()=>lre,flow:()=>fre,flowInitial:()=>dre,insideSpan:()=>hre,string:()=>pre,text:()=>mre}),lre={42:UB,43:UB,45:UB,48:UB,49:UB,50:UB,51:UB,52:UB,53:UB,54:UB,55:UB,56:UB,57:UB,62:DB},ure={91:pne},dre={[-2]:MB,[-1]:MB,32:MB},fre={35:yne,42:HB,45:[WB,HB],60:Cne,61:WB,95:HB,96:jB,126:jB},pre={38:kB,92:OB},mre={[-5]:VB,[-4]:VB,[-3]:VB,33:Vne,38:kB,42:wB,60:[Ute,Ane],91:Une,92:[_ne,OB],93:BB,95:wB,96:nne},hre={null:[wB,ire]},gre={null:[42,95]},_re={null:[]};function vre(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=iB(o,e),g(),o[o.length-1]===null?(S(t,0),l.events=CB(a,l.events,l),l.events):[]}function f(e,t){return bre(p(e),t)}function p(e){return yre(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,re()}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){pB(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,re()):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=ne(),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&&rB(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function ne(){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,re()}}function re(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function yre(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 bre(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=`
|
|
139
|
-
`;break;case-3:o=`\r
|
|
140
|
-
`;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 xre(e){let t={constructs:oB([cre,...(e||{}).extensions||[]]),content:n(Ite),defined:[],document:n(Rte),flow:n(nre),lazy:{},string:n(are),text:n(ore)};return t;function n(e){return n;function n(n){return vre(t,e,n)}}}function Sre(e){for(;!PB(e););return e}var qB=/[\0\t\n\r]/g;function JB(){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(qB.lastIndex=u,c=qB.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 YB=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function XB(e){return e.replace(YB,ZB)}function ZB(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return sB(n.slice(t?2:1),t?16:10)}return nB(n)||e}var QB={}.hasOwnProperty;function $B(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),eV(n)(Sre(xre(n).document().write(JB()(e,t,!0))))}function eV(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(Oe),autolinkProtocol:ne,autolinkEmail:ne,atxHeading:a(we),blockQuote:a(ye),characterEscape:ne,characterReference:ne,codeFenced:a(be),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(be,o),codeText:a(xe,o),codeTextData:ne,data:ne,codeFlowValue:ne,definition:a(Se),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(Ce),hardBreakEscape:a(Te),hardBreakTrailing:a(Te),htmlFlow:a(Ee,o),htmlFlowData:ne,htmlText:a(Ee,o),htmlTextData:ne,image:a(De),label:o,link:a(Oe),listItem:a(Ae),listItemValue:f,listOrdered:a(ke,d),listUnordered:a(ke),paragraph:a(je),reference:fe,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(we),strong:a(Me),thematicBreak:a(Pe)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:ve,autolinkProtocol:_e,blockQuote:c(),characterEscapeValue:re,characterReferenceMarkerHexadecimal:me,characterReferenceMarkerNumeric:me,characterReferenceValue:he,characterReference:ge,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:re,codeIndented:c(_),codeText:c(oe),codeTextData:re,data:re,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(w),hardBreakTrailing:c(w),htmlFlow:c(ie),htmlFlowData:re,htmlText:c(ae),htmlTextData:re,image:c(ce),label:ue,labelText:le,lineEnding:C,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()}};nV(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]];QB.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]||iV).call(a,void 0,e[0])}for(r.position={start:tV(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:tV(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:tV(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]||iV).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+zz({start:e.start,end:e.end})+`): it’s not open`);n.position.end=tV(e.end)}function u(){return Qz(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=cB(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 ne(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Ne(),n.position={start:tV(e.start),end:void 0},t.push(n)),this.stack.push(n)}function re(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=tV(e.end)}function C(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=tV(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(ne.call(this,e),re.call(this,e))}function w(){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=XB(t),n.identifier=cB(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=cB(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=sB(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=nB(t);let i=this.stack[this.stack.length-1];i.value+=r}function ge(e){let t=this.stack.pop();t.position.end=tV(e.end)}function _e(e){re.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ve(e){re.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 Ce(){return{type:`emphasis`,children:[]}}function we(){return{type:`heading`,depth:0,children:[]}}function Te(){return{type:`break`}}function Ee(){return{type:`html`,value:``}}function De(){return{type:`image`,title:null,url:``,alt:null}}function Oe(){return{type:`link`,title:null,url:``,children:[]}}function ke(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Ae(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function je(){return{type:`paragraph`,children:[]}}function Me(){return{type:`strong`,children:[]}}function Ne(){return{type:`text`,value:``}}function Pe(){return{type:`thematicBreak`}}}function tV(e){return{line:e.line,column:e.column,offset:e.offset}}function nV(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?nV(e,r):rV(e,r)}}function rV(e,t){let n;for(n in t)if(QB.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 iV(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+zz({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+zz({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+zz({start:t.start,end:t.end})+`) is still open`)}function aV(e){let t=this;t.parser=n;function n(n){return $B(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function oV(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 sV(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
141
|
-
`}]}function cV(e,t){let n=t.value?t.value+`
|
|
142
|
-
`:``,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 lV(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function uV(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function dV(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=yB(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 fV(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 pV(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function mV(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 hV(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return mV(e,t);let i={src:yB(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 gV(e,t){let n={src:yB(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 _V(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 vV(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return mV(e,t);let i={href:yB(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 yV(e,t){let n={href:yB(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 bV(e,t,n){let r=e.all(t),i=n?xV(n):SV(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:`
|
|
143
|
-
`}),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:`
|
|
144
|
-
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function xV(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=SV(n[r])}return t}function SV(e){return e.spread??e.children.length>1}function CV(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 wV(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function TV(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function EV(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function DV(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=Iz(t.children[1]),o=Fz(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 OV(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 kV(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var AV=9,jV=32;function MV(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(NV(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(NV(t.slice(i),i>0,!1)),a.join(``)}function NV(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===AV||t===jV;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===AV||t===jV;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function PV(e,t){let n={type:`text`,value:MV(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function FV(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var IV={blockquote:oV,break:sV,code:cV,delete:lV,emphasis:uV,footnoteReference:dV,heading:fV,html:pV,imageReference:hV,image:gV,inlineCode:_V,linkReference:vV,link:yV,listItem:bV,list:CV,paragraph:wV,root:TV,strong:EV,table:DV,tableCell:kV,tableRow:OV,text:PV,thematicBreak:FV,toml:LV,yaml:LV,definition:LV,footnoteDefinition:LV};function LV(){}var RV=typeof self==`object`?self:globalThis,zV=(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 RV[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 RV[a](o),i)};return r},BV=e=>zV(new Map,e)(0),VV=``,{toString:HV}={},{keys:UV}=Object,WV=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=HV.call(e).slice(8,-1);switch(n){case`Array`:return[1,VV];case`Object`:return[2,VV];case`Date`:return[3,VV];case`RegExp`:return[4,VV];case`Map`:return[5,VV];case`Set`:return[6,VV];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},GV=([e,t])=>e===0&&(t===`function`||t===`symbol`),KV=(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]=WV(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 UV(r))(e||!GV(WV(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||!(GV(WV(n))||GV(WV(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!GV(WV(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},qV=(e,{json:t,lossy:n}={})=>{let r=[];return KV(!(t||n),!!t,new Map,r)(e),r},JV=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?BV(qV(e,t)):structuredClone(e):(e,t)=>BV(qV(e,t));function YV(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 XV(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function ZV(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||YV,r=e.options.footnoteBackLabel||XV,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=yB(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:{...JV(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
145
|
-
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
146
|
-
`}]}}var QV=(function(e){if(e==null)return rH;if(typeof e==`function`)return nH(e);if(typeof e==`object`)return Array.isArray(e)?$V(e):eH(e);if(typeof e==`string`)return tH(e);throw Error(`Expected function, string, or object as test`)});function $V(e){let t=[],n=-1;for(;++n<e.length;)t[n]=QV(e[n]);return nH(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function eH(e){let t=e;return nH(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function tH(e){return nH(t);function t(t){return t&&t.type===e}}function nH(e){return t;function t(t,n,r){return!!(iH(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function rH(){return!0}function iH(e){return typeof e==`object`&&!!e&&`type`in e}function aH(e){return e}var oH=[],sH=`skip`;function cH(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=QV(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 (`+aH(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=oH,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=lH(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 lH(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?oH:[e]}function uH(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),cH(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 dH={}.hasOwnProperty,fH={};function pH(e,t){let n=t||fH,r=new Map,i=new Map,a={all:s,applyData:hH,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...IV,...n.handlers},one:o,options:n,patch:mH,wrap:_H};return uH(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(dH.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=JV(n);return r.children=a.all(e),r}return JV(e)}return(a.options.unknownHandler||gH)(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=vH(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=vH(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function mH(e,t){e.position&&(t.position=Rz(e))}function hH(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,JV(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function gH(e,t){let n=t.data||{},r=`value`in t&&!(dH.call(n,`hProperties`)||dH.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 _H(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
147
|
-
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
148
|
-
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
149
|
-
`}),n}function vH(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function yH(e,t){let n=pH(e,t),r=n.one(e,void 0),i=ZV(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
150
|
-
`},i)),a}function bH(e,t){return e&&`run`in e?async function(n,r){let i=yH(n,{file:r,...t});await e.run(i,r)}:function(n,r){return yH(n,{file:r,...e||t})}}function xH(e){if(e)throw e}var SH=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 CH(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 wH(){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?TH(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 TH(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 EH={basename:DH,dirname:OH,extname:kH,join:AH,sep:`/`};function DH(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);NH(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 OH(e){if(NH(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 kH(e){NH(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 AH(...e){let t=-1,n;for(;++t<e.length;)NH(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:jH(n)}function jH(e){NH(e);let t=e.codePointAt(0)===47,n=MH(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function MH(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 NH(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var PH={cwd:FH};function FH(){return`/`}function IH(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function LH(e){if(typeof e==`string`)e=new URL(e);else if(!IH(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 RH(e)}function RH(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 zH=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],BH=class{constructor(e){let t;t=e?IH(e)?{path:e}:typeof e==`string`||WH(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:PH.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<zH.length;){let e=zH[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)zH.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?EH.basename(this.path):void 0}set basename(e){HH(e,`basename`),VH(e,`basename`),this.path=EH.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?EH.dirname(this.path):void 0}set dirname(e){UH(this.basename,`dirname`),this.path=EH.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?EH.extname(this.path):void 0}set extname(e){if(VH(e,`extname`),UH(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=EH.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){IH(e)&&(e=LH(e)),HH(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?EH.basename(this.path,this.extname):void 0}set stem(e){HH(e,`stem`),VH(e,`stem`),this.path=EH.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 Uz(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 VH(e,t){if(e&&e.includes(EH.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+EH.sep+"`")}function HH(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function UH(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function WH(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var GH=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),KH=l(SH(),1),qH={}.hasOwnProperty,JH=new class e extends GH{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=wH()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,KH.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(ZH(`data`,this.frozen),this.namespace[e]=t,this):qH.call(this.namespace,e)&&this.namespace[e]||void 0:e?(ZH(`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=eU(e),n=this.parser||this.Parser;return YH(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),YH(`process`,this.parser||this.Parser),XH(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=eU(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);nU(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(),YH(`processSync`,this.parser||this.Parser),XH(`processSync`,this.compiler||this.Compiler),this.process(e,r),$H(`processSync`,`process`,t),n;function r(e,r){t=!0,xH(e),n=r}}run(e,t,n){QH(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=eU(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),$H(`runSync`,`run`,n),r;function i(e,t){xH(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=eU(t),r=this.compiler||this.Compiler;return XH(`stringify`,r),QH(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(ZH(`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,KH.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];CH(o)&&CH(r)&&(r=(0,KH.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function YH(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function XH(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function ZH(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 QH(e){if(!CH(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function $H(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function eU(e){return tU(e)?e:new BH(e)}function tU(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function nU(e){return typeof e==`string`||rU(e)}function rU(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var iU=[],aU={allowDangerousHtml:!0},oU=/^(https?|ircs?|mailto|xmpp)$/i,sU=[{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 cU(e){let t=lU(e),n=uU(e);return dU(t.runSync(t.parse(n),n),e)}function lU(e){let t=e.rehypePlugins||iU,n=e.remarkPlugins||iU,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...aU}:aU;return JH().use(aV).use(n).use(bH,r).use(t)}function uU(e){let t=e.children||``,n=new BH;return typeof t==`string`?n.value=t:``+t,n}function dU(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||fU;for(let e of sU)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return uH(e,l),pte(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 Zz)if(Object.hasOwn(Zz,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Zz[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 fU(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||oU.test(e.slice(0,t))?e:``}function pU(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 mU(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function hU(e,t,n){let r=QV((n||{}).ignore||[]),i=gU(t),a=-1;for(;++a<i.length;)cH(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 gU(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([_U(e[0]),vU(e[1])])}return t}function _U(e){return typeof e==`string`?new RegExp(mU(e),`g`):e}function vU(e){return typeof e==`function`?e:function(){return e}}var yU=`phrasing`,bU=[`autolink`,`link`,`image`,`label`];function xU(){return{transforms:[kU],enter:{literalAutolink:CU,literalAutolinkEmail:wU,literalAutolinkHttp:wU,literalAutolinkWww:wU},exit:{literalAutolink:OU,literalAutolinkEmail:DU,literalAutolinkHttp:TU,literalAutolinkWww:EU}}}function SU(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:yU,notInConstruct:bU},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:yU,notInConstruct:bU},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:yU,notInConstruct:bU}]}}function CU(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function wU(e){this.config.enter.autolinkProtocol.call(this,e)}function TU(e){this.config.exit.autolinkProtocol.call(this,e)}function EU(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 DU(e){this.config.exit.autolinkEmail.call(this,e)}function OU(e){this.exit(e)}function kU(e){hU(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,AU],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,jU]],{ignore:[`link`,`linkReference`]})}function AU(e,t,n,r,i){let a=``;if(!PU(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!MU(n)))return!1;let o=NU(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 jU(e,t,n,r){return!PU(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function MU(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 NU(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=pU(e,`(`),a=pU(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 PU(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||_B(n)||gB(n))&&(!t||n!==47)}WU.peek=UU;function FU(){this.buffer()}function IU(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function LU(){this.buffer()}function RU(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function zU(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=cB(this.sliceSerialize(e)).toLowerCase(),n.label=t}function BU(e){this.exit(e)}function VU(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=cB(this.sliceSerialize(e)).toLowerCase(),n.label=t}function HU(e){this.exit(e)}function UU(){return`[`}function WU(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 GU(){return{enter:{gfmFootnoteCallString:FU,gfmFootnoteCall:IU,gfmFootnoteDefinitionLabelString:LU,gfmFootnoteDefinition:RU},exit:{gfmFootnoteCallString:zU,gfmFootnoteCall:BU,gfmFootnoteDefinitionLabelString:VU,gfmFootnoteDefinition:HU}}}function KU(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:WU},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?`
|
|
151
|
-
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?JU:qU))),s(),o}}function qU(e,t,n){return t===0?e:JU(e,t,n)}function JU(e,t,n){return(n?``:` `)+e}var YU=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];eW.peek=tW;function XU(){return{canContainEols:[`delete`],enter:{strikethrough:QU},exit:{strikethrough:$U}}}function ZU(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:YU}],handlers:{delete:eW}}}function QU(e){this.enter({type:`delete`,children:[]},e)}function $U(e){this.exit(e)}function eW(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 tW(){return`~`}function nW(e){return e.length}function rW(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||nW,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=iW(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]=aW(r[d]);else{let e=aW(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(`
|
|
152
|
-
`)}function iW(e){return e==null?``:String(e)}function aW(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 oW(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()),sW);return i(),o}function sW(e,t,n){return`>`+(n?``:` `)+e}function cW(e,t){return lW(e,t.inConstruct,!0)&&!lW(e,t.notInConstruct,!1)}function lW(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 uW(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
153
|
-
`&&cW(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
154
|
-
`}function dW(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 fW(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 pW(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function mW(e,t,n,r){let i=pW(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(fW(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,hW);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(dW(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:`
|
|
155
|
-
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
156
|
-
`),a&&(u+=s.move(a+`
|
|
157
|
-
`)),u+=s.move(c),l(),u}function hW(e,t,n){return(n?``:` `)+e}function gW(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function _W(e,t,n,r){let i=gW(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?` `:`
|
|
158
|
-
`,...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 vW(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function yW(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function bW(e,t,n){let r=SB(e),i=SB(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}}xW.peek=SW;function xW(e,t,n,r){let i=vW(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=bW(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=yW(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=bW(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+yW(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function SW(e,t,n){return n.options.emphasis||`*`}function CW(e,t){let n=!1;return uH(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)&&Qz(e)&&(t.options.setext||n))}function wW(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(CW(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
159
|
-
`,after:`
|
|
160
|
-
`});return r(),t(),o+`
|
|
161
|
-
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
162
|
-
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
163
|
-
`,...a.current()});return/^[\t ]/.test(l)&&(l=yW(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}TW.peek=EW;function TW(e){return e.value||``}function EW(){return`<`}DW.peek=OW;function DW(e,t,n,r){let i=gW(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 OW(){return`!`}kW.peek=AW;function kW(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 AW(){return`!`}jW.peek=MW;function jW(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 MW(){return"`"}function NW(e,t){let n=Qz(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))}PW.peek=FW;function PW(e,t,n,r){let i=gW(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(NW(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 FW(e,t,n){return NW(e,n)?`<`:`[`}IW.peek=LW;function IW(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 LW(){return`[`}function RW(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 zW(e){let t=RW(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 BW(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function VW(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 HW(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?BW(n):RW(n),s=e.ordered?o===`.`?`)`:`.`:zW(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),VW(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 UW(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 WW(e,t,n,r){let i=UW(n),a=n.bulletCurrent||RW(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 GW(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var KW=QV([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function qW(e,t,n,r){return(e.children.some(function(e){return KW(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function JW(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}YW.peek=XW;function YW(e,t,n,r){let i=JW(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=bW(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=yW(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=bW(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+yW(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function XW(e,t,n){return n.options.strong||`*`}function ZW(e,t,n,r){return n.safe(e.value,r)}function QW(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 $W(e,t,n){let r=(VW(n)+(n.options.ruleSpaces?` `:``)).repeat(QW(n));return n.options.ruleSpaces?r.slice(0,-1):r}var eG={blockquote:oW,break:uW,code:mW,definition:_W,emphasis:xW,hardBreak:uW,heading:wW,html:TW,image:DW,imageReference:kW,inlineCode:jW,link:PW,linkReference:IW,list:HW,listItem:WW,paragraph:GW,root:qW,strong:YW,text:ZW,thematicBreak:$W};function tG(){return{enter:{table:nG,tableData:oG,tableHeader:oG,tableRow:iG},exit:{codeText:sG,table:rG,tableData:aG,tableHeader:aG,tableRow:aG}}}function nG(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 rG(e){this.exit(e),this.data.inTable=void 0}function iG(e){this.enter({type:`tableRow`,children:[]},e)}function aG(e){this.exit(e)}function oG(e){this.enter({type:`tableCell`,children:[]},e)}function sG(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,cG));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function cG(e,t){return t===`|`?t:e}function lG(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
164
|
-
`,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(`
|
|
165
|
-
`))}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 rW(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=eG.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function uG(){return{exit:{taskListCheckValueChecked:fG,taskListCheckValueUnchecked:fG,paragraph:pG}}}function dG(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:mG}}}function fG(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function pG(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 mG(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=eG.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 hG(){return[xU(),GU(),XU(),tG(),uG()]}function gG(e){return{extensions:[SU(),KU(e),ZU(),lG(e),dG()]}}var _G={tokenize:jG,partial:!0},vG={tokenize:MG,partial:!0},yG={tokenize:NG,partial:!0},bG={tokenize:PG,partial:!0},xG={tokenize:FG,partial:!0},SG={name:`wwwAutolink`,tokenize:kG,previous:IG},CG={name:`protocolAutolink`,tokenize:AG,previous:LG},wG={name:`emailAutolink`,tokenize:OG,previous:RG},TG={};function EG(){return{text:TG}}for(var DG=48;DG<123;)TG[DG]=wG,DG++,DG===58?DG=65:DG===91&&(DG=97);TG[43]=wG,TG[45]=wG,TG[46]=wG,TG[95]=wG,TG[72]=[wG,CG],TG[104]=[wG,CG],TG[87]=[wG,SG],TG[119]=[wG,SG];function OG(e,t,n){let r=this,i,a;return o;function o(t){return!zG(t)||!RG.call(r,r.previous)||BG(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return zG(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(xG,u,l)(t):t===45||t===95||uB(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&&lB(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function kG(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!IG.call(r,r.previous)||BG(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(_G,e.attempt(vG,e.attempt(yG,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function AG(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&LG.call(r,r.previous)&&!BG(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(lB(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||dB(t)||mB(t)||_B(t)||gB(t)?n(t):e.attempt(vG,e.attempt(yG,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function jG(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 MG(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(bG,c,s)(t):t===null||mB(t)||_B(t)||t!==45&&gB(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 NG(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(bG,t,a)(o):o===null||mB(o)||_B(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function PG(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||mB(o)||_B(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||mB(e)||_B(e)?t(e):r(e)}function a(e){return lB(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):lB(t)?(e.consume(t),o):n(t)}}function FG(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return uB(e)?n(e):t(e)}}function IG(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||mB(e)}function LG(e){return!lB(e)}function RG(e){return!(e===47||zG(e))}function zG(e){return e===43||e===45||e===46||e===95||uB(e)}function BG(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 VG={tokenize:YG,partial:!0};function HG(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:KG,continuation:{tokenize:qG},exit:JG}},text:{91:{name:`gfmFootnoteCall`,tokenize:GG},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:UG,resolveTo:WG}}}}function UG(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=cB(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 WG(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 GG(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||mB(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(cB(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return mB(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 KG(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||mB(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=cB(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return mB(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),bB(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function qG(e,t,n){return e.check(EB,t,e.attempt(VG,t,n))}function JG(e){e.exit(`gfmFootnoteDefinition`)}function YG(e,t,n){let r=this;return bB(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 XG(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&&rB(o,o.length,0,CB(s,e.slice(r+1,n),t)),rB(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),rB(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=SB(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=SB(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var ZG=class{constructor(){this.map=[]}add(e,t,n){QG(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 QG(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 $G(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 eK(){return{flow:{null:{name:`table`,tokenize:tK,resolveAll:nK}}}}function tK(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):pB(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):hB(t)?bB(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||mB(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,hB(t)?bB(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 hB(t)?bB(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||pB(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 hB(t)?bB(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||pB(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||pB(n)?(e.exit(`tableRow`),t(n)):hB(n)?bB(e,te,`whitespace`)(n):(e.enter(`data`),S(n))}function S(t){return t===null||t===124||mB(t)?(e.exit(`data`),te(t)):(e.consume(t),t===92?ne:S)}function ne(t){return t===92||t===124?(e.consume(t),S):S(t)}}function nK(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 ZG;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(iK(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=rK(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=rK(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=rK(f,t,o,i,n,d)):(o[0]=o[1],d=rK(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&iK(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=$G(t.events,n))}return e}function rK(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},aK(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=aK(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=aK(t.events,n[2]),a=aK(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({},aK(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function iK(e,t,n,r,i){let a=[],o=aK(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 aK(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var oK={name:`tasklistCheck`,tokenize:cK};function sK(){return{text:{91:oK}}}function cK(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 mB(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 pB(r)?t(r):hB(r)?e.check({tokenize:lK},t,n)(r):n(r)}}function lK(e,t,n){return bB(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function uK(e){return oB([EG(),HG(),XG(e),eK(),sK()])}var dK={};function fK(e){let t=this,n=e||dK,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(uK(n)),a.push(hG()),o.push(gG(n))}function pK(e){hU(e,[/\r?\n|\r/g,mK])}function mK(){return{type:`break`}}function hK(){return function(e){pK(e)}}function gK(e){return e.replace(/<think>([\s\S]*?)(?:<\/think>|$)/gi,(e,t)=>`\n> 💭 **思考过程**\n>\n${String(t||``).trim().split(`
|
|
166
|
-
`).filter(Boolean).map(e=>`> ${e}`).join(`
|
|
167
|
-
`)}\n\n`)}function _K(e){return/^\s*\|(?:\s*[:\-]+\s*\|){2,}\s*$/.test(e)}function vK(e){let t=e.trim();return t.startsWith(`|`)?t.split(`|`).length>=4:!1}function yK(e){let t=e.trim();return t.startsWith(`|`)?t.replace(/^\|/,``).replace(/\|\s*$/,``).split(`|`).map(e=>e.trim()):[]}function bK(e,t=``){return`${t}| ${e.join(` | `)} |`}function xK(e){let t=e.split(`
|
|
168
|
-
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(vK(e)&&r+1<t.length&&_K(t[r+1])){let i=e.match(/^(\s*)/)?.[1]||``,a=yK(e),o=yK(t[r+1]),s=[],c=r+2,l=Math.max(a.length,o.length);for(;c<t.length&&vK(t[c]);){let e=yK(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(bK(u(a),i)),n.push(bK((e=>{let t=[...e];for(;t.length<l;)t.push(`---`);return t})(o),i));for(let e of s)n.push(bK(u(e),i));r=c}else n.push(e),r+=1}return n.join(`
|
|
169
|
-
`)}function SK(e){return _K(e)||/\|\|/.test(e)||/\|(?:\s*[:\-]+\s*\|){2,}/.test(e)&&/\|(?:[^|\n]*\|){2,}/.test(e)}function CK(e){return SK(e)?e.replace(/\|\s*\|/g,`|
|
|
170
|
-
|`).split(`
|
|
171
|
-
`).map(e=>e.trimEnd()).filter(e=>e.trim().length>0):[e]}function wK(e){return vK(e)?e.replace(/\|\s*(?:\*{1,2}|_{1,2})\s*$/u,`|`):e}function TK(e){let t=e.trim();return vK(t)?t.split(`|`).slice(1,-1).length:0}function EK(e){let t=e.match(/^(\s*)/)?.[1]||``,n=TK(e);return n<2?``:`${t}| ${Array.from({length:n},()=>`---`).join(` | `)} |`}function DK(e){let t=[];for(let n of e.split(`
|
|
172
|
-
`)){if(/^\s*\|\s*$/.test(n))continue;let e=n.match(/^(\s*)\|\s*([^|]+)$/);if(e){t.push(`${e[1]}${e[2].trim()}`);continue}t.push(...CK(n).map(wK))}let n=[];for(let e=0;e<t.length;e+=1){let r=t[e];r.trim().length===0&&vK(n[n.length-1]||``)&&_K(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),vK(t)&&vK(i)&&!_K(i)&&TK(t)===TK(i)){let i=vK(n[e-1]||``),a=t.match(/^(\s*)/)?.[1]||``;if(!i&&a.length===0){let e=EK(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=vK(t)&&(a.trim().length===0||!vK(a)),s=vK(t)&&(n.trim().length===0||!vK(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(`
|
|
173
|
-
`)}function OK(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 kK(e){let t=e;return t=t.split(`
|
|
174
|
-
`).map(e=>OK(e)).join(`
|
|
175
|
-
`),t=t.replace(/^[ \t]+(#{1,6}\s*)/gm,`$1`),t=t.replace(/([^\n#])\s*(#{1,6}\s*[^\s|])/g,`$1
|
|
176
|
-
|
|
177
|
-
$2`),t=t.replace(/^(#{1,6}\s*[^\n]+)\n(?!\n)/gm,`$1
|
|
178
|
-
|
|
179
|
-
`),t=t.replace(/^(#{1,6}[^\n|]+?)\s*(\|)/gm,`$1
|
|
180
|
-
$2`),t=t.replace(/([。;;::])\s*(\d+\.\s*)/g,`$1
|
|
181
|
-
$2`),t=t.replace(/([^\n\s])(\d+\.\s+)/g,`$1
|
|
182
|
-
$2`),t=t.replace(/([。;;::\.])\s*-(?!-)\s*/g,`$1
|
|
183
|
-
- `),t=t.replace(/([^\n\s-])-\s+/g,`$1
|
|
184
|
-
- `),t=t.replace(/^-(?!-)(\S)/gm,`- $1`),t=DK(t),t=t.replace(/\n{3,}/g,`
|
|
185
|
-
|
|
186
|
-
`),t.trim()}function AK(e){return e.map((t,n)=>{if(n%2==1)return t;let r=kK(t),i=n>0,a=n<e.length-1;return r?(i&&!r.startsWith(`
|
|
187
|
-
`)&&(r=`\n${r}`),a&&!r.endsWith(`
|
|
188
|
-
`)&&(r=`${r}\n`),r):i&&a?`
|
|
189
|
-
|
|
190
|
-
`:i||a?`
|
|
191
|
-
`:r})}function jK(e){if(!e)return e;let t=String(e).replace(/\r\n/g,`
|
|
192
|
-
`).replace(/\r/g,`
|
|
193
|
-
`).trim();return t=gK(t),t=xK(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),AK(t.split("```")).join("```").trim()}var MK=`modulepreload`,NK=function(e,t){return new URL(e,t).href},PK={},J=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=NK(t,n),t in PK)return;PK[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`:MK,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)})},FK=b.lazy(()=>J(()=>import(`./CodeBlock-DOH6MVcn.js`).then(e=>({default:e.CodeBlock})),[],import.meta.url)),IK=b.lazy(()=>J(()=>import(`./MermaidBlock-Dz4IP-Tx.js`).then(e=>({default:e.MermaidBlock})),[],import.meta.url)),LK=b.lazy(()=>J(()=>import(`./MathMessageMarkdown-BL8my1R2.js`).then(e=>({default:e.MathMessageMarkdown})),__vite__mapDeps([0,1,2,3,4]),import.meta.url));function RK(e){return/\$[^$]+\$|\$\$[^$]+\$\$/.test(e)}var zK={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(`
|
|
194
|
-
`))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)(IK,{chart:i})}):(0,U.jsx)(b.Suspense,{fallback:(0,U.jsx)(`pre`,{className:`p-4 text-sm`,children:i}),children:(0,U.jsx)(FK,{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})}},BK=b.memo(({content:e})=>{let t=jK(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)(cU,{remarkPlugins:[fK,hK],components:zK,children:t})})}),VK=b.memo(({content:e})=>RK(e)?(0,U.jsx)(b.Suspense,{fallback:(0,U.jsx)(BK,{content:e}),children:(0,U.jsx)(LK,{content:e})}):(0,U.jsx)(BK,{content:e})),HK=/^diff --git "?a\/(.+?)"? "?b\/(.+?)"?$/;function UK(e){let t=[],n=new Map,r=null;for(let i of e.split(`
|
|
195
|
-
`)){let e=i.match(HK);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 WK(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 GK(e){return/^diff --git /m.test(e)}function KK(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function qK(e){let t=KK(e.properties)||{},n=Array.isArray(e.required)?new Set(e.required.map(String)):new Set,r=[];for(let[e,i]of Object.entries(t)){let t=KK(i),a=String(t?.type||``).toLowerCase(),o=a===`string`||a===`number`||a===`boolean`?a:`unknown`;r.push({name:e,title:typeof t?.title==`string`?t.title:void 0,type:o,required:n.has(e),enumValues:Array.isArray(t?.enum)?t.enum:void 0})}return r}function JK({schema:e,values:t,onChange:n,disabled:r,onSubmit:i,onCancel:a}){return(0,U.jsxs)(`div`,{className:`mt-3`,"data-testid":`interaction-schema-form`,children:[qK(e).map(e=>(0,U.jsxs)(`label`,{className:`mb-2 block text-xs text-slate-600 dark:text-slate-300`,children:[(0,U.jsxs)(`span`,{className:`mb-1 block font-medium`,children:[e.title||e.name,e.required?(0,U.jsx)(`span`,{className:`ml-0.5 text-rose-500`,children:`*`}):null]}),e.enumValues&&e.enumValues.length>0?(0,U.jsxs)(`select`,{"data-testid":`interaction-field-${e.name}`,disabled:r,value:String(t[e.name]??``),onChange:r=>n({...t,[e.name]:r.target.value}),className:`w-full rounded-md border border-amber-300/70 bg-white px-2 py-1.5 text-sm dark:border-amber-900/60 dark:bg-slate-950`,children:[(0,U.jsx)(`option`,{value:``,children:`请选择…`}),e.enumValues.map(e=>(0,U.jsx)(`option`,{value:String(e),children:String(e)},String(e)))]}):e.type===`boolean`?(0,U.jsx)(`input`,{type:`checkbox`,"data-testid":`interaction-field-${e.name}`,disabled:r,checked:!!t[e.name],onChange:r=>n({...t,[e.name]:r.target.checked}),className:`h-4 w-4`}):e.type===`number`?(0,U.jsx)(`input`,{type:`number`,"data-testid":`interaction-field-${e.name}`,disabled:r,value:t[e.name]===void 0?``:String(t[e.name]),onChange:r=>n({...t,[e.name]:r.target.value===``?void 0:Number(r.target.value)}),className:`w-full rounded-md border border-amber-300/70 bg-white px-2 py-1.5 text-sm dark:border-amber-900/60 dark:bg-slate-950`}):(0,U.jsx)(`input`,{type:`text`,"data-testid":`interaction-field-${e.name}`,disabled:r,value:String(t[e.name]??``),onChange:r=>n({...t,[e.name]:r.target.value}),className:`w-full rounded-md border border-amber-300/70 bg-white px-2 py-1.5 text-sm dark:border-amber-900/60 dark:bg-slate-950`})]},e.name)),(0,U.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,"data-testid":`interaction-submit`,disabled:r,onClick:i,className:`inline-flex min-h-8 items-center rounded-md bg-emerald-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-55`,children:`提交`}),(0,U.jsx)(`button`,{type:`button`,"data-testid":`interaction-form-cancel`,disabled:r,onClick:a,className:`inline-flex min-h-8 items-center rounded-md px-3 py-1.5 text-xs font-medium text-slate-500 underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:opacity-55 dark:text-slate-400`,children:`取消本次确认`})]})]})}function YK({surfaceId:e,messages:t}){let{processMessages:n}=pk();return(0,b.useEffect)(()=>{n(t)},[t,n]),(0,U.jsx)(ate,{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 XK({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)(ete,{catalog:xk,onAction:n,children:(0,U.jsx)(YK,{surfaceId:e,messages:t})})})}function ZK({a2ui:e,disabled:t,onSubmit:n,onCancel:r}){return(0,U.jsxs)(`div`,{className:`mt-3`,"data-testid":`interaction-a2ui-surface`,children:[(0,U.jsx)(XK,{surfaceId:`interaction-${e.wireVersion}`,messages:e.messages,onAction:t?void 0:e=>{let t=e.userAction?.context||{};n(typeof t.payload==`object`&&t.payload!==null?t.payload:{...t})}}),t?null:(0,U.jsx)(`button`,{type:`button`,"data-testid":`interaction-a2ui-cancel`,onClick:r,className:`mt-1 inline-flex min-h-8 items-center rounded-md px-3 py-1.5 text-xs font-medium text-slate-500 underline-offset-2 hover:underline dark:text-slate-400`,children:`取消本次确认`})]})}function QK(e){for(let t of e?.messages||[]){let e=t.inputSchema??t.input_schema??t.schema;if(typeof e==`object`&&e)return e}return null}function $K(e){if(!e.expiresAt)return!1;let t=Date.parse(e.expiresAt);return Number.isFinite(t)&&t<=Date.now()}function eq(e){let t=e.extensions.submit_error;return typeof t==`object`&&t&&`code`in t&&`message`in t?{code:String(t.code),message:String(t.message),retryable:!!t.retryable}:null}var tq={approved:`已同意`,rejected:`已拒绝`,submitted:`已提交`,cancelled:`已取消`,expired:`已过期`};function nq({interactions:e,activeIndex:t,onSelectIndex:n,onRespond:r,localCatalog:i}){let[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)({}),l=e[Math.min(t,Math.max(e.length-1,0))];if(!l)return null;let u=$K(l),d=eq(l),f=u||l.status===`resolving`,p=mA(l.presentation?.a2ui,i),m=l.requestSchema??QK(l.presentation?.a2ui)??null,h=p===`a2ui`?`a2ui`:p===`json-schema-form`&&m||l.requestSchema&&!l.presentation?`json-schema-form`:`basic-controls`,g=h===`json-schema-form`&&m||l.requestSchema,_=(e,t)=>{f||r({interactionId:l.interactionId,expectedRevision:l.revision,action:e,response:t,idempotencyKey:Jk(l.interactionId,l.revision)})};return(0,U.jsx)(`div`,{"data-testid":`interaction-tray`,"data-interaction-status":l.status,"data-interaction-count":e.length,className:`mx-auto mb-2 w-full max-w-3xl px-6`,children:(0,U.jsxs)(`div`,{className:`rounded-xl border border-amber-300/80 bg-amber-50/80 p-3 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-amber-900 dark:text-amber-200`,children:[(0,U.jsx)(`span`,{"data-testid":`interaction-tray-title`,children:l.title}),e.length>1?(0,U.jsxs)(`span`,{"data-testid":`interaction-tray-count`,className:`rounded-full border border-amber-400/60 px-1.5 py-0.5 text-xs`,children:[t+1,`/`,e.length]}):null]}),e.length>1?(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(`button`,{type:`button`,"data-testid":`interaction-tray-prev`,disabled:t<=0,onClick:()=>n(Math.max(t-1,0)),className:`rounded border border-amber-400/60 p-1 text-amber-900 disabled:opacity-40 dark:text-amber-200`,"aria-label":`上一条待确认`,children:(0,U.jsx)(MM,{className:`h-3.5 w-3.5`})}),(0,U.jsx)(`button`,{type:`button`,"data-testid":`interaction-tray-next`,disabled:t>=e.length-1,onClick:()=>n(Math.min(t+1,e.length-1)),className:`rounded border border-amber-400/60 p-1 text-amber-900 disabled:opacity-40 dark:text-amber-200`,"aria-label":`下一条待确认`,children:(0,U.jsx)(NM,{className:`h-3.5 w-3.5`})})]}):null]}),(0,U.jsx)(`p`,{className:`mt-2 text-sm text-slate-700 dark:text-slate-200`,"data-testid":`interaction-tray-message`,children:l.message}),u?(0,U.jsxs)(`p`,{className:`mt-2 text-xs font-medium text-rose-600 dark:text-rose-400`,"data-testid":`interaction-tray-expired`,children:[`该确认已过期(`,tq.expired,`),等待运行时继续处理。`]}):null,d?(0,U.jsxs)(`p`,{className:`mt-2 text-xs font-medium text-rose-600 dark:text-rose-400`,"data-testid":`interaction-tray-error`,children:[`提交失败(`,d.code,`):`,d.message,d.retryable?`,可重试。`:``]}):null,h===`a2ui`&&l.presentation?.a2ui?(0,U.jsx)(ZK,{a2ui:l.presentation.a2ui,disabled:f,onSubmit:e=>_(`submit`,e),onCancel:()=>_(`cancel`,{})}):h===`json-schema-form`&&g?(0,U.jsx)(JK,{schema:g,values:s,onChange:c,disabled:f,onSubmit:()=>_(`submit`,s),onCancel:()=>_(`cancel`,{})}):(0,U.jsxs)(`div`,{className:`mt-3`,"data-testid":`interaction-tray-basic`,children:[(0,U.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`备注(可选)`,disabled:f,"data-testid":`interaction-tray-comment`,className:`mb-2 w-full rounded-md border border-amber-300/70 bg-white px-2 py-1.5 text-sm dark:border-amber-900/60 dark:bg-slate-950`}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,"data-testid":`interaction-approve`,disabled:f,onClick:()=>_(`approve`,{decision:`approve`,...a?{comment:a}:{}}),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)(AM,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,U.jsxs)(`button`,{type:`button`,"data-testid":`interaction-reject`,disabled:f,onClick:()=>_(`reject`,{decision:`reject`,...a?{comment:a}:{}}),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)(FM,{className:`h-3.5 w-3.5`}),`拒绝`]}),(0,U.jsx)(`button`,{type:`button`,"data-testid":`interaction-cancel`,disabled:f,onClick:()=>_(`cancel`,{}),className:`inline-flex min-h-8 items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium text-slate-500 underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:opacity-55 dark:text-slate-400`,children:`取消本次确认`})]})]}),l.status===`resolving`?(0,U.jsx)(`p`,{className:`mt-2 text-xs text-amber-700 dark:text-amber-300`,children:`正在提交,请稍候…`}):null]})})}function rq({outcome:e}){return(0,U.jsx)(`span`,{className:K(`rounded border px-1.5 py-0.5 text-xs font-medium`,e===`approved`?`border-emerald-300 text-emerald-700 dark:border-emerald-900 dark:text-emerald-300`:e===`rejected`?`border-rose-300 text-rose-700 dark:border-rose-900 dark:text-rose-300`:`border-slate-300 text-slate-600 dark:border-slate-700 dark:text-slate-300`),children:tq[e]||e})}function iq(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function aq(e){let t=e?.properties;return typeof t!=`object`||!t?[]:Object.keys(t)}function oq({interaction:e}){let t=e.status===`resolved`||e.status===`cancelled`||e.status===`expired`,n=aq(e.requestSchema);return(0,U.jsxs)(`div`,{"data-testid":`interaction-history-anchor`,"data-interaction-id":e.interactionId,"data-interaction-status":e.status,className:`mt-2 rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-xs text-slate-600 dark:border-slate-800 dark:bg-slate-900/60 dark:text-slate-300`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`font-medium text-slate-700 dark:text-slate-200`,children:e.title}),(0,U.jsx)(rq,{outcome:e.outcome||e.status})]}),t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`mt-1 leading-relaxed`,children:[e.actor?(0,U.jsxs)(`span`,{children:[`操作人:`,e.actor,` · `]}):null,e.resolvedAt?(0,U.jsxs)(`span`,{children:[`决定时间:`,iq(e.resolvedAt),` · `]}):null,(0,U.jsx)(`span`,{"data-testid":`interaction-history-response-summary`,children:e.responseSummary||`响应内容已脱敏`})]}),(0,U.jsxs)(`details`,{"data-testid":`interaction-history-detail`,className:`mt-1`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer select-none text-slate-500 hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-200`,children:`查看确认快照`}),(0,U.jsxs)(`div`,{"data-testid":`interaction-history-snapshot`,className:`mt-1 rounded border border-slate-200 bg-white px-2 py-1.5 leading-relaxed dark:border-slate-800 dark:bg-slate-950`,children:[(0,U.jsxs)(`div`,{children:[`操作者:`,(0,U.jsx)(`span`,{"data-testid":`interaction-history-actor-ref`,children:e.actor||`—`})]}),(0,U.jsxs)(`div`,{children:[`决定时间:`,iq(e.resolvedAt)||`—`]}),(0,U.jsxs)(`div`,{children:[`关键参数:`,n.length>0?(0,U.jsx)(`span`,{"data-testid":`interaction-history-schema-keys`,children:n.join(`、`)}):(0,U.jsx)(`span`,{children:`无结构化参数`})]})]})]})]}):(0,U.jsxs)(`div`,{className:`mt-1`,children:[`状态:`,e.status===`pending`?`待处理(见输入区确认面板)`:`处理中…`]})]})}function sq({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)(XM,{className:`h-3.5 w-3.5 animate-spin text-slate-400`}):(0,U.jsx)(jM,{className:K(`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 cq({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)(mN,{className:K(`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)(jM,{className:K(`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)(VK,{content:e.content})})]})}function lq({block:e,tool:t,isStreaming:n,interactionRecord:r,onRespondToApproval:i,onRespondToAguiApproval:a}){let o=t?.status??e.status,s=t?.args??e.args,c=t?.output??e.output,l=e.extra||{},u=l.approvalStatus||t?.approvalStatus,d=l.approvalRequestId||t?.approvalRequestId,f=l.approvalMessage||t?.approvalMessage,p=l.approvalProtocol||t?.approvalProtocol,m=l.previousResponseId||t?.previousResponseId,h=o===`running`,g=o===`error`,_=o===`paused`,v=g?`执行失败`:u===`pending`?`等待确认`:u===`rejected`?`已拒绝`:h?u===`approved`?`已授权 · 执行中`:`正在运行`:u===`approved`?`已授权`:_?`已暂停`:`已完成`,y=g?`text-rose-500 dark:text-rose-400`:_?`text-amber-500 dark:text-amber-400`:h?`text-slate-500 dark:text-slate-400`:`text-slate-400 dark:text-slate-500`;return(0,U.jsx)(sq,{streaming:h&&!s,defaultOpen:u===`pending`||_,summary:(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(CN,{className:K(`h-3.5 w-3.5 shrink-0`,y)}),(0,U.jsx)(`span`,{className:y,children:v}),(0,U.jsx)(`span`,{className:`truncate font-medium text-slate-600 dark:text-slate-300`,children:e.toolName}),h&&s&&(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:[d&&u===`pending`&&!r&&(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:f||`允许后将执行此工具调用。`})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>p===`ag-ui`?a?.({interruptId:d||``,approve:!0}):i?.({approvalRequestId:d||``,approve:!0,previousResponseId:m}),className:`inline-flex h-7 items-center rounded-md bg-primary px-2.5 text-[12px] font-medium text-primary-foreground transition hover:bg-primary/90 disabled:opacity-55`,children:`允许执行`}),(0,U.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>p===`ag-ui`?a?.({interruptId:d||``,approve:!1}):i?.({approvalRequestId:d||``,approve:!1,previousResponseId:m}),className:`inline-flex h-7 items-center rounded-md px-2 text-[12px] font-medium text-slate-500 transition hover:bg-slate-100 hover:text-rose-600 disabled:opacity-55 dark:text-slate-400 dark:hover:bg-slate-800`,children:`拒绝`})]})]}),d&&u===`pending`&&r?(0,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`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400`,"aria-hidden":`true`}),`请在输入区确认面板中操作。`]}):null,d&&u&&u!==`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:u===`approved`?`已授权`:`已拒绝`}),u===`approved`&&h?(0,U.jsx)(`span`,{children:`· 工具执行中`}):null,u===`approved`&&g?(0,U.jsx)(`span`,{children:`· 工具执行失败`}):null]}),s?(0,U.jsx)(mq,{label:`入参`,value:s,tone:`input`}):null,c?uq(e.toolName,c,g):null]})})}function uq(e,t,n){if(GK(t))return(0,U.jsx)(dq,{output:t});let r=e.toLowerCase();if(r.includes(`web_search`)||r.includes(`search`)){let e=fq(t);if(e.length>0)return(0,U.jsx)(pq,{sources:e})}return(0,U.jsx)(mq,{label:`输出`,value:t,tone:n?`error`:`output`})}function dq({output:e}){let t=UK(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)(WM,{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}=WK(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 fq(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 pq({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)(zM,{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)(zM,{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 mq({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:K(`custom-scrollbar max-h-60 overflow-auto rounded-lg px-3 py-2 text-[12.5px] leading-relaxed whitespace-pre-wrap break-all`,t===`error`?`bg-rose-50/60 text-rose-700 dark:bg-rose-950/20 dark:text-rose-200`:t===`output`?`bg-emerald-50/40 text-emerald-800 dark:bg-emerald-950/20 dark:text-emerald-200`:`bg-slate-50 text-slate-700 dark:bg-slate-900/40 dark:text-slate-200`),children:n})]})}function hq({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)(VK,{content:e.content})}):null}function gq({message:e,isStreaming:t,onRespondToApproval:n,onRespondToAguiApproval:r,interactionRecords:i}){return(0,U.jsx)(`div`,{className:`mb-3 min-w-0`,children:(e.blocks??[]).map(a=>{if(a.type===`thinking`)return(0,U.jsx)(cq,{block:a},a.id);if(a.type===`tool`){let o=a.extra||{},s=String(o.approvalRequestId||e.tools?.[a.toolName]?.approvalRequestId||``),c=s?i?.find(e=>e.interactionId===s):void 0;return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(lq,{block:a,tool:e.tools?.[a.toolName],isStreaming:t,interactionRecord:c,onRespondToApproval:n,onRespondToAguiApproval:r}),c?(0,U.jsx)(oq,{interaction:c}):null]},a.id)}return(0,U.jsx)(hq,{block:a},a.id)})})}function _q({onRetry:e}){let t=D(e=>e.banner);if(!t)return null;let n=t.kind===`rate_limited`?(0,U.jsx)(vq,{message:t.message,retryAfterSec:t.retryAfterSec},t.createdAt||`${t.sessionId||``}:${t.retryAfterSec||0}`):null,r={rate_limited:{icon:(0,U.jsx)(TN,{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)(XM,{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)(SN,{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:K(`mx-auto mb-3 flex w-full max-w-3xl items-center gap-2.5 rounded-xl border px-3.5 py-2.5 text-sm shadow-sm`,r.bg,r.text),role:`status`,children:[r.icon,(0,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)(lN,{className:`h-3 w-3`}),`重试`]}):null]})}function vq({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 yq(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 bq(e,t,n){return Math.max(t,Math.min(n,e))}function xq({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=bq(g-l,0,e.length),_=bq(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}})}}var Sq=140,Cq=4;function wq(e){let t=String(e||``).trim().toLowerCase();return t===`elevated`?`高风险`:t===`always`?`始终确认`:t===`confirm`?`需确认`:e||``}function Tq(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 Eq({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 Dq(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 Oq(e){return e<1e3?`刚刚`:e<6e4?`${Math.floor(e/1e3)} 秒前`:`${Math.floor(e/6e4)} 分钟前`}function kq(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 Aq({contextIndicator:e}){let t=e?.usedTokens,n=e?.contextWindowTokens,r=kq(t),i=kq(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 jq({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)(PM,{className:`h-3 w-3 text-rose-500`}):e.status===`completed`?(0,U.jsx)(AM,{className:`h-3 w-3 text-emerald-500`}):e.status===`stopped`?(0,U.jsx)(pN,{className:`h-3 w-3 text-amber-500`}):(0,U.jsx)(cN,{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`?`恢复`:`运行`,` `,Dq(i-e.startedAt)]}),o?(0,U.jsx)(`span`,{className:K(`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:Oq(i-e.lastEventAt)}),(0,U.jsx)(Aq,{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)(PM,{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)(FM,{className:`h-3 w-3`}),`取消`]}):null]}):null]})}function Mq({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
|
|
196
|
-
flex items-center justify-center shadow-lg shadow-blue-500/20`,children:(0,U.jsx)(kM,{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 Nq(){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 Pq({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:K(`group relative overflow-hidden rounded-xl border border-slate-200 shadow-sm dark:border-slate-700`,t?`w-full max-w-full`:`max-w-[200px]`),children:(0,U.jsx)(`img`,{src:e.url,alt:e.name,className:K(`object-cover transition group-hover:scale-[1.02]`,t?`max-h-[16rem] w-full max-w-full`:`max-h-[200px] max-w-[200px]`)})},`${e.name}-${r}`):(0,U.jsx)(`div`,{className:K(`flex items-center justify-center rounded-xl border border-dashed border-slate-300 bg-slate-50 px-4 text-sm text-slate-500 dark:border-slate-700 dark:bg-slate-900/40 dark:text-slate-400`,t?`h-28 w-full`:`h-[120px] w-[200px]`),children:e.name},`${e.name}-${r}`):(0,U.jsxs)(`div`,{className:K(`flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-2 shadow-sm dark:border-slate-700 dark:bg-slate-800`,t?`w-full max-w-full`:`w-max max-w-full`),children:[(0,U.jsx)(iN,{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 Fq({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)(cN,{className:`h-4 w-4 animate-spin text-amber-600 dark:text-amber-300`}):e.status===`failed`?(0,U.jsx)(PM,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,U.jsx)(AM,{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)(VK,{content:e.summary})})]}):null]})})}function Iq({label:e,tone:t,value:n}){let[r,i]=(0,b.useState)(`idle`),a=GA(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 yq(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:K(`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)(AM,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,U.jsx)(LM,{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 Lq({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=Lj(n,t,e),u=!!n.feedback?.pending,d=n.feedback?.rating,f=async()=>{let e=n.content||``;e&&yq(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)(LM,{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:K(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,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)(yN,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,U.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{c(n.feedback?.comment||``),o(e=>!e)},className:K(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,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)(vN,{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)(bN,{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 Rq({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,message:i,onDeleteFeedback:a,onOpenAttachmentPreview:o,onRespondToApproval:s,onRespondToAguiApproval:c,onSubmitFeedback:l,onSubmitAguiAction:u,interactionRecords:d}){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)(Pq,{attachments:i.attachments,isMobile:t,onOpenAttachmentPreview:o}):null,i.content]})}):i.role===`a2ui`&&i.aguiActivity?(0,U.jsx)(XK,{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)(kM,{className:`w-3.5 h-3.5`}),(0,U.jsx)(`span`,{children:e})]}),i.attachments?.length?(0,U.jsx)(Pq,{attachments:i.attachments,isMobile:t,onOpenAttachmentPreview:o}):null,i.blocks?.length?(0,U.jsx)(gq,{message:i,isStreaming:n,onRespondToApproval:s,interactionRecords:d,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)(cN,{className:`h-4 w-4 animate-spin text-slate-500`}):(0,U.jsx)(AM,{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)(jM,{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)(VK,{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:K(`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)(cN,{className:`h-4 w-4 animate-spin text-slate-500`}):e.status===`paused`?(0,U.jsx)(pN,{className:`h-4 w-4 text-amber-500`}):e.status===`error`?(0,U.jsx)(FM,{className:`h-4 w-4 text-rose-500`}):(0,U.jsx)(AM,{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:K(`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:K(`mt-2 inline-flex items-center rounded border px-1.5 py-0.5 text-xs font-medium`,Tq(e.approvalLevel)),children:[`审批级别:`,wq(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)(AM,{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)(FM,{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)(AM,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,U.jsx)(FM,{className:`h-3.5 w-3.5 text-rose-500`}),e.approvalStatus===`approved`?`已批准`:`已拒绝`]})]}):null,e.args?(0,U.jsx)(Iq,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,U.jsx)(Iq,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,i.tools?Object.values(i.tools).filter(e=>d?.some(t=>t.interactionId===e.approvalRequestId)).map(e=>(0,U.jsx)(oq,{interaction:d.find(t=>t.interactionId===e.approvalRequestId)},`anchor-${e.approvalRequestId}`)):null,(0,U.jsx)(`div`,{className:`w-full break-words`,children:i.content?(0,U.jsx)(VK,{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)(XK,{surfaceId:e.surfaceId,messages:e.messages,onAction:u},e.surfaceId)),(0,U.jsx)(Lq,{isLastMessage:r,isStreaming:n,message:i,onDeleteFeedback:a,onSubmitFeedback:l})]})}function zq({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,interactionRecords:_,scrollRef:v}){let[y,x]=(0,b.useState)(0),[ee,te]=(0,b.useState)(0),[S,ne]=(0,b.useState)(new Map),re=(0,b.useRef)(S);(0,b.useLayoutEffect)(()=>{let e=v.current;if(!e)return;let t=()=>{x(e.scrollTop),te(e.clientHeight)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>t());return n.observe(e),()=>n.disconnect()},[v]);let C=(0,b.useMemo)(()=>xq({items:a,scrollTop:y,viewportHeight:ee,overscan:Cq,defaultItemHeight:Sq,measuredHeights:S,getItemKey:(e,t)=>e?.id||String(t)}),[S,a,y,ee]),w=C.visibleItems,ie=(0,b.useCallback)((e,t,n)=>{if(!e||!Number.isFinite(t)||t<=0)return;let r=re.current,i=r.get(e)??Sq;if(i===t)return;let a=new Map(r);a.set(e,t),re.current=a,ne(a);let o=v.current;o&&n<o.scrollTop&&(o.scrollTop+=t-i,x(o.scrollTop))},[v]);return(0,U.jsxs)(`div`,{ref:v,onScroll:e=>x(e.currentTarget.scrollTop),className:K(`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:K(`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)(Nq,{}):a.length===0?(0,U.jsx)(Mq,{agentName:e}):(0,U.jsx)(`div`,{style:{height:C.totalHeight},className:`relative`,children:w.map(r=>(0,U.jsx)(Eq,{messageId:r.item.id||String(r.index),top:r.top,onMeasure:ie,children:r.item.role===`system`?(0,U.jsx)(Fq,{message:r.item}):(0,U.jsx)(Rq,{agentName:e,isMobile:t,isStreaming:n,isLastMessage:r.index===a.length-1,message:r.item,onDeleteFeedback:s,onOpenAttachmentPreview:c,onRespondToApproval:l,interactionRecords:_,onRespondToAguiApproval:u,onSubmitFeedback:d,onSubmitAguiAction:f})},r.item.id||r.index))})}),(0,U.jsx)(_q,{}),y>320?(0,U.jsx)(`button`,{type:`button`,onClick:()=>{let e=v.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)(DM,{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)(jq,{activity:r,contextIndicator:i,onStopGeneration:p,onCancelRemote:m})}):null]})}var Bq=vR,Vq=yR,Hq=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(bR,{ref:n,className:K(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));Hq.displayName=bR.displayName;var Uq=b.forwardRef(({className:e,children:t,...n},r)=>(0,U.jsxs)(Vq,{children:[(0,U.jsx)(Hq,{}),(0,U.jsxs)(xR,{ref:r,className:K(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...n,children:[t,(0,U.jsxs)(wR,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground`,children:[(0,U.jsx)(wN,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));Uq.displayName=xR.displayName;var Wq=({className:e,...t})=>(0,U.jsx)(`div`,{className:K(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});Wq.displayName=`DialogHeader`;var Gq=({className:e,...t})=>(0,U.jsx)(`div`,{className:K(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Gq.displayName=`DialogFooter`;var Kq=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(SR,{ref:n,className:K(`text-lg font-semibold leading-none tracking-tight`,e),...t}));Kq.displayName=SR.displayName;var qq=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(CR,{ref:n,className:K(`text-sm text-muted-foreground`,e),...t}));qq.displayName=CR.displayName;function Jq(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function Yq(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function Xq({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,U.jsx)(Bq,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,U.jsxs)(Uq,{className:K(`gap-0 overflow-hidden border-slate-700 bg-slate-950 p-0 text-slate-100 shadow-2xl [&>button]:right-3 [&>button]:top-3 [&>button]:rounded-md [&>button]:border [&>button]:border-slate-700 [&>button]:bg-slate-900/70 [&>button]:p-1.5 [&>button]:text-slate-200 [&>button]:opacity-100`,t?`left-0 top-0 h-[var(--app-height)] max-h-[var(--app-height)] w-screen max-w-none translate-x-0 translate-y-0 rounded-none border-0`:`max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] rounded-2xl`),style:Yq(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)(Kq,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,U.jsx)(`div`,{className:K(`flex items-center justify-center overflow-auto bg-slate-950`,t?`h-full p-4 pb-[calc(var(--safe-area-bottom)+1rem)]`:`max-h-[calc(100vh-7rem)] p-4`),children:e?e.type.startsWith(`image/`)?(0,U.jsx)(`img`,{src:e.url,alt:e.name,className:K(`object-contain`,t?`h-auto max-h-full w-full max-w-full`:`h-auto w-auto max-h-[calc(100vh-9rem)] max-w-[calc(100vw-5rem)]`),style:Jq(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 Zq(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 Qq(e){return/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]/u.test(e)}function $q(e){let t=String(e||``).trim();if(!t)return 0;let n=0,r=0;for(let e of t){if(Qq(e)){n+=1;continue}r+=1}return Math.max(1,n+Math.ceil(r/4))}function eJ(e){if(!e)return 0;if(e.role===`system`)return e.eventType===`context_checkpoint`?$q(e.summary||``):0;let t=$q(e.content||``);return e.tools&&(t+=Object.values(e.tools).reduce((e,t)=>e+$q(t?.name||``)+$q(t?.args||``)+$q(t?.output||``),0)),t}function tJ(e){return e?Zq(e.context_window_tokens)??Zq(e?.limits?.context_window_tokens):null}function nJ(e){return e?Zq(e.auto_compact_threshold_percentage)??84:84}function rJ({messages:e,draftInput:t,selectedModel:n}){let r=tJ(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=eJ(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+eJ(t),0)+$q(t||``);if(a<=0)return null;let o=Math.min(100,Math.max(0,Math.round(a/r*100)));return o>=nJ(n)?{label:`估算上下文 ${o}% · 即将压缩`,phase:`warning`,percent:o,usedTokens:a,contextWindowTokens:r}:{label:`估算上下文 ${o}%`,phase:`normal`,percent:o,usedTokens:a,contextWindowTokens:r}}function iJ(e){return e.requestedSessionId===e.activeSessionId&&e.requestToken===e.activeRequestToken}function aJ({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,interactionRecords:f}){let p=an(e=>e.messages),m=Ze(e=>e.currentSessionId),h=Ze(e=>e.isLoadingSessions),g=D(e=>!!(e.getSessionActivity(m)&&e.isSessionStreaming(m))),_=D(e=>e.getSessionActivity(m)),v=PA(e=>e.getSessionCheckpoints(m)),y=Ze(e=>m?e.messageHistory[m]:null),x=h||!!y?.isLoadingInitial,ee=C(e=>e.input),te=Te(e=>e.availableModels),S=Te(e=>e.selectedModel),ne=C(e=>e.previewAttachment),re=C(e=>e.previewImageSize),w=(0,b.useRef)(null),ie=(0,b.useRef)(!0),ae=(0,b.useRef)(!1),oe=(0,b.useRef)(0),se=(0,b.useRef)(g),ce=(0,b.useRef)(!1),le=(0,b.useRef)(null),ue=(0,b.useRef)(!0),T=(0,b.useMemo)(()=>te.find(e=>e.id===S)||null,[te,S]),E=(0,b.useMemo)(()=>rJ({messages:p,draftInput:ee,selectedModel:T}),[ee,p,T]);return(0,b.useEffect)(()=>{se.current=g},[g]),(0,b.useEffect)(()=>{ue.current=!0,ie.current=!0,ae.current=!1,oe.current=0,ce.current=!1,le.current=null},[m]),(0,b.useEffect)(()=>{let e=w.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<oe.current-2;if(oe.current=e.scrollTop,e.scrollTop<200&&m&&y?.hasMore&&!y.isLoadingOlder&&!ce.current&&d){let t=e.scrollHeight,n=m,r=Symbol(n);ce.current=!0,le.current=r,d(n).then(()=>{iJ({requestedSessionId:n,activeSessionId:Ze.getState().currentSessionId,requestToken:r,activeRequestToken:le.current})&&requestAnimationFrame(()=>{if(!iJ({requestedSessionId:n,activeSessionId:Ze.getState().currentSessionId,requestToken:r,activeRequestToken:le.current}))return;let e=w.current;if(!e)return;let i=e.scrollHeight-t;e.scrollTop+=i,oe.current=e.scrollTop})}).finally(()=>{le.current===r&&(le.current=null,ce.current=!1)})}if(se.current&&n){ae.current=!0,ie.current=!1;return}if(ae.current){let e=t<=12;ae.current=!e,ie.current=e;return}ie.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[y,m,d]),(0,b.useEffect)(()=>{let e=w.current;if(e){if(p.length>0&&ue.current){let e=Ze.getState().currentSessionId,t=w.current,n=t?t.style.scrollBehavior:``;t&&(t.style.scrollBehavior=`auto`,t.scrollTop=t.scrollHeight,oe.current=t.scrollTop);let r=0,i=t?.scrollHeight??-1,a=!1,o=0,s=()=>{a||(a=!0,t&&(t.style.scrollBehavior=n),ie.current=!0,ae.current=!1,ue.current=!1)},c=()=>{if(a)return;if(Ze.getState().currentSessionId!==e){a=!0;return}let t=w.current;if(t){if(t.scrollHeight!==i)i=t.scrollHeight,t.scrollTop=t.scrollHeight,oe.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()}}ie.current&&(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop)}},[p,g]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(zq,{agentName:e,isMobile:t,isStreaming:g,activity:_,contextIndicator:E,messages:p,isLoadingInitialHistory:x,onDeleteFeedback:n,onOpenAttachmentPreview:e=>{C.getState().setPreviewAttachment(e),C.getState().setPreviewImageSize(null)},onRespondToApproval:i,onRespondToAguiApproval:a,interactionRecords:f,onSubmitFeedback:r,onSubmitAguiAction:o,onStopGeneration:s,onCancelRemote:c,checkpoints:l?v:[],onResumeCheckpoint:u,scrollRef:w}),(0,U.jsx)(Xq,{attachment:ne,isMobile:t,previewImageSize:re,onClose:()=>{C.getState().setPreviewAttachment(null),C.getState().setPreviewImageSize(null)},onImageLoad:e=>C.getState().setPreviewImageSize(e)})]})}function oJ({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:K(`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?`${sJ(e.usedTokens)} / ${sJ(e.contextWindowTokens)}`:e.label})]})]})}function sJ(e){return e>=1e6?`${(e/1e6).toFixed(1)}m`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e)}var cJ=[{value:`plan`,label:`计划模式`,description:`先分析并形成可执行计划`,icon:YM},{value:`goal`,label:`设定目标`,description:`朝可验证的停止条件持续推进`,icon:_N}],lJ={plan:`计划模式`,goal:`目标`};function uJ({attachmentsEnabled:e,mode:t,support:n,onSelectMode:r,onUpload:i}){let[a,o]=(0,b.useState)(!1),s=(0,b.useRef)(null),c=cJ.filter(e=>n[e.value]);return(0,b.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]),!e&&c.length===0?null:(0,U.jsxs)(`div`,{ref:s,className:`relative flex min-w-0 items-center gap-1`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-text-secondary transition hover:bg-muted hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,"aria-expanded":a,"aria-haspopup":`menu`,"aria-label":`添加附件或选择执行模式`,title:`添加附件或选择执行模式`,children:(0,U.jsx)(sN,{className:`h-[19px] w-[19px]`})}),t?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:K(`flex h-8 max-w-[8.5rem] items-center gap-1 rounded-xl px-2 text-[12px] transition`,t===`goal`?`bg-amber-50 text-amber-700 hover:bg-amber-100 dark:bg-amber-950/40 dark:text-amber-300`:`text-text-secondary hover:bg-muted hover:text-text-primary`),"aria-label":`当前执行模式:${lJ[t]}`,children:[(0,U.jsx)(`span`,{className:`truncate`,children:lJ[t]}),(0,U.jsx)(jM,{className:`h-3.5 w-3.5 shrink-0`})]}):null,a?(0,U.jsxs)(`div`,{role:`menu`,"aria-label":`附件与执行模式`,className:`absolute bottom-[calc(100%+0.65rem)] left-0 z-40 w-[min(19rem,calc(100vw-2rem))] rounded-2xl border border-border/80 bg-popover p-1.5 shadow-[0_18px_44px_rgba(15,23,42,0.16)]`,children:[e?(0,U.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{i(),o(!1)},className:`flex w-full items-center gap-2.5 rounded-xl px-2.5 py-2.5 text-left transition hover:bg-muted/70`,children:[(0,U.jsx)(xN,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`span`,{className:`block text-[13px] font-medium text-text-primary`,children:`上传附件`}),(0,U.jsx)(`span`,{className:`block text-[11px] text-text-muted`,children:`添加文件或图片到当前消息`})]})]}):null,e&&c.length>0?(0,U.jsx)(`div`,{className:`my-1 h-px bg-border/70`}):null,c.map(e=>{let n=e.icon,i=t===e.value;return(0,U.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":i,onClick:()=>{r(e.value),o(!1)},className:K(`flex w-full items-center gap-2.5 rounded-xl px-2.5 py-2.5 text-left transition`,i?`bg-muted`:`hover:bg-muted/70`),children:[(0,U.jsx)(n,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block text-[13px] font-medium text-text-primary`,children:e.label}),(0,U.jsx)(`span`,{className:`block text-[11px] text-text-muted`,children:e.description})]}),i?(0,U.jsx)(AM,{className:`h-4 w-4 shrink-0 text-text-primary`}):null]},e.value)})]}):null]})}var dJ=[{value:`auto`,label:`自动`,description:`使用模型或 Agent 的默认设置`},{value:`enabled`,label:`开启`,description:`请求模型输出推理过程`},{value:`disabled`,label:`关闭`,description:`不额外请求模型推理`}],fJ={auto:`自动`,enabled:`开启`,disabled:`关闭`};function pJ({availableModels:e,selectedModel:t,thinkingEnabled:n,thinkingMode:r,onSelectModel:i,onSelectThinkingMode:a}){let[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(`model`),u=(0,b.useRef)(null),d=e.find(e=>e.id===t)?.display_name||t||`选择模型`,f=n?c:`model`;return(0,b.useEffect)(()=>{if(!o)return;let e=e=>{u.current&&!u.current.contains(e.target)&&s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]),(0,U.jsxs)(`div`,{ref:u,className:`relative`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex h-8 max-w-[15rem] items-center gap-1.5 rounded-xl bg-muted/80 px-3 text-[13px] text-text-primary transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,"aria-expanded":o,"aria-haspopup":`menu`,"aria-label":n?`模型 ${d},推理 ${fJ[r]}`:`模型 ${d}`,title:n?`选择模型与推理设置`:`选择模型`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:d}),n?(0,U.jsx)(`span`,{className:`shrink-0 text-text-muted`,children:fJ[r]}):null,(0,U.jsx)(jM,{className:K(`h-3.5 w-3.5 shrink-0 text-text-muted transition-transform`,o&&`rotate-180`)})]}),o?(0,U.jsxs)(`div`,{className:`absolute bottom-[calc(100%+0.65rem)] right-0 z-40 flex items-end gap-2 sm:flex-row-reverse`,children:[(0,U.jsxs)(`div`,{role:`menu`,"aria-label":f===`model`?`选择模型`:`选择推理设置`,className:`max-h-[min(54vh,22rem)] w-[min(18rem,calc(100vw-2rem))] overflow-y-auto rounded-2xl border border-border/80 bg-popover p-1.5 shadow-[0_18px_44px_rgba(15,23,42,0.16)]`,children:[n?(0,U.jsxs)(`div`,{className:`mb-1 grid grid-cols-2 gap-1 sm:hidden`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>l(`model`),className:K(`rounded-lg px-2 py-1.5 text-xs`,f===`model`?`bg-muted text-text-primary`:`text-text-muted`),children:`模型`}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>l(`reasoning`),className:K(`rounded-lg px-2 py-1.5 text-xs`,f===`reasoning`?`bg-muted text-text-primary`:`text-text-muted`),children:`推理`})]}):null,(0,U.jsx)(`div`,{className:`px-2.5 pb-1.5 pt-1 text-[11px] font-medium text-text-muted`,children:f===`model`?`模型`:`推理设置`}),f===`model`?e.map(e=>{let n=e.id===t;return(0,U.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":n,onClick:()=>{i(e.id),s(!1)},className:K(`flex w-full items-center gap-2 rounded-xl px-2.5 py-2 text-left text-[13px] transition-colors`,n?`bg-muted text-text-primary`:`text-text-secondary hover:bg-muted/70 hover:text-text-primary`),children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.display_name||e.id}),n?(0,U.jsx)(AM,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}):null]},e.id)}):dJ.map(e=>{let t=e.value===r;return(0,U.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":t,onClick:()=>{a(e.value),s(!1)},className:K(`flex w-full items-center gap-2 rounded-xl px-2.5 py-2 text-left transition-colors`,t?`bg-muted`:`hover:bg-muted/70`),children:[(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block text-[13px] font-medium text-text-primary`,children:e.label}),(0,U.jsx)(`span`,{className:`block text-[11px] leading-4 text-text-muted`,children:e.description})]}),t?(0,U.jsx)(AM,{className:`h-4 w-4 shrink-0 text-text-primary`,"aria-hidden":`true`}):null]},e.value)})]}),(0,U.jsxs)(`div`,{className:`hidden w-[16rem] rounded-2xl border border-border/80 bg-popover p-1.5 shadow-[0_18px_44px_rgba(15,23,42,0.13)] sm:block`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>l(`model`),className:K(`flex w-full items-center gap-2 rounded-xl px-2.5 py-2.5 text-left text-[13px] transition-colors`,f===`model`?`bg-muted text-text-primary`:`text-text-secondary hover:bg-muted/70`),children:[(0,U.jsx)(`span`,{className:`font-medium`,children:`模型`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right text-text-muted`,children:d}),(0,U.jsx)(NM,{className:`h-4 w-4 shrink-0 text-text-muted`})]}),n?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>l(`reasoning`),className:K(`flex w-full items-center gap-2 rounded-xl px-2.5 py-2.5 text-left text-[13px] transition-colors`,f===`reasoning`?`bg-muted text-text-primary`:`text-text-secondary hover:bg-muted/70`),children:[(0,U.jsx)(`span`,{className:`font-medium`,children:`推理`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right text-text-muted`,children:fJ[r]}),(0,U.jsx)(NM,{className:`h-4 w-4 shrink-0 text-text-muted`})]}):null]})]}):null]})}var mJ=[{value:`ask`,label:`请求批准`,description:`有副作用的操作执行前先确认`,icon:qM},{value:`risk`,label:`风险操作需确认`,description:`只对命令、写入和外部副作用确认`,icon:pN},{value:`full`,label:`完全访问`,description:`本次会话不再为默认规则弹出确认`,icon:fN}],hJ={ask:`请求批准`,risk:`风险确认`,full:`完全访问`};function gJ({approvalPolicy:e}){let[t,n]=(0,b.useState)(!1),r=(0,b.useRef)(null),i=ke(e=>e.permissionMode),a=ke(e=>e.setPermissionMode),o=i===`ask`?qM:i===`full`?fN:pN,s=(0,b.useMemo)(()=>mJ.filter(t=>!e||e.Modes.includes(t.value)),[e]);return(0,b.useEffect)(()=>{s.some(e=>e.value===i)||a(e?.DefaultMode||s[0]?.value||`risk`)},[e?.DefaultMode,i,a,s]),(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:K(`flex h-8 items-center gap-1.5 rounded-xl px-2.5 text-[13px] transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,i===`full`?`text-amber-600 dark:text-amber-400`:`text-text-secondary hover:text-text-primary`),"aria-expanded":t,"aria-haspopup":`menu`,title:`设置本次会话的工具审批规则`,children:[(0,U.jsx)(o,{className:`h-3.5 w-3.5`}),(0,U.jsx)(`span`,{children:hJ[i]}),(0,U.jsx)(jM,{className:K(`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:`本次会话的默认审批规则`}),s.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:K(`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:K(`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:K(`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)(AM,{className:`h-4 w-4 shrink-0 text-primary`,"aria-hidden":`true`}):null]},e.value)})]}):null]})}function _J({attachments:e,composerContextIndicator:t,composerMaxHeight:n,fileInputRef:r,input:i,isMobile:a,isStreaming:o,attachmentsEnabled:s=!0,approvalEnabled:c=!1,approvalPolicy:l,thinkingEnabled:u=!1,executionMode:d,executionModeSupport:f,queuedDrafts:p,onAppendAttachments:m,onInputChange:h,onSelectExecutionMode:g,onPaste:_,onRemoveAttachment:v,onStopGeneration:y,onCancelRemote:b,onSubmit:x,textareaRef:ee}){let te=d===`goal`?`描述需要持续完成的目标…`:d===`plan`?`描述需要先规划的任务…`:a?`发送消息...`:`发送消息…`,S=b?`保留恢复点并结束本次执行`:`停止生成`,ne=d===`goal`?!!i.trim():!!(i.trim()||e.length>0),re=Te(e=>e.availableModels),C=Te(e=>e.selectedModel),w=Te(e=>e.thinkingMode),ie=Te(e=>e.setSelectedModel),ae=Te(e=>e.setThinkingMode),oe=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:[p.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:[`发送队列 · `,p.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:[p.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}`)}),p.length>3?(0,U.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-amber-700/80 dark:text-amber-200/80`,children:[`还有 `,p.length-3,` 条等待发送`]}):null]})]}):null,(0,U.jsx)(`div`,{className:`relative rounded-[28px] bg-surface shadow-[0_0_0_0.5px_rgba(15,23,42,0.08),0_5px_18px_rgba(15,23,42,0.07)] dark:shadow-[0_0_0_0.5px_rgba(255,255,255,0.06),0_8px_24px_rgba(0,0,0,0.24)]`,children:(0,U.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,U.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),o){b?b():y();return}let n=i.trim();ne&&x(n,e)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),s&&e.dataTransfer.files&&e.dataTransfer.files.length>0&&m(Array.from(e.dataTransfer.files))},className:`relative flex min-h-[116px] min-w-0 flex-1 flex-col rounded-[28px] border border-border/55 bg-background px-4 pb-3 pt-3 transition-all focus-within:border-primary/40 focus-within:ring-2 focus-within:ring-primary/15 sm:px-5`,children:[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:K(`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)(iN,{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:oe(e.size)})]}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>v(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:ee,rows:1,value:i,onChange:h,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},onPaste:_,placeholder:te,className:K(`custom-scrollbar max-h-[176px] min-h-[62px] w-full resize-none overflow-y-auto border-0 bg-transparent px-0 pb-1 pt-1 text-[15px] leading-6 text-text-primary outline-none placeholder:text-text-muted/60`,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.5`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`input`,{ref:r,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(m(Array.from(e.target.files)),e.target.value=``)}}),(0,U.jsx)(uJ,{attachmentsEnabled:s,mode:d,support:f,onSelectMode:g,onUpload:()=>r.current?.click()}),c?(0,U.jsx)(gJ,{approvalPolicy:l}):null]}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[t?(0,U.jsx)(oJ,{indicator:t}):null,re.length>0?(0,U.jsx)(pJ,{availableModels:re,selectedModel:C,thinkingEnabled:u,thinkingMode:w,onSelectModel:ie,onSelectThinkingMode:ae}):null,(0,U.jsx)(`button`,{type:`submit`,disabled:!o&&!ne,className:K(`flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,o||ne?`bg-[#1f1f1f] text-white hover:opacity-80`:`bg-muted text-text-muted/45`),title:o?S:`发送消息`,children:o?(0,U.jsx)(gN,{className:`h-3.5 w-3.5 fill-current`}):(0,U.jsx)(OM,{className:`h-[18px] w-[18px]`})})]})]})]})})})]})})}function vJ(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function yJ(e,t){let n=new Map;for(let t of e)n.set(vJ(t),t);for(let e of t)n.set(vJ(e),e);return Array.from(n.values())}function bJ(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function xJ({composerMaxHeight:e,submitDraft:t,stopGeneration:n,cancelRemote:r,isMobile:i,attachmentsEnabled:a=!0,approvalEnabled:o=!1,approvalPolicy:s,thinkingEnabled:c=!1,runtimeCapabilityMatrix:l,pendingInteractions:u,onRespondInteraction:d,localCatalog:f}){let[p,m]=(0,b.useState)(0),[h,g]=(0,b.useState)(),_=C(e=>e.input),v=C(e=>e.attachments),y=Ze(e=>e.currentSessionId),x=D(e=>!!(e.getSessionActivity(y)&&e.isSessionStreaming(y))),ee=C(e=>e.queuedDrafts),te=an(e=>e.messages),S=Te(e=>e.availableModels),ne=Te(e=>e.selectedModel),re=Te(e=>e.setThinkingMode),w=(0,b.useRef)(null),ie=(0,b.useRef)(null),ae=(0,b.useMemo)(()=>S.find(e=>e.id===ne)||null,[S,ne]),oe=(0,b.useMemo)(()=>rJ({messages:te,draftInput:_,selectedModel:ae}),[_,te,ae]),se=(0,b.useMemo)(()=>({plan:!!l?.plan?.supported,goal:!!l?.goal?.supported}),[l]),ce=h&&se[h]?h:void 0,le=(0,b.useCallback)((e,n)=>{!e&&n.length===0||(C.getState().setInput(``),C.getState().setAttachments([]),t(e,n,void 0,void 0,ce),ce===`goal`&&g(void 0))},[ce,t]);(0,b.useEffect)(()=>{ie.current&&(ie.current.style.height=`auto`,ie.current.style.height=`${Math.min(ie.current.scrollHeight,e)}px`)},[_,e]);let ue=t=>{C.getState().setInput(t.target.value),t.target.style.height=`auto`,t.target.style.height=`${Math.min(t.target.scrollHeight,e)}px`},T=e=>{!a||!e.length||C.getState().setAttachments(t=>yJ(t,e))},E=e=>{if(!a)return;let t=bJ(e);t.length&&(e.preventDefault(),e.stopPropagation(),T(t))},de=u||[],fe=Math.min(p,Math.max(de.length-1,0));return(0,b.useEffect)(()=>{c||re(`auto`)},[re,c]),(0,U.jsxs)(`div`,{className:`flex w-full flex-col justify-center`,children:[de.length>0&&d?(0,U.jsx)(nq,{interactions:de,activeIndex:fe,onSelectIndex:m,onRespond:d,localCatalog:f}):null,(0,U.jsx)(_J,{attachments:v,composerContextIndicator:oe,composerMaxHeight:e,fileInputRef:w,input:_,isMobile:i,isStreaming:x,attachmentsEnabled:a,approvalEnabled:o,approvalPolicy:s,thinkingEnabled:c,executionMode:ce,executionModeSupport:se,queuedDrafts:ee,onAppendAttachments:T,onInputChange:ue,onSelectExecutionMode:g,onPaste:E,onRemoveAttachment:e=>C.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:n,onCancelRemote:r,onSubmit:le,textareaRef:ie})]})}var SJ=(0,b.lazy)(()=>J(()=>import(`./NativeTerminalPanel-DUrK0JpZ.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function CJ({availableModels:e,selectedModel:t,onSelectModel:n,selectedModelLabel:r,modelCatalogLoaded:i,modelSource:a,thinkingEnabled:o,thinkingMode:s,onSelectThinkingMode:c,compact:l=!1}){let u=K(`rounded-full border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition-colors focus:ring-1 focus:ring-blue-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300`,l?`w-full`:`max-w-[13rem]`),d=e.length>1?(0,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:K(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:K(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:K(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function wJ({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),ne=!!x?.Enabled,re=n?i?(0,U.jsx)(nN,{className:`h-5 w-5`}):(0,U.jsx)(rN,{className:`h-5 w-5`}):r?(0,U.jsx)(nN,{className:`h-5 w-5`}):(0,U.jsx)(rN,{className:`h-5 w-5`});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`header`,{className:K(`flex flex-shrink-0 items-center justify-between border-b border-black/[0.06] bg-background/95 px-3 py-2 backdrop-blur dark:border-white/[0.08] dark:bg-background/95 sm:px-4`,n?`pt-[calc(var(--safe-area-top)+0.5rem)]`:`h-12`),children:[(0,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:re}),(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)(BM,{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)(VM,{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)(KM,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:`Workspace`})]}):null,ne?(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)(hN,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:`TUI`})]}):null,!ee&&n?(0,U.jsx)(CJ,{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)(OR,{open:h,onOpenChange:g,children:(0,U.jsxs)(MR,{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)(NR,{className:`text-left`,children:[(0,U.jsx)(FR,{children:`会话设置`}),(0,U.jsx)(IR,{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)(KM,{className:`h-4 w-4`}),`工作区文件`]}):null,ne?(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)(hN,{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)(VM,{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)(CJ,{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)(SJ,{capability:x,open:te,sessionId:t,onClose:()=>S(!1)})}):null]})}var TJ=(0,b.lazy)(()=>J(()=>import(`./NativeTerminalPanel-DUrK0JpZ.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function EJ({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)(pN,{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)($M,{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)(VM,{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)(KM,{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)(KM,{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)(hN,{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)(hN,{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)(TJ,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var DJ=[],OJ=[];(()=>{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?OJ:DJ).push(n+=e[t])})();function kJ(e){if(e<768)return!1;for(let t=0,n=DJ.length;;){let r=t+n>>1;if(e<DJ[r])n=r;else if(e>=OJ[r])t=r+1;else return!0;if(t==n)return!1}}function AJ(e){return e>=127462&&e<=127487}var jJ=8205;function MJ(e,t,n=!0,r=!0){return(n?NJ:PJ)(e,t,r)}function NJ(e,t,n){if(t==e.length)return t;t&&IJ(e.charCodeAt(t))&&LJ(e.charCodeAt(t-1))&&t--;let r=FJ(e,t);for(t+=RJ(r);t<e.length;){let i=FJ(e,t);if(r==jJ||i==jJ||n&&kJ(i))t+=RJ(i),r=i;else if(AJ(i)){let n=0,r=t-2;for(;r>=0&&AJ(FJ(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function PJ(e,t,n){for(;t>0;){let r=NJ(e,t-2,n);if(r<t)return r;t--}return 0}function FJ(e,t){let n=e.charCodeAt(t);if(!LJ(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return IJ(r)?(n-55296<<10)+(r-56320)+65536:n}function IJ(e){return e>=56320&&e<57344}function LJ(e){return e>=55296&&e<56320}function RJ(e){return e<65536?1:2}var zJ=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]=YJ(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),VJ.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]=YJ(this,e,t);let n=[];return this.decompose(e,t,n,0),VJ.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 GJ(this),i=new GJ(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 GJ(this,e)}iterRange(e,t=this.length){return new KJ(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 qJ(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 BJ(t):VJ.from(BJ.split(t,[]))}},BJ=class e extends zJ{constructor(e,t=HJ(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 JJ(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(WJ(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=UJ(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]=YJ(this,t,n);let i=UJ(this.text,UJ(r.text,WJ(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):VJ.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
197
|
-
`){[e,t]=YJ(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}},VJ=class e extends zJ{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]=YJ(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=`
|
|
198
|
-
`){[e,t]=YJ(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 BJ(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 BJ&&c&&(n=u[u.length-1])instanceof BJ&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new BJ(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)}};zJ.empty=new BJ([``],0);function HJ(e){let t=-1;for(let n of e)t+=n.length+1;return t}function UJ(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 WJ(e,t,n){return UJ(e,[``],t,n)}var GJ=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 BJ?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 BJ?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=`
|
|
199
|
-
`,this;e--}else if(r instanceof BJ){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 BJ?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)}},KJ=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new GJ(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!=``}},qJ=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`&&(zJ.prototype[Symbol.iterator]=function(){return this.iter()},GJ.prototype[Symbol.iterator]=KJ.prototype[Symbol.iterator]=qJ.prototype[Symbol.iterator]=function(){return this});var JJ=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 YJ(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function XJ(e,t,n=!0,r=!0){return MJ(e,t,n,r)}function ZJ(e){return e>=56320&&e<57344}function QJ(e){return e>=55296&&e<56320}function $J(e,t){let n=e.charCodeAt(t);if(!QJ(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return ZJ(r)?(n-55296<<10)+(r-56320)+65536:n}function eY(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function tY(e){return e<65536?1:2}var nY=/\r\n?|\n/,rY=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(rY||={}),iY=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){cY(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:uY(this,e)}mapDesc(e,t=!1){return e.empty?this:lY(this,e,t)}mapPos(e,t=-1,n=rY.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!=rY.Simple&&c>=e&&(n==rY.TrackDel&&r<e&&c>e||n==rY.TrackBefore&&r<e||n==rY.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)}},aY=class e extends iY{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 cY(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return lY(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(zJ.empty);r.push(a?t.slice(i,i+a):zJ.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:uY(this,e,!0)}map(e,t=!1){return e.empty?this:lY(this,e,t,!0)}iterChanges(e,t=!1){cY(this,e,t)}get desc(){return iY.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new dY(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);oY(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;oY(n,e,t),t>0&&sY(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);oY(n,e,-1),oY(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:iY.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&&oY(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`?zJ.of(l.split(r||nY)):l:zJ.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&oY(i,e-o,-1),oY(i,s-e,d),sY(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(zJ.empty);r[e]=zJ.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 oY(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 sY(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(zJ.empty);e.push(n)}}function cY(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=zJ.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 lY(e,t,n,r=!1){let i=[],a=r?[]:null,o=new dY(e),s=new dY(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);oY(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(oY(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(oY(i,0,o.ins),a&&sY(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;oY(i,t,e<o.i?o.ins:0),a&&e<o.i&&sY(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?aY.createSet(i,a):iY.create(i);else throw Error(`Mismatched change set lengths`)}function uY(e,t,n=!1){let r=[],i=n?[]:null,a=new dY(e),o=new dY(t);for(let e=!1;;)if(a.done&&o.done)return i?aY.createSet(r,i):iY.create(r);else if(a.ins==0)oY(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)oY(r,0,o.ins,e),i&&sY(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;oY(r,t,n,e),i&&n&&sY(i,r,o.text)}else o.ins==-1?(oY(r,a.off?0:a.len,t,e),i&&sY(i,r,a.textBit(t))):(oY(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&sY(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 dY=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?zJ.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?zJ.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)}},fY=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return Y.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Y.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return Y.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},Y=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>fY.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 fY.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?fY.create(t,e,48|a):fY.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 pY(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var mY=0,hY=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=mY++,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:gY),!!t.static,t.enables)}of(e){return new _Y([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new _Y(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new _Y(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function gY(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var _Y=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=mY++}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)||yY(e,c)){let r=t(e);if(a?!vY(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=MY(o,c);if(this.dependencies.every(t=>t instanceof hY?o.facet(t)===e.facet(t):t instanceof SY?o.field(t,!1)==e.field(t,!1):!0)||(a?vY(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 vY(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 yY(e,t){let n=!1;for(let r of t)jY(e,r)&1&&(n=!0);return n}function bY(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=MY(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)jY(e,t);return e.values[o]=s(e),1},update(e,n){if(!yY(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=yY(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&gY(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 xY=hY.define({static:!0}),SY=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(mY++,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(xY).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(xY),i=n.facet(xY),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,xY.of({field:this,create:e})]}get extension(){return this}},CY={lowest:4,low:3,default:2,high:1,highest:0};function wY(e){return t=>new EY(t,e)}var TY={highest:wY(CY.highest),high:wY(CY.high),default:wY(CY.default),low:wY(CY.low),lowest:wY(CY.lowest)},EY=class{constructor(e,t){this.inner=e,this.prec=t}},DY=class e{of(e){return new OY(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},OY=class{constructor(e,t){this.compartment=e,this.inner=t}},kY=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 AY(t,n,o))e instanceof SY?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,gY(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=>bY(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function AY(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 OY&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof OY){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 EY)a(e.inner,e.prec);else if(e instanceof SY)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof _Y)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,CY.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,CY.default),r.reduce((e,t)=>e.concat(t))}function jY(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 MY(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var NY=hY.define(),PY=hY.define({combine:e=>e.some(e=>e),static:!0}),FY=hY.define({combine:e=>e.length?e[0]:void 0,static:!0}),IY=hY.define(),LY=hY.define(),RY=hY.define(),zY=hY.define({combine:e=>e.length?e[0]:!1}),BY=class{constructor(e,t){this.type=e,this.value=t}static define(){return new VY}},VY=class{of(e){return new BY(this,e)}},HY=class{constructor(e){this.map=e}of(e){return new UY(this,e)}},UY=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 HY(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}};UY.reconfigure=UY.define(),UY.appendConfig=UY.define();var WY=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&&pY(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]==`.`))}};WY.time=BY.define(),WY.userEvent=BY.define(),WY.addToHistory=BY.define(),WY.remote=BY.define();function GY(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 KY(e,t,n){let r,i,a;return n?(r=t.changes,i=aY.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:UY.mapEffects(e.effects,r).concat(UY.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function qY(e,t,n){let r=t.selection,i=QY(t.annotations);return t.userEvent&&(i=i.concat(WY.userEvent.of(t.userEvent))),{changes:t.changes instanceof aY?t.changes:aY.of(t.changes||[],n,e.facet(FY)),selection:r&&(r instanceof Y?r:Y.single(r.anchor,r.head)),effects:QY(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function JY(e,t,n){let r=qY(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=KY(r,qY(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=WY.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return XY(n?YY(i):i)}function YY(e){let t=e.startState,n=!0;for(let r of t.facet(IY)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:GY(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=aY.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=WY.create(t,r,e.selection&&e.selection.map(i),UY.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(LY);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof WY?i:Array.isArray(i)&&i.length==1&&i[0]instanceof WY?i[0]:JY(t,QY(i),!1)}return e}function XY(e){let t=e.startState,n=t.facet(RY),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=KY(r,qY(t,a,e.changes.newLength),!0))}return r==e?e:WY.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var ZY=[];function QY(e){return e==null?ZY:Array.isArray(e)?e:[e]}var $Y=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})($Y||={}),eX=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,tX;try{tX=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function nX(e){if(tX)return tX.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||eX.test(n)))return!0}return!1}function rX(e){return t=>{if(!/\S/.test(t))return $Y.Space;if(nX(t))return $Y.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return $Y.Word;return $Y.Other}}var iX=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++)jY(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 jY(this,n),MY(this,n)}update(...e){return JY(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(DY.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(UY.reconfigure)?(n=null,r=e.value):e.is(UY.appendConfig)&&(n=null,r=QY(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=kY.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(PY)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:Y.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=QY(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=UY.mapEffects(a,c).concat(UY.mapEffects(QY(o.effects),l))}return{changes:r,selection:Y.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof aY?t:aY.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return zJ.of(t.split(this.facet(e.lineSeparator)||nY))}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:(jY(this,t),MY(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 SY&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:Y.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=kY.resolve(t.extensions||[],new Map),r=t.doc instanceof zJ?t.doc:zJ.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||nY)),i=t.selection?t.selection instanceof Y?t.selection:Y.single(t.selection.anchor,t.selection.head):Y.single(0);return pY(i,r.length),n.staticFacet(PY)||(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)||`
|
|
200
|
-
`}get readOnly(){return this.facet(zY)}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(NY))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 rX(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=XJ(t,a,!1);if(i(t.slice(e,a))!=$Y.Word)break;a=e}for(;o<r;){let e=XJ(t,o);if(i(t.slice(o,e))!=$Y.Word)break;o=e}return a==o?null:Y.range(a+n,o+n)}};iX.allowMultipleSelections=PY,iX.tabSize=hY.define({combine:e=>e.length?e[0]:4}),iX.lineSeparator=FY,iX.readOnly=zY,iX.phrases=hY.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])}}),iX.languageData=NY,iX.changeFilter=IY,iX.transactionFilter=LY,iX.transactionExtender=RY,DY.reconfigure=UY.define();function aX(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 oX=class{eq(e){return this==e}range(e,t=e){return cX.create(e,t,this)}};oX.prototype.startSide=oX.prototype.endSide=0,oX.prototype.point=!1,oX.prototype.mapMode=rY.TrackDel;function sX(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var cX=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 lX(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var uX=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}}},dX=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(lX)),this.isEmpty)return n.length?e.of(n):this;let s=new hX(this,null,-1).goto(0),c=0,l=[],u=new pX;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(cX.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 gX.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return gX.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=mX(a,o,n),c=new vX(a,s,i),l=new vX(o,s,i);n.iterGaps((e,t,n)=>yX(c,e,l,t,n,r)),n.empty&&n.length==0&&yX(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=mX(i,a),s=new vX(i,o,0).goto(n),c=new vX(a,o,0).goto(n);for(;;){if(s.to!=c.to||!bX(s.active,c.active)||s.point&&(!c.point||!sX(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 vX(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 pX;for(let r of e instanceof cX?[e]:t?fX(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}};dX.empty=new dX([],[],null,-1);function fX(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(lX(t,r)>0)return e.slice().sort(lX);t=r}return e}dX.empty.nextLayer=dX.empty;var pX=class e{finishChunk(e){this.chunks.push(new uX(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(dX.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=dX.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function mX(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 hX=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}},gX=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 hX(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--)_X(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--)_X(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(),_X(this.heap,0)}}};function _X(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 vX=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=gX.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){xX(this.active,e),xX(this.activeTo,e),xX(this.activeRank,e),this.minActive=CX(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++;SX(this.active,t,n),SX(this.activeTo,t,r),SX(this.activeRank,t,i),e&&SX(e,t,this.cursor.from),this.minActive=CX(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&&xX(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 yX(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&&sX(e.point,n.point)&&bX(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&a.boundChange(s),d>s&&!bX(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 bX(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!sX(e[n],t[n]))return!1;return!0}function xX(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function SX(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function CX(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 wX(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=XJ(e,i));return r}function TX(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=XJ(e,r)}return r===!0?-1:e.length}for(var EX=`ͼ`,DX=typeof Symbol>`u`?`__ͼ`:Symbol.for(EX),OX=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),kX=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{},AX=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(`
|
|
201
|
-
`)}static newName(){let e=kX[DX]||1;return kX[DX]=e+1,EX+e.toString(36)}static mount(e,t,n){let r=e[OX],i=n&&n.nonce;r?i&&r.setNonce(i):r=new MX(e,i),r.mount(Array.isArray(t)?t:[t],e)}},jX=new Map,MX=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=jX.get(n);if(t)return e[OX]=t;this.sheet=new r.CSSStyleSheet,jX.set(n,this)}else this.styleTag=n.createElement(`style`),t&&this.styleTag.setAttribute(`nonce`,t);this.modules=[],e[OX]=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()+`
|
|
202
|
-
`;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)}},NX={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:`'`},PX={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},FX=typeof navigator<`u`&&/Mac/.test(navigator.platform),IX=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),LX=0;LX<10;LX++)NX[48+LX]=NX[96+LX]=String(LX);for(var LX=1;LX<=24;LX++)NX[LX+111]=`F`+LX;for(var LX=65;LX<=90;LX++)NX[LX]=String.fromCharCode(LX+32),PX[LX]=String.fromCharCode(LX);for(var RX in NX)PX.hasOwnProperty(RX)||(PX[RX]=NX[RX]);function zX(e){var t=!(FX&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||IX&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?PX:NX)[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 BX(){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++)VX(e,arguments[t]);return e}function VX(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++)VX(e,t[n]);else throw RangeError(`Unsupported child node: `+t)}var HX=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},UX=typeof document<`u`?document:{documentElement:{style:{}}},WX=/Edge\/(\d+)/.exec(HX.userAgent),GX=/MSIE \d/.test(HX.userAgent),KX=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(HX.userAgent),qX=!!(GX||KX||WX),JX=!qX&&/gecko\/(\d+)/i.test(HX.userAgent),YX=!qX&&/Chrome\/(\d+)/.exec(HX.userAgent),XX=`webkitFontSmoothing`in UX.documentElement.style,ZX=!qX&&/Apple Computer/.test(HX.vendor),QX=ZX&&(/Mobile\/\w+/.test(HX.userAgent)||HX.maxTouchPoints>2),$X={mac:QX||/Mac/.test(HX.platform),windows:/Win/.test(HX.platform),linux:/Linux|X11/.test(HX.platform),ie:qX,ie_version:GX?UX.documentMode||6:KX?+KX[1]:WX?+WX[1]:0,gecko:JX,gecko_version:JX?+(/Firefox\/(\d+)/.exec(HX.userAgent)||[0,0])[1]:0,chrome:!!YX,chrome_version:YX?+YX[1]:0,ios:QX,android:/Android\b/.test(HX.userAgent),webkit:XX,webkit_version:XX?+(/\bAppleWebKit\/(\d+)/.exec(HX.userAgent)||[0,0])[1]:0,safari:ZX,safari_version:ZX?+(/\bVersion\/(\d+(\.\d+)?)/.exec(HX.userAgent)||[0,0])[1]:0,tabSize:UX.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function eZ(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 tZ=Object.create(null);function nZ(e,t,n){if(e==t)return!0;e||=tZ,t||=tZ;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 rZ(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 iZ(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 aZ(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 oZ=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){}},sZ=(function(e){return e[e.Text=0]=`Text`,e[e.WidgetBefore=1]=`WidgetBefore`,e[e.WidgetAfter=2]=`WidgetAfter`,e[e.WidgetRange=3]=`WidgetRange`,e})(sZ||={}),cZ=class extends oX{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 lZ(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 dZ(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}=fZ(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new dZ(e,n,r,t,e.widget||null,!0)}static line(e){return new uZ(e)}static set(e,t=!1){return dX.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};cZ.none=dX.empty;var lZ=class e extends cZ{constructor(e){let{start:t,end:n}=fZ(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?eZ(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||tZ}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&nZ(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};lZ.prototype.point=!1;var uZ=class e extends cZ{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&nZ(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)}};uZ.prototype.mapMode=rY.TrackBefore,uZ.prototype.point=!0;var dZ=class e extends cZ{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?rY.TrackBefore:rY.TrackAfter:rY.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?sZ.WidgetBefore:sZ.WidgetAfter:sZ.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&pZ(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)}};dZ.prototype.point=!0;function fZ(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function pZ(e,t){return e==t||!!(e&&t&&e.compare(t))}function mZ(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 hZ=class e extends oX{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&&nZ(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||tZ,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return dX.of(e,t)}};hZ.prototype.startSide=hZ.prototype.endSide=-1;function gZ(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function _Z(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function vZ(e,t){if(!t.anchorNode)return!1;try{return _Z(e,t.anchorNode)}catch{return!1}}function yZ(e){return e.nodeType==3?PZ(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function bZ(e,t,n,r){return n?CZ(e,t,n,r,-1)||CZ(e,t,n,r,1):!1}function xZ(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function SZ(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function CZ(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:wZ(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||n.nodeType!=1)return!1;t=xZ(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?wZ(e):0}else return!1}}function wZ(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function TZ(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function EZ(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 DZ(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 OZ(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=EZ(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}=DZ(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 kZ(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 AZ=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?wZ(t):0),n,Math.min(e.focusOffset,n?wZ(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},jZ=null;$X.safari&&$X.safari_version>=26&&(jZ=!1);function MZ(e){if(e.setActive)return e.setActive();if(jZ)return e.focus(jZ);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(jZ==null?{get preventScroll(){return jZ={preventScroll:!0},!0}}:void 0),!jZ){jZ=!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 NZ;function PZ(e,t,n=t){let r=NZ||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function FZ(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 IZ(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function LZ(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,wZ(n));;)if(r){if(n.nodeType!=1)return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=wZ(n))}else if(n==e)return!0;else r=xZ(n),n=n.parentNode}function RZ(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 zZ(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=wZ(n)}else if(n.parentNode&&!SZ(n))r=xZ(n),n=n.parentNode;else return null}function BZ(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&&!SZ(n))r=xZ(n)+1,n=n.parentNode;else return null}var VZ=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,xZ(t),n)}static after(t,n){return new e(t.parentNode,xZ(t)+1,n)}},HZ=(function(e){return e[e.LTR=0]=`LTR`,e[e.RTL=1]=`RTL`,e})(HZ||={}),UZ=HZ.LTR,WZ=HZ.RTL;function GZ(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}var KZ=GZ(`88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008`),qZ=GZ(`4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333`),JZ=Object.create(null),YZ=[];for(let e of[`()`,`[]`,`{}`]){let t=e.charCodeAt(0),n=e.charCodeAt(1);JZ[t]=n,JZ[n]=-t}function XZ(e){return e<=247?KZ[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?qZ[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var ZZ=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,QZ=class{get dir(){return this.level%2?WZ:UZ}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 $Z(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||!$Z(r.inner,i.inner))return!1}return!0}var eQ=[];function tQ(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=XZ(e.charCodeAt(t));i==512?i=n:i==8&&r==4&&(i=16),eQ[t]=i==4?2:i,i&7&&(r=i),n=i}for(let e=o,t=c,r=c;e<s;e++){let i=eQ[e];if(i==128)e<s-1&&t==eQ[e+1]&&t&24?i=eQ[e]=t:eQ[e]=256;else if(i==64){let i=e+1;for(;i<s&&eQ[i]==64;)i++;let a=e&&t==8||i<n&&eQ[i]==8?r==1?1:8:256;for(let t=e;t<i;t++)eQ[t]=a;e=i-1}else i==8&&r==1&&(eQ[e]=1);t=i,i&7&&(r=i)}}}function nQ(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=JZ[n=e.charCodeAt(t)])if(r<0){for(let e=s-3;e>=0;e-=3)if(YZ[e+1]==-r){let n=YZ[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(eQ[t]=eQ[YZ[e]]=r),s=e;break}}else if(YZ.length==189)break;else YZ[s++]=t,YZ[s++]=n,YZ[s++]=c;else if((o=eQ[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=YZ[t+2];if(n&2)break;if(e)YZ[t+2]|=2;else{if(n&4)break;YZ[t+2]|=4}}}}}function rQ(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=eQ[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(eQ[o]==256)o++;else break;let l=a==1,u=l==((o<t?eQ[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),eQ[--t]=u;c=o}else a=o,c++}}}function iQ(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=eQ[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(eQ[e]==s)break run;else break}l++,d?d.push(m):(m.from>c&&o.push(new QZ(c,m.from,f)),aQ(e,m.direction==UZ==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?eQ[p]!=s:eQ[p]==s))break;else p++;d?iQ(e,c,p,r+1,i,d,o):c<p&&o.push(new QZ(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=eQ[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(eQ[e-1]==s)break run;else break}d?d.push(m):(m.to<c&&o.push(new QZ(m.to,c,f)),aQ(e,m.direction==UZ==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.from),p=m.from}else if(p==t||(n?eQ[p-1]!=s:eQ[p-1]==s))break;else p--;d?iQ(e,p,c,r+1,i,d,o):p<c&&o.push(new QZ(p,c,f)),c=p}}function aQ(e,t,n,r,i,a,o){let s=t%2?2:1;tQ(e,i,a,r,s),nQ(e,i,a,r,s),rQ(i,a,r,s),iQ(e,i,a,t,n,r,o)}function oQ(e,t,n){if(!e)return[new QZ(0,0,+(t==WZ))];if(t==UZ&&!n.length&&!ZZ.test(e))return sQ(e.length);if(n.length)for(;e.length>eQ.length;)eQ[eQ.length]=256;let r=[],i=t==UZ?0:1;return aQ(e,i,i,n,0,e.length,r),r}function sQ(e){return[new QZ(0,e,0)]}var cQ=``;function lQ(e,t,n,r,i){let a=r.head-e.from,o=QZ.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=XJ(e.text,a,s.forward(i,n));(l<s.from||l>s.to)&&(l=c),cQ=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?Y.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):Y.cursor(l+e.from,s.forward(i,n)?-1:1,s.level)}function uQ(e,t,n){for(let r=t;r<n;r++){let t=XZ(e.charCodeAt(r));if(t==1)return UZ;if(t==2||t==4)return WZ}return UZ}var dQ=hY.define(),fQ=hY.define(),pQ=hY.define(),mQ=hY.define(),hQ=hY.define(),gQ=hY.define(),_Q=hY.define(),vQ=hY.define(),yQ=hY.define(),bQ=hY.define({combine:e=>e.some(e=>e)}),xQ=hY.define({combine:e=>e.some(e=>e)}),SQ=hY.define(),CQ=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(Y.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},wQ=UY.define({map:(e,t)=>e.map(t)}),TQ=UY.define();function EQ(e,t,n){let r=e.facet(mQ);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 DQ=hY.define({combine:e=>e.length?e[0]:!0}),OQ=0,kQ=hY.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})}}),AQ=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(kQ.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(kQ.of({plugin:this,arg:e}))}static define(t,n){let{eventHandlers:r,eventObservers:i,provide:a,decorations:o}=n||{};return new e(OQ++,t,r,i,e=>{let t=[];return o&&t.push(PQ.of(t=>{let n=t.plugin(e);return n?o(n):cZ.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},jQ=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){EQ(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(EQ(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){EQ(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},MQ=hY.define(),NQ=hY.define(),PQ=hY.define(),FQ=hY.define(),IQ=hY.define(),LQ=hY.define(),RQ=hY.define();function zQ(e,t){let n=e.state.facet(RQ);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return dX.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??=uQ(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 BQ=hY.define();function VQ(e){let t=0,n=0,r=0,i=0;for(let a of e.state.facet(BQ)){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 HQ=hY.define(),UQ=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}},WQ=class e{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=aY.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 UQ(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}},GQ=[],KQ=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 GQ}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&&rZ(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=xZ(this.dom),r=this.length?e>0:t>0;return new VZ(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 YQ)return e;return null}static get(e){return e.cmTile}},qQ=class extends KQ{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=JQ(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=JQ(r);this.length=a}};function JQ(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var YQ=class extends qQ{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=KQ.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 XQ)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}}},XQ=class e extends qQ{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}},ZQ=class e extends qQ{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&&$Q(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 VZ(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 VZ(e.dom,0);e==n.tile&&(a=!0)}}return new VZ(this.dom,0)}};function QQ(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=yZ(t);return n[n.length-1]||null}function $Q(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var e$=class e extends qQ{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}},t$=class e extends KQ{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?$X.chrome||$X.gecko||(e?(r--,a=1):i<n&&(i++,a=-1)):t<0?r--:i<n&&i++;let o=PZ(this.dom,r,i).getClientRects();if(!o.length)return null;let s=o[(a?a<0:t>=0)?0:o.length-1];return $X.safari&&!a&&s.width==0&&(s=Array.prototype.find.call(o,e=>e.width)||s),a?TZ(s,a<0):s||null}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},n$=class e extends KQ{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 TZ(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 TZ(n,!r)}}get overrideDOMText(){if(!this.length)return zJ.empty;let{root:e}=this;if(!e)return zJ.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)}},r$=class extends KQ{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 zJ.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},i$=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}},a$=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},o$=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 t$(a.dom,a.text+e);t.parent=i}else i.append(r||t$.of(e,this.cache.find(t$)?.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)?g$(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 e$&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(g$(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=KQ.get(n.dom);e&&e.setDOM(g$(n.dom))}let e=e$.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=KQ.get(e.text);i&&this.cache.reused.set(i,2);let a=new t$(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||=p$;let n=ZQ.start(e,t||this.cache.find(ZQ)?.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 e$&&a.mark.eq(i))n=a,t--;else{let e=e$.of(i,this.cache.find(e$,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||!d$(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!($X.ios&&d$(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(v$,0,32)||new n$(v$.toDOM(),0,v$,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 a$(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 XQ&&n.wrapper.eq(t.wrapper))e=n;else{let n=XQ.of(t.wrapper,this.cache.find(XQ,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(r$,void 0,1);return n&&(n.flags=t),n||new r$(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},s$=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}},c$=[n$,ZQ,t$,e$,r$,XQ,YQ];for(let e=0;e<c$.length;e++)c$[e].bucket=e;var l$=class{constructor(e){this.view=e,this.buckets=c$.map(()=>[]),this.index=c$.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 n$(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}},u$=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 l$(e),this.text=new s$(e.state.doc),this.builder=new o$(this.cache,new YQ(e,e.contentDOM),dX.iter(n)),this.cache.reused.set(t,2),this.old=new i$(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=h$(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?n$.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 r$)this.cache.add(e);else if(e instanceof e$)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 e$&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof e$&&(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=dX.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof dZ){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?_$.block:_$.inline),c=f$(a),l=this.cache.findWidget(i,t-e,c)||n$.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=m$(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=KQ.get(r);if(r==this.view.contentDOM)break;e instanceof e$?t.push(e):e?.isLine()?n=e:e instanceof XQ||(r.nodeName==`DIV`&&!n&&r!=this.view.contentDOM?n=new ZQ(r,p$):n||t.push(e$.of(new lZ({tagName:r.nodeName.toLowerCase(),attributes:aZ(r)}),r)))}return{line:n,marks:t}}};function d$(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 f$(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 p$={class:`cm-line`};function m$(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r?e:(e||={class:`cm-line`},n&&eZ(n,e),r&&(e.class+=` `+r),e)}function h$(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 e$&&t.push(r.mark)}return t}function g$(e){let t=KQ.get(e);return t&&t.setDOM(e.cloneNode()),e}var _$=class extends oZ{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}};_$.inline=new _$(`span`),_$.block=new _$(`div`);var v$=new class extends oZ{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},y$=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=cZ.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 YQ(e,e.contentDOM),this.updateInner([new UQ(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:!A$(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?C$(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new UQ(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,($X.ie||$X.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=E$(i,this.decorations,e.changes);o.length&&(t=UQ.extendWithRanges(t,o));let s=O$(a,this.blockWrappers,e.changes);return s.length&&(t=UQ.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 u$(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&KQ.get(t.text)&&r.cache.reused.set(KQ.get(t.text),2),this.tile=r.run(e,t),b$(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=$X.chrome||$X.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 j$&&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(TQ)&&(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(DQ)||n.tabIndex>-1)&&vZ(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)),$X.gecko&&s.empty&&!this.hasComposition&&x$(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new VZ(e,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!bZ(c.node,c.offset,u.anchorNode,u.anchorOffset)||!bZ(l.node,l.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,s))&&(this.view.observer.ignore(()=>{$X.android&&$X.chrome&&n.contains(u.focusNode)&&k$(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=gZ(this.view.root);if(e)if(s.empty){if($X.gecko){let e=w$(c.node,c.offset);if(e&&e!=3){let t=(e==1?zZ:BZ)(c.node,c.offset);t&&(c=new VZ(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 VZ(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new VZ(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&bZ(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=gZ(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=wZ(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&&!KQ.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 j$?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=XJ(e.text,t);if(n==t)return null;let r=PZ(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==HZ.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 XQ)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?yZ(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`?HZ.RTL:HZ.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=yZ(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=yZ(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(cZ.replace({widget:new j$(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return cZ.set(e)}updateDeco(){let e=1,t=this.view.state.facet(PQ).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(IQ).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(dX.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(FQ).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(SQ))try{if(t(this.view,e.range,e))return!0}catch(e){EQ(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=VQ(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(OZ(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==HZ.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(){b$(this.tile)}};function b$(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)b$(n,t)}}function x$(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 S$(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=zZ(n.focusNode,n.focusOffset),i=BZ(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=KQ.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=KQ.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 C$(e,t,n){let r=S$(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 UQ(c.mapPos(a),c.mapPos(o),a,o),text:i}}function w$(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 T$=class{constructor(){this.changes=[]}compareRange(e,t){mZ(e,t,this.changes)}comparePoint(e,t){mZ(e,t,this.changes)}boundChange(e){mZ(e,e,this.changes)}};function E$(e,t,n){let r=new T$;return dX.compare(e,t,n,r),r.changes}var D$=class{constructor(){this.changes=[]}compareRange(e,t){mZ(e,t,this.changes)}comparePoint(){}boundChange(e){mZ(e,e,this.changes)}};function O$(e,t,n){let r=new D$;return dX.compare(e,t,n,r),r.changes}function k$(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 A$(e,t){let n=!1;return t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)}),n}var j$=class extends oZ{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 M$(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return Y.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=XJ(i.text,a,!1):s=XJ(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=XJ(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;s<i.length;){let e=XJ(i.text,s);if(r(i.text.slice(s,e))!=c)break;s=e}return Y.range(o+i.from,s+i.from)}function N$(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+TX(o,a,e.state.tabSize)}function P$(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==sZ.Text&&(e.type!=i.type||(n<0?i.from<t:i.to>t)))&&(e=i)}}return e||r}return r}function F$(e,t,n,r){let i=P$(e,t.head,t.assoc||-1),a=!r||i.type!=sZ.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==HZ.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o!=null)return Y.cursor(o,n?-1:1)}return Y.cursor(n?i.to:i.from,n?-1:1)}function I$(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=lQ(i,a,o,s,n),l=cQ;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=`
|
|
203
|
-
`,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 L$(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==$Y.Space&&(i=t),i==t}}function R$(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return Y.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=U$(e,{x:d,y:r},!1,a);if(n?r>c.bottom:r<c.top)return Y.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 Y.cursor(i.pos,i.assoc,void 0,o)}}function z$(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 B$(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=z$(e,i.from,0);t!=i.from&&(a=Y.cursor(t,-1))}else{let t=z$(e,i.from,-1),n=z$(e,i.to,1);(t!=i.from||n!=i.to)&&(a=Y.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}a&&(n||=t.ranges.slice(),n[r]=a)}return n?Y.create(n,t.mainIndex):t}function V$(e,t,n){let r=z$(e.state.facet(LQ).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:Y.cursor(r,r<n.from?1:-1)}var H$=class{constructor(e,t){this.pos=e,this.assoc=t}};function U$(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 H$(0,1);if(c>e.viewState.docHeight)return new H$(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==sZ.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==sZ.Text){let t=N$(e,i,l,o,s);return new H$(t,t==l.from?1:-1)}}if(l.type!=sZ.Text)return c<(l.top+l.bottom)/2?new H$(l.from,1):new H$(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 W$(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var W$=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[QZ.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[QZ.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==HZ.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)==HZ.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=XJ(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 PZ(e.dom,i,a).getClientRects()});return r.after?new H$(n[r.i+1],-1):new H$(n[r.i],1)}scanTile(e,t){if(!e.length)return new H$(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:PZ(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 H$(n[r.i+1],-1):new H$(a,1)}},G$=``,K$=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(iX.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=G$}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=KQ.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=KQ.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:SZ(r))||SZ(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!J$(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=KQ.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+(q$(e,n.node,n.offset)?t:0))}};function q$(e,t,n){for(;;){if(!t||n<wZ(t))return!1;if(t==e)return!0;n=xZ(t)+1,t=t.parentNode}}function J$(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let t=KQ.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 Y$=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},X$=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=Z$(e.docView.tile,t,n,0))){let t=i||a?[]:n1(e),n=new K$(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=r1(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!_Z(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!_Z(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if(($X.ios||$X.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(Y.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=Y.create([Y.cursor(n,r)])}else this.newSel=Y.single(r,n)}}};function Z$(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 Z$(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 Q$(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||$X.android&&t.text.length<r-e)&&(s=a.to,c=`end`);let l=i.doc.sliceString(e,r,G$),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:zJ.of(t.text.slice(a.from-e,u).split(G$))}:(d=t1(l,t.text,s-e,c))&&($X.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:zJ.of(t.text.slice(d.from,d.toB).split(G$))})}else r&&(!e.hasFocus&&i.facet(DQ)||i1(r,a))&&(r=null);if(!n&&!r)return!1;if(($X.mac||$X.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=Y.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:zJ.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)}:$X.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==`
|
|
204
|
-
`&&e.lineWrapping&&(r&&=Y.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:zJ.of([` `])}),n)return $$(e,n,r,o);if(r&&!i1(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=B$(i.facet(LQ).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}else return!1}function $$(e,t,n,r=-1){if($X.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if($X.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&&FZ(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)&&FZ(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&FZ(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=e1(e,t,n);return e.state.facet(gQ).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function e1(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=z$(i.facet(LQ).map(t=>t(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:Y.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&&S$(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?Y.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 t1(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 n1(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 Y$(n,r)),(i!=n||a!=r)&&t.push(new Y$(i,a))),t}function r1(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?Y.single(n+t,r+t):null}function i1(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var a1=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,$X.safari&&e.contentDOM.addEventListener(`input`,()=>null),$X.gecko&&V1(e.contentDOM.ownerDocument)}handleEvent(e){!v1(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=s1(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&&u1.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),$X.android&&$X.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return $X.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=c1.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||l1.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,FZ(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:$X.safari&&!$X.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 o1(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){EQ(n.state,e)}}}function s1(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(o1(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(o1(t.value,r))}}for(let e in y1)n(e).handlers.push(y1[e]);for(let e in b1)n(e).observers.push(b1[e]);return t}var c1=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],l1=`dthko`,u1=[16,17,18,20,91,92,224,225],d1=6;function f1(e){return Math.max(0,e)*.7+8}function p1(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var m1=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=kZ(e.contentDOM),this.atoms=e.state.facet(LQ).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(iX.allowMultipleSelections)&&h1(e,t),this.dragging=_1(e,t)&&A1(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&&p1(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=VQ(this.view);e.clientX-s.left<=r+d1?t=-f1(r-e.clientX):e.clientX+s.right>=a-d1&&(t=f1(e.clientX-a)),e.clientY-s.top<=i+d1?n=-f1(i-e.clientY):e.clientY+s.bottom>=o-d1&&(n=f1(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=B$(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 h1(e,t){let n=e.state.facet(dQ);return n.length?n[0](t):$X.mac?t.metaKey:t.ctrlKey}function g1(e,t){let n=e.state.facet(fQ);return n.length?n[0](t):$X.mac?!t.altKey:!t.ctrlKey}function _1(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=gZ(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 v1(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=KQ.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var y1=Object.create(null),b1=Object.create(null),x1=$X.ie&&$X.ie_version<15||$X.ios&&$X.webkit_version<604;function S1(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(),w1(e,n.value)},50)}function C1(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function w1(e,t){t=C1(e.state,vQ,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(I1!=null&&n.selection.ranges.every(e=>e.empty)&&I1==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:Y.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:Y.cursor(e.from+t.length)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}b1.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},b1.wheel=b1.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},y1.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),b1.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`)},b1.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},y1.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(pQ))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=j1(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new m1(e,t,n,r)),r&&e.observer.ignore(()=>{MZ(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 T1(e,t,n,r){if(r==1)return Y.cursor(t,n);if(r==2)return M$(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++,Y.range(a,o)}}var E1=$X.ie&&$X.ie_version<=11,D1=null,O1=0,k1=0;function A1(e){if(!E1)return e.detail;let t=D1,n=k1;return D1=e,k1=Date.now(),O1=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(O1+1)%3:1}function j1(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=A1(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=T1(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=T1(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i<l.from?Y.range(i,a,l.assoc):Y.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=M1(i,s.pos))?c:o?i.addRange(l):Y.create([l])}}}function M1(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 Y.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}y1.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=Y.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,C1(e.state,yQ,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},y1.dragend=e=>(e.inputState.draggedContent=null,!1);function N1(e,t,n,r){if(n=C1(e.state,vQ,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&g1(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}y1.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&&N1(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 N1(e,t,n,!0),!0}return!1},y1.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=x1?null:t.clipboardData;return n?(w1(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(S1(e),!1)};function P1(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 F1(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:C1(e,yQ,t.join(e.lineBreak)),ranges:n,linewise:r}}var I1=null;y1.copy=y1.cut=(e,t)=>{if(!vZ(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=F1(e.state);if(!n&&!i)return!1;I1=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=x1?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(P1(e,n),!1)};var L1=BY.define();function R1(e,t){let n=[];for(let r of e.facet(_Q)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:L1.of(!0)}):null}function z1(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=R1(e.state,t);n?e.dispatch(n):e.update([])}},10)}b1.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),z1(e)},b1.blur=e=>{e.observer.clearSelectionRange(),z1(e)},b1.compositionstart=b1.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},b1.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,$X.chrome&&$X.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},b1.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},y1.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 $$(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($X.chrome&&$X.android&&(n=c1.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 $X.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),$X.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>b1.compositionend(e,t),20),!1};var B1=new Set;function V1(e){B1.has(e)||(B1.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var H1=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],U1=!1;function W1(){U1=!1}var G1=class{constructor(e){this.lineWrapping=e,this.doc=zJ.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 H1.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=H1.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}},K1=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},q1=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`?sZ.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 dZ?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)}},J1=(function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(J1||={}),Y1=.001,X1=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)>Y1&&(U1=!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,J1.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,J1.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,J1.ByPosNoHeight,n,0,0));l+=d.from-s,s=d.from;let p=a0.build(n.setDoc(a),e,l,u);i=Z1(i,i.replace(s,c,p))}return i.updateHeight(n,0)}static empty(){return new e0(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 n0(e.of(t.slice(0,n)),o,e.of(t.slice(r)))}};function Z1(e,t){return e==t?e:(e.constructor!=t.constructor&&(U1=!0),t)}X1.prototype.size=1;var Q1=cZ.replace({}),$1=class extends X1{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new q1(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 q1(r,0,n,this.spaceAbove,Q1):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,J1.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})`}},e0=class e extends $1{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 q1(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 t0&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof t0?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):X1.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:``})`}},t0=class e extends X1{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 q1(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 q1(s,c,n+o*r,o,0)}}lineAt(e,t,n,r,i){if(t==J1.ByHeight)return this.blockAt(e,n,r,i);if(t==J1.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new q1(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 q1(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 q1(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 X1.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)>=Y1&&(s=-2);let c=new e0(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=X1.of(r);return(s<0||Math.abs(c.height-this.height)>=Y1||Math.abs(s-this.heightMetrics(t,n).perLine)>=Y1)&&(U1=!0),Z1(this,c)}else (r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},n0=class extends X1{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==J1.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==J1.ByPosNoHeight?J1.ByPosNoHeight:J1.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,J1.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&&r0(i,a-1),t<this.length){let e=i.length;this.decomposeRight(t,i),r0(i,e)}return X1.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?X1.of(this.break?[e,null,t]:[e,t]):(this.left=Z1(this.left,e),this.right=Z1(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 r0(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof t0&&(r=e[t+1])instanceof t0&&e.splice(t-1,3,new t0(n.length+1+r.length))}var i0=5,a0=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 e0?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new e0(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 $1(a,r,n)):(a||i||r>=i0)&&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 e0(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new t0(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 e0)return e;let t=new e0(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 e0)&&!this.isCovered?this.nodes.push(new e0(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 e0&&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 dX.spans(n,r,i,a,0),a.finish(r)}};function o0(e,t,n){let r=new s0;return dX.compare(e,t,n,r,0),r.changes}var s0=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&mZ(e,t,this.changes,5)}};function c0(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 l0(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 u0(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var d0=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 cZ.replace({widget:new f0(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},f0=class extends oZ{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}},p0=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=y0,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=HZ.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(NQ).some(e=>typeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new G1(n),this.stateDeco=b0(t),this.heightMap=X1.empty().applyChanges(this.stateDeco,zJ.empty,this.heightOracle.setDoc(t.doc),[new UQ(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=cZ.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 m0(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?y0:new x0(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(S0(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=b0(this.state);let r=e.changedRanges,i=UQ.extendWithRanges(r,o0(n,this.stateDeco,e?e.changes:aY.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);W1(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||U1)&&(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(xQ)&&(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`?HZ.RTL:HZ.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}=DZ(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=kZ(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=RZ(this.scrollParent||e.win);let m=(this.printing?u0:c0)(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&&!l0(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)),W1();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?X1.empty().applyChanges(this.stateDeco,zJ.empty,this.heightOracle,[new UQ(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new K1(n.from,i))}U1&&(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 m0(r.lineAt(a-n*1e3,J1.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,J1.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,J1.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 m0(r.lineAt(o-1e3/2,J1.ByHeight,i,0,0).from,r.lineAt(o+n+1e3/2,J1.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 m0(this.heightMap.lineAt(n,J1.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,J1.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,J1.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,J1.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 d0(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!=HZ.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=v0(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(Y.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new d0(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length<a||t.type!=sZ.Text)return;let i=h0(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=_0(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=g0(i,n),l=g0(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=_0(i,o),t=((d-u)/2+a)/n;f=e-t,p=e+t}else f=(u-a)/n,p=(d+a)/n;c=g0(i,f),l=g0(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=_0(r,n)-_0(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){d0.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=cZ.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=[];dX.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)||S0(this.heightMap.lineAt(e,J1.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)||S0(this.heightMap.lineAt(this.scaler.fromDOM(e),J1.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 S0(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}},m0=class{constructor(e,t){this.from=e,this.to=t}};function h0(e,t,n){let r=[],i=e,a=0;return dX.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 g0({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 _0(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 v0(e,t){for(let n of e)if(t(n))return n}var y0={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function b0(e){let t=e.facet(PQ).filter(e=>typeof e!=`function`),n=e.facet(IQ).filter(e=>typeof e!=`function`);return n.length&&t.push(dX.join(n)),t}var x0=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,J1.ByPos,e,0,0).top,o=t.lineAt(i,J1.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 S0(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new q1(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>S0(e,t)):e._content)}var C0=hY.define({combine:e=>e.join(` `)}),w0=hY.define({combine:e=>e.indexOf(!0)>-1}),T0=AX.newName(),E0=AX.newName(),D0=AX.newName(),O0={"&light":`.`+E0,"&dark":`.`+D0};function k0(e,t,n){return new AX(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 A0=k0(`.`+T0,{"&":{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`}},O0),j0={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},M0=$X.ie&&$X.ie_version<=11,N0=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new AZ,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);($X.ie&&$X.ie_version<=11||$X.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&&$X.android&&e.constructor.EDIT_CONTEXT!==!1&&!($X.chrome&&$X.chrome_version<126)&&(this.editContext=new L0(e),e.state.facet(DQ)&&(e.contentDOM.editContext=this.editContext.editContext)),M0&&(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(DQ)?n.root.activeElement!=this.dom:!vZ(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}($X.ie&&$X.ie_version<=11||$X.android&&$X.chrome)&&!n.state.selection.main.empty&&r.focusNode&&bZ(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=gZ(e.root);if(!t)return!1;let n=$X.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&I0(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=vZ(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&LZ(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,j0),M0&&this.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),M0&&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&&FZ(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&&vZ(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 X$(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=Q$(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!i1(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=P0(t,e.previousSibling||e.target.previousSibling,-1),r=P0(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(DQ)!=e.state.facet(DQ)&&(e.view.contentDOM.editContext=e.state.facet(DQ)?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 P0(e,t,n){for(;t;){let r=KQ.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 F0(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 bZ(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function I0(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return F0(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?F0(e,n):null}var L0=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=t1(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=Y.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));i1(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:zJ.of(n.text.slice(l.from,l.toB).split(`
|
|
205
|
-
`))};if(($X.mac||$X.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:zJ.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);$$(e,u,Y.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(cZ.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:TQ.of(cZ.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=gZ(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])}},R0=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||IZ(e.parent)||document,this.viewState=new p0(this,e.state||iX.create(e)),e.scrollTo&&e.scrollTo.is(wQ)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(kQ).map(e=>new jQ(e));for(let e of this.plugins)e.update(this);this.observer=new N0(this),this.inputState=new a1(this),this.inputState.ensureHandlers(this.plugins),this.docView=new y$(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 WY?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(L1))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=R1(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(iX.phrases)!=this.state.facet(iX.phrases))return this.setState(a);i=WQ.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 CQ(t.empty?t:Y.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(wQ)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=V0.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(HQ)!=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(C0)!=i.state.facet(C0)&&(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(hQ))try{e(i)}catch(e){EQ(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!Q$(this,u)&&l.force&&FZ(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 p0(this,e),this.plugins=e.facet(kQ).map(e=>new jQ(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new y$(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(kQ),n=e.state.facet(kQ);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new jQ(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){EQ(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(RZ(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 EQ(this.state,e),B0}}),l=WQ.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]!=B0)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){EQ(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(hQ))e(t)}get themeClasses(){return T0+` `+(this.state.facet(w0)?D0:E0)+` `+this.state.facet(C0)}updateAttrs(){let e=H0(this,MQ,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(DQ)?`true`:`false`,class:`cm-content`,style:`${$X.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),H0(this,NQ,t);let n=this.observer.ignore(()=>{let n=iZ(this.contentDOM,this.contentAttrs,t),r=iZ(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(HQ);let t=this.state.facet(e.cspNonce);AX.mount(this.root,this.styleModules.concat(A0).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 V$(this,e,I$(this,e,t,n))}moveByGroup(e,t){return V$(this,e,I$(this,e,t,t=>L$(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return Y.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return F$(this,e,t,n)}moveVertically(e,t,n){return V$(this,e,R$(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=U$(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),U$(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[QZ.find(i,e-r.from,-1,t)];return TZ(n,a.dir==HZ.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(bQ)||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>z0)return sQ(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||$Z(r.isolates,n=zQ(this,e))))return r.order;n||=zQ(this,e);let r=oQ(e.text,t,n);return this.bidiCache.push(new V0(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||$X.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{MZ(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 wQ.of(new CQ(typeof e==`number`?Y.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return wQ.of(new CQ(Y.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return AQ.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return AQ.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=AX.newName(),r=[C0.of(n),HQ.of(k0(`.${n}`,e))];return t&&t.dark&&r.push(w0.of(!0)),r}static baseTheme(e){return TY.lowest(HQ.of(k0(`.`+T0,e,O0)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&KQ.get(t)||KQ.get(e))?.root?.view||null}};R0.styleModule=HQ,R0.inputHandler=gQ,R0.clipboardInputFilter=vQ,R0.clipboardOutputFilter=yQ,R0.scrollHandler=SQ,R0.focusChangeEffect=_Q,R0.perLineTextDirection=bQ,R0.exceptionSink=mQ,R0.updateListener=hQ,R0.editable=DQ,R0.mouseSelectionStyle=pQ,R0.dragMovesSelection=fQ,R0.clickAddsSelectionRange=dQ,R0.decorations=PQ,R0.blockWrappers=FQ,R0.outerDecorations=IQ,R0.atomicRanges=LQ,R0.bidiIsolatedRanges=RQ,R0.cursorScrollMargin=hY.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}}}),R0.scrollMargins=BQ,R0.darkTheme=w0,R0.cspNonce=hY.define({combine:e=>e.length?e[0]:``}),R0.contentAttributes=NQ,R0.editorAttributes=MQ,R0.lineWrapping=R0.contentAttributes.of({class:`cm-lineWrapping`}),R0.announce=UY.define();var z0=4096,B0={},V0=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:HZ.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 H0(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&&eZ(a,n)}return n}var U0=$X.mac?`mac`:$X.windows?`win`:$X.linux?`linux`:`key`;function W0(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 G0(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 K0=TY.default(R0.domEventHandlers({keydown(e,t){return t2(Y0(t.state),e,t,`editor`)}})),q0=hY.define({enables:K0}),J0=new WeakMap;function Y0(e){let t=e.facet(q0),n=J0.get(t);return n||J0.set(t,n=$0(t.reduce((e,t)=>e.concat(t),[]))),n}function X0(e,t,n){return t2(Y0(e.state),t,e,n)}var Z0=null,Q0=4e3;function $0(e,t=U0){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=>W0(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=Z0={view:t,prefix:n,scope:e};return setTimeout(()=>{Z0==r&&(Z0=null)},Q0),!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,e2))}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 e2=null;function t2(e,t,n,r){e2=t;let i=zX(t),a=tY($J(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;Z0&&Z0.view==n&&Z0.scope==r&&(o=Z0.prefix+` `,u1.indexOf(t.keyCode)<0&&(c=!0,Z0=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+G0(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!($X.windows&&t.ctrlKey&&t.altKey)&&!($X.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=NX[t.keyCode])&&p!=i?(d(f[o+G0(p,t,!0)])||t.shiftKey&&(m=PX[t.keyCode])!=i&&m!=p&&d(f[o+G0(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+G0(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),e2=null,s}var n2=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=r2(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return Cre(t,n,r)}};function r2(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==HZ.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function i2(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 Cre(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==HZ.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=r2(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=P$(e,r,1),m=P$(e,i,-1),h=p.type==sZ.Text?p:null,g=m.type==sZ.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=i2(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=i2(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==sZ.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new n2(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==HZ.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 a2(e,t){return e.constructor==t.constructor&&e.eq(t)}var o2=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(s2)!=e.state.facet(s2)&&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(s2);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)=>!a2(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,$X.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},s2=hY.define();function c2(e){return[AQ.define(t=>new o2(t,e)),s2.of(e)]}var l2=hY.define({combine(e){return aX(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function u2(e={}){return[l2.of(e),f2,m2,h2,xQ.of(!0)]}function d2(e){return e.startState.facet(l2)!=e.state.facet(l2)}var f2=c2({above:!0,markers(e){let{state:t}=e,n=t.facet(l2),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&$X.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:Y.cursor(i.head,i.assoc);for(let i of n2.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=d2(e);return n&&p2(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){p2(t.state,e)},class:`cm-cursorLayer`});function p2(e,t){t.style.animationDuration=e.facet(l2).cursorBlinkRate+`ms`}var m2=c2({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 n2.forRange(e,`cm-selectionBackground`,n))t.push(r);if($X.ios&&!n.empty&&e.state.facet(l2).iosSelectionHandles){for(let r of n2.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,Y.cursor(n.from,1)))t.push(r);for(let r of n2.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,Y.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||d2(e)},class:`cm-selectionLayer`}),h2=TY.highest(R0.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`}}}})),g2=UY.define({map(e,t){return e==null?null:t.mapPos(e)}}),_2=SY.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(g2)?t.value:e,e)}}),v2=AQ.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(_2);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(_2)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(_2),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(_2)!=e&&this.view.dispatch({effects:g2.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 y2(){return[_2,v2]}/x/.unicode;function b2(){return S2}var x2=cZ.line({class:`cm-activeLine`}),S2=AQ.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(x2.range(i.from)),t=i.from)}return cZ.set(n)}},{decorations:e=>e.decorations}),C2=2e3;function w2(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>C2||n.off>C2||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=s&&a.push(Y.range(n.from+o,n.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=TX(n.text,o,e.tabSize,!0);if(r<0)a.push(Y.cursor(n.to));else{let t=TX(n.text,s,e.tabSize);a.push(Y.range(n.from+r,n.from+t))}}}return a}function T2(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function E2(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>C2?-1:i==r.length?T2(e,t.clientX):wX(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function D2(e,t){let n=E2(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=E2(e,t);if(!o)return r;let s=w2(e.state,n,o);return s.length?a?Y.create(s.concat(r.ranges)):Y.create(s):r}}:null}function O2(e){let t=e?.eventFilter||(e=>e.altKey&&e.button==0);return R0.mouseSelectionStyle.of((e,n)=>t(n)?D2(e,n):null)}var k2={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},A2={style:`cursor: crosshair`};function j2(e={}){let[t,n]=k2[e.key||`Alt`],r=AQ.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,R0.contentAttributes.of(e=>e.plugin(r)?.isDown?A2:null)]}var M2=`-10000px`,N2=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 P2(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var F2=hY.define({combine:e=>({position:$X.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||P2})}),I2=new WeakMap,L2=AQ.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(F2);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 N2(e,V2,(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(F2);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=M2,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($X.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=VQ(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(F2).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=M2;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=I2.get(c)??d.bottom-d.top,g=c.offset||B2,_=this.view.textDirection==HZ.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=M2;continue}I2.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`,R2(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,R2(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=M2}},{eventObservers:{scroll(){this.maybeMeasure()}}});function R2(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var z2=R0.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`}}}),B2={x:0,y:0},V2=hY.define({enables:[L2,z2]});function H2(e,t){let n=e.plugin(L2);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var U2=hY.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function W2(e,t){let n=e.plugin(G2),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var G2=AQ.fromClass(class{constructor(e){this.input=e.state.facet(J2),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(U2);this.top=new K2(e,!0,t.topContainer),this.bottom=new K2(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(U2);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new K2(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new K2(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(J2);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=>R0.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),K2=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=q2(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=q2(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 q2(e){let t=e.nextSibling;return e.remove(),t}var J2=hY.define({enables:G2});function Y2(e,t){let n,r=new Promise(e=>n=e),i=e=>$2(e,t,n);e.state.field(X2,!1)?e.dispatch({effects:Z2.of(i)}):e.dispatch({effects:UY.appendConfig.of(X2.init(()=>[i]))});let a=Q2.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(X2).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var X2=SY.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(Z2)?e=[n.value].concat(e):n.is(Q2)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>J2.computeN([e],t=>t.field(e))}),Z2=UY.define(),Q2=UY.define();function $2(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=BX(`form`),t.input){let e=BX(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(BX(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(BX(`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=BX(`div`,r,BX(`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 e4=class extends oX{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};e4.prototype.elementClass=``,e4.prototype.toDOM=void 0,e4.prototype.mapMode=rY.TrackBefore,e4.prototype.startSide=e4.prototype.endSide=-1,e4.prototype.point=!0;var t4=hY.define(),n4=hY.define(),r4={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>dX.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},i4=hY.define();function a4(e){return[s4(),i4.of({...r4,...e})]}var o4=hY.define({combine:e=>e.some(e=>e)});function s4(e){let t=[c4];return e&&e.fixed===!1&&t.push(o4.of(!0)),t}var c4=AQ.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(i4).map(t=>new f4(e,t)),this.fixed=!e.state.facet(o4);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(o4)!=!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=dX.iter(this.view.state.facet(t4),this.view.viewport.from),r=[],i=this.gutters.map(e=>new d4(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==sZ.Text&&t){u4(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==sZ.Text){u4(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(i4),n=e.state.facet(i4),r=e.docChanged||e.heightChanged||e.viewportChanged||!dX.eq(e.startState.facet(t4),e.state.facet(t4),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 f4(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=>R0.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==HZ.LTR?{left:r,right:i}:{right:r,left:i}})});function l4(e){return Array.isArray(e)?e:[e]}function u4(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var d4=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=dX.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 p4(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=[];u4(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(n4)){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()}}},f4=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=l4(t.markers(e)),t.initialSpacer&&(this.spacer=new p4(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=l4(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!dX.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()}},p4=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`:``),m4(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 m4(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 h4=hY.define(),g4=hY.define(),_4=hY.define({combine(e){return aX(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}})}}),v4=class extends e4{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function y4(e,t){return e.state.facet(_4).formatNumber(t,e.state)}var b4=i4.compute([_4],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(h4)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new v4(y4(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(g4)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(_4)!=e.state.facet(_4),initialSpacer(e){return new v4(y4(e,S4(e.state.doc.lines)))},updateSpacer(e,t){let n=y4(t.view,S4(t.view.state.doc.lines));return n==e.number?e:new v4(n)},domEventHandlers:e.facet(_4).domEventHandlers,side:`before`}));function x4(e={}){return[_4.of(e),s4(),b4]}function S4(e){let t=9;for(;t<e;)t=t*10+9;return t}var C4=new class extends e4{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},w4=t4.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(C4.range(i)))}return dX.of(t)});function T4(){return w4}var E4=1024,D4=0,O4=class{constructor(e,t){this.from=e,this.to=t}},k4=class{constructor(e={}){this.id=D4++,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=M4.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};k4.closedBy=new k4({deserialize:e=>e.split(` `)}),k4.openedBy=new k4({deserialize:e=>e.split(` `)}),k4.group=new k4({deserialize:e=>e.split(` `)}),k4.isolate=new k4({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),k4.contextHash=new k4({perNode:!0}),k4.lookAhead=new k4({perNode:!0}),k4.mounted=new k4({perNode:!0});var A4=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[k4.mounted.id]}},j4=Object.create(null),M4=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):j4,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(k4.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(k4.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};M4.none=new M4(``,Object.create(null),0,8);var N4=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 M4(e.name,r,e.id,e.flags):e)}return new e(n)}},P4=new WeakMap,F4=new WeakMap,I4;(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`})(I4||={});var L4=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=A4.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 Z4(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new Z4(P4.get(this)||this.topNode);return r.moveTo(e,t),P4.set(this,r._tree),r}get topNode(){return new U4(this,0,0,null)}resolve(e,t=0){let n=V4(P4.get(this)||this.topNode,e,t,!1);return P4.set(this,n),n}resolveInner(e,t=0){let n=V4(F4.get(this)||this.topNode,e,t,!0);return F4.set(this,n),n}resolveStack(e,t=0){return X4(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&I4.IncludeAnonymous)>0;for(let e=this.cursor(a|I4.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:n3(M4.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(M4.none,t,n,r)))}static build(e){return $4(e)}};L4.empty=new L4(M4.none,[],[],0);var R4=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)}},z4=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return M4.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&&!(B4(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 B4(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 V4(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 U4&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:I4.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof U4&&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 H4=class{cursor(e=0){return new Z4(this,e)}getChild(e,t=null,n=null){let r=W4(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return W4(this,e,t,n)}resolve(e,t=0){return V4(this,e,t,!1)}resolveInner(e,t=0){return V4(this,e,t,!0)}matchContext(e){return G4(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}},U4=class e extends H4{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&I4.EnterBracketed&&l instanceof L4&&(d=A4.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!B4(i,r,u,u+l.length))){if(l instanceof z4){if(a&I4.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new q4(new K4(o,l,t,u),null,e)}else if(a&I4.IncludeAnonymous||!l.type.isAnonymous||Q4(l)){let s;if(!(a&I4.IgnoreMounts)&&(s=A4.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&I4.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&I4.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&I4.IgnoreOverlays)&&(i=A4.get(this._tree))&&i.overlay){let a=t-this.from,o=r&I4.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 W4(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 G4(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 K4=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},q4=class e extends H4{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&I4.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 L4(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function J4(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 U4&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new Y4(i,n)}var Y4=class{constructor(e,t){this.heads=e,this.node=t}get next(){return J4(this.heads)}};function X4(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof U4?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=A4.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new U4(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(V4(o,t,n,!1))}}return i?J4(i):r}var Z4=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&~I4.EnterBracketed,e instanceof U4)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 U4?(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&I4.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&I4.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&I4.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&I4.IncludeAnonymous||e instanceof z4||!e.type.isAnonymous||Q4(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 q4(this.buffer,t,this.stack[e]);return this.bufferNode=new q4(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 G4(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 G4(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 Q4(e){return e.children.some(e=>e instanceof z4||!e.type.isAnonymous||Q4(e))}function $4(e){let{buffer:t,nodeSet:n,maxBufferLength:r=E4,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new R4(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,ne=l,re=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 C=s[x],w,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);w=new z4(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,ne,re),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,ne,re),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(C,re);w=n3(C,t,n,0,t.length,0,te-ee,e,e)}else w=m(C,t,n,te-ee,ne-te,re)}_.push(w),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 z4(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 L4){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(k4.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=[k4.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[k4.lookAhead,i];o=o?[e].concat(o):[e]}return new L4(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 L4(s[e.topID],_.reverse(),v.reverse(),y)}var e3=new WeakMap;function t3(e,t){if(!e.isAnonymous||t instanceof z4||t.type!=e)return 1;let n=e3.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof L4)){n=1;break}n+=t3(e,r)}e3.set(t,n)}return n}function n3(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=t3(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=t3(e,t[s]);for(s++;s<i;s++){let n=t3(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(n3(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 r3=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 q4?this.setBuffer(e.context.buffer,e.index,t):e instanceof U4&&this.map.set(e.tree,t)}get(e){return e instanceof q4?this.getBuffer(e.context.buffer,e.index):e instanceof U4?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)}},i3=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}},a3=class{startParse(e,t,n){return typeof e==`string`&&(e=new o3(e)),n=n?n.length?n.map(e=>new O4(e.from,e.to)):[new O4(0,0)]:[new O4(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}}},o3=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 s3(e){return(t,n,r,i)=>new f3(t,e,n,r,i)}var c3=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 l3(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var u3=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=[]}},d3=new k4({perNode:!0}),f3=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 L4(e.type,e.children,e.positions,e.length,e.propValues.concat([[d3,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[k4.mounted.id]=new A4(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 _3(this.fragments),t=null,n=null,r=new Z4(new U4(this.baseTree,this.ranges[0].from,0,null),I4.IncludeAnonymous|I4.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=p3(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||(h3(r),t&&t.depth++,n&&n.depth++);let a=e.findMounts(r.from,i.parser);if(typeof i.overlay==`function`)t=new u3(i.parser,i.overlay,a,this.inner.length,r.from,!!i.bracketed,r.tree,t);else{let e=v3(this.ranges,i.overlay||(r.from<r.to?[new O4(r.from,r.to)]:[]));e.length&&l3(e),(e.length||!i.overlay)&&this.inner.push(new c3(i.parser,e.length?i.parser.startParse(this.input,b3(a,e),e):i.parser.startParse(``),i.overlay?i.overlay.map(e=>new O4(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 O4(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=v3(this.ranges,t.ranges);e.length&&(l3(e),this.inner.splice(t.index,0,new c3(t.parser,t.parser.startParse(this.input,b3(t.mounts,e),e),t.ranges.map(e=>new O4(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 p3(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 m3(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 h3(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=[];m3(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),m3(o,s[f+3],r,p,m,a),new L4(i,p,m,u)}i.children[a]=l(0,s.length,M4.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 U4(n,r+e.from,t,e._tree))}}var g3=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(I4.IncludeAnonymous|I4.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,I4.IgnoreOverlays|I4.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 L4)t=t.children[0];else break}return!1}},_3=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(d3)??t.to,this.inner=new g3(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(d3)??e.to,this.inner=new g3(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(k4.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 v3(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 O4(e.from,o),e.to>s&&n.splice(a+1,0,new O4(s,e.to))):e.to>s?n[a--]=new O4(s,e.to):n.splice(a--,1))}}return r}function y3(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 O4(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 b3(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=y3(t,i.overlay.map(e=>new O4(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 i3(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 i3(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}var x3=0,S3=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=x3++}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 w3(e);return e=>e.modified.indexOf(t)>-1?e:w3.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},C3=0,w3=class e{constructor(e){this.name=e,this.instances=[],this.id=C3++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&T3(n,e.modified));if(r)return r;let i=[],a=new S3(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=E3(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 T3(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function E3(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 D3(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 k3(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return O3.add(t)}var O3=new k4({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 k3(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),k3=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}};k3.empty=new k3([],2,null);function A3(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 j3(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function M3(e,t,n,r=0,i=e.length){let a=new N3(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var N3=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=P3(e)||k3.empty,u=j3(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(k4.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 P3(e){let t=e.type.prop(O3);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var X=S3.define,F3=X(),I3=X(),L3=X(I3),R3=X(I3),z3=X(),B3=X(z3),V3=X(z3),H3=X(),U3=X(H3),W3=X(),G3=X(),K3=X(),q3=X(K3),J3=X(),Z={comment:F3,lineComment:X(F3),blockComment:X(F3),docComment:X(F3),name:I3,variableName:X(I3),typeName:L3,tagName:X(L3),propertyName:R3,attributeName:X(R3),className:X(I3),labelName:X(I3),namespace:X(I3),macroName:X(I3),literal:z3,string:B3,docString:X(B3),character:X(B3),attributeValue:X(B3),number:V3,integer:X(V3),float:X(V3),bool:X(z3),regexp:X(z3),escape:X(z3),color:X(z3),url:X(z3),keyword:W3,self:X(W3),null:X(W3),atom:X(W3),unit:X(W3),modifier:X(W3),operatorKeyword:X(W3),controlKeyword:X(W3),definitionKeyword:X(W3),moduleKeyword:X(W3),operator:G3,derefOperator:X(G3),arithmeticOperator:X(G3),logicOperator:X(G3),bitwiseOperator:X(G3),compareOperator:X(G3),updateOperator:X(G3),definitionOperator:X(G3),typeOperator:X(G3),controlOperator:X(G3),punctuation:K3,separator:X(K3),bracket:q3,angleBracket:X(q3),squareBracket:X(q3),paren:X(q3),brace:X(q3),content:H3,heading:U3,heading1:X(U3),heading2:X(U3),heading3:X(U3),heading4:X(U3),heading5:X(U3),heading6:X(U3),contentSeparator:X(H3),list:X(H3),quote:X(H3),emphasis:X(H3),strong:X(H3),link:X(H3),monospace:X(H3),strikethrough:X(H3),inserted:X(),deleted:X(),changed:X(),invalid:X(),meta:J3,documentMeta:X(J3),annotation:X(J3),processingInstruction:X(J3),definition:S3.defineModifier(`definition`),constant:S3.defineModifier(`constant`),function:S3.defineModifier(`function`),standard:S3.defineModifier(`standard`),local:S3.defineModifier(`local`),special:S3.defineModifier(`special`)};for(let e in Z){let t=Z[e];t instanceof S3&&(t.name=e)}A3([{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 Y3=new k4;function X3(e){return hY.define({combine:e?t=>t.concat(e):void 0})}var Z3=new k4,Q3=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,iX.prototype.hasOwnProperty(`tree`)||Object.defineProperty(iX.prototype,"tree",{get(){return t6(this)}}),this.parser=t,this.extension=[u6.of(this),iX.languageData.of((e,t,n)=>{let r=$3(e,t,n),i=r.type.prop(Y3);if(!i)return[];let a=e.facet(i),o=r.type.prop(Z3);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 $3(e,t,n).type.prop(Y3)==this.data}findRegions(e){let t=e.facet(u6);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(Y3)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(k4.mounted);if(i){if(i.tree.prop(Y3)==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 L4&&r(i,e.positions[n]+t)}};return r(t6(e),0),n}get allowsNesting(){return!0}};Q3.setState=UY.define();function $3(e,t,n){let r=e.facet(u6),i=t6(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,I4.ExcludeBuffers|I4.EnterBracketed))e.type.isTop&&(i=e);return i}var e6=class e extends Q3{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=X3(t.languageData);return new e(n,t.parser.configure({props:[Y3.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 t6(e){let t=e.field(Q3.state,!1);return t?t.tree:L4.empty}var n6=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)}},r6=null,i6=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,[],L4.empty,0,r,[],null)}startParse(){return this.parser.startParse(new n6(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=L4.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(i3.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(i3.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=r6;r6=this;try{return e()}finally{r6=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=a6(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=i3.applyChanges(r,e),i=L4.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=a6(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 a3{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=r6;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 L4(M4.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 r6}};function a6(e,t,n){return i3.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var o6=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=i6.create(t.facet(u6).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};Q3.state=SY.define({create:o6.init,update(e,t){for(let e of t.effects)if(e.is(Q3.setState))return e.value;return t.startState.facet(u6)==t.state.facet(u6)?e.apply(t):o6.init(t.state)}});var s6=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(s6=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var c6=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,l6=AQ.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(Q3.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(Q3.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=s6(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(Q3.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!c6?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>c6&&c6()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Q3.setState.of(new o6(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=>EQ(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),u6=hY.define({combine(e){return e.length?e[0]:null},enables:e=>[Q3.state,l6,R0.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),d6=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}},f6=hY.define(),p6=hY.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 m6(e){let t=e.facet(p6);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function h6(e,t){let n=``,r=e.tabSize,i=e.facet(p6)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function g6(e,t){e instanceof iX&&(e=new _6(e));for(let n of e.state.facet(f6)){let r=n(e,t);if(r!==void 0)return r}let n=t6(e.state);return n.length>=t?y6(e,n,t):null}var _6=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=m6(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 wX(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}},v6=new k4;function y6(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 b6(r,e,n)}function b6(e,t,n){for(let r=e;r;r=r.next){let e=S6(r.node);if(e)return e(w6.create(t,n,r))}return 0}function x6(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function S6(e){let t=e.type.prop(v6);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(k4.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>O6(e,!0,1,void 0,n&&!x6(e)?t.from:void 0)}return e.parent==null?C6:null}function C6(){return 0}var w6=class e extends _6{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(T6(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return b6(this.context.next,this.base,this.pos)}};function T6(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function E6(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 D6({closing:e,align:t=!0,units:n=1}){return r=>O6(r,t,n,e)}function O6(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?E6(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var k6=e=>e.baseIndent;function A6({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var j6=200;function M6(){return iX.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+j6)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=g6(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=h6(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 N6=hY.define(),P6=new k4;function F6(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 I6(e,t,n){let r=t6(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(P6);if(s&&(i.to<r.length-50||r.length==e.doc.length||!L6(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function L6(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function R6(e,t,n){for(let r of e.facet(N6)){let i=r(e,t,n);if(i)return i}return I6(e,t,n)}function z6(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 B6=UY.define({map:z6}),V6=UY.define({map:z6});function H6(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 U6=SY.define({create(){return cZ.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=W6(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(B6)&&!K6(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet($6),i=r?cZ.replace({widget:new r8(r(t.state,n.value))}):n8;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(V6)&&(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=W6(e,t.selection.main.head)),e},provide:e=>R0.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(n8.range(r,i))}return cZ.set(t,!0)}});function W6(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 G6(e,t,n){var r;let i=null;return(r=e.field(U6,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function K6(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function q6(e,t){return e.field(U6,!1)?t:t.concat(UY.appendConfig.of(e8()))}var J6=e=>{for(let t of H6(e)){let n=R6(e.state,t.from,t.to);if(n)return e.dispatch({effects:q6(e.state,[B6.of(n),X6(e,n)])}),!0}return!1},Y6=e=>{if(!e.state.field(U6,!1))return!1;let t=[];for(let n of H6(e)){let r=G6(e.state,n.from,n.to);r&&t.push(V6.of(r),X6(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function X6(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return R0.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var Z6=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:J6},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:Y6},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=R6(t,i.from,i.to);a&&n.push(B6.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:q6(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(U6,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(V6.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],Q6={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},$6=hY.define({combine(e){return aX(e,Q6)}});function e8(e){let t=[U6,s8];return e&&t.push($6.of(e)),t}function t8(e,t){let{state:n}=e,r=n.facet($6),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=G6(e.state,n.from,n.to);r&&e.dispatch({effects:V6.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 n8=cZ.replace({widget:new class extends oZ{toDOM(e){return t8(e,null)}}}),r8=class extends oZ{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return t8(e,this.value)}},i8={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},a8=class extends e4{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 o8(e={}){let t={...i8,...e},n=new a8(t,!0),r=new a8(t,!1),i=AQ.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(u6)!=e.state.facet(u6)||e.startState.field(U6,!1)!=e.state.field(U6,!1)||t6(e.startState)!=t6(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new pX;for(let i of e.viewportLineBlocks){let a=G6(e.state,i.from,i.to)?r:R6(e.state,i.from,i.to)?n:null;a&&t.add(i.from,i.from,a)}return t.finish()}}),{domEventHandlers:a}=t;return[i,a4({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||dX.empty},initialSpacer(){return new a8(t,!1)},domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let r=G6(e.state,t.from,t.to);if(r)return e.dispatch({effects:V6.of(r)}),!0;let i=R6(e.state,t.from,t.to);return i?(e.dispatch({effects:B6.of(i)}),!0):!1}}}),e8()]}var s8=R0.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`}}),c8=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=AX.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 Q3?e=>e.prop(Y3)==a.data:a?e=>e==a:void 0,this.style=A3(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new AX(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},l8=hY.define(),u8=hY.define({combine(e){return e.length?[e[0]]:null}});function d8(e){let t=e.facet(l8);return t.length?t:e.facet(u8)}function f8(e,t){let n=[m8],r;return e instanceof c8&&(e.module&&n.push(R0.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(u8.of(e)):r?n.push(l8.computeN([R0.darkTheme],t=>t.facet(R0.darkTheme)==(r==`dark`)?[e]:[])):n.push(l8.of(e)),n}var p8=class{constructor(e){this.markCache=Object.create(null),this.tree=t6(e.state),this.decorations=this.buildDeco(e,d8(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=t6(e.state),n=d8(e.state),r=n!=d8(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 cZ.none;let n=new pX;for(let{from:r,to:i}of e.visibleRanges)M3(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=cZ.mark({class:r})))},r,i);return n.finish()}},m8=TY.high(AQ.fromClass(p8,{decorations:e=>e.decorations})),h8=c8.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`}]),g8=R0.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),_8=1e4,v8=`()[]{}`,y8=hY.define({combine(e){return aX(e,{afterCursor:!0,brackets:v8,maxScanDistance:_8,renderMatch:S8})}}),b8=cZ.mark({class:`cm-matchingBracket`}),x8=cZ.mark({class:`cm-nonmatchingBracket`});function S8(e){let t=[],n=e.matched?b8:x8;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 C8(e){let t=[],n=e.facet(y8);for(let r of e.selection.ranges){if(!r.empty)continue;let i=k8(e,r.head,-1,n)||r.head>0&&k8(e,r.head-1,1,n)||n.afterCursor&&(k8(e,r.head,1,n)||r.head<e.doc.length&&k8(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return cZ.set(t,!0)}var w8=[AQ.fromClass(class{constructor(e){this.paused=!1,this.decorations=C8(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=C8(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),g8];function T8(e={}){return[y8.of(e),w8]}var E8=new k4;function D8(e,t,n){let r=e.prop(t<0?k4.openedBy:k4.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 O8(e){let t=e.type.prop(E8);return t?t(e.node):e}function k8(e,t,n,r={}){let i=r.maxScanDistance||_8,a=r.brackets||v8,o=t6(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=D8(r.type,n,a);if(i&&r.from<r.to){let o=O8(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return A8(e,t,n,r,o,i,a)}}return j8(e,t,n,o,s.type,i,a)}function A8(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=O8(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(D8(u.type,n,o))l++;else if(D8(u.type,-n,o)){if(l==0){let e=O8(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 j8(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 M8(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 N8=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=M8(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??M8(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 wre(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||Tre,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||R8,mergeTokens:e.mergeTokens!==!1}}function Tre(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 P8=new WeakMap,Ere=class e extends Q3{constructor(e){let t=X3(e.languageData),n=wre(e),r,i=new class extends a3{createParse(e,t,n){return new Ore(r,e,t,n)}};super(t,i,[],e.name),this.topNode=jre(t,this),r=this,this.streamParser=n,this.stateAfter=new k4({perNode:!0}),this.tokenTable=e.tokenTable?new U8(n.tokenTable):Are}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=P8.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=F8(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 N8(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)L8(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&&P8.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function F8(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 L4&&s<i&&F8(e,o,s,r,i);if(c)return c}return null}function I8(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 L4){if(!(c=I8(e,s,n-o,r-o,i)))break;return i?new L4(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function Dre(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&&F8(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=I8(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?m6(i):4),tree:L4.empty}}var Ore=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=i6.get(),a=r[0].from,{state:o,tree:s}=Dre(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(m6(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=i6.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==`
|
|
206
|
-
`&&(t=``);else{let e=t.indexOf(`
|
|
207
|
-
`);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 N8(t,e?e.state.tabSize:4,e?m6(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=L8(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=L4.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:kre,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new L4(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 L4(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function L8(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 R8=Object.create(null),z8=[M4.none],kre=new N4(z8),B8=[],V8=Object.create(null),H8=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`]])H8[e]=G8(R8,t);var U8=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),H8)}resolve(e){return e?this.table[e]||(this.table[e]=G8(this.extra,e)):0}},Are=new U8(R8);function W8(e,t){B8.indexOf(e)>-1||(B8.push(e),console.warn(t))}function G8(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):W8(n,`Modifier ${n} used at start of tag`):t.length?W8(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:W8(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=V8[i];if(a)return a.id;let o=V8[i]=M4.define({id:z8.length,name:r,props:[D3({[r]:n})]});return z8.push(o),o.id}function jre(e,t){let n=M4.define({id:z8.length,name:`Document`,props:[Y3.add(()=>e),v6.add(()=>e=>t.getIndent(e))],top:!0});return z8.push(n),n}HZ.RTL,HZ.LTR;var Mre=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=q8(e.state,n.from);return r.line?Nre(e):r.block?Fre(e):!1};function K8(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 Nre=K8(Rre,0),Pre=K8(Y8,0),Fre=K8((e,t)=>Y8(e,t,Lre(t)),0);function q8(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var J8=50;function Ire(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-J8,r),o=e.sliceDoc(i,i+J8),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*J8?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+J8),d=e.sliceDoc(i-J8,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 Lre(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 Y8(e,t,n=t.selection.ranges){let r=n.map(e=>q8(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Ire(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 Rre(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=q8(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 X8=BY.define(),zre=BY.define(),Bre=hY.define(),Z8=hY.define({combine(e){return aX(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)})}}),Q8=SY.define({create(){return c5.empty},update(e,t){let n=t.state.facet(Z8),r=t.annotation(X8);if(r){let i=n5.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?r5(o,o.length,n.minDepth,i):o5(o,t.startState.selection),new c5(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(zre);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(WY.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=n5.fromTransaction(t),o=t.annotation(WY.time),s=t.annotation(WY.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 c5(e.done.map(n5.fromJSON),e.undone.map(n5.fromJSON))}});function Vre(e={}){return[Q8,Z8.of(e),R0.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?e5:e.inputType==`historyRedo`?t5:null;return n?(e.preventDefault(),n(t)):!1}})]}function $8(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(Q8,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var e5=$8(0,!1),t5=$8(1,!1),Hre=$8(0,!0),Ure=$8(1,!0),n5=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&&aY.fromJSON(t.changes),[],t.mapped&&iY.fromJSON(t.mapped),t.startSelection&&Y.fromJSON(t.startSelection),t.selectionsAfter.map(Y.fromJSON))}static fromTransaction(t,n){let r=a5;for(let e of t.startState.facet(Bre)){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,a5)}static selection(t){return new e(void 0,a5,void 0,void 0,t)}};function r5(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 Wre(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 Gre(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function i5(e,t){return e.length?t.length?e.concat(t):e:t}var a5=[],Kre=200;function o5(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Kre));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),r5(e,e.length-1,1e9,n.setSelAfter(r)))}else return[n5.selection([t])]}function qre(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 s5(e,t){if(!e.length)return e;let n=e.length,r=a5;for(;n;){let i=Jre(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?[n5.selection(r)]:a5}function Jre(e,t,n){let r=i5(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):a5,n);if(!e.changes)return n5.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new n5(i,UY.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Yre=/^(input\.type|delete)($|\.)/,c5=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||Yre.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Wre(s.changes,t.changes))||r==`input.type.compose`)?r5(o,o.length-1,i.minDepth,new n5(t.changes.compose(s.changes),i5(UY.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,a5)):r5(o,o.length,i.minDepth,t),new e(o,a5,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:a5;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Gre(a[a.length-1],t)?this:new e(o5(this.done,t),this.undone,n,r)}addMapping(t){return new e(s5(this.done,t),s5(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:X8.of({side:e,rest:qre(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?a5:r.slice(0,r.length-1);return i.mapped&&(n=s5(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:X8.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};c5.empty=new c5(a5,a5);var Xre=[{key:`Mod-z`,run:e5,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:t5,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:t5,preventDefault:!0},{key:`Mod-u`,run:Hre,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Ure,preventDefault:!0}];function l5(e,t){return Y.create(e.ranges.map(t),e.mainIndex)}function u5(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function d5({state:e,dispatch:t},n){let r=l5(e.selection,n);return r.eq(e.selection,!0)?!1:(t(u5(e,r)),!0)}function f5(e,t){return Y.cursor(t?e.to:e.from)}function p5(e,t){return d5(e,n=>n.empty?e.moveByChar(n,t):f5(n,t))}function m5(e){return e.textDirectionAt(e.state.selection.main.head)==HZ.LTR}var h5=e=>p5(e,!m5(e)),g5=e=>p5(e,m5(e));function _5(e,t){return d5(e,n=>n.empty?e.moveByGroup(n,t):f5(n,t))}var Zre=e=>_5(e,!m5(e)),Qre=e=>_5(e,m5(e));typeof Intl<`u`&&Intl.Segmenter;function $re(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 v5(e,t,n){let r=t6(e).resolveInner(t.head),i=n?k4.closedBy:k4.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;$re(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?k8(e,r.from,1):k8(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,Y.cursor(s,n?-1:1)}var eie=e=>d5(e,t=>v5(e.state,t,!m5(e))),tie=e=>d5(e,t=>v5(e.state,t,m5(e)));function y5(e,t){return d5(e,n=>{if(!n.empty)return f5(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var b5=e=>y5(e,!1),x5=e=>y5(e,!0);function S5(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(R0.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 C5(e,t){let n=S5(e),{state:r}=e,i=l5(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):f5(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=R0.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(u5(r,i),{effects:a}),!0}var w5=e=>C5(e,!1),T5=e=>C5(e,!0);function E5(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=Y.cursor(r.from+n))}return i}var nie=e=>d5(e,t=>E5(e,t,!0)),rie=e=>d5(e,t=>E5(e,t,!1)),iie=e=>d5(e,t=>E5(e,t,!m5(e))),aie=e=>d5(e,t=>E5(e,t,m5(e))),oie=e=>d5(e,t=>Y.cursor(e.lineBlockAt(t.head).from,1)),sie=e=>d5(e,t=>Y.cursor(e.lineBlockAt(t.head).to,-1));function cie(e,t,n){let r=!1,i=l5(e.selection,t=>{let i=k8(e,t.head,-1)||k8(e,t.head,1)||t.head>0&&k8(e,t.head-1,1)||t.head<e.doc.length&&k8(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?Y.range(t.anchor,a):Y.cursor(a)});return r?(t(u5(e,i)),!0):!1}var lie=({state:e,dispatch:t})=>cie(e,t,!1);function D5(e,t){let n=l5(e.state.selection,e=>{let n=t(e);return Y.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(u5(e.state,n)),!0)}function O5(e,t){return D5(e,n=>e.moveByChar(n,t))}var k5=e=>O5(e,!m5(e)),A5=e=>O5(e,m5(e));function j5(e,t){return D5(e,n=>e.moveByGroup(n,t))}var uie=e=>j5(e,!m5(e)),die=e=>j5(e,m5(e)),fie=e=>D5(e,t=>v5(e.state,t,!m5(e))),pie=e=>D5(e,t=>v5(e.state,t,m5(e)));function M5(e,t){return D5(e,n=>e.moveVertically(n,t))}var N5=e=>M5(e,!1),P5=e=>M5(e,!0);function F5(e,t){return D5(e,n=>e.moveVertically(n,t,S5(e).height))}var I5=e=>F5(e,!1),L5=e=>F5(e,!0),mie=e=>D5(e,t=>E5(e,t,!0)),hie=e=>D5(e,t=>E5(e,t,!1)),gie=e=>D5(e,t=>E5(e,t,!m5(e))),_ie=e=>D5(e,t=>E5(e,t,m5(e))),vie=e=>D5(e,t=>Y.cursor(e.lineBlockAt(t.head).from)),yie=e=>D5(e,t=>Y.cursor(e.lineBlockAt(t.head).to)),R5=({state:e,dispatch:t})=>(t(u5(e,{anchor:0})),!0),z5=({state:e,dispatch:t})=>(t(u5(e,{anchor:e.doc.length})),!0),B5=({state:e,dispatch:t})=>(t(u5(e,{anchor:e.selection.main.anchor,head:0})),!0),V5=({state:e,dispatch:t})=>(t(u5(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),bie=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),xie=({state:e,dispatch:t})=>{let n=X5(e).map(({from:t,to:n})=>Y.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:Y.create(n),userEvent:`select`})),!0},Sie=({state:e,dispatch:t})=>{let n=l5(e.selection,t=>{let n=t6(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return Y.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(u5(e,n)),!0)};function H5(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(u5(n,Y.create(i,i.length-1))),!0)}var Cie=e=>H5(e,!1),wie=e=>H5(e,!0),Tie=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=Y.create([n.main]):n.main.empty||(r=Y.create([Y.cursor(n.main.head)])),r?(t(u5(e,r)),!0):!1};function U5(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=W5(e,o,!1)):o>i&&(n=`delete.forward`,o=W5(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=W5(e,i,!1),a=W5(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:Y.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?R0.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function W5(e,t,n){if(e instanceof R0)for(let r of e.state.facet(R0.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var G5=(e,t,n)=>U5(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=wX(s,a.tabSize)%m6(a)||m6(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=XJ(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=XJ(o.text,c-o.from,!1,!1)+o.from);return c}),K5=e=>G5(e,!1,!0),q5=e=>G5(e,!0,!1),J5=(e,t)=>U5(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=XJ(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}),Y5=e=>J5(e,!1),Eie=e=>J5(e,!0),Die=e=>U5(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Oie=e=>U5(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),kie=e=>U5(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Aie=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:zJ.of([``,``])},range:Y.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},jie=({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:XJ(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:XJ(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:Y.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function X5(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 Z5(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of X5(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(Y.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(Y.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:Y.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Mie=({state:e,dispatch:t})=>Z5(e,t,!1),Nie=({state:e,dispatch:t})=>Z5(e,t,!0);function Q5(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of X5(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 Pie=({state:e,dispatch:t})=>Q5(e,t,!1),Fie=({state:e,dispatch:t})=>Q5(e,t,!0),Iie=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(X5(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=l5(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 Lie(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=t6(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(k4.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 $5=e7(!1),Rie=e7(!0);function e7(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&&Lie(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new _6(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=g6(s,r);for(c??=wX(/^\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=[``,h6(t,c)];return o&&l.push(h6(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:zJ.of(l)},range:Y.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function t7(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:Y.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var zie=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new _6(e,{overrideIndentation:e=>n[e]??-1}),i=t7(e,(t,i,a)=>{let o=g6(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=h6(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},n7=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(t7(e,(t,n)=>{n.push({from:t.from,insert:e.facet(p6)})}),{userEvent:`input.indent`})),!0),r7=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(t7(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=wX(r,e.tabSize),a=0,o=h6(e,Math.max(0,i-m6(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),Bie=e=>(e.setTabFocusMode(),!0),Vie=[{key:`Ctrl-b`,run:h5,shift:k5,preventDefault:!0},{key:`Ctrl-f`,run:g5,shift:A5},{key:`Ctrl-p`,run:b5,shift:N5},{key:`Ctrl-n`,run:x5,shift:P5},{key:`Ctrl-a`,run:oie,shift:vie},{key:`Ctrl-e`,run:sie,shift:yie},{key:`Ctrl-d`,run:q5},{key:`Ctrl-h`,run:K5},{key:`Ctrl-k`,run:Die},{key:`Ctrl-Alt-h`,run:Y5},{key:`Ctrl-o`,run:Aie},{key:`Ctrl-t`,run:jie},{key:`Ctrl-v`,run:T5}],Hie=[{key:`ArrowLeft`,run:h5,shift:k5,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Zre,shift:uie,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:iie,shift:gie,preventDefault:!0},{key:`ArrowRight`,run:g5,shift:A5,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Qre,shift:die,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:aie,shift:_ie,preventDefault:!0},{key:`ArrowUp`,run:b5,shift:N5,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:R5,shift:B5},{mac:`Ctrl-ArrowUp`,run:w5,shift:I5},{key:`ArrowDown`,run:x5,shift:P5,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:z5,shift:V5},{mac:`Ctrl-ArrowDown`,run:T5,shift:L5},{key:`PageUp`,run:w5,shift:I5},{key:`PageDown`,run:T5,shift:L5},{key:`Home`,run:rie,shift:hie,preventDefault:!0},{key:`Mod-Home`,run:R5,shift:B5},{key:`End`,run:nie,shift:mie,preventDefault:!0},{key:`Mod-End`,run:z5,shift:V5},{key:`Enter`,run:$5,shift:$5},{key:`Mod-a`,run:bie},{key:`Backspace`,run:K5,shift:K5,preventDefault:!0},{key:`Delete`,run:q5,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Y5,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Eie,preventDefault:!0},{mac:`Mod-Backspace`,run:Oie,preventDefault:!0},{mac:`Mod-Delete`,run:kie,preventDefault:!0}].concat(Vie.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Uie=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:eie,shift:fie},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:tie,shift:pie},{key:`Alt-ArrowUp`,run:Mie},{key:`Shift-Alt-ArrowUp`,run:Pie},{key:`Alt-ArrowDown`,run:Nie},{key:`Shift-Alt-ArrowDown`,run:Fie},{key:`Mod-Alt-ArrowUp`,run:Cie},{key:`Mod-Alt-ArrowDown`,run:wie},{key:`Escape`,run:Tie},{key:`Mod-Enter`,run:Rie},{key:`Alt-l`,mac:`Ctrl-l`,run:xie},{key:`Mod-i`,run:Sie,preventDefault:!0},{key:`Mod-[`,run:r7},{key:`Mod-]`,run:n7},{key:`Mod-Alt-\\`,run:zie},{key:`Shift-Mod-k`,run:Iie},{key:`Shift-Mod-\\`,run:lie},{key:`Mod-/`,run:Mre},{key:`Alt-A`,run:Pre},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Bie}].concat(Hie),Wie={key:`Tab`,run:n7,shift:r7},Gie=`#e5c07b`,i7=`#e06c75`,Kie=`#56b6c2`,qie=`#ffffff`,a7=`#abb2bf`,o7=`#7d8799`,Jie=`#61afef`,Yie=`#98c379`,s7=`#d19a66`,Xie=`#c678dd`,Zie=`#21252b`,c7=`#2c313a`,l7=`#282c34`,u7=`#353a42`,Qie=`#3E4451`,d7=`#528bff`,f7=[R0.theme({"&":{color:a7,backgroundColor:l7},".cm-content":{caretColor:d7},".cm-cursor, .cm-dropCursor":{borderLeftColor:d7},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Qie},".cm-panels":{backgroundColor:Zie,color:a7},".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:l7,color:o7,border:`none`},".cm-activeLineGutter":{backgroundColor:c7},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:u7},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:u7,borderBottomColor:u7},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:c7,color:a7}}},{dark:!0}),f8(c8.define([{tag:Z.keyword,color:Xie},{tag:[Z.name,Z.deleted,Z.character,Z.propertyName,Z.macroName],color:i7},{tag:[Z.function(Z.variableName),Z.labelName],color:Jie},{tag:[Z.color,Z.constant(Z.name),Z.standard(Z.name)],color:s7},{tag:[Z.definition(Z.name),Z.separator],color:a7},{tag:[Z.typeName,Z.className,Z.number,Z.changed,Z.annotation,Z.modifier,Z.self,Z.namespace],color:Gie},{tag:[Z.operator,Z.operatorKeyword,Z.url,Z.escape,Z.regexp,Z.link,Z.special(Z.string)],color:Kie},{tag:[Z.meta,Z.comment],color:o7},{tag:Z.strong,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.link,color:o7,textDecoration:`underline`},{tag:Z.heading,fontWeight:`bold`,color:i7},{tag:[Z.atom,Z.bool,Z.special(Z.variableName)],color:s7},{tag:[Z.processingInstruction,Z.string,Z.inserted],color:Yie},{tag:Z.invalid,color:qie}]))],p7=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,m7=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(p7(e)):p7,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 $J(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=eY(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=tY(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`&&(m7.prototype[Symbol.iterator]=function(){return this});var h7={from:-1,to:-1,match:/.*/.exec(``),precise:!0},g7=`gm`+(/x/.unicode==null?``:`u`),_7=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=h7,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new b7(e,t,n,r,i);this.re=new RegExp(t,g7+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=x7(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=x7(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}}},v7=new WeakMap,y7=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=v7.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return v7.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)),v7.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},b7=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=h7,this.matchPos=x7(e,r),this.re=new RegExp(t,g7+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=y7.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=x7(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=y7.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(_7.prototype[Symbol.iterator]=b7.prototype[Symbol.iterator]=function(){return this});function $ie(e){try{return new RegExp(e,g7),!0}catch{return!1}}function x7(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 eae=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=Y2(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=Y.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,R0.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},S7={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},C7=hY.define({combine(e){return aX(e,S7,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function tae(e){let t=[oae,aae];return e&&t.push(C7.of(e)),t}var nae=cZ.mark({class:`cm-selectionMatch`}),rae=cZ.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function w7(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=$Y.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=$Y.Word)}function iae(e,t,n,r){return e(t.sliceDoc(n,n+1))==$Y.Word&&e(t.sliceDoc(r-1,r))==$Y.Word}var aae=AQ.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(C7),{state:n}=e,r=n.selection;if(r.ranges.length>1)return cZ.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return cZ.none;let e=n.wordAt(i.head);if(!e)return cZ.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 cZ.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(w7(o,n,i.from,i.to)&&iae(o,n,i.from,i.to)))return cZ.none}else if(a=n.sliceDoc(i.from,i.to),!a)return cZ.none}let s=[];for(let r of e.visibleRanges){let e=new m7(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||w7(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(rae.range(r,a)):(r>=i.to||a<=i.from)&&s.push(nae.range(r,a)),s.length>t.maxMatches))return cZ.none}}return cZ.set(s)}},{decorations:e=>e.decorations}),oae=R0.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),sae=({state:e,dispatch:t})=>{let{selection:n}=e,r=Y.create(n.ranges.map(t=>e.wordAt(t.head)||Y.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function cae(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 m7(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new m7(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 lae=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return sae({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=cae(e,r);return i?(t(e.update({selection:e.selection.addRange(Y.range(i.from,i.to),!1),effects:R0.scrollIntoView(i.to)})),!0):!1},T7=hY.define({combine(e){return aX(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Cae(e),scrollToMatch:e=>R0.scrollIntoView(e)})}}),E7=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||$ie(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`?`
|
|
208
|
-
`: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 hae(this):new fae(this)}getCursor(e,t=0,n){let r=e.doc?e:iX.create({doc:e});return n??=r.doc.length,this.regexp?k7(this,r,t,n):O7(this,r,t,n)}},D7=class{constructor(e){this.spec=e}};function uae(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 O7(e,t,n,r){let i;return e.wholeWord&&(i=dae(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=uae(e.test,t,i)),new m7(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function dae(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(A7(i,n-a))!=$Y.Word||t(j7(i,n-a))!=$Y.Word)&&(t(j7(i,r-a))!=$Y.Word||t(A7(i,r-a))!=$Y.Word))}var fae=class extends D7{constructor(e){super(e)}nextMatch(e,t,n){let r=O7(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=O7(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=O7(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=O7(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=O7(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 pae(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function k7(e,t,n,r){let i;return e.wholeWord&&(i=mae(t.charCategorizer(t.selection.main.head))),e.test&&(i=pae(e.test,t,i)),new _7(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function A7(e,t){return e.slice(XJ(e,t,!1),t)}function j7(e,t){return e.slice(t,XJ(e,t))}function mae(e){return(t,n,r)=>!r[0].length||(e(A7(r.input,r.index))!=$Y.Word||e(j7(r.input,r.index))!=$Y.Word)&&(e(j7(r.input,r.index+r[0].length))!=$Y.Word||e(A7(r.input,r.index+r[0].length))!=$Y.Word)}var hae=class extends D7{nextMatch(e,t,n){let r=k7(this.spec,e,n,e.doc.length).next();return r.done&&(r=k7(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=k7(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=k7(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=k7(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)}},M7=UY.define(),N7=UY.define(),P7=SY.define({create(e){return new F7(V7(e).create(),null)},update(e,t){for(let n of t.effects)n.is(M7)?e=new F7(n.value.create(),e.panel):n.is(N7)&&(e=new F7(e.query,n.value?B7:null));return e},provide:e=>J2.from(e,e=>e.panel)}),F7=class{constructor(e,t){this.query=e,this.panel=t}},gae=cZ.mark({class:`cm-searchMatch`}),_ae=cZ.mark({class:`cm-searchMatch cm-searchMatch-selected`}),vae=AQ.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(P7))}update(e){let t=e.state.field(P7);(t!=e.startState.field(P7)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return cZ.none;let{view:n}=this,r=new pX;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?_ae:gae)})}return r.finish()}},{decorations:e=>e.decorations});function I7(e){return t=>{let n=t.state.field(P7,!1);return n&&n.query.spec.valid?e(t,n):W7(t)}}var L7=I7((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=Y.single(r.from,r.to),a=e.state.facet(T7);return e.dispatch({selection:i,effects:[Y7(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),U7(e),!0}),R7=I7((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=Y.single(i.from,i.to),o=e.state.facet(T7);return e.dispatch({selection:a,effects:[Y7(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),U7(e),!0}),yae=I7((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:Y.create(n.map(e=>Y.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),bae=({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 m7(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(Y.range(t.value.from,t.value.to))}return t(e.update({selection:Y.create(a,o),userEvent:`select.search.matches`})),!0},z7=I7((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(R0.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=Y.single(o.from,o.to).map(d),u.push(Y7(e,o)),u.push(n.facet(T7).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),xae=I7((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:R0.announce.of(r),userEvent:`input.replace.all`}),!0});function B7(e){return e.state.facet(T7).createPanel(e)}function V7(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(T7);return new E7({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 H7(e){let t=W2(e,B7);return t&&t.dom.querySelector(`[main-field]`)}function U7(e){let t=H7(e);t&&t==e.root.activeElement&&t.select()}var W7=e=>{let t=e.state.field(P7,!1);if(t&&t.panel){let n=H7(e);if(n&&n!=e.root.activeElement){let r=V7(e.state,t.query.spec);r.valid&&e.dispatch({effects:M7.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[N7.of(!0),t?M7.of(V7(e.state,t.query.spec)):UY.appendConfig.of(Tae)]});return!0},G7=e=>{let t=e.state.field(P7,!1);if(!t||!t.panel)return!1;let n=W2(e,B7);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:N7.of(!1)}),!0},Sae=[{key:`Mod-f`,run:W7,scope:`editor search-panel`},{key:`F3`,run:L7,shift:R7,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:L7,shift:R7,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:G7,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:bae},{key:`Mod-Alt-g`,run:eae},{key:`Mod-d`,run:lae,preventDefault:!0}],Cae=class{constructor(e){this.view=e;let t=this.query=e.state.field(P7).query.spec;this.commit=this.commit.bind(this),this.searchField=BX(`input`,{value:t.search,placeholder:K7(e,`Find`),"aria-label":K7(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=BX(`input`,{value:t.replace,placeholder:K7(e,`Replace`),"aria-label":K7(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=BX(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=BX(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=BX(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return BX(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=BX(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>L7(e),[K7(e,`next`)]),n(`prev`,()=>R7(e),[K7(e,`previous`)]),n(`select`,()=>yae(e),[K7(e,`all`)]),BX(`label`,null,[this.caseField,K7(e,`match case`)]),BX(`label`,null,[this.reField,K7(e,`regexp`)]),BX(`label`,null,[this.wordField,K7(e,`by word`)]),...e.state.readOnly?[]:[BX(`br`),this.replaceField,n(`replace`,()=>z7(e),[K7(e,`replace`)]),n(`replaceAll`,()=>xae(e),[K7(e,`replace all`)])],BX(`button`,{name:`close`,onclick:()=>G7(e),"aria-label":K7(e,`close`),type:`button`},[`×`])])}commit(){let e=new E7({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:M7.of(e)}))}keydown(e){X0(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?R7:L7)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),z7(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(M7)&&!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(T7).top}};function K7(e,t){return e.state.phrase(t)}var q7=30,J7=/[\s\.,:;?!]/;function Y7(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-q7),o=Math.min(i,n+q7),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<q7;e++)if(!J7.test(s[e+1])&&J7.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-q7;e--)if(!J7.test(s[e-1])&&J7.test(s[e])){s=s.slice(0,e);break}}return R0.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var wae=R0.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`}}),Tae=[P7,TY.low(vae),wae],X7=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=t6(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(t9(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 Z7(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 Eae(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=Z7(t)+Z7(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function Q7(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:Eae(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function Dae(e,t){return n=>{for(let t=t6(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 $7=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function e9(e){return e.selection.main.from}function t9(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 n9=BY.define();function Oae(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:Y.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var r9=new WeakMap;function kae(e){if(!Array.isArray(e))return e;let t=r9.get(e);return t||r9.set(e,t=Q7(e)),t}var i9=UY.define(),a9=UY.define(),Aae=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=$J(e,t),r=tY(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push($J(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=$J(e,0),i=tY(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=$J(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=tY(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=$J(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=eY(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+=tY(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?tY($J(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)}},jae=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)}},o9=hY.define({combine(e){return aX(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:Mae,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=>s9(e(n),t(n)),optionClass:(e,t)=>n=>s9(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function s9(e,t){return e?t?e+` `+t:e:t}function Mae(e,t,n,r,i,a){let o=e.textDirection==HZ.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 c9=UY.define();function Nae(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 l9(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 Pae=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(o9);this.optionContent=Nae(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=l9(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:c9.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(o9).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:a9.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=l9(r.length,i,e.state.facet(o9).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=l9(t.options.length,t.selected,this.view.state.facet(o9).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=>EQ(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&&Iae(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(o9).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 Fae(e,t){return n=>new Pae(n,e,t)}function Iae(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 u9(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function Lae(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(o9);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 $7(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new jae(n):new Aae(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 $7(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):u9(e.completion)>u9(c)&&(s[s.length-1]=e),c=e.completion}return s}var Rae=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,d9(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=Lae(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(o9).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,d9(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:Gae,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)}},zae=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(Uae,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(o9),i=(r.override||n.languageDataAt(`autocomplete`,e9(n)).map(kae)).map(e=>(this.active.find(t=>t.source==e)||new p9(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(h9));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!Bae(i,this.active)||o?a=Rae.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 p9(e.source,0):e));for(let e of t.effects)e.is(c9)&&(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?Vae:Hae}};function Bae(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 Vae={"aria-autocomplete":`list`},Hae={};function d9(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var Uae=[];function f9(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(n9);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 p9=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=f9(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(i9))i=new e(i.source,1,n.value);else if(n.is(a9))i=new e(i.source,0);else if(n.is(h9))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(e9(e.state))}},m9=class e extends p9{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=e9(t.state);if(o>a||!r||n&2&&(e9(t.startState)==this.from||o<this.limit))return new p9(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return Wae(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 X7(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??e9(t.state)):new p9(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 p9(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function Wae(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):t9(e,!0).test(i)}var h9=UY.define({map(e,t){return e.map(e=>e.map(t))}}),g9=SY.define({create(){return zae.start()},update(e,t){return e.update(t)},provide:e=>[V2.from(e,e=>e.tooltip),R0.contentAttributes.from(e,e=>e.attrs)]});function _9(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(g9).active.find(e=>e.source==t.source);return r instanceof m9?(typeof n==`string`?e.dispatch({...Oae(e.state,n,r.from,r.to),annotations:n9.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var Gae=Fae(g9,_9);function v9(e,t=`option`){return n=>{let r=n.state.field(g9,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(o9).interactionDelay)return!1;let i=1,a;t==`page`&&(a=H2(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:c9.of(s)}),!0}}var Kae=e=>{let t=e.state.field(g9,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(o9).interactionDelay?!1:_9(e,t.open.options[t.open.selected])},y9=e=>e.state.field(g9,!1)?(e.dispatch({effects:i9.of(!0)}),!0):!1,qae=e=>{let t=e.state.field(g9,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:a9.of(null)}),!0)},Jae=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},Yae=50,Xae=1e3,Zae=AQ.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(g9).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(g9),n=e.state.facet(o9);if(!e.selectionSet&&!e.docChanged&&e.startState.field(g9)==t)return;let r=e.transactions.some(e=>{let t=f9(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>Yae&&Date.now()-n.time>Xae){for(let e of n.context.abortListeners)try{e()}catch(e){EQ(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(i9)))&&(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(g9);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(o9).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new X7(t,e9(t),e.explicit,this.view),r=new Jae(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:a9.of(null)}),EQ(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(o9).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(o9),n=this.view.state.field(g9);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=e9(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new m9(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 p9(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:h9.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(g9,!1);if(t&&t.tooltip&&this.view.state.facet(o9).closeOnBlur){let n=t.open&&H2(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:a9.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:i9.of(!1)}),20),this.composing=0}}}),Qae=typeof navigator==`object`&&/Win/.test(navigator.platform),$ae=TY.highest(R0.domEventHandlers({keydown(e,t){let n=t.state.field(g9,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Qae&&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&&_9(t,r),!1}})),b9=R0.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`}}}),eoe=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},toe=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,rY.TrackDel),r=t.mapPos(this.to,1,rY.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},noe=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(p6);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 toe(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 eoe(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)}},roe=cZ.widget({widget:new class extends oZ{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),ioe=cZ.mark({class:`cm-snippetField`}),x9=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=cZ.set(e.map(e=>(e.from==e.to?roe:ioe).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))}},S9=UY.define({map(e,t){return e&&e.map(t)}}),aoe=UY.define(),C9=SY.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(S9))return n.value;if(n.is(aoe)&&e)return new x9(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=>R0.decorations.from(e,e=>e?e.deco:cZ.none)});function w9(e,t){return Y.create(e.filter(e=>e.field==t).map(e=>Y.range(e.from,e.to)))}function ooe(e){let t=noe.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:zJ.of(a)},scrollIntoView:!0,annotations:n?[n9.of(n),WY.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=w9(o,0)),o.some(e=>e.field>0)){let t=new x9(o,0),n=c.effects=[S9.of(t)];e.state.field(C9,!1)===void 0&&n.push(UY.appendConfig.of([C9,coe,uoe,b9]))}e.dispatch(e.state.update(c))}}function T9(e){return({state:t,dispatch:n})=>{let r=t.field(C9,!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:w9(r.ranges,i),effects:S9.of(a?null:new x9(r.ranges,i)),scrollIntoView:!0})),!0}}var soe=[{key:`Tab`,run:T9(1),shift:T9(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(C9,!1)?(t(e.update({effects:S9.of(null)})),!0):!1}],E9=hY.define({combine(e){return e.length?e[0]:soe}}),coe=TY.highest(q0.compute([E9],e=>e.facet(E9)));function loe(e,t){return{...t,apply:ooe(e)}}var uoe=R0.domEventHandlers({mousedown(e,t){let n=t.state.field(C9,!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:w9(n.ranges,i.field),effects:S9.of(n.ranges.some(e=>e.field>i.field)?new x9(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),D9={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},O9=UY.define({map(e,t){return t.mapPos(e,-1,rY.TrackAfter)??void 0}}),k9=new class extends oX{};k9.startSide=1,k9.endSide=-1;var A9=SY.define({create(){return dX.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(O9)&&(e=e.update({add:[k9.range(n.value,n.value+1)]}));return e}});function doe(){return[poe,A9]}var j9=`()[]{}<>«»»«[]{}`;function M9(e){for(let t=0;t<16;t+=2)if(j9.charCodeAt(t)==e)return j9.charAt(t+1);return eY(e<128?e:e+1)}function N9(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||D9}var foe=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),poe=R0.inputHandler.of((e,t,n,r)=>{if((foe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&tY($J(r,0))==1||t!=i.from||n!=i.to)return!1;let a=hoe(e.state,r);return a?(e.dispatch(a),!0):!1}),moe=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=N9(e,e.selection.main.head).brackets||D9.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=goe(e.doc,t.head);for(let i of n)if(i==r&&F9(e.doc,t.head)==M9($J(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:Y.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function hoe(e,t){let n=N9(e,e.selection.main.head),r=n.brackets||D9.brackets;for(let i of r){let a=M9($J(i,0));if(t==i)return a==i?yoe(e,i,r.indexOf(i+i+i)>-1,n):_oe(e,i,a,n.before||D9.before);if(t==a&&P9(e,e.selection.main.from))return voe(e,i,a)}return null}function P9(e,t){let n=!1;return e.field(A9).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function F9(e,t){let n=e.sliceString(t,t+2);return n.slice(0,tY($J(n,0)))}function goe(e,t){let n=e.sliceString(t-2,t);return tY($J(n,0))==n.length?n:n.slice(1)}function _oe(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:O9.of(a.to+t.length),range:Y.range(a.anchor+t.length,a.head+t.length)};let o=F9(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:O9.of(a.head+t.length),range:Y.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function voe(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&F9(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:Y.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function yoe(e,t,n,r){let i=r.stringPrefixes||D9.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:O9.of(r.to+t.length),range:Y.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=F9(e.doc,o),c;if(s==t){if(I9(e,o))return{changes:{insert:t+t,from:o},effects:O9.of(o+t.length),range:Y.cursor(o+t.length)};if(P9(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:Y.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=L9(e,o-2*t.length,i))>-1&&I9(e,c))return{changes:{insert:t+t+t+t,from:o},effects:O9.of(o+t.length),range:Y.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=$Y.Word&&L9(e,o,i)>-1&&!boe(e,o,t,i))return{changes:{insert:t+t,from:o},effects:O9.of(o+t.length),range:Y.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function I9(e,t){let n=t6(e).resolveInner(t+1);return n.parent&&n.from==t}function boe(e,t,n,r){let i=t6(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 L9(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=$Y.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))!=$Y.Word)return n}return-1}function xoe(e={}){return[$ae,g9,o9.of(e),Zae,Soe,b9]}var R9=[{key:`Ctrl-Space`,run:y9},{mac:"Alt-`",run:y9},{mac:`Alt-i`,run:y9},{key:`Escape`,run:qae},{key:`ArrowDown`,run:v9(!0)},{key:`ArrowUp`,run:v9(!1)},{key:`PageDown`,run:v9(!0,`page`)},{key:`PageUp`,run:v9(!1,`page`)},{key:`Enter`,run:Kae}],Soe=TY.highest(q0.computeN([o9],e=>e.facet(o9).defaultKeymap?[R9]:[]));function $(e){return new d6(Ere.define(e))}function z9(e){return J(()=>import(`./dist-BE7bu-DL.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var Coe=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return J(()=>import(`./dist-DmldrHd_.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return J(()=>import(`./dist-DmldrHd_.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return z9(`Cassandra`)}}),Q.of({name:`CSS`,extensions:[`css`],load(){return J(()=>import(`./dist-B7seoj3d.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([10,8]),import.meta.url)}}),Q.of({name:`Go`,extensions:[`go`],load(){return J(()=>import(`./dist-CSh_DE14.js`).then(e=>e.go()),__vite__mapDeps([11,8]),import.meta.url)}}),Q.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return J(()=>import(`./dist-BjU6y-A2.js`).then(e=>e.html()),__vite__mapDeps([12,10,8,13]),import.meta.url)}}),Q.of({name:`Java`,extensions:[`java`],load(){return J(()=>import(`./dist-8hqcx0sU.js`).then(e=>e.java()),__vite__mapDeps([14,8]),import.meta.url)}}),Q.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return J(()=>import(`./dist-DnfXs8Vn.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return J(()=>import(`./dist-BX8z72IC.js`).then(e=>e.jinja()),__vite__mapDeps([15,12,10,8,13]),import.meta.url)}}),Q.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return J(()=>import(`./dist-BVDffZ0U.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return J(()=>import(`./dist-DnfXs8Vn.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`LESS`,extensions:[`less`],load(){return J(()=>import(`./dist-DNp6rLRA.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return J(()=>import(`./dist-ngtN0DJB.js`).then(e=>e.liquid()),__vite__mapDeps([18,12,10,8,13]),import.meta.url)}}),Q.of({name:`MariaDB SQL`,load(){return z9(`MariaSQL`)}}),Q.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return J(()=>import(`./dist-CttYUqzS.js`).then(e=>e.markdown()),__vite__mapDeps([19,12,10,8,13]),import.meta.url)}}),Q.of({name:`MS SQL`,load(){return z9(`MSSQL`)}}),Q.of({name:`MySQL`,load(){return z9(`MySQL`)}}),Q.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return J(()=>import(`./dist-CXYYBw3_.js`).then(e=>e.php()),__vite__mapDeps([20,12,10,8,13]),import.meta.url)}}),Q.of({name:`PLSQL`,extensions:[`pls`],load(){return z9(`PLSQL`)}}),Q.of({name:`PostgreSQL`,load(){return z9(`PostgreSQL`)}}),Q.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return J(()=>import(`./dist-dDdADKFA.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return J(()=>import(`./dist-DUX-id_F.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return J(()=>import(`./dist-dydu68Fl.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SCSS`,extensions:[`scss`],load(){return J(()=>import(`./dist-dydu68Fl.js`).then(e=>e.sass()),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SQL`,extensions:[`sql`],load(){return z9(`StandardSQL`)}}),Q.of({name:`SQLite`,load(){return z9(`SQLite`)}}),Q.of({name:`TSX`,extensions:[`tsx`],load(){return J(()=>import(`./dist-DnfXs8Vn.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return J(()=>import(`./dist-DnfXs8Vn.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return J(()=>import(`./dist-ClxGviKw.js`).then(e=>e.wast()),__vite__mapDeps([24,8]),import.meta.url)}}),Q.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return J(()=>import(`./dist-Bf2M8m3N.js`).then(e=>e.xml()),__vite__mapDeps([25,8]),import.meta.url)}}),Q.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return J(()=>import(`./dist-W-TIVntx.js`).then(e=>e.yaml()),__vite__mapDeps([26,8]),import.meta.url)}}),Q.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return J(()=>import(`./apl-CnwPGSsG.js`).then(e=>$(e.apl)),[],import.meta.url)}}),Q.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return J(()=>import(`./asciiarmor-qTkVPQu6.js`).then(e=>$(e.asciiArmor)),[],import.meta.url)}}),Q.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return J(()=>import(`./asn1-Dr8qZg38.js`).then(e=>$(e.asn1({}))),[],import.meta.url)}}),Q.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return J(()=>import(`./asterisk-Bja0s6e1.js`).then(e=>$(e.asterisk)),[],import.meta.url)}}),Q.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return J(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[],import.meta.url)}}),Q.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return J(()=>import(`./cobol-B_OZ4V-R.js`).then(e=>$(e.cobol)),[],import.meta.url)}}),Q.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.csharp)),[],import.meta.url)}}),Q.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`ClojureScript`,extensions:[`cljs`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return J(()=>import(`./css-CYpP4FRV.js`).then(e=>$(e.gss)),[],import.meta.url)}}),Q.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return J(()=>import(`./cmake-CyVbuzPu.js`).then(e=>$(e.cmake)),[],import.meta.url)}}),Q.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return J(()=>import(`./coffeescript-B2pKbFk8.js`).then(e=>$(e.coffeeScript)),[],import.meta.url)}}),Q.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return J(()=>import(`./commonlisp-CcllspGY.js`).then(e=>$(e.commonLisp)),[],import.meta.url)}}),Q.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return J(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[],import.meta.url)}}),Q.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return J(()=>import(`./python-BqYw9LYJ.js`).then(e=>$(e.cython)),[],import.meta.url)}}),Q.of({name:`Crystal`,extensions:[`cr`],load(){return J(()=>import(`./crystal-M5-qzICs.js`).then(e=>$(e.crystal)),[],import.meta.url)}}),Q.of({name:`D`,extensions:[`d`],load(){return J(()=>import(`./d-BhMjBjQP.js`).then(e=>$(e.d)),[],import.meta.url)}}),Q.of({name:`Dart`,extensions:[`dart`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.dart)),[],import.meta.url)}}),Q.of({name:`diff`,extensions:[`diff`,`patch`],load(){return J(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[],import.meta.url)}}),Q.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return J(()=>import(`./dockerfile-BLkNEvjs.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([27,28]),import.meta.url)}}),Q.of({name:`DTD`,extensions:[`dtd`],load(){return J(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[],import.meta.url)}}),Q.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return J(()=>import(`./dylan-C6jEEEk-.js`).then(e=>$(e.dylan)),[],import.meta.url)}}),Q.of({name:`EBNF`,load(){return J(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[],import.meta.url)}}),Q.of({name:`ECL`,extensions:[`ecl`],load(){return J(()=>import(`./ecl-BSZaIHnp.js`).then(e=>$(e.ecl)),[],import.meta.url)}}),Q.of({name:`edn`,extensions:[`edn`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Eiffel`,extensions:[`e`],load(){return J(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[],import.meta.url)}}),Q.of({name:`Elm`,extensions:[`elm`],load(){return J(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[],import.meta.url)}}),Q.of({name:`Erlang`,extensions:[`erl`],load(){return J(()=>import(`./erlang-DaB2Rkuy.js`).then(e=>$(e.erlang)),[],import.meta.url)}}),Q.of({name:`Esper`,load(){return J(()=>import(`./sql-DcCJ9jop.js`).then(e=>$(e.esper)),[],import.meta.url)}}),Q.of({name:`Factor`,extensions:[`factor`],load(){return J(()=>import(`./factor-D7LVTn2l.js`).then(e=>$(e.factor)),__vite__mapDeps([29,28]),import.meta.url)}}),Q.of({name:`FCL`,load(){return J(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[],import.meta.url)}}),Q.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return J(()=>import(`./forth-Cezjo90N.js`).then(e=>$(e.forth)),[],import.meta.url)}}),Q.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return J(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[],import.meta.url)}}),Q.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[],import.meta.url)}}),Q.of({name:`Gas`,extensions:[`s`],load(){return J(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[],import.meta.url)}}),Q.of({name:`Gherkin`,extensions:[`feature`],load(){return J(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[],import.meta.url)}}),Q.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return J(()=>import(`./groovy-BC3IOsC8.js`).then(e=>$(e.groovy)),[],import.meta.url)}}),Q.of({name:`Haskell`,extensions:[`hs`],load(){return J(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[],import.meta.url)}}),Q.of({name:`Haxe`,extensions:[`hx`],load(){return J(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.haxe)),[],import.meta.url)}}),Q.of({name:`HXML`,extensions:[`hxml`],load(){return J(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.hxml)),[],import.meta.url)}}),Q.of({name:`HTTP`,load(){return J(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[],import.meta.url)}}),Q.of({name:`IDL`,extensions:[`pro`],load(){return J(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[],import.meta.url)}}),Q.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return J(()=>import(`./javascript-9Tg8ixDm.js`).then(e=>$(e.jsonld)),[],import.meta.url)}}),Q.of({name:`Julia`,extensions:[`jl`],load(){return J(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[],import.meta.url)}}),Q.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.kotlin)),[],import.meta.url)}}),Q.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return J(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[],import.meta.url)}}),Q.of({name:`Lua`,extensions:[`lua`],load(){return J(()=>import(`./lua-CiA1ziua.js`).then(e=>$(e.lua)),[],import.meta.url)}}),Q.of({name:`mIRC`,extensions:[`mrc`],load(){return J(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[],import.meta.url)}}),Q.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return J(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[],import.meta.url)}}),Q.of({name:`Modelica`,extensions:[`mo`],load(){return J(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[],import.meta.url)}}),Q.of({name:`MUMPS`,extensions:[`mps`],load(){return J(()=>import(`./mumps-CW_TBmxz.js`).then(e=>$(e.mumps)),[],import.meta.url)}}),Q.of({name:`Mbox`,extensions:[`mbox`],load(){return J(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[],import.meta.url)}}),Q.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return J(()=>import(`./nginx-BMaDbqW3.js`).then(e=>$(e.nginx)),[],import.meta.url)}}),Q.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return J(()=>import(`./nsis-AQ_alPln.js`).then(e=>$(e.nsis)),__vite__mapDeps([30,28]),import.meta.url)}}),Q.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return J(()=>import(`./ntriples-d28e9m0E.js`).then(e=>$(e.ntriples)),[],import.meta.url)}}),Q.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveC)),[],import.meta.url)}}),Q.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveCpp)),[],import.meta.url)}}),Q.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[],import.meta.url)}}),Q.of({name:`Octave`,extensions:[`m`],load(){return J(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[],import.meta.url)}}),Q.of({name:`Oz`,extensions:[`oz`],load(){return J(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[],import.meta.url)}}),Q.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return J(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[],import.meta.url)}}),Q.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return J(()=>import(`./perl-CdEHsPfU.js`).then(e=>$(e.perl)),[],import.meta.url)}}),Q.of({name:`Pig`,extensions:[`pig`],load(){return J(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[],import.meta.url)}}),Q.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return J(()=>import(`./powershell-CzG71I4L.js`).then(e=>$(e.powerShell)),[],import.meta.url)}}),Q.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return J(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[],import.meta.url)}}),Q.of({name:`ProtoBuf`,extensions:[`proto`],load(){return J(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[],import.meta.url)}}),Q.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return J(()=>import(`./pug-Bugr-47h.js`).then(e=>$(e.pug)),__vite__mapDeps([31,32]),import.meta.url)}}),Q.of({name:`Puppet`,extensions:[`pp`],load(){return J(()=>import(`./puppet-B4hC2X4m.js`).then(e=>$(e.puppet)),[],import.meta.url)}}),Q.of({name:`Q`,extensions:[`q`],load(){return J(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[],import.meta.url)}}),Q.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return J(()=>import(`./r-DADKenSm.js`).then(e=>$(e.r)),[],import.meta.url)}}),Q.of({name:`RPM Changes`,load(){return J(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[],import.meta.url)}}),Q.of({name:`RPM Spec`,extensions:[`spec`],load(){return J(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmSpec)),[],import.meta.url)}}),Q.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return J(()=>import(`./ruby-DsYpTuWg.js`).then(e=>$(e.ruby)),[],import.meta.url)}}),Q.of({name:`SAS`,extensions:[`sas`],load(){return J(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[],import.meta.url)}}),Q.of({name:`Scala`,extensions:[`scala`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.scala)),[],import.meta.url)}}),Q.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return J(()=>import(`./scheme-CyDdOh7e.js`).then(e=>$(e.scheme)),[],import.meta.url)}}),Q.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return J(()=>import(`./shell-Du5Qg9im.js`).then(e=>$(e.shell)),[],import.meta.url)}}),Q.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return J(()=>import(`./sieve-BAxa3IjF.js`).then(e=>$(e.sieve)),[],import.meta.url)}}),Q.of({name:`Smalltalk`,extensions:[`st`],load(){return J(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[],import.meta.url)}}),Q.of({name:`Solr`,load(){return J(()=>import(`./solr-BBopId9w.js`).then(e=>$(e.solr)),[],import.meta.url)}}),Q.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[],import.meta.url)}}),Q.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return J(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[],import.meta.url)}}),Q.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return J(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[],import.meta.url)}}),Q.of({name:`Squirrel`,extensions:[`nut`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.squirrel)),[],import.meta.url)}}),Q.of({name:`Stylus`,extensions:[`styl`],load(){return J(()=>import(`./stylus-DLLZ8dgm.js`).then(e=>$(e.stylus)),[],import.meta.url)}}),Q.of({name:`Swift`,extensions:[`swift`],load(){return J(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[],import.meta.url)}}),Q.of({name:`sTeX`,load(){return J(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return J(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return J(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`Tcl`,extensions:[`tcl`],load(){return J(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[],import.meta.url)}}),Q.of({name:`Textile`,extensions:[`textile`],load(){return J(()=>import(`./textile-DWBqthVk.js`).then(e=>$(e.textile)),[],import.meta.url)}}),Q.of({name:`TiddlyWiki`,load(){return J(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[],import.meta.url)}}),Q.of({name:`Tiki wiki`,load(){return J(()=>import(`./tiki-CxVlf5KZ.js`).then(e=>$(e.tiki)),[],import.meta.url)}}),Q.of({name:`TOML`,extensions:[`toml`],load(){return J(()=>import(`./toml-LvoKBwCs.js`).then(e=>$(e.toml)),[],import.meta.url)}}),Q.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return J(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[],import.meta.url)}}),Q.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return J(()=>import(`./ttcn-BePYh-hG.js`).then(e=>$(e.ttcn)),[],import.meta.url)}}),Q.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return J(()=>import(`./ttcn-cfg-CY0aot7Q.js`).then(e=>$(e.ttcnCfg)),[],import.meta.url)}}),Q.of({name:`Turtle`,extensions:[`ttl`],load(){return J(()=>import(`./turtle-BDLWE2cD.js`).then(e=>$(e.turtle)),[],import.meta.url)}}),Q.of({name:`Web IDL`,extensions:[`webidl`],load(){return J(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[],import.meta.url)}}),Q.of({name:`VB.NET`,extensions:[`vb`],load(){return J(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[],import.meta.url)}}),Q.of({name:`VBScript`,extensions:[`vbs`],load(){return J(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[],import.meta.url)}}),Q.of({name:`Velocity`,extensions:[`vtl`],load(){return J(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[],import.meta.url)}}),Q.of({name:`Verilog`,extensions:[`v`],load(){return J(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return J(()=>import(`./vhdl-CMrOq2q1.js`).then(e=>$(e.vhdl)),[],import.meta.url)}}),Q.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return J(()=>import(`./xquery-fj_R-kMw.js`).then(e=>$(e.xQuery)),[],import.meta.url)}}),Q.of({name:`Yacas`,extensions:[`ys`],load(){return J(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[],import.meta.url)}}),Q.of({name:`Z80`,extensions:[`z80`],load(){return J(()=>import(`./z80-CL1naaMV.js`).then(e=>$(e.z80)),[],import.meta.url)}}),Q.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[],import.meta.url)}}),Q.of({name:`Xù`,extensions:[`xu`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[],import.meta.url)}}),Q.of({name:`MsGenny`,extensions:[`msgenny`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[],import.meta.url)}}),Q.of({name:`Vue`,extensions:[`vue`],load(){return J(()=>import(`./dist-Dq9gLD7L.js`).then(e=>e.vue()),__vite__mapDeps([33,12,10,8,13]),import.meta.url)}}),Q.of({name:`Angular Template`,load(){return J(()=>import(`./dist-BytlxIDT.js`).then(e=>e.angular()),__vite__mapDeps([34,12,10,8,13]),import.meta.url)}})];function B9(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function V9(e){return Q.matchFilename(Coe,`file${e}`)}function H9({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 DY),u=(0,b.useRef)(new DY),d=(0,b.useRef)(new DY),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=q0.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new R0({state:iX.create({doc:e,extensions:[x4(),T4(),Vre(),o8(),u2(),y2(),iX.allowMultipleSelections.of(!0),M6(),f8(h8,{fallback:!0}),T8(),doe(),xoe(),O2(),j2(),b2(),tae(),q0.of([...moe,...Uie,...Sae,...Xre,...Z6,...R9,Wie]),i,R0.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(iX.readOnly.of(n)),l.current.of([]),u.current.of(r?f7:[]),R0.theme({"&":{height:`100%`},".cm-scroller":{overflow:`auto`}})]}),parent:s.current});c.current=a,o&&(o.current=()=>a.state.doc.toString());let f=V9(B9(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=V9(B9(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(iX.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?f7:[])})});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 U9({content:e,objectUrl:t,kind:n,filename:r,path:i}){return n===`markdown`?(0,U.jsx)(VK,{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)(H9,{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 W9(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function woe(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 G9(...e){return Array.from(new Set(e.filter(e=>!!e))).join(` `)}function Toe(e){let t=e?woe(e):void 0,n=G9(`'unsafe-inline'`,`'unsafe-eval'`,`'self'`,`https:`,t),r=G9(`'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 Eoe(e){try{let t=new URL(e,window.location.href);return[`http:`,`https:`,`mailto:`].includes(t.protocol)}catch{return!1}}function K9(e,t={}){let{channelId:n,basePath:r}=typeof t==`string`?{channelId:t}:t,i=Toe(r),a=`<script>
|
|
209
|
-
function ksadkScrollToHash(rawHref) {
|
|
210
|
-
if (!rawHref || rawHref === '#') return;
|
|
211
|
-
var rawId = rawHref.slice(1);
|
|
212
|
-
var id = rawId;
|
|
213
|
-
try {
|
|
214
|
-
id = decodeURIComponent(rawId);
|
|
215
|
-
} catch (_) {}
|
|
216
|
-
var target = document.getElementById(id) || document.getElementsByName(id)[0];
|
|
217
|
-
if (target) {
|
|
218
|
-
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
document.addEventListener('click', function(event) {
|
|
222
|
-
var target = event.target && event.target.closest ? event.target.closest('a') : null;
|
|
223
|
-
if (!target) return;
|
|
224
|
-
var rawHref = target.getAttribute('href') || '';
|
|
225
|
-
if (rawHref.charAt(0) === '#') {
|
|
226
|
-
event.preventDefault();
|
|
227
|
-
ksadkScrollToHash(rawHref);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
if (target.href) {
|
|
231
|
-
event.preventDefault();
|
|
232
|
-
window.parent.postMessage({
|
|
233
|
-
type: 'ksadk:linkClick',
|
|
234
|
-
channelId: ${JSON.stringify(n||``)},
|
|
235
|
-
href: target.href,
|
|
236
|
-
target: target.target || '_self'
|
|
237
|
-
}, '*');
|
|
238
|
-
}
|
|
239
|
-
}, true);
|
|
240
|
-
<\/script>`,o=`${`<meta http-equiv="Content-Security-Policy" content="${W9(i)}">`}${r?`<base href="${W9(r)}">`:``}${a}`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,`$&${o}`):`${o}${e}`}function q9(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&&Eoe(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function Doe({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=ft(t),d=dt(t),f=(0,b.useCallback)(()=>K9(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]),q9(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:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,U.jsx)(IM,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,U.jsxs)(`button`,{onClick:()=>l(`preview`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,U.jsx)(HM,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,U.jsx)(H9,{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)(H9,{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)(HM,{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)(VM,{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)(IM,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function J9(e){e.current&&clearTimeout(e.current)}function Ooe({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)(()=>(J9(u),u.current=setTimeout(()=>l(e),300),()=>J9(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:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,U.jsx)(IM,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,U.jsxs)(`button`,{onClick:()=>s(`preview`),className:K(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,U.jsx)(HM,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,U.jsx)(H9,{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)(VK,{content:c})})]}):o===`editor`?(0,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.jsx)(H9,{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)(HM,{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)(VK,{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)(IM,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var koe=`/agentengine/api/v1/GetWorkspaceFileContent`,Aoe=4e3;function Y9(e){let t=lt(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function joe(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function X9(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 Moe=[{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 Noe(e){return dt(e)}function Z9({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:Moe.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 Q9({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)(``),[ne,re]=(0,b.useState)(null),[C,w]=(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)(St()),E=(0,b.useMemo)(()=>m.find(e=>e.Path===ne)??null,[m,ne]),de=(0,b.useMemo)(()=>E?bt({path:E.Path,mimeType:E.MimeType}):null,[E]),fe=(0,b.useCallback)(()=>ie?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[ie]),pe=t.ContentPath||koe,me=t.RootLabel||`Workspace`,he=me?`${me.charAt(0).toUpperCase()}${me.slice(1)}`:`Workspace`,ge=mt(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=lt(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),ue.current=r?`background-refresh`:`selection`,re(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})},Aoe);return()=>window.clearInterval(e)},[f,ie,u,ve,n]);let ye=(0,b.useCallback)(async t=>{let n=T.current.next(t.Path),r=vt({path:t.Path,mimeType:t.MimeType});if(le.current=t.Path,r===`unsupported`){_e(),w({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}_e(),w({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=vt({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,w({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=vt({path:t.Path,mimeType:e});w({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=vt({path:t.Path,mimeType:e});w({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),w({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(),w(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=pt(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=lt(n.Path);if(window.confirm(`删除 ${r} ?`)){S(``);try{await s.deleteWorkspaceFile(e,r),ne&<(ne)===r&&(re(null),ae(!1)),await ve(n.Type===`directory`&&(lt(f)===r||lt(f).startsWith(`${r}/`))?Y9(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)(Z9,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!C||C.path!==E.Path||C.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)(XM,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):C.status===`error`?(0,U.jsx)(Z9,{label:C.error||`文件预览加载失败。`}):C.kind===`markdown`?(0,U.jsx)(Ooe,{content:C.content||``,path:E.Path,onSave:Ce,onDirtyChange:ae,getContentRef:ce,isMobile:o}):C.kind===`image`&&C.objectUrl?(0,U.jsx)(U9,{content:null,objectUrl:C.objectUrl,kind:`image`,filename:E.Name,mimeType:C.mimeType||``}):C.kind===`pdf`&&C.objectUrl?(0,U.jsx)(U9,{content:null,objectUrl:C.objectUrl,kind:`pdf`,filename:E.Name,mimeType:C.mimeType||``}):C.kind===`html`?(0,U.jsx)(Doe,{content:C.content||``,path:E.Path,onSave:Ce,onDirtyChange:ae,getContentRef:ce,isMobile:o,agentId:e,contentPath:pe}):C.kind===`text`||C.kind===`code`?(0,U.jsx)(H9,{content:C.content||``,path:E.Path,onSave:Ce,onDirtyChange:ae,getContentRef:ce}):(0,U.jsx)(U9,{content:null,kind:`unsupported`,filename:E.Name,mimeType:C.mimeType||``}),Ce=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),w(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)}}},we=E?.Type===`file`&&C?.path===E.Path&&C.status===`ready`&&(C.kind===`text`||C.kind===`code`||C.kind===`html`||C.kind===`markdown`),Te=E?.Type===`file`&&C?.path===E.Path&&C.status===`ready`&&C.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)(xN,{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)(tN,{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)(eN,{className:`h-4 w-4`}):(0,U.jsx)(ZM,{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)(wN,{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)(lN,{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(Y9(f))},disabled:g||pt(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)(OM,{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)(lN,{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=vt({path:e.Path,mimeType:e.MimeType}),r=ne===e.Path,i=e.Type===`file`?Noe(e.Path):``;return(0,U.jsxs)(`div`,{title:e.Path,className:K(`group flex items-center gap-1 rounded-lg px-1.5 py-1 transition`,r?`bg-slate-100 text-slate-950 dark:bg-slate-800 dark:text-slate-50`:`text-slate-700 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-900`),children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){ve(e.Path);return}ne!==e.Path&&!fe()||re(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,U.jsx)(`div`,{className:K(`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md`,r?`text-slate-900 dark:text-slate-50`:`text-slate-400 dark:text-slate-500`),children:e.Type===`directory`?(0,U.jsx)(KM,{className:`h-3.5 w-3.5`}):n===`image`?(0,U.jsx)(JM,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,U.jsx)(UM,{className:`h-3.5 w-3.5`}):(0,U.jsx)(GM,{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:K(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:X9(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:K(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`下载`,children:(0,U.jsx)(RM,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,U.jsx)(`button`,{type:`button`,onClick:()=>void xe(e),className:K(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`删除`,children:(0,U.jsx)(bN,{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:[X9(E.SizeBytes),E.MimeType?` · ${E.MimeType}`:``,E.ModifiedAt?` · ${joe(E.ModifiedAt)}`:``]})]}),de===`text`||de===`code`||de===`html`||de===`markdown`?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{let e=ce.current;e&&Ce(e())},disabled:!ie||oe,className:K(`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)(uN,{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:K(`custom-scrollbar min-h-0 flex-1`,Te||we?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:Se()})]})]})]})}function Poe({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:K(i?`fixed inset-0 z-40 flex h-[var(--app-height)] w-screen overflow-hidden bg-white dark:bg-slate-950`:`hidden h-full flex-shrink-0 overflow-hidden bg-white transition-[width] duration-200 ease-out dark:bg-slate-950 md:flex`,n?`border-l border-slate-200/30 dark:border-slate-800/40`:`w-0 border-l border-transparent`),children:n?(0,U.jsx)(Q9,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>C.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,U.jsx)(OR,{open:n,onOpenChange:e=>{e||C.getState().setWorkspacePanelFullscreen(!1),C.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,U.jsxs)(MR,{side:c.side,showOverlay:c.showOverlay,onInteractOutside:e=>{c.preventOutsideClose&&e.preventDefault()},showCloseButton:!1,className:K(`border-slate-200 bg-white p-0 dark:border-slate-800 dark:bg-slate-950`,a?`h-[70vh] rounded-t-[1.75rem]`:`h-[calc(100vh-1.5rem)] w-[min(72rem,calc(100vw-1.5rem))] max-w-[calc(100vw-1.5rem)] rounded-l-[1.5rem] border-l shadow-2xl`),children:[(0,U.jsx)(FR,{className:`sr-only`,children:`Workspace 文件`}),(0,U.jsx)(IR,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,U.jsx)(Q9,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}async function Foe(e,t){let n=await qt(`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 Ioe(e,t){return(await qt(`CreateSession`,{AgentId:e},t)).Session}async function Loe(e,t){return qt(`DeleteSession`,{SessionId:e},t)}async function Roe(e,t){return(await qt(`GetSession`,{SessionId:e},t)).Session}async function zoe(e,t){let n=await qt(`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 Boe(e,t,n){return Zt(`SubscribeSessionEvents`,{SessionId:e,after_seq:String(t)},n)}async function Voe(e,t){let n=await qt(`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 Hoe(e,t){return Xt(`RunAgent`,e,t)}async function Uoe(e,t){return Kc(await qt(`SubmitAgentControl`,{CommandType:e.commandType,IdempotencyKey:e.idempotencyKey,Payload:e.payload},t))}async function Woe(e,t){return Kc(await qt(`SubmitInteraction`,{...e},t))}async function Goe(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId};return e.runId&&(n.RunId=e.runId),qt(`ListSessionCheckpoints`,n,t)}async function Koe(e,t){return qt(`GetCheckpointResumePreview`,{AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId},t)}async function qoe(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId};return e.runId&&(n.RunId=e.runId),e.checkpointId&&(n.CheckpointId=e.checkpointId),qt(`ListToolReceipts`,n,t)}async function Joe(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),Xt(`ResumeRun`,n,t)}async function Yoe(e,t,n){return qt(`ListWorkspaceFiles`,{AgentId:e,Path:t,Recursive:n})}async function Xoe(e){return Jt(`AddWorkspaceFile`,e)}async function Zoe(e,t){return qt(`DeleteWorkspaceFile`,{AgentId:e,Path:t})}async function Qoe(e,t,n){return Yt(`GetWorkspaceFileContent`,{AgentId:e,FilePath:t},{signal:n?.signal,asText:n?.asText??!0})}async function $oe(e,t){return Jt(`UploadFile`,e,t)}var ese=new class{async listSessions(e,t){return Foe(e,t)}async createSession(e,t){return{SessionId:(await Ioe(e,t)).SessionId}}async deleteSession(e,t){return Loe(e,t)}async getSession(e,t){return Roe(e,t)}async listSessionEvents(e,t){return zoe(e,t)}async listSessionMessages(e,t){return Voe(e,t)}async listSessionCheckpoints(e,t){return Goe(e,t)}async previewCheckpointResume(e,t){return Koe(e,t)}async listToolReceipts(e,t){return qoe(e,t)}async runAgent(e,t){return Hoe(e,t)}async resumeRun(e,t){return Joe(e,t)}async subscribeRunEvents(e,t){return Zt(`SubscribeRunEvents`,{SessionId:e.sessionId,InvocationId:e.invocationId,AfterSeqId:String(e.afterSeqId)},t)}async submitControl(e,t){return Uoe({commandType:e.command_type,idempotencyKey:e.idempotency_key,payload:e.payload},t)}async submitInteraction(e,t){return Woe(e,t)}async getAgentStatus(e){return qt(`GetAgentStatus`,{},e)}async subscribeSessionEvents(e,t,n){return Boe(e,t,n)}async cancelRun(e,t,n,r){return qt(`CancelRun`,{AgentId:e,SessionId:t,InvocationId:n},r)}async getResponseFeedback(e,t){return qt(`GetResponseFeedback`,e,t)}async upsertResponseFeedback(e,t){return qt(`UpsertResponseFeedback`,e,t)}async deleteResponseFeedback(e,t){await qt(`DeleteResponseFeedback`,e,t)}async listWorkspaceFiles(e,t,n){return Yoe(e,t,n)}async addWorkspaceFile(e){return Xoe(e)}async deleteWorkspaceFile(e,t){await Zoe(e,t)}async getWorkspaceFileContent(e,t,n){return Qoe(e,t,n)}async listAgentModels(e){return $t(e)}async getAgentUiBootstrap(){return Qt()}async uploadFile(e,t){return $oe(e,t)}},tse=b.lazy(()=>J(()=>import(`./ArtifactsPanel-DSU1sWD_.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url)),nse=b.lazy(()=>J(()=>import(`./NativeTerminalPanel-DUrK0JpZ.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function rse({apiAdapter:e,initialSurface:t=`chat`,routeShell:n}={}){let r=e||ese,i=Ce(e=>e.agentId),a=Ze(e=>e.currentSessionId),o=D(e=>e.isStreaming),s=C(e=>e.sidebarOpen),c=C(e=>e.mobileSidebarOpen),l=C(e=>e.mobileActionsOpen),u=Ce(e=>e.agentName),d=Te(e=>e.selectedModel),f=Te(e=>e.availableModels),p=Te(e=>e.modelSource),m=Te(e=>e.modelCatalogLoaded),h=Te(e=>e.thinkingMode),g=ke(e=>e.permissionMode),_=Ce(e=>e.agentFramework),v=Ce(e=>e.workspaceFiles),y=Ce(e=>e.accessMode),x=Ce(e=>e.status),ee=Ce(e=>e.errorMessage),te=C(e=>e.workspacePanelOpen),S=C(e=>e.workspacePanelWidth),ne=C(e=>e.workspacePanelFullscreen),re=Ce(e=>e.apiFormats),w=Ce(e=>e.capabilities),ie=Qe(e=>e.visible&&!!e.content),ae=(0,b.useRef)([]),oe=(0,b.useRef)(null),{isMobile:se,viewportHeight:ce}=Vt(),le=nt({isMobile:se,viewportHeight:ce}),{fetchSessions:ue,loadMoreSessions:T,loadSession:E,loadOlderSessionMessages:de,createNewSession:fe,deleteSession:pe,currentSessionIdRef:me,agentIdRef:he,runSubscriptionAbortRef:ge}=gM({agentId:i,currentSessionId:a,isMobile:se,uiCapabilities:w,api:r,resetCompaction:()=>{},disconnectRun:()=>oe.current?.()}),_e=(0,b.useCallback)(e=>{if(!e)return;let t=()=>{Ze.getState().clearSessionMessageHistory(e),ue(he.current,e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[he,ue]),ve=f.find(e=>e.id===d)||null,{submitDraft:ye,stopGeneration:be,disconnectRun:Se,resumeCheckpoint:we,submitAguiAction:Ee,respondToAguiApproval:De}=Nj({agentId:i,currentSessionId:a,agentFramework:_,apiFormats:re,selectedModel:d,selectedModelMetadata:ve,thinkingMode:h,permissionMode:g,uiCapabilities:w,isMobile:se,api:r,currentSessionIdRef:me,agentIdRef:he,queuedDraftRef:ae,onRunSettled:_e});(0,b.useEffect)(()=>{oe.current=Se},[Se]);let Oe=(0,b.useCallback)(()=>{let e=me.current;ge.current?.abort(),D.getState().stopActivity(),D.getState().stopSessionActivity(e),be()},[me,ge,be]),Ae=(0,b.useCallback)(async()=>{let e=me.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})}_e(e)},[r,i,me,_e]),{submitResponseFeedback:je,deleteResponseFeedback:Me,respondToApproval:Ne}=Wj({agentId:i,currentSessionId:a,isStreaming:o,api:r,submitDraft:ye}),Pe=(0,b.useRef)(Ne),Fe=(0,b.useRef)(De);(0,b.useEffect)(()=>{Pe.current=Ne,Fe.current=De},[Ne,De]);let{pending:Ie,records:Le,respond:Re,localCatalog:ze}=Gj({agentId:i,getAgentId:()=>he.current,currentSessionId:a,api:r,interactionV1Enabled:!!w.InteractionV1,legacyResponsesApproval:(e,t)=>{Pe.current({approvalRequestId:e,approve:t})},legacyAguiResume:(e,t,n)=>Fe.current({interruptId:e,approve:t===`resolved`})});rn({fetchSessions:ue}),(0,b.useEffect)(()=>{he.current=i,me.current=a,kt(i,a)},[i,a,he,me]),(0,b.useEffect)(()=>{se?C.getState().setWorkspacePanelFullscreen(!1):(C.getState().setMobileSidebarOpen(!1),C.getState().setMobileActionsOpen(!1))},[se]),(0,b.useEffect)(()=>{te||C.getState().setWorkspacePanelFullscreen(!1)},[te]),(0,b.useEffect)(()=>()=>{ge.current?.abort()},[ge]);let Be=xe(w),Ve=!!w.Thinking,He=Ct({workspaceFiles:v,accessMode:y}),Ue=xt({isMobile:se}),We=Ft({capability:w.NativeDashboard,agentFramework:_,accessMode:y,origin:window.location.origin}),Ge=!Be,Ke=_===`openclaw`?`OpenClaw`:_===`hermes`?`Hermes`:`原生运行时`,qe=ve?.display_name||d||``,Je=!se&&s&&Be,Ye=(0,b.useRef)(!1),[Xe,$e]=(0,b.useState)(t===`tui`),et=Xe&&!!w.NativeTerminal?.Enabled;(0,b.useEffect)(()=>{Ye.current||t!==`workspace`||!He||(Ye.current=!0,C.getState().setWorkspacePanelOpen(!0),C.getState().setWorkspacePanelFullscreen(!0))},[t,He]);let tt=()=>{C.getState().setWorkspacePanelFullscreen(!1),C.getState().setWorkspacePanelOpen(!1)};if(x!==`ready`){let e=x===`auth-required`,t=(0,U.jsx)(`div`,{className:`flex h-[var(--app-height)] min-h-[var(--app-height)] items-center justify-center bg-slate-50 px-6 font-sans text-slate-800 dark:bg-slate-950 dark:text-slate-100`,children:(0,U.jsxs)(`div`,{className:`w-full max-w-lg rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm dark:border-slate-800 dark:bg-slate-900`,children:[(0,U.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-blue-50 text-xl text-blue-600 dark:bg-blue-950/50`,children:x===`loading`?`…`:`↗`}),(0,U.jsx)(`h1`,{className:`text-xl font-semibold`,children:x===`loading`?`正在连接 Agent`:e?`需要有效的访问链接`:`Agent 暂时无法连接`}),x===`loading`?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-slate-500 dark:text-slate-400`,children:[ee,e?` 请从 AgentEngine 控制台重新打开 Dashboard,或使用 agentengine dashboard open 获取临时链接。`:``]}),(0,U.jsx)(`button`,{type:`button`,className:`mt-6 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-blue-500`,onClick:()=>window.location.reload(),children:`重新加载`})]})]})});return n?(0,U.jsx)(n,{children:t}):t}let rt=(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)(RR,{uiCapabilities:w,createNewSession:fe,deleteSession:pe,loadSession:E,loadMoreSessions:T}),(0,U.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,U.jsx)(wJ,{agentName:u,currentSessionId:a,nativeLauncherMode:Ge,isMobile:se,sidebarOpen:s,mobileSidebarOpen:c,onToggleSidebar:()=>{se?C.getState().toggleMobileSidebar():C.getState().toggleSidebar()},availableModels:f,selectedModel:d,onSelectModel:e=>{Te.getState().setSelectedModel(e),se&&C.getState().setMobileActionsOpen(!1)},selectedModelLabel:qe,modelCatalogLoaded:m,modelSource:p,thinkingEnabled:Ve,thinkingMode:h,onSelectThinkingMode:e=>Te.getState().setThinkingMode(Lt(e)),mobileActionsOpen:l,onMobileActionsOpenChange:e=>C.getState().setMobileActionsOpen(e),workspaceEnabled:He,onOpenWorkspace:()=>C.getState().setWorkspacePanelOpen(!0),nativeManagementLink:We,nativeTerminal:w.NativeTerminal}),Ge?(0,U.jsx)(EJ,{productLabel:Ke,nativeManagementLink:We,nativeTerminal:w.NativeTerminal,workspaceEnabled:He,onOpenWorkspace:()=>C.getState().setWorkspacePanelOpen(!0)}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(aJ,{agentName:u,isMobile:se,onDeleteFeedback:Me,onSubmitFeedback:je,onRespondToApproval:Ne,onRespondToAguiApproval:De,onSubmitAguiAction:Ee,onStopGeneration:Oe,onCancelRemote:w.StopRun?Ae:void 0,checkpointResumeEnabled:w.RunLifecycle.Enabled&&w.RunLifecycle.Checkpoints&&w.RunLifecycle.CheckpointResume,onResumeCheckpoint:we,onLoadOlderSessionMessages:de,interactionRecords:Le}),(0,U.jsx)(xJ,{composerMaxHeight:le,submitDraft:ye,stopGeneration:Oe,cancelRemote:w.StopRun?Ae:void 0,isMobile:se,attachmentsEnabled:w.Attachments!==!1,approvalEnabled:!!w.Approval&&w.ApprovalPolicy?.RuntimeOverride!==!1,approvalPolicy:w.ApprovalPolicy,thinkingEnabled:Ve,runtimeCapabilityMatrix:w.RuntimeCapabilityMatrix,pendingInteractions:Ie,onRespondInteraction:e=>{Re(e)},localCatalog:ze})]})]}),(0,U.jsx)(Poe,{agentId:i,capability:v,workspacePanelOpen:te,workspacePanelWidth:S,workspacePanelFullscreen:ne,isMobile:se,workspaceEnabled:He,workspaceFiles:v,workspacePanelPresentation:Ue,closeWorkspacePanel:tt,handleWorkspacePanelResizeStart:e=>{if(ne||se)return;e.preventDefault();let t=e.clientX,n=S,r=Be&&Je?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;C.getState().setWorkspacePanelWidth(wl(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}),ie&&(0,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(tse,{})}),et?(0,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(nse,{capability:w.NativeTerminal,open:!0,sessionId:a,onClose:()=>$e(!1)})}):null]});return n?(0,U.jsx)(n,{children:rt}):rt}function ise(){return(0,U.jsx)(rse,{})}function ase(e){let t=e instanceof Error?e.message:String(e||``);return/loading chunk|chunkloaderror|failed to fetch dynamically imported module|error loading dynamically imported module|importing a module script failed/i.test(t)}var $9=`agentengine-ui:chunk-reload-attempted`,ose=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),ase(e))try{window.sessionStorage.getItem($9)||(window.sessionStorage.setItem($9,String(Date.now())),window.location.reload())}catch{window.location.reload()}}handleReload=()=>{try{window.sessionStorage.removeItem($9)}catch{}this.setState({hasError:!1,error:null}),window.location.reload()};render(){return this.state.hasError?(0,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 sse(){let e=C(e=>e.toasts),t=C(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)(wN,{size:14})})]},e.id))}):null}ne.createRoot(document.getElementById(`root`)).render((0,U.jsxs)(ose,{children:[(0,U.jsx)(ise,{}),(0,U.jsx)(sse,{})]}));export{bB as $,k4 as A,iX as B,Z3 as C,o as Ct,Z as D,D3 as E,L4 as F,jK as G,wX as H,s3 as I,dW as J,hK as K,R0 as L,M4 as M,r3 as N,E4 as O,a3 as P,QV as Q,q0 as R,Y3 as S,p as St,S3 as T,l as Tt,yq as U,TY as V,J as W,sH as X,cU as Y,cH as Z,F6 as _,LM as _t,Dae as a,wz as at,v6 as b,lT as bt,Q3 as c,zR as ct,i6 as d,bN as dt,pB as et,E8 as f,hN as ft,k6 as g,RM as gt,D6 as h,HM as ht,Q7 as i,Oz as it,N4 as j,I4 as k,Q as l,K as lt,X3 as m,sN as mt,q9 as n,kz as nt,loe as o,ZR as ot,A6 as p,lN as pt,fK as q,X7 as r,Dz as rt,e6 as s,BR as st,K9 as t,nB as tt,d6 as u,wN as ut,P6 as v,AM as vt,t6 as w,s as wt,p6 as x,Qe as xt,N6 as y,EM as yt,Y as z};
|